New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[1.16] Unit tests for [drains], [poison] and [slows], including apply_to=opponent #6582
[1.16] Unit tests for [drains], [poison] and [slows], including apply_to=opponent #6582
Conversation
{FAIL} | ||
[/then] | ||
[/if] | ||
[if] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why randomly indenting stuff? (Or was this caused by wmlindent
? In which case the question would be, why isn't the change already in master and why didn't the CI fail because it's not?)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Revised plan - I won't change wml_unit_test_macros.cfg
in this PR.
Instead of adding the COMMON_KEEP_A_B_UNIT_TEST
to wml_unit_test_macros.cfg
, I want to put it in a separate file. There will then be a separate PR for master (possibly backported too) that moves GENERIC_UNIT_TEST
to its own file and extracts COMMON_KEEP_A_B_C_D_UNIT_TEST
from the 4 side setup in firststrike_and_laststrike
.
The main reason for having these in 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.
If there's no more coments then I'll use similar code for |
7eaf9ce
to
deee302
Compare
It now tests slows, poison and drains. The slows and poison tests are just a find-and-replace of each other, but drains is a separate test. I've called it |
Obviously not for 1.16, but this could (and probably should) be added. |
We should, but even for 1.17 I think that's going to be a separate feature. At the moment, attack prediction for petrify works by running a combat simulation with damage set to the potentially petrified unit's max hp, and includes a FIXME comment about drain. wesnoth/src/attack_prediction.cpp Lines 2076 to 2085 in c1d7e65
|
@CelticMinstrel okay to merge? |
Going to rebase and force-push for a trivial fixup to the commit message - there's now seven asserts for preserving the known status, not four. (Noticed now because I'm rebasing the 1.17 version). Edit: seven asserts but only five lines. The single line in |
Slightly different to PR wesnoth#6582, which was the 1.16 version of this. The five lines that were labelled 'preserving known bug` are changed to test that it's been fixed. 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. 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. 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 changed in 650f704. My thoughts on testing the others are: * [firststrike]'s test is in 650f704. * [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.
deee302
to
7e11619
Compare
Slightly different to PR wesnoth#6582, which was the 1.16 version of this. The five lines that were labelled `preserving known bug` are changed to test that it's been fixed. 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. 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. 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 changed in 650f704. My thoughts on testing the others are: * [firststrike]'s test is in 650f704. * [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.
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 7b39b65. 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 7b39b65. 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.
Slightly different to PR wesnoth#6582, which was the 1.16 version of this. The five lines that were labelled `preserving known bug` are changed to test that it's been fixed. 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. 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. 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 changed in 650f704. My thoughts on testing the others are: * [firststrike]'s test is in 650f704. * [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.
7e11619
to
0d8353c
Compare
I'm not quite sure why you're asking me, but yeah, it seems fine. |
Slightly different to PR #6582, which was the 1.16 version of this. The five lines that were labelled `preserving known bug` are changed to test that it's been fixed. 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. 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. 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 changed in 650f704. My thoughts on testing the others are: * [firststrike]'s test is in 650f704. * [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.
Here
apply_to=opponent
means that the weapon special gives the opponent theability, 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 tosee it it's
unpoisonable
,undrainable
etc. It also checks the wrong unit tosee 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 four tests
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 theGENERIC_UNIT_TEST
macro that starts the leaders next to each other, readyto attack. The
A_B
is because I'm planning a multiple-side variant too.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 7b39b65. That's sufficient to prevent any accidental
copy of the 1.17 fix to 1.16, and my thoughts on testing the others are: