@@ -381,9 +381,10 @@ export int consumer_flag_v() {
381381
382382 // Holds the machine: compiles at the same time need the budget's slots (SPEC-017 O11).
383383 " 860 a workspaces programs compile at the same time" _test[resource{" machine" }] = [] {
384- // A: at -j 4 the members' build programs compile at the same time, and three run. B: at
385- // -j 1 they compile one after another and run in the same order. C: when two do not
386- // compile, the failure reported is that of the first to run, at either -j.
384+ // A: at -j 4 the members' build programs compile at the same time -- more than one is under
385+ // way at once -- and three run. B: at -j 1 they compile one after another and run in the
386+ // same order. C: when two do not compile, the failure reported is that of the first to
387+ // run, at either -j.
387388 s::project ws (s::case_dir () / " ws" , {{" mcpp.toml" , " [workspace]\n members = [\" pa\" , \" pb\" , \" pc\" ]\n " }});
388389 for (std::string m : {" pa" , " pb" , " pc" }) {
389390 ws.write (m + " /mcpp.toml" , std::format (" [package]\n name = \" {0}\"\n version = \" 0.1.0\"\n\n [targets.{0}]\n kind = \" bin\"\n main = \" src/main.cpp\"\n " , m));
@@ -405,47 +406,41 @@ export int consumer_flag_v() {
405406 auto clean = [&] {
406407 for (std::string d : {" target" , " pa/target" , " pb/target" , " pc/target" }) fs::remove_all (ws.at (d));
407408 };
408- // What A measures is the programs' compiles alone. The first build of the case's home
409- // also compiles the engine's module (`import mcpp`) into the home's cache, and under
410- // clang its code generation may continue after its interface is published, holding a
411- // slot of the budget: on three processors the three compiles then did not all overlap
412- // (macOS, CI 2026-11-21). A later build stages the module from the cache.
413- auto r = ws.mcpp ({" build" , " --workspace" , " -j" , " 4" }, inherited);
414- expect (fatal (e2e::succeeded (r))) << " A: the workspace did not build at -j 4: " << s::text (r);
415- clean ();
416- r = ws.mcpp ({" build" , " --workspace" , " -j" , " 4" }, inherited);
417- expect (fatal (e2e::succeeded (r))) << " A: the workspace did not build again at -j 4: " << s::text (r);
418- long latest_start = 0 , earliest_end = std::numeric_limits<long >::max ();
419- for (std::string m : {" pa" , " pb" , " pc" }) {
420- const auto sp = span (m);
421- expect (fatal (sp.has_value ())) << " A: the build programs' .ninja_log does not record every compile" ;
422- latest_start = std::max (latest_start, sp->first );
423- earliest_end = std::min (earliest_end, sp->second );
424- }
409+ // The members' compiles, and the most of them under way at one instant.
410+ const auto compiles = [&](std::string_view part) {
411+ std::vector<std::pair<long , long >> out;
412+ for (std::string m : {" pa" , " pb" , " pc" }) {
413+ const auto sp = span (m);
414+ expect (fatal (sp.has_value ())) << part << " : the build programs' .ninja_log does not record the compile of " << m;
415+ out.push_back (*sp);
416+ }
417+ return out;
418+ };
419+ const auto most_at_once = [](const std::vector<std::pair<long , long >>& spans) {
420+ std::size_t most = 0 ;
421+ for (const auto & [at, _] : spans)
422+ most = std::max<std::size_t >(most, std::ranges::count_if (spans, [&](const auto & o) { return o.first <= at && at < o.second ; }));
423+ return most;
424+ };
425425 const auto graph_rows = [&] {
426426 std::string text;
427427 for (const auto & log : s::find_files (ws.at (" target/.build-mcpp/host" ), R"( \.ninja_log)" ))
428428 for (const auto & row : ninja_rows (log)) text += std::format (" \n {} {} {}" , row[0 ], row[1 ], row[3 ]);
429429 return text;
430430 };
431- expect (fatal (latest_start < earliest_end)) << " A: the compiles did not overlap at -j 4 (latest start " << latest_start << " , earliest end " << earliest_end << " ); the graph's steps:" << graph_rows ();
431+ // Not all three at one instant: each compile waits for its own unit's scan, and on three
432+ // processors the scans of the same file ended 1.9, 3.5 and 7.7 s into the graph, so the
433+ // first compile had ended before the third began while two were under way together
434+ // (macOS, CI 2026-11-21).
435+ auto r = ws.mcpp ({" build" , " --workspace" , " -j" , " 4" }, inherited);
436+ expect (fatal (e2e::succeeded (r))) << " A: the workspace did not build at -j 4: " << s::text (r);
437+ expect (fatal (most_at_once (compiles (" A" )) >= 2u )) << " A: no two compiles were under way at once at -j 4; the graph's steps:" << graph_rows ();
432438 const auto order = ran (s::text (r), " p[abc]" );
433439 expect (fatal (order.size () == 3u )) << " A: expected three programs to run, got " << order.size () << " : " << s::text (r);
434440 clean ();
435441 r = ws.mcpp ({" build" , " --workspace" , " -j" , " 1" }, inherited);
436442 expect (fatal (e2e::succeeded (r))) << " B: the workspace did not build at -j 1: " << s::text (r);
437- std::vector<std::pair<long , long >> spans;
438- for (std::string m : {" pa" , " pb" , " pc" }) {
439- const auto sp = span (m);
440- expect (fatal (sp.has_value ())) << " B: the build programs' .ninja_log does not record the compile of " << m;
441- spans.push_back (*sp);
442- }
443- std::ranges::sort (spans);
444- long prev_end = 0 ;
445- for (const auto & [st, en] : spans) {
446- expect (fatal (st >= prev_end)) << " B: two compiles overlapped at -j 1" ;
447- prev_end = en;
448- }
443+ expect (fatal (most_at_once (compiles (" B" )) == 1u )) << " B: two compiles overlapped at -j 1; the graph's steps:" << graph_rows ();
449444 expect (fatal (ran (s::text (r), " p[abc]" ) == order)) << " B: the programs ran in another order at -j 1 than at -j 4" ;
450445 const auto first = order[0 ], second = order[1 ];
451446 ws.write (first + " /build.mcpp" , " #include <regex>\n #include <map>\n #error T860-failure-in-" + first + " \n int main() { return 0; }\n " );
0 commit comments