Skip to content

progress_dashboard: report test discovery errors before writing - #7083

Open
Barbital11111 wants to merge 1 commit into
ItsNotRexed:mainfrom
Barbital11111:fix/progress-dashboard-discovery-errors
Open

Barbital11111 wants to merge 1 commit into
ItsNotRexed:mainfrom
Barbital11111:fix/progress-dashboard-discovery-errors

Conversation

@Barbital11111

Copy link
Copy Markdown
Contributor

Coordination claim.

When --run-tests cannot list a test directory or open a test file, ci_test_files() raises before the existing error handler. Report the discovery error with the path and exit 2 before creating the output folder. The scan still fails fast as in #4515. This leaves the output and JSON handling proposed in #4846 outside the discovery path.

Validation

  • Windows 11, CPython 3.14.3, CPU only. The synthetic permission-error regression raised PermissionError on the base. With the fix, python -I tests/test_progress_dashboard.py passed all 40 tests.
  • The CLI ran one filtered test file (11 cases), recorded its passing outcome and generated the dashboard in a temporary folder.
  • git diff --check and the changed-file no-game-data check passed.
  • The repository-wide test_text_write_line_endings.py reports one pre-existing failure on two unchanged writer sites, in f64_omod_probe.py and leonida_tui.py.

AI-assisted (Codex). Synthetic inputs only.

@tikD1337

Copy link
Copy Markdown
Contributor

No blocking findings in the supplied diff. This is a focused fix that turns a test-discovery filesystem failure into a clear CLI error before the dashboard creates its output directory or reaches output-writing code.

Previously, an OSError from ci_test_files() escaped from the list comprehension. The implementation now completes discovery inside a narrow try block, reports the failure to stderr, and returns exit status 2. Successful discovery continues through the existing test filter and unmatched-filter validation unchanged.

The exception handling is appropriately scoped:

  • Catching OSError covers filesystem failures such as PermissionError without broadly swallowing unrelated programming errors.
  • The diagnostic includes the failing filename and filesystem error message. The fallbacks also accommodate exceptions without a filename or strerror.
  • Returning immediately preserves the discovery failure as an error. It does not reinterpret an incomplete scan as an empty or successful test selection.
  • Keeping discovery and selection ahead of os.makedirs() preserves the intended ordering: validate the requested test run before creating dashboard output.

The new regression test exercises the CLI boundary directly. It injects a PermissionError from ci_test_files(), invokes main() with --run-tests, and asserts all three observable requirements: exit status 2, the exact stderr diagnostic, and absence of the output directory. Using a synthetic exception makes this deterministic on Windows without depending on ACL configuration or the privileges of the account running the tests.

The existing test_unlistable_subfolder_raises_instead_of_a_partial_scan complements that test by covering the discovery function’s refusal to return a partial scan. Together, they check error propagation from discovery and error handling at the CLI boundary. The new test specifically covers a destination that does not yet exist; preservation of an existing output directory on this failure path follows from the early return before output-writing code, rather than from a new direct assertion.

Verification evidence supplied for Windows 11 / CPython 3.13: all reported checks passed without game files:

  • git diff --check
  • Python compilation via compileall
  • check_no_game_data.py
  • make_game.py --help
  • tests/test_progress_dashboard.py: 40 tests passed, exit status 0, in 2.003 seconds

The passing suite includes the new discovery-error regression, the partial-scan rejection test, invalid and unmatched test-filter handling, cached-result preservation, and the existing dashboard parsing, freshness, and output checks. These are the supplied verification results; I have not independently rerun them.

The diff adheres to the project constraints: it adds no game data or derived game artifacts, introduces no keys, decryption, or protection workarounds, and adds no calls to online services. It also follows fix, don’t disable: discovery failures remain visible failures, with no skipped tests, suppressed errors, or fabricated success results. No GPU, MSVC, or Ninja validation is needed for this Python CLI error-handling change.

AI-assisted.

@kapitche

Copy link
Copy Markdown
Contributor

Tested 2a4ffae merged with main 8575d36 on Linux/Python 3.12.16: pass

Commands run (merged worktree, -I isolated mode):

  • python -I tests/test_progress_dashboard.py -> Ran 40 tests, OK
  • Negative control: git checkout upstream/main -- tools/progress_dashboard.py, rerun -> FAILED (errors=1): the new test_test_discovery_error_is_reported_before_creating_output ends in an uncaught PermissionError: [Errno 13] Permission denied: '.../tests/locked'. Restored with git checkout HEAD -- tools/progress_dashboard.py.

Diff read: ci_test_files() is wrapped so an OSError prints error discovering tests: <path>: <strerror> and returns 2 before os.makedirs(out_dir); the test checks the one-line stderr, the exit code and that the output folder is not created. Minor: if an OSError carries no filename the message reads error discovering tests: : <strerror>; not tested and not a blocker.

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.

3 participants