Skip to content

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

Open
itsmiso-ai wants to merge 1 commit into
mainfrom
saffron-normal/fix-issue-176-test-repair
Open

fix: repair 4 failing tests and add exit-code checks for reservation CI (#176)#198
itsmiso-ai wants to merge 1 commit 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.

…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 requested a review from joryirving as a code owner June 10, 2026 09:17

@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

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 explicitly exit 1 if the command fails. This prevents the CI from passing if the reservation tests fail but the cat command succeeds.

Test Repairs

  • tests/test_food_upkeep.gd:
    • Changed extends TestSuite to extends SceneTree to match the project's testing pattern.
    • Implemented a custom _initialize() runner that executes individual test functions, tracks pass/fail counts, and uses quit(1) on failure to ensure the CI detects the failure.
    • Updated test functions to return Variant (returning true on success or a String error message on failure) to support this new reporting mechanism.
  • tests/test_recruit_worker.gd: Added explicit type annotation var initial_count: int = ... to resolve GDScript v2 strict type inference errors.
  • tests/test_resource_trends.gd:
    • Implemented a _make_main() helper to instantiate Main directly, avoiding reliance on the Globals autoload 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 Variant for error reporting.
  • scripts/game_state.gd: Added class_name GameState to allow the class to be globally accessible, resolving compilation errors in test_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, and test_worker_cap.gd (via the GameState fix), 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 int annotations) and the established testing pattern seen in test_runner.gd.
  • CI/CD: The use of set -euo pipefail in 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.

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

1 participant