Commit dea5ce2
test: stop compile-fail tests racing on the shared build tree
Each compile-fail test runs `cmake --build` on the shared build tree as
its test command. When that tree is out of date - someone edited a
CMakeLists.txt - all 24 of them re-run CMake at once under `ctest -j N`
and corrupt each other's regeneration. On Ninja the losers die with
ninja: error: failed recompaction: No such file or directory
FAILED: build.ninja
before compiling anything, so the expected diagnostic never reaches the
output and PASS_REGULAR_EXPRESSION fails. It reproduces in roughly two
runs out of three with
touch test/CMakeLists.txt; ctest -R compile_fail -j32
and not at all on an up-to-date tree, which is why it looked random.
644c3e2 predicted this ("other generators race analogously on the
cmake-regeneration step") but 0b0e7db narrowed the RESOURCE_LOCK to the
Visual Studio generator, leaving Ninja exposed.
Do the regeneration once, in a CTest fixture, so no test regenerates
while another runs. That keeps the 24 compiles parallel, unlike a lock.
10/10 stale-tree runs at -j32 are now clean.
The Visual Studio lock stays, and its comment was wrong: the race there
is not the regeneration step, so the fixture does not help. Every MSBuild
invocation walks the whole project dependency graph and rewrites the
.tlog/.lastbuildstate of each project it passes through, the dependencies'
as well as ZERO_CHECK's, so concurrent invocations collide whether or not
anything needs regenerating. Measured with VS 18 2026: 7-13 of 24 fail on
every run without the lock, 3/3 clean with it. Windows users who want
these parallel should configure with -G Ninja, which is clean at -j32 and
~14x faster.
b2 is unaffected: it compiles these sources as ordinary targets in its own
dependency graph rather than shelling out to a nested build. ~40 runs at
-j32/-j64/-j128 found nothing.
Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>1 parent e5ce8f5 commit dea5ce2
2 files changed
Lines changed: 59 additions & 8 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
99 | 99 | | |
100 | 100 | | |
101 | 101 | | |
| 102 | + | |
| 103 | + | |
| 104 | + | |
| 105 | + | |
| 106 | + | |
| 107 | + | |
| 108 | + | |
| 109 | + | |
| 110 | + | |
| 111 | + | |
| 112 | + | |
| 113 | + | |
| 114 | + | |
| 115 | + | |
| 116 | + | |
| 117 | + | |
| 118 | + | |
| 119 | + | |
| 120 | + | |
| 121 | + | |
| 122 | + | |
| 123 | + | |
102 | 124 | | |
103 | 125 | | |
104 | 126 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
108 | 108 | | |
109 | 109 | | |
110 | 110 | | |
| 111 | + | |
| 112 | + | |
| 113 | + | |
| 114 | + | |
| 115 | + | |
| 116 | + | |
| 117 | + | |
| 118 | + | |
| 119 | + | |
| 120 | + | |
| 121 | + | |
| 122 | + | |
| 123 | + | |
| 124 | + | |
| 125 | + | |
| 126 | + | |
| 127 | + | |
| 128 | + | |
| 129 | + | |
| 130 | + | |
| 131 | + | |
| 132 | + | |
| 133 | + | |
| 134 | + | |
| 135 | + | |
111 | 136 | | |
112 | 137 | | |
113 | 138 | | |
| |||
116 | 141 | | |
117 | 142 | | |
118 | 143 | | |
119 | | - | |
120 | | - | |
121 | | - | |
122 | | - | |
123 | | - | |
124 | | - | |
| 144 | + | |
| 145 | + | |
| 146 | + | |
| 147 | + | |
| 148 | + | |
| 149 | + | |
| 150 | + | |
| 151 | + | |
| 152 | + | |
| 153 | + | |
125 | 154 | | |
126 | | - | |
127 | | - | |
| 155 | + | |
| 156 | + | |
128 | 157 | | |
129 | 158 | | |
130 | 159 | | |
| |||
0 commit comments