fix: repair 4 failing tests and add exit-code checks for reservation CI (#176)#198
Open
itsmiso-ai wants to merge 1 commit into
Open
fix: repair 4 failing tests and add exit-code checks for reservation CI (#176)#198itsmiso-ai wants to merge 1 commit into
itsmiso-ai wants to merge 1 commit into
Conversation
…CI (#176) - test_resource_trends.gd: Replace Globals.get_node with direct Main instance creation to work in headless mode (fixes 'Globals not declared' error) - test_food_upkeep.gd: Change extends TestSuite → extends SceneTree, wrap all tests in _initialize() (fixes 'Could not find base class TestSuite') - test_recruit_worker.gd: Add explicit type annotation for initial_count: int (fixes 'Cannot infer type' parse error) - game_state.gd: Add class_name GameState so it's accessible in strict mode (fixes 'Identifier not found: GameState' compile error) - .github/workflows/test.yml: Add exit-code capture and check for reservation tests step (was silently ignoring failures)
There was a problem hiding this comment.
AI Automated Review
Full PR review.
Analysis engine: review@https://litellm.jory.dev/v1 (openai)
Recommendation
This PR successfully addresses all requirements of issue PR 176 by repairing failing standalone test scripts and enforcing exit-code checks for reservation tests in the CI pipeline.
Change-by-change Findings
CI Configuration
.github/workflows/test.yml: Added logic to capture the exit code (RES_EXIT=$?) of the reservation tests and explicitlyexit 1if the command fails. This prevents the CI from passing if the reservation tests fail but thecatcommand succeeds.
Test Repairs
tests/test_food_upkeep.gd:- Changed
extends TestSuitetoextends SceneTreeto match the project's testing pattern. - Implemented a custom
_initialize()runner that executes individual test functions, tracks pass/fail counts, and usesquit(1)on failure to ensure the CI detects the failure. - Updated test functions to return
Variant(returningtrueon success or aStringerror message on failure) to support this new reporting mechanism.
- Changed
tests/test_recruit_worker.gd: Added explicit type annotationvar initial_count: int = ...to resolve GDScript v2 strict type inference errors.tests/test_resource_trends.gd:- Implemented a
_make_main()helper to instantiateMaindirectly, avoiding reliance on theGlobalsautoload which is unavailable in headless mode. - Updated test functions to use this local instance instead of
Globals.get_node("/root/Main"). - Updated test functions to return
Variantfor error reporting.
- Implemented a
scripts/game_state.gd: Addedclass_name GameStateto allow the class to be globally accessible, resolving compilation errors intest_worker_cap.gd.
Linked Issue Fit
- Issue PR 176: The PR directly implements the requested fixes for
test_resource_trends.gd,test_food_upkeep.gd,test_recruit_worker.gd, andtest_worker_cap.gd(via theGameStatefix), and adds the requested exit-code enforcement for reservation tests.
Standards Compliance
- GDScript Conventions: The changes follow the project's move towards strict typing (e.g., explicit
intannotations) and the established testing pattern seen intest_runner.gd. - CI/CD: The use of
set -euo pipefailin the workflow is a good practice for robust shell scripts.
Unknowns or Needs Verification
- None. The changes appear to resolve the specific parse and compile errors identified in the issue description.
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 #176
This PR repairs all 4 failing standalone test scripts and adds exit-code enforcement for reservation tests in CI.
Changes
test_resource_trends.gd: Replace
Globals.get_node("/root/Main")with direct Main instance creation via a_make_main()helper function. This eliminates the parse error 'Identifier Globals not declared' that occurs in headless mode since there's no autoload scene tree.test_food_upkeep.gd: Change
extends TestSuite→extends SceneTreeand wrap all tests inside_initialize(). TestSuite is not a built-in Godot class; the pattern now matches test_runner.gd, test_recruit_worker.gd, and test_worker_cap.gd.test_recruit_worker.gd: Add explicit type annotation
var initial_count: int = main.state.workers.size()to satisfy GDScript v2 strict type inference (fixes 'Cannot infer the type of initial_count variable').game_state.gd: Add
class_name GameStateat the top so the class is globally accessible in strict mode. This fixes the compile error 'Identifier not found: GameState' that occurs when test_worker_cap.gd preloads main.gd (which uses GameState as a type annotation)..github/workflows/test.yml: Add exit-code capture (
RES_EXIT=$?) and conditional check for the reservation tests step. Previously failures were silently ignored since onlycatwas run after the Godot command.