Commit Graph

12 Commits

Author SHA1 Message Date
13127c76db Fail semantic runs without a completed unittest verdict
Retain process tracking and interrupt/timeout handling from main.
2026-11-27 23:41:32 +00:00
30a2a1862c run_semantic_tests: terminate process tree on Windows via taskkill and increase sleep margin (SEMANTIC-RUNNER-INTERRUPT)
- On Windows, terminate child processes using taskkill /F /T /PID to ensure
  launcher processes (e.g. venv python.exe wrappers) terminate all child workers.
- Increase synthetic sleep duration in tests from 5s to 10s and timeout margin to
  eliminate timing flakiness under high machine load.

AI-assisted (Claude Code).
2026-11-25 19:55:46 +03:00
542c046c50 run_semantic_tests: stop active subprocesses and cancel queued modules on interrupt (SEMANTIC-RUNNER-INTERRUPT)
Catch KeyboardInterrupt in run_semantic_tests.py, cancelling queued test modules via pool.shutdown(wait=False, cancel_futures=True) and terminating active child subprocesses so that no orphaned zombie processes or queued modules run after Ctrl+C. In serial mode (-j 1), terminate the discover subprocess on interrupt.

Return exit code 130 and output 'interrupted' to stderr without printing a false success summary.

Adds regression and lifecycle tests in tests/test_run_semantic_tests.py.

AI-assisted (Claude Code)
2026-11-25 19:11:41 +03:00
f48c2b2a35 semantic tests: count from unittest's result object
The count came from a line of the shape "Ran N tests in ..." in the module's
stderr. unittest writes that summary after every test has run, but a module
can write a line of the same shape after it: an atexit handler that runs a
nested runner does exactly that, and the runner counted "Ran 0 tests", so a
module with one passing test looked empty and the run exited 1 with "no
tests ran".

The count is now taken from unittest's own result object. The child program
runs the module through unittest's program, the way "python -m unittest
<module>" does, writes the result to a file and exits with unittest's own
exit codes: 1 when a test failed, 5 when nothing ran at all, 0 otherwise.
Nothing the module writes can change the count any more.

Follow-up to @lixonik's review on #662, which asked for the count to come
from the result rather than from a line of the module's stderr. AI-assisted.
2026-11-25 01:18:48 +08:00
7d184af582 semantic tests: count from unittest's own summary
A test that runs a nested unittest runner writes that runner's summary to
stderr while the test runs, before unittest writes its own. The count came
from the first "Ran N tests" line in stderr, so a nested summary of "Ran 0
tests" was counted and a passing module looked empty: the runner exited 1
with "no tests ran".

The count is now the last summary in stderr, which is unittest's own: it
writes that summary after every test has run, so nothing a test wrote can
come after it. A summary a test writes to stdout is never counted at all.
2026-11-24 19:43:31 +08:00
23b190b19e run_semantic_tests: count the tests from unittest, not from the merged output
unittest writes its own summary (Ran N tests in X s) and its NO TESTS RAN to stderr, while a test's own
output goes to stdout. The runner scanned the merged output for the first line of that shape, so a test that
printed one could be counted instead of the summary, and which line won depended on stdout buffering.

Reported by @Dezmonius on #14. AI-assisted.
2026-11-24 11:45:00 +00:00
66dac0d938 run_semantic_tests: a package initializer runs once, and a run with no tests fails
`python -m unittest pkg.__init__` imports pkg and then executes the same file again as
pkg.__init__, so a registration in the initializer happens twice in the -j 2 worker while
discover imports it once. Hand unittest the package name instead; module_path() still
resolves the initializer, so the largest-file-first order is unchanged.

A suite whose only module is an empty package initializer reported "1 files, 0 tests, 0
files failed" and exit 0 in parallel mode, where -j 1 (discover) exits 5. A run where every
job ran no tests now prints "no tests ran" and exits 1; an empty initializer next to real
tests is still fine because those count.

Both new cases in tests/test_run_semantic_tests.py fail against the previous script.
2026-11-24 16:02:00 +08:00
b45d7c2d14 SEMANTIC-PACKAGE-TESTS: run package initializers in parallel
unittest discover loads TestCase classes defined in a package's __init__.py regardless of the filename pattern. The parallel runner only selected test*.py files, so a failing package initializer could be skipped while -j 1 reported it. Include package initializers in the parallel module list; an empty initializer with no tests is not a failure. Add regressions for failing initializers and for a pattern that matches no test filenames.

AI-assisted.
2026-11-24 00:37:28 -06:00
90eb7284fe Reject semantic-test timeouts beyond portable wait limits 2026-11-23 22:20:42 -08:00
973593f4a7 Add optional timeout to semantic test subprocesses 2026-11-23 21:47:06 -08:00
3746a6ff0b feat: select semantic test files by glob pattern 2026-11-24 00:23:58 +03:00
c2cc4bfe7f scripts/run_semantic_tests.py: run tests/semantic one process per file, in parallel (253 s -> 26 s) (#4961)
Squash-merged after review of PR #4961 - scripts/run_semantic_tests.py: run tests/semantic one process per file, in parallel (253 s -> 26 s)
2026-11-23 08:10:57 -06:00