From a313e7277fc1c856494212c7f20db93e47796b1a Mon Sep 17 00:00:00 2001 From: Sunrisepeak Date: Sun, 22 Nov 2026 14:12:54 +0900 Subject: [PATCH 1/2] test: case 860 holds the members' build programs under way together by their steps, not by when their compiles fall --- ...-11-20-test-architecture-upgrade-design.md | 5 ++ tests/e2e/workspace/graph.cpp | 56 ++++++++++++------- 2 files changed, 40 insertions(+), 21 deletions(-) diff --git a/.agents/docs/2026-11-20-test-architecture-upgrade-design.md b/.agents/docs/2026-11-20-test-architecture-upgrade-design.md index 02c556dc0..f12d3ac03 100644 --- a/.agents/docs/2026-11-20-test-architecture-upgrade-design.md +++ b/.agents/docs/2026-11-20-test-architecture-upgrade-design.md @@ -1006,6 +1006,11 @@ doctest 适配器(5.14)、依赖的调试信息(5.15)。boost-m 自己 分片的用时 W,N × W 按每片 30 分钟折算(`ci-unit.yml`;两次运行都得出三个分片)。N 与 W 从各分片作业保存的存储 读出:作业的存储经导入保存为 mtest 的运行记录,其中没有分片;历史中另有子系统作业的运行。套件陈述的时间不变:它们界定 挂起,在三个分片中留有余量。 +19. **发布之后:`graph/860` 的重叠断言(macOS,`pr` 档,运行 44959494484)。** 用例断言 `-j 4` 时至少两个成员的 + build program 的编译同时进行。每个编译等待自己单元的扫描;三个处理器的 macOS runner 上同一文件的三次扫描用时 0.19、 + 1.65 与 2.75 s,编译(各 0.7 至 0.9 s)先后进行,用例失败,重跑通过。编译是否重叠由扫描的用时决定,不是构建图的性质; + 图的性质是各成员的 build program 在同一张图中并行推进,三个成员的扫描在图开始后 35 ms 内同时开始。断言改为成员的步骤 + (扫描、编译、链接):`-j 4` 时至少两个成员的步骤同时进行,`-j 1` 时同一时刻只有一个成员;各成员的编译仍须有记录。 ## 15. 子方案 diff --git a/tests/e2e/workspace/graph.cpp b/tests/e2e/workspace/graph.cpp index cbb91e16f..896153e17 100644 --- a/tests/e2e/workspace/graph.cpp +++ b/tests/e2e/workspace/graph.cpp @@ -381,10 +381,10 @@ export int consumer_flag_v() { // Holds the machine: compiles at the same time need the budget's slots (SPEC-017 O11). "860 a workspaces programs compile at the same time"_test[resource{"machine"}] = [] { - // A: at -j 4 the members' build programs compile at the same time -- more than one is under - // way at once -- and three run. B: at -j 1 they compile one after another and run in the - // same order. C: when two do not compile, the failure reported is that of the first to - // run, at either -j. + // A: at -j 4 the members' build programs are built at the same time -- steps of more than + // one member under way at once -- each is compiled, and three run. B: at -j 1 they are + // built one after another and run in the same order. C: when two do not compile, the + // failure reported is that of the first to run, at either -j. s::project ws(s::case_dir() / "ws", {{"mcpp.toml", "[workspace]\nmembers = [\"pa\", \"pb\", \"pc\"]\n"}}); for (std::string m : {"pa", "pb", "pc"}) { ws.write(m + "/mcpp.toml", std::format("[package]\nname = \"{0}\"\nversion = \"0.1.0\"\n\n[targets.{0}]\nkind = \"bin\"\nmain = \"src/main.cpp\"\n", m)); @@ -406,20 +406,30 @@ export int consumer_flag_v() { auto clean = [&] { for (std::string d : {"target", "pa/target", "pb/target", "pc/target"}) fs::remove_all(ws.at(d)); }; - // The members' compiles, and the most of them under way at one instant. - const auto compiles = [&](std::string_view part) { - std::vector> out; - for (std::string m : {"pa", "pb", "pc"}) { - const auto sp = span(m); - expect(fatal(sp.has_value())) << part << ": the build programs' .ninja_log does not record the compile of " << m; - out.push_back(*sp); - } + // Each member's build program was compiled. + const auto compiled = [&](std::string_view part) { + for (std::string m : {"pa", "pb", "pc"}) + expect(fatal(span(m).has_value())) << part << ": the build programs' .ninja_log does not record the compile of " << m; + }; + // The steps of each member's build program -- its scan, compile and link (`obj/-...`, + // `bin/-...`) -- and the most members with a step under way at one instant. + const auto steps = [&](std::string_view part) { + std::vector>> out; + const auto logs = s::find_files(ws.at("target/.build-mcpp/host"), R"(\.ninja_log)"); + expect(fatal(!logs.empty())) << part << ": the build programs' graph left no .ninja_log"; + const std::regex re{R"(^(obj|bin)/(p[abc])-[0-9a-f]+/)"}; + for (const auto& row : ninja_rows(logs.front())) + if (std::smatch m; std::regex_search(row[3], m, re)) out.push_back({m[2].str(), {std::stol(row[0]), std::stol(row[1])}}); return out; }; - const auto most_at_once = [](const std::vector>& spans) { + const auto members_at_once = [](const std::vector>>& all) { std::size_t most = 0; - for (const auto& [at, _] : spans) - most = std::max(most, std::ranges::count_if(spans, [&](const auto& o) { return o.first <= at && at < o.second; })); + for (const auto& [_, at] : all) { + std::set busy; + for (const auto& [m, sp] : all) + if (sp.first <= at.first && at.first < sp.second) busy.insert(m); + most = std::max(most, busy.size()); + } return most; }; const auto graph_rows = [&] { @@ -428,19 +438,23 @@ export int consumer_flag_v() { for (const auto& row : ninja_rows(log)) text += std::format("\n {} {} {}", row[0], row[1], row[3]); return text; }; - // Not all three at one instant: each compile waits for its own unit's scan, and on three - // processors the scans of the same file ended 1.9, 3.5 and 7.7 s into the graph, so the - // first compile had ended before the third began while two were under way together - // (macOS, CI 2026-11-21). + // THE MEMBERS' STEPS, NOT THEIR COMPILES. Each compile waits for its own unit's scan, and + // on a three-processor macOS runner the scans of the same file took 0.19, 1.65 and 2.75 s, + // so the compiles (0.7 to 0.9 s each) were under way one at a time; the scans of all three + // members began within 35 ms of the graph's start and ran together (CI, 2026-11-22). That + // the members' programs are built in one graph is the steps under way together; when they + // compile follows from the scans' times. auto r = ws.mcpp({"build", "--workspace", "-j", "4"}, inherited); expect(fatal(e2e::succeeded(r))) << "A: the workspace did not build at -j 4: " << s::text(r); - 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(); + compiled("A"); + expect(fatal(members_at_once(steps("A")) >= 2u)) << "A: no two members' build programs were under way at once at -j 4; the graph's steps:" << graph_rows(); const auto order = ran(s::text(r), "p[abc]"); expect(fatal(order.size() == 3u)) << "A: expected three programs to run, got " << order.size() << ": " << s::text(r); clean(); r = ws.mcpp({"build", "--workspace", "-j", "1"}, inherited); expect(fatal(e2e::succeeded(r))) << "B: the workspace did not build at -j 1: " << s::text(r); - expect(fatal(most_at_once(compiles("B")) == 1u)) << "B: two compiles overlapped at -j 1; the graph's steps:" << graph_rows(); + compiled("B"); + expect(fatal(members_at_once(steps("B")) == 1u)) << "B: two members' build programs overlapped at -j 1; the graph's steps:" << graph_rows(); expect(fatal(ran(s::text(r), "p[abc]") == order)) << "B: the programs ran in another order at -j 1 than at -j 4"; const auto first = order[0], second = order[1]; ws.write(first + "/build.mcpp", "#include \n#include \n#error T860-failure-in-" + first + "\nint main() { return 0; }\n"); From e873dc9bbc9315457f217ff51c4c345bb2eee7e2 Mon Sep 17 00:00:00 2001 From: Sunrisepeak Date: Sun, 22 Nov 2026 14:39:10 +0900 Subject: [PATCH 2/2] test: case 860 counts a member's steps by edge, so the Windows runtime deployment written for every member is no member's --- ...-11-20-test-architecture-upgrade-design.md | 5 +++- tests/e2e/workspace/graph.cpp | 23 ++++++++++++++----- 2 files changed, 21 insertions(+), 7 deletions(-) diff --git a/.agents/docs/2026-11-20-test-architecture-upgrade-design.md b/.agents/docs/2026-11-20-test-architecture-upgrade-design.md index f12d3ac03..3c1439cae 100644 --- a/.agents/docs/2026-11-20-test-architecture-upgrade-design.md +++ b/.agents/docs/2026-11-20-test-architecture-upgrade-design.md @@ -1010,7 +1010,10 @@ doctest 适配器(5.14)、依赖的调试信息(5.15)。boost-m 自己 build program 的编译同时进行。每个编译等待自己单元的扫描;三个处理器的 macOS runner 上同一文件的三次扫描用时 0.19、 1.65 与 2.75 s,编译(各 0.7 至 0.9 s)先后进行,用例失败,重跑通过。编译是否重叠由扫描的用时决定,不是构建图的性质; 图的性质是各成员的 build program 在同一张图中并行推进,三个成员的扫描在图开始后 35 ms 内同时开始。断言改为成员的步骤 - (扫描、编译、链接):`-j 4` 时至少两个成员的步骤同时进行,`-j 1` 时同一时刻只有一个成员;各成员的编译仍须有记录。 + (扫描、编译、资源、链接):`-j 4` 时至少两个成员的步骤同时进行,`-j 1` 时同一时刻只有一个成员;各成员的编译仍须有记录。 + 步骤按边计:日志中同一命令的各行(命令的哈希与时间相同)是一条边,一条边写的文件都属于一个成员时才是该成员的步骤。 + Windows 上为各成员的程序部署 C++ 运行时 DLL 的边写入三个成员的目录,按行计时它使 `-j 1` 显得三个成员同时进行 + (运行 44988440716),按边计它不属于任何成员。 ## 15. 子方案 diff --git a/tests/e2e/workspace/graph.cpp b/tests/e2e/workspace/graph.cpp index 896153e17..053d0365c 100644 --- a/tests/e2e/workspace/graph.cpp +++ b/tests/e2e/workspace/graph.cpp @@ -411,15 +411,26 @@ export int consumer_flag_v() { for (std::string m : {"pa", "pb", "pc"}) expect(fatal(span(m).has_value())) << part << ": the build programs' .ninja_log does not record the compile of " << m; }; - // The steps of each member's build program -- its scan, compile and link (`obj/-...`, - // `bin/-...`) -- and the most members with a step under way at one instant. + // The steps of each member's build program -- its scan, compile, resource and link + // (`obj/-...`, `res/-...`, `bin/-...`) -- and the most members with a step under + // way at one instant. A step is an edge: the log's rows of one command share its hash and + // times (an edge writes several files), and an edge is a member's when every file it + // writes is that member's. The edge that deploys the C++ runtime's DLLs beside each + // member's program on Windows writes into all three, and is no member's step. const auto steps = [&](std::string_view part) { - std::vector>> out; const auto logs = s::find_files(ws.at("target/.build-mcpp/host"), R"(\.ninja_log)"); expect(fatal(!logs.empty())) << part << ": the build programs' graph left no .ninja_log"; - const std::regex re{R"(^(obj|bin)/(p[abc])-[0-9a-f]+/)"}; - for (const auto& row : ninja_rows(logs.front())) - if (std::smatch m; std::regex_search(row[3], m, re)) out.push_back({m[2].str(), {std::stol(row[0]), std::stol(row[1])}}); + const std::regex re{R"(^(obj|res|bin)/(p[abc])-[0-9a-f]+/)"}; + std::map, std::pair>> edges; + for (const auto& row : ninja_rows(logs.front())) { + auto& edge = edges[(row.size() > 4 ? row[4] : row[3]) + "@" + row[0] + "-" + row[1]]; + edge.second = {std::stol(row[0]), std::stol(row[1])}; + std::smatch m; + edge.first.insert(std::regex_search(row[3], m, re) ? m[2].str() : std::string{"-"}); + } + std::vector>> out; + for (const auto& [_, edge] : edges) + if (edge.first.size() == 1 && *edge.first.begin() != "-") out.push_back({*edge.first.begin(), edge.second}); return out; }; const auto members_at_once = [](const std::vector>>& all) {