Repository navigation
test+ci: gate parallel ctest with serial retry, harden test framework - #1267
Merged
Merged
Conversation
…#1260) Parallel ctest runs flake with 0xc0000409 fail-fast and environment-sensitive assertion failures that all pass serially. Gate wrapper (scripts/ctest-gate.ps1): run ctest in parallel, and on failure re-run only the failed tests (ctest --rerun-failed) serially once. A serial green is annotated and passes the gate; a test that also fails serially stays red, so real regressions still block. The x64 CI test step now runs through the gate in parallel. Root-cause fixes in the test framework: - TempDir: replace the GetTempFileNameW + DeleteFile + create_directory sequence with atomic CreateDirectoryW on a pid/tick/counter name. The old code left a window where a parallel worker could claim the same path, and a leftover file at that name made create_directory throw out of the before-hook, terminating the test process (0xc0000409). - run_command: drain stdout/stderr and feed stdin on separate threads instead of serially - a child filling the stderr pipe blocked forever while the parent drained stdout first, hanging until the ctest timeout. Also check CreatePipe/CreateProcessW so a transient spawn failure returns exit -1 instead of waiting on a NULL handle and reporting an uninitialized exit code. - Pipeline::run: feed stdin on a thread for the same reason - a blocked WriteFile used to prevent the reader threads from ever starting. - TEST runner: catch exceptions thrown by before/after hooks and record them as test failures instead of letting them escape to terminate(); move the per-test failure reset above the hooks so hook-reported failures are not cleared. Generated with [Devin](https://devin.ai) Co-Authored-By: Devin <158243242+devin-ai-integration[bot]@users.noreply.github.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fixes #1260
Summary
scripts/ctest-gate.ps1): runsctest -j <procs>and, on failure, re-runs only the failed tests (ctest --rerun-failed -j1) serially once. A serial green emits a::warning::annotation listing the recovered tests and passes the gate; a test that also fails serially stays red, so real regressions still block. The x64 CI test step now invokes the gate (parallel + serial retry) instead of a bare serialctest.tests/framework/temp_dir.h): the oldGetTempFileNameW+DeleteFileW+create_directorysequence left a window where a parallel worker could claim the same path — two tests shared/deleted each other's files, and a leftover file at that name madecreate_directorythrow out of the before-hook →terminate→ 0xc0000409. Replaced with atomicCreateDirectoryWon awct-<pid>-<tick>-<counter>name, retrying on collision.run_command(tests/framework/process_win32.cpp): stdout/stderr/stdin are now pumped on separate threads. Draining stdout fully before stderr let a child that filled the stderr pipe block forever →INFINITEwait → ctest timeout kill under parallel load. Also checksCreatePipe/CreateProcessW: a transient spawn failure previously leftpi.hProcess = NULL, soWaitForSingleObjectreturned immediately and an uninitializedcodewas returned as a garbage exit status.Pipeline::run(tests/framework/pipeline.cpp): stdinWriteFilemoved to a thread — a child that never reads stdin used to block the write before the output-reader threads started, same deadlock class.TESTrunner (tests/framework/wctest.h): exceptions thrown by before/after hooks are now recorded as test failures instead of escaping toterminate()(the 0xc0000409 class). The per-test failure reset moved above the before-hooks so a hook-reported failure is no longer cleared; the test body is skipped when before-hooks failed (TempDir may be unset).Test plan
-j 16) targeted runs against Debug build in this worktree, all green on first pass: ticket-named flake groupsls|mktemp|timeout|wc|which|cut|find|head|join|realpath(477 tests),wpm|integration|winuxcmd(131), pipe-heavytput|cat|tee|sed|yes|trincl.probe_stdin_leftovercoverage (249).::warning::annotations instead of fake reds.I18N impact
None — no user-visible strings in
src/changed; test framework, CI, and script output are not part of the catalog.Generated with Devin