[wesnoth-commits] [wesnoth/wesnoth] 1d1aa1: Unit tests for [drains], [poison] and [slow], with...

Steve Cotton noreply at github.com
Tue Apr 19 13:27:35 UTC 2022


  Branch: refs/heads/1.16
  Home:   https://github.com/wesnoth/wesnoth
  Commit: 1d1aa1f790ddcac381f1b4cbb6d9fce231fdd1f3
      https://github.com/wesnoth/wesnoth/commit/1d1aa1f790ddcac381f1b4cbb6d9fce231fdd1f3
  Author: Steve Cotton <steve at octalot.co.uk>
  Date:   2022-04-19 (Tue, 19 Apr 2022)

  Changed paths:
    A data/test/macros/start_position_common_keep_a_b.cfg
    A data/test/maps/2p_single_castle.map
    A data/test/scenarios/reflexive_drains.cfg
    A data/test/scenarios/reflexive_poison.cfg
    A data/test/scenarios/reflexive_slow.cfg
    M wml_test_schedule

  Log Message:
  -----------
  Unit tests for [drains], [poison] and [slow], with apply_to=opponent

Here `apply_to=opponent` means that the weapon special gives the opponent the
ability, the unit that should get poisoned or slowed is the unit that has the
weapon special.

There's a known bug in 1.16, that `apply_to=opponent` check the wrong unit to
see it it's `unpoisonable`, `undrainable` etc. It also checks the wrong unit to
see if it's already poisoned or slowed, so a battle between two units that both
have reverse-poison results in at most one being poisoned.

As 1.16 has already been released, to avoid OOS the test is checking that the
current behavior's known bug is preserved. For the 1.17 branch, the five lines
labelled `preserving known bug` will be changed to test the reverse.

Most of the credit for this is Newfrenchy's, as he's already written a fix
and a WML based test. This commit uses a Lua test instead to test more
combinations of statuses.

This adds a `COMMON_KEEP_A_B_UNIT_TEST` macro, which is a counterpart to the
`GENERIC_UNIT_TEST` macro that starts the leaders next to each other, ready
to attack. The `A_B` is because I'm planning a multiple-side variant too, and
the main reason for using separate files is Git's fuzzy-patch matching when
merging and rebasing. Having large blocks of identical text in
`wml_unit_test_macros.cfg` can mean the wrong section gets patched.

There's no test for [petrify], as simulate_combat doesn't provide a stat for it.

This tests only 3 of the 6 abilities whose behavior will change in 1.17's
equivalent of 1.16's 7b39b656063. That's sufficient to prevent any accidental
copy of the 1.17 fix to 1.16, and my thoughts on testing the others are:
* [firststrike]'s test is in 7b39b656063. It crashed, so is fixed in 1.16.
* [drains], [poison] and [slow] are tested here.
* [petrify] ends combat, it's also not exposed in simulate_combat's stats.
* [plague] triggers after combat ends.





More information about the Commits mailing list