Fix debug test suite for Factorio 2.0#1575
Merged
Merged
Conversation
Two long-standing failures in the in-game test runner: - The Gui top-button toggle test counted all children of the gui roots, but GUIs like the production hud hide their screen frame on close to preserve its position rather than destroying it. Count only visible elements so hide-on-close toggles pass. - Helper.modify_lua_object rawset fields on LuaObjects, which worked in Factorio 1.1 where they were tables but errors since 2.0 where they are userdata. Add Helper.fake_lua_object (a table that reads and writes through to the wrapped object except for overridden fields) and Helper.modify_global (replaces e.g. the game global until teardown), and migrate the death corpse tags, restart command and landfill remover tests to them. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
grilledham
approved these changes
Jul 11, 2026
grilledham
left a comment
Collaborator
There was a problem hiding this comment.
Thanks for fixing the tests.
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.
Fixes two long-standing failures in the in-game test runner (
_DEBUG+/test-runner), both fallout from the Factorio 2.0 engine update.Gui toggle test:
13 ~= 14 - after close count should be equal to before countThe top-button toggle test counted every child of the gui roots (top/left/center/screen). GUIs like the production hud hide their screen frame on close to preserve its dragged position instead of destroying it, so the count stayed one high after closing. The test now counts only visible elements, which keeps the "open shows something / close removes it" contract while allowing the hide-on-close pattern.
helper.lua: bad argument #1 to 'rawset' (table expected, got userdata)Helper.modify_lua_objectmonkey-patched fields directly onto LuaObjects (player.print,game.get_player, ...) withrawset. That worked in Factorio 1.1 where LuaObjects were Lua tables, but they are userdata since 2.0, so every test using it errored. This PR adds:Helper.fake_lua_object(object, overrides)— a proxy table that reads and writes through to the wrapped LuaObject except for the overridden fields.Helper.modify_global(context, name, value)— replaces a global (e.g.game) with such a proxy until test teardown.The death corpse tags, restart command and landfill remover tests are migrated to the new helpers;
modify_lua_objectnow raises a clear error when given a LuaObject. This is safe for these tests because the features under test only read through the player object (print,admin,force, ...) and never pass it back into engine APIs.Verified in-game on a vanilla-mod map: the Gui toggle tests and death corpse tags test now pass. The restart command and landfill remover suites are migrated mechanically but were not exercised, as those features are not loaded on the default map.
🤖 Generated with Claude Code