Skip to content

fix: repair 4 failing tests and add exit-code checks for reservation CI (#176)#198

Merged
joryirving merged 2 commits into
mainfrom
saffron-normal/fix-issue-176-test-repair
Jun 12, 2026
Merged

fix: repair 4 failing tests and add exit-code checks for reservation CI (#176)#198
joryirving merged 2 commits into
mainfrom
saffron-normal/fix-issue-176-test-repair

Conversation

@itsmiso-ai

Copy link
Copy Markdown
Contributor

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 TestSuiteextends SceneTree and 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 GameState at 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 only cat was run after the Godot command.

@itsmiso-ai itsmiso-ai requested a review from joryirving as a code owner June 10, 2026 09:17
its-saffron[bot]

This comment was marked as outdated.

its-saffron[bot]

This comment was marked as outdated.

@itsmiso-ai itsmiso-ai force-pushed the saffron-normal/fix-issue-176-test-repair branch from 63842ff to bc51cd3 Compare June 12, 2026 01:58
its-saffron[bot]

This comment was marked as outdated.

…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)
@itsmiso-ai itsmiso-ai force-pushed the saffron-normal/fix-issue-176-test-repair branch from bc51cd3 to ab58ef4 Compare June 12, 2026 04:24
its-saffron[bot]

This comment was marked as outdated.

The 'class_name GameState' declaration conflicts with the autoload
singleton named 'GameState' in project.godot. This caused a parse error:
  Class 'GameState' hides an autoload singleton.

Remove class_name and use dynamic typing for the local variable that
instantiates the autoload singleton.

@its-saffron its-saffron Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

AI Automated Review (incremental)

Incremental review: reviewed the changes since the last managed review; unresolved findings from that review are carried forward.

Analysis engine: review@https://litellm.jory.dev/v1 (openai)

Recommendation

Approved. This PR addresses several critical issues in the test suite and CI pipeline, ensuring that failing tests are repaired and that CI failures are correctly captured rather than silently ignored.

Changes

Scripts

  • scripts/game_state.gd: Removed class_name GameState. This is a necessary change to resolve an autoload conflict where GameState was being treated as a global singleton in some contexts but needed to be instantiated manually in others (specifically for testing).
  • scripts/main.gd: Updated _on_startup_new_game to use untyped var _gs = GameState.new() instead of explicit type annotation var _gs: GameState = GameState.new(). This is a direct consequence of removing the class_name from game_state.gd to fix the autoload conflict.

Tests

  • tests/test_recruit_worker.gd: Added explicit type annotation var initial_count: int = main.state.workers.size() to satisfy GDScript v2 strict type inference requirements.
  • tests/test_food_upkeep.gd (implied by PR description): Updated to extend SceneTree and use _initialize() to align with the project's testing pattern.
  • tests/test_resource_trends.gd (implied by PR description): Refactored to use a _make_main() helper instead of relying on Globals.get_node("/root/Main"), which fails in headless mode.

CI/CD

  • .github/workflows/test.yml: Added exit-code capture (RES_EXIT=$?) and conditional checks for reservation tests. This ensures that if the Godot test command fails, the CI step correctly reports a failure instead of silently passing due to the subsequent cat command.

Linked Issue Fit

  • Fixes PR 176: The PR successfully addresses the failing tests and CI issues described in the linked issue. The implementation follows the requirements to repair the standalone test scripts and enforce exit codes in the workflow.

Standards Compliance

  • GDScript Conventions: The PR correctly addresses strict type inference issues in test_recruit_worker.gd and resolves the class_name conflict in game_state.gd which was causing compilation errors in the test environment.
  • Testing Pattern: The changes to test_food_upkeep.gd align the test structure with existing patterns in test_runner.gd and other test files in the repository.

@joryirving joryirving merged commit 9364438 into main Jun 12, 2026
4 checks passed
@joryirving joryirving deleted the saffron-normal/fix-issue-176-test-repair branch June 12, 2026 05:11
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Make all checked-in tests runnable and enforce them in CI

2 participants