describe_exit labeled every code >= 0xC0000000 "the process crashed", but a
process can exit with any 32-bit value on purpose, so the range alone doesn't
show a crash. Only the NTSTATUS values in NTSTATUS_CRASHES (access violation,
illegal instruction, out of memory, stack overflow, heap corruption, fail
fast) get the crash label now. Ctrl+C (0xC000013A) is still named but not
called a crash, and any other value is just "exit code 0x...".
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
A failed module was printed as "==== FAILED: <name>" and its output, never its
exit code. A module whose interpreter crashes prints nothing, so it left a bare
header with nothing under it, and the run gave no clue why it failed.
The header now carries the exit code: "exit code 1" for a test failure, the
signal for a POSIX kill ("killed by SIGSEGV (-11)"), and the hexadecimal
NTSTATUS with its meaning for a Windows crash ("exit code 0xC0000005, access
violation (the process crashed)"). A module that printed nothing also gets a
"(no output: the process ended before printing anything)" line.
Only the FAILED print in main() changes; run_module is untouched.
Tests (tests/test_run_semantic_tests.py): the header of a plain failure, a
module that really crashes (SIGSEGV on POSIX, exit code 0xC0000005 on
Windows) and describe_exit itself.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
- 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).
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)
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.
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.
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.
`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.
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.