Skip to content

run_semantic_tests: preserve package discovery in parallel - #7073

Open
ODanielAtaide wants to merge 5 commits into
ItsNotRexed:mainfrom
ODanielAtaide:ci/parallel-package-test-discovery
Open

ODanielAtaide wants to merge 5 commits into
ItsNotRexed:mainfrom
ODanielAtaide:ci/parallel-package-test-discovery

Conversation

@ODanielAtaide

Copy link
Copy Markdown

Claimed in the coordination issue.

What and why

The CI runner schedules nested test*.py files directly when using multiple jobs. This skips tests and import errors in package initializers and bypasses the package's load_tests hook. A failing initializer can produce a green run, and an excluded test can produce a red run.

Schedule each top-level test package as one standard unittest discover job, with the suite directory as the import root. Standalone test files still run one per worker. The package regressions cover initializer tests, import errors, load_tests selection, and recursive discovery.

Tested

  • Windows, CPython 3.14: python -I tests/test_run_semantic_tests.py -v passed all 8 tests. Before the runner change, the new regressions reproduced two false passes and one false failure.
  • A mixed package and standalone suite ran 3 tests through the actual -j 2 -v CLI.
  • Local three-way merge with run_semantic_tests: reject --jobs < 1 and check empty/missing suites before -j 1 #6515 at e6c4d25a applied cleanly; the combined runner suite passed all 10 tests.
  • Python compilation, whitespace checks, and the repository's No Game Data check passed for both changed files.

AI-assisted: yes (Codex).

Checklist

  • No game data, keys or decryption.

@Yedayaa

Yedayaa commented Nov 23, 2026

Copy link
Copy Markdown

I reproduced a serial/parallel discrepancy at 99e3b43 on Windows with CPython 3.15.2. The synthetic suite has one passing test_top.py and an otherwise empty pkg/__init__.py. On the base, -j 2 exits 0 with one test. On the PR head, -j 1 still exits 0 with one test, but -j 2 exits 1 and marks pkg failed because its discovery subprocess reports Ran 0 tests / NO TESTS RAN (exit 5).

Could the runner treat a package job with exit 5 and zero discovered tests as empty, while still failing if the entire suite runs zero tests? It would keep the initializer/import-error coverage without turning a passing suite red because it contains a helper package. A mixed passing-file/empty-package regression test would cover the difference.

AI-assisted (Codex). Synthetic inputs only.

Keep all-empty runs failing and preserve unittest skip results.
Reported-by: Yedayaa
@ODanielAtaide

Copy link
Copy Markdown
Author

Thanks for the reproducer. I confirmed the same false failure with CPython 3.14.7 on Windows. b52c25d treats unittest's empty discovery result as neutral for packages and standalone files. A run where every target is empty still exits 1. An explicit unittest skip keeps its usual result, and a subprocess failure without the unittest summary still fails.

The updated runner passed all 11 tests, including the new empty-package, empty-file, all-empty, and explicit-skip cases. A clean three-way merge with #6515 at e6c4d25a passed all 13 runner tests. The original 99e3b43 also ran the local semantic suite in parallel: 433 files, 6,150 tests and zero failed files.

No Game Data and whitespace checks passed. AI-assisted: yes (Codex).

@kapitche

Copy link
Copy Markdown
Contributor

Tested 99e3b43 merged with main 8575d36 on Linux/Python 3.12.16: pass

  • python -I tests/test_run_semantic_tests.py: 8 tests OK
  • Negative control: git checkout upstream/main -- scripts/run_semantic_tests.py, same test: FAILED (failures=4). Restored with git checkout HEAD --.
  • End to end: python -I scripts/run_semantic_tests.py tests/semantic -j 4 on the merged tree: 443 files, 5889 tests, 3 files failed in 261 s with 4 jobs: test_float_nan_fract, test_image_atomics_guard, test_image_store_d16. Those three files each report errors=1 when run alone as python -I -m unittest <module> from tests/semantic, on the merged tree and on plain main alike, so they are not caused by this PR. There is no package under tests/semantic at present (only fixtures/ without __init__.py), so the new package path (discover -s <pkg> -t <dir>) was exercised by the unit tests only, not by the real suite.

Fail discovery before launching unittest workers when a standalone test and a package import under the same name.
@Arkex-ai

Copy link
Copy Markdown
Contributor

On Windows with CPython 3.14.7 I compared serial and parallel discovery with two synthetic files: test_real.py containing one passing unittest, and an identical backup named test_real.saved.py. At d3821ab, running scripts/run_semantic_tests.py SUITE -j 1 passes one test (exit 0). With -j 2 the runner also schedules test_real.saved and reports AttributeError from unittest (exit 1). On main 7ec3056 the parallel path instead fails in getsize on test_real/saved.py. Would you include the standalone filename filtering in this PR? We have left that selector with your change. AI-assisted.

@ODanielAtaide

Copy link
Copy Markdown
Author

Thanks for the reproducer. I pushed 1dd8c17 to skip backup filenames in parallel discovery. With test_real.py and test_real.saved.py, both -j 1 and -j 2 now run one test and exit 0. The runner suite passes all 13 tests, and the local combination with #7270 passes all 16.

Keep the valid module filename check and preserve the filename's spelling
when loading it. Cover mixed-case prefixes and extensions on Windows.
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.

4 participants