Repository navigation
test(coop): start soldiers empty in the base-screen tests that move items - #238
Merged
Merged
Conversation
…tes stages its grenade base_write_9 stages the host's soldier H by moving one grenade from the ground onto H's belt. The fixture does not pin H's starting gear. In the failing CI run H's belt already held two autocannon clips, a grenade and a smoke grenade, which fill all six belt cells, so the grenade had no cell, the move failed and the setup check failed. The host now moves every item off H's belt to the ground on the same screen before the grenade move, repeating until the belt is empty. The setup check also requires the belt to be empty, and the moves are kept in the row's evidence.
When a base or craft inventory screen opens, the game hands starting gear to every soldier that has no saved layout. The items come out of a container ordered by memory address, so the gear changes from boot to boot and differs between the host and the client. A test that moves an item into a slot that gear already fills fails on some boots: test_shared_base_writes failed once in CI when the host soldier's belt held two autocannon clips, a grenade and a smoke grenade. harness.NO_AUTO_EQUIP turns on the stock disableAutoEquip option, so every soldier starts with empty slots on both machines. The eight tests that move items on these screens boot with it. test_shared_craft_loads keeps the old setting for its option-ON boot, whose setup needs every craft crew member to leave the soldier screen with a layout. Rows that relied on the starting gear now stage their own items: - test_shared_base_writes base_write_4 and base_write_8 put a pistol in the client soldier's left hand before saving its layout. - test_shared_equip_transfer drags its soldier's gear on the host's screen in place of writing the layout with give_layout. The host's OK sends only the records the screen changed, and that record is what carries the soldier's new name to the client. With empty starting gear a layout written before the screen opened was sent only when the item order happened to change (3 of 6 runs failed).
soldiers_ok presses OK on a SoldiersState found anywhere in the state stack, and OK closes whatever screen is on top. When another screen sits above SoldiersState at that moment, soldiers_ok closes that screen and leaves the soldier screen open. test_shared_base_writes separate_template_armor failed once locally with that signature: soldiers_ok replied ok and SoldiersState stayed open for the whole 30 s wait. The row's later close then failed as a knock-on. close_soldier_screen now waits until SoldiersState is the top screen before it presses OK, and keeps the stack before and after the press in the cell, so a repeat names the screen that was on top. Forced with a notice pushed over the soldier screen and closed 1.5 s later: the old helper left SoldiersState open (3 of 3 runs), the new one closed it once the notice was gone (3 of 3).
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Symptom
test_shared_base_writesfailed once in CI: PR #233, run 42113610511 attempt 1,coop-shard (3). Rowbase_write_9failed its setup check, and attempt 2 passed.Cause (reproduced)
base_write_9moves a grenade onto the host soldier H's belt. In the CI run, H's belt was already full: two autocannon clips at (0, 0) and (2, 0), two cells wide each, a grenade at (0, 1) and a smoke grenade at (3, 1). The grenade had no free cell.That gear comes from the base inventory screen. When it opens, the game hands items to every soldier that has no saved layout (
BattlescapeGenerator::autoEquip). The items come out of a container ordered by memory address, so the gear changes from boot to boot. It also differs between the host and the client for the same soldier in the same boot. In one probe boot, the host's screen showed a soldier with a rifle and the client's screen showed the same soldier with a rocket launcher.test_base_partner_held(#224) failed for the same reason.Fix
base_write_9moves every item off H's belt before it stages the grenade.harness.NO_AUTO_EQUIPturns on the stockdisableAutoEquipoption, so every soldier starts with empty slots on both machines. The 8 tests that move items on base or craft inventory screens boot with it. Two boots keep the old setting:test_shared_craft_loads, whose setup needs every craft crew member to leave the soldier screen with a saved layout.test_separate_equipment_templates, which starts a battle (deployment would hand out nothing either).base_write_4andbase_write_8put a pistol in the client soldier's left hand before saving its layout.test_shared_equip_transfernow drags its soldier's gear on the host's screen instead of writing the layout withgive_layout. When the host closes the screen it sends only the soldier records the screen changed, and that record is what carries the soldier's new name to the client. With empty starting gear, a layout written before the screen opened was sent only when the item order happened to change. In failing runs the host's shared-command count stayed at 3 and the client never got the new name or gear.close_soldier_screenhelper presses OK only onceSoldiersStateis the top screen, and keeps the stack before and after the press.soldiers_okpresses OK on aSoldiersStateanywhere in the stack, and OK closes whatever screen is on top. So a screen sitting above the soldier screen got closed instead and the soldier screen stayed open.separate_template_armorfailed once locally with that exact signature. It did not reproduce in about 260 runs, so what sat on top that time is unknown. The kept stacks will name it if it happens again. The helper is used by 5 test files. The other 22soldiers_okcall sites in 12 files are unchanged.Proof
base_write_9once by itself in 5 runs.disableAutoEquipprobe: in 2 boots, 0 of 8 soldiers carried anything on either machine.test_shared_equip_transfer: with the option and the oldgive_layout, 5 of 10 runs failed the world-equality check after equip and unseat. With the change, 9 of 9 passed.SoldiersStateopen withsoldiers_okreplying ok, 3 of 3 runs, the same signature as the local failure. The new helper waited for the notice and then closed the screen, 3 of 3. All 5 tests that use the helper passed afterwards.test_base_visit_pointertook 7.0 s, old and new.Old and new were run interleaved on the same harness slot. CPU load was 5 to 18 % for most runs.
test_shared_base_writestest_shared_base_equiptest_base_partner_heldtest_base_partner_viewtest_shared_craft_loadstest_coop_equip_layout_synctest_coop_peer_equip_screenstest_shared_equip_transfer