Skip to content

Commit 90de27f

Browse files
committed
fix: the self-review's findings: the gate keeps no record in the shards' store, the runner fallback is the archive run's, an archive that names programs is schema 2
1 parent 9cb49fd commit 90de27f

9 files changed

Lines changed: 110 additions & 63 deletions

File tree

‎.agents/docs/2026-11-14-ci-and-release-time-cost-design.md‎

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -198,3 +198,14 @@ I 使从缓存恢复的 emsdk 在 mcpp 2026.11.13.1 起自动重建链接;K
198198
解决需要一项跨仓库的契约:mcpp 向构建程序陈述链接所用的 SDK(为空即链接中没有系统的存根),由 `flags.cppm` 的同一判定给出;
199199
openkal-macos 仅在其为空时提供自己的存根,旧版 mcpp 不设该变量时行为不变;同时更正 `build_program.cppm` 的陈述。该契约待负责人确认;
200200
在此之前矩阵按测量记为 `fails` 并注明原因,修复后 canary 报告该格与矩阵不符,矩阵随之改回 `ok`。
201+
202+
**自我审查(本节各提交)。** 独立审查给出以下问题,均已处理:
203+
204+
| 问题 | 处理 |
205+
|---|---|
206+
| gate 在分片 1 中运行,其记录进入运行存储:作为最新一次运行,它改变分片 1 的测试时长,使分片 1 的分配与其他分片不同(有的测试运行两次、有的不运行);分片 1 重试时,`--failed` 读到的是通过的 gate 而不是失败的那次尝试 | gate 先于历史运行;取历史前清空本作业的存储,gate 的记录不保留 |
207+
| runner 的回退对所有准备生效,正常的 `mcpp run`/`test` 在未找到平台工具时也会构建 carrier | `BuildContext::intent` 记录准备的意图;回退只在 `RunBuilt` 下发生,其余准备仍报告 runner 未找到 |
208+
| 写有 `named_programs` 的归档仍为 schema 1,只读 schema 1 的旧 mcpp 会在没有被测程序的情况下运行其测试 | 此类归档写为 schema 2,读取接受 1 与 2;其余归档仍为 schema 1 |
209+
| 归档的运行在任何腿运行前要求全部所列程序,另一台机器运行的腿也被要求 | 在腿确定于本机运行后才向环境要求该腿的程序 |
210+
| e2e-cases 以 MSYS 形式导出 `MCPP_BIN_MCPP` | 与 mcpp-unit 相同,以 `cygpath -w` 给出系统自身的拼写 |
211+
| MSVC ABI 的 clang 也运行 libc++ 探测,可能记下不相干的“未回答” | 不对 MSVC ABI 的驱动提出该问题,其 std 模块按 STL 查找 |

‎.github/actions/e2e-cases/action.yml‎

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -76,7 +76,13 @@ runs:
7676
[ "${#cases[@]}" -gt 0 ] || { echo "::error::no case named"; exit 1; }
7777
args=(--archive "$RUNNER_TEMP/mcpp-tests/mcpp-tests.tar.gz")
7878
for c in "${cases[@]}"; do args+=(--case "$c"); done
79-
[ -z "$UNDER_TEST" ] || export MCPP_E2E_MCPP="$UNDER_TEST" MCPP_BIN_MCPP="$UNDER_TEST"
79+
# The system's own spelling of the path: mcpp reads MCPP_BIN_MCPP
80+
# itself, and a Windows mcpp does not read an MSYS path.
81+
if [ -n "$UNDER_TEST" ]; then
82+
under="$UNDER_TEST"
83+
if command -v cygpath >/dev/null 2>&1; then under="$(cygpath -w "$under")"; fi
84+
export MCPP_E2E_MCPP="$under" MCPP_BIN_MCPP="$under"
85+
fi
8086
log="$RUNNER_TEMP/e2e-cases.log"
8187
status=0
8288
"$RUNNER_MCPP" test "${args[@]}" 2>&1 | tee "$log" || status=$?

‎.github/workflows/ci-unit.yml‎

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -196,12 +196,11 @@ jobs:
196196

197197
# The program the tests run is this commit's, as build.yml built it: an
198198
# archive written with --no-programs takes it from MCPP_BIN_MCPP.
199-
- name: The history the shards share
199+
- name: The program under test
200200
shell: bash
201201
run: |
202202
echo "MCPP_VENDORED_XLINGS=$XLINGS_BIN" >> "$GITHUB_ENV"
203203
echo "MCPP_BIN_MCPP=$MCPP" >> "$GITHUB_ENV"
204-
python3 .github/tools/test_history.py take target/mtest "$RUNNER_TEMP/unit/history"
205204
206205
# THE HOST'S GATE (build.yml): a new program scaffolded, built and run by
207206
# this commit's mcpp, seconds of running, from the archive. A red commit
@@ -226,6 +225,16 @@ jobs:
226225
gh run cancel "$GITHUB_RUN_ID" -R "$GITHUB_REPOSITORY" \
227226
|| echo "::warning::the run could not be cancelled (the token's actions permission)"
228227
228+
# One history for every shard, taken after the gate: the gate's run is
229+
# not the shard's, and a record of it in the store would be the newest,
230+
# sizing this shard's tests unlike the others' and answering a re-run's
231+
# `--failed` in place of the attempt that failed.
232+
- name: The history the shards share
233+
shell: bash
234+
run: |
235+
rm -rf -- "$GITHUB_WORKSPACE/target/mtest"
236+
python3 .github/tools/test_history.py take target/mtest "$RUNNER_TEMP/unit/history"
237+
229238
- name: Unit + integration tests via `mcpp test`
230239
uses: ./.github/actions/mcpp-unit
231240
with:

‎docs/08-testing.md‎

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -453,8 +453,9 @@ name is refused before anything is built.
453453
The archive carries the package's programs beside the tests, and its run gives
454454
each test `MCPP_BIN_<NAME>` as the build would. Written with `--no-programs`,
455455
the archive carries none of them and its manifest names their variables
456-
(`named_programs`); its run takes each from its own environment and refuses one
457-
the environment does not name (2026.11.13.1+). The run of an archive builds
456+
(`named_programs`, schema 2, which an mcpp that reads only schema 1 refuses);
457+
the run of a leg that runs here takes each from its own environment and refuses
458+
one the environment does not name (2026.11.13.1+). The run of an archive builds
458459
nothing, and is refused `--no-programs`.
459460

460461
```bash

‎docs/zh/08-testing.md‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -343,8 +343,8 @@ mcpp test --archive tests.tar.gz # 在检出中运
343343
`.tgz`)、`.tar.zst`、`.tar.xz` 或 `.tar`;其他名称在构建前即被拒绝。
344344

345345
归档在测试旁携带包的程序,其运行像构建那样给每个测试 `MCPP_BIN_<NAME>`。以 `--no-programs` 写出的归档
346-
不携带它们,清单列出其变量(`named_programs`);运行从自身的环境取得各程序,环境未指定者被拒绝
347-
(2026.11.13.1+)。归档的运行不构建任何东西,不接受 `--no-programs`。
346+
不携带它们,清单列出其变量(`named_programs`,schema 2,只读 schema 1 的 mcpp 拒绝它);在本机运行的腿
347+
从自身的环境取得各程序,环境未指定者被拒绝(2026.11.13.1+)。归档的运行不构建任何东西,不接受 `--no-programs`。
348348

349349
```bash
350350
mcpp test --no-run --no-programs --archive tests.tar.gz # 只有测试

‎src/build/execute.cppm‎

Lines changed: 33 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -94,15 +94,20 @@ namespace libc = mcpplibs::mwrap::libc::macros;
9494
// legs/<triple>/programs/<program> the package's own programs, which a
9595
// test finds as MCPP_BIN_<NAME> (L5)
9696
//
97-
// `mcpp-tests.json` (schema 1): `package`, `cwd` (the directory the tests run
97+
// `mcpp-tests.json` (schema 1, or 2 with `named_programs`): `package`, `cwd` (the directory the tests run
9898
// in, relative to the project root: the package's own), and `legs`, each with
9999
// its `triple`, `programs` (environment name to path) and `tests` (`name`,
100100
// `program`, the `files` beside it, the test `protocol` it implements, 0 for
101101
// none, as the build decided it, and `own_files`, the files that are its own:
102102
// an archive is run by the same runner as a build's tests). Paths are relative to the archive's directory and use `/`.
103103
export namespace mcpp::build::test_archive {
104104

105+
// Schema 2 is an archive whose legs name programs it does not carry
106+
// (`named_programs`, `--no-programs`): an mcpp that reads only schema 1 refuses
107+
// it, rather than running its tests without the programs they test. Every
108+
// other archive is written as schema 1, and both are read.
105109
inline constexpr int kSchema = 1;
110+
inline constexpr int kSchemaNamed = 2;
106111
inline constexpr std::string_view kManifestName = "mcpp-tests.json";
107112

108113
struct Test {
@@ -188,14 +193,16 @@ nlohmann::json to_json(const Manifest& m) {
188193
if (!l.named.empty()) leg["named_programs"] = l.named;
189194
legs.push_back(std::move(leg));
190195
}
191-
return {{"schema", kSchema}, {"mcpp", std::string(mcpp::MCPP_VERSION)},
196+
const bool named = std::ranges::any_of(m.legs, [](auto const& l) { return !l.named.empty(); });
197+
return {{"schema", named ? kSchemaNamed : kSchema}, {"mcpp", std::string(mcpp::MCPP_VERSION)},
192198
{"package", m.package}, {"cwd", m.cwd}, {"legs", std::move(legs)}};
193199
}
194200

195201
std::expected<Manifest, std::string> from_json(const nlohmann::json& d) {
196-
if (!d.is_object() || d.value("schema", 0) != kSchema)
197-
return std::unexpected(std::format("{} is not a schema-{} test archive manifest",
198-
kManifestName, kSchema));
202+
const int schema = d.is_object() ? d.value("schema", 0) : 0;
203+
if (schema != kSchema && schema != kSchemaNamed)
204+
return std::unexpected(std::format("{} is not a schema-{} or schema-{} test archive manifest",
205+
kManifestName, kSchema, kSchemaNamed));
199206
Manifest m;
200207
m.package = d.value("package", "");
201208
m.cwd = d.value("cwd", "");
@@ -1350,7 +1357,9 @@ std::optional<std::filesystem::path> platform_tool(const mcpp::build::BuildConte
13501357
// A preparation that provisions no tool -- the run of an archive
13511358
// (PrepareIntent::RunBuilt) -- has not located the platform's tool for this
13521359
// machine either. Its runner is then the platform's runner for this machine's
1353-
// architecture, the same program, made the way another architecture's is.
1360+
// architecture, the same program, made the way another architecture's is
1361+
// (under the checkout's target/carrier-pack/). Any other preparation that did
1362+
// not locate the tool reports the runner not found, as before.
13541363
struct RunnerTool {
13551364
std::filesystem::path program;
13561365
std::string arch; // the architecture it is built for
@@ -1359,7 +1368,9 @@ std::expected<std::optional<RunnerTool>, std::string>
13591368
runner_tool(const mcpp::build::BuildContext& ctx, std::string_view word, std::string_view tripleKey,
13601369
bool noRunner, bool build = true) {
13611370
auto tool = platform_tool(ctx, word);
1362-
if (!tool && !ctx.plan.platform.fields.tools.contains(std::string(word))) return std::nullopt;
1371+
const bool provisionedNone = ctx.intent == mcpp::build::PrepareIntent::RunBuilt;
1372+
if (!tool && !(provisionedNone && ctx.plan.platform.fields.tools.contains(std::string(word))))
1373+
return std::nullopt;
13631374
auto t = mcpp::toolchain::triple::parse(tripleKey);
13641375
std::string arch = t ? std::string(t->arch) : std::string{};
13651376
if (!t || mcpp::platform::runner_reach(ctx.plan.platform.fields.runner, t->arch,
@@ -6282,17 +6293,6 @@ export int run_test_archive(std::span<const std::string> passthrough, BuildOverr
62826293
const auto cwd = opened->manifest.cwd.empty() ? *root : *root / opened->manifest.cwd;
62836294
// THE PROGRAMS THE RUN NAMES: an archive written with `--no-programs`
62846295
// carries none of the package's programs.
6285-
std::map<std::string, std::string> namedPrograms;
6286-
{
6287-
std::vector<std::pair<std::string, std::string>> named;
6288-
for (auto const& leg : opened->manifest.legs)
6289-
for (auto const& env : leg.named) named.emplace_back(env, "");
6290-
if (auto why = programs_from_environment(named)) {
6291-
mcpp::ui::error(std::format("--archive {}: {}", testOpts.archive.string(), *why));
6292-
return 2;
6293-
}
6294-
namedPrograms.insert(named.begin(), named.end());
6295-
}
62966296
int passed = 0, failed = 0, notRun = 0, notReached = 0;
62976297
std::vector<std::string> reasons;
62986298
for (auto const& leg : opened->manifest.legs) {
@@ -6325,7 +6325,20 @@ export int run_test_archive(std::span<const std::string> passthrough, BuildOverr
63256325
std::vector<std::pair<std::string, std::string>> legEnv;
63266326
for (auto const& [env, path] : leg.programs)
63276327
legEnv.emplace_back(env, (opened->root / path).lexically_normal().string());
6328-
for (auto const& env : leg.named) legEnv.emplace_back(env, namedPrograms[env]);
6328+
// THE PROGRAMS THE LEG NAMES, from this run's environment, asked for
6329+
// once the leg is known to run here: a leg another machine runs needs
6330+
// none of them. One the environment does not name is refused before
6331+
// any of the leg's tests run.
6332+
if (!leg.named.empty()) {
6333+
std::vector<std::pair<std::string, std::string>> named;
6334+
for (auto const& env : leg.named) named.emplace_back(env, "");
6335+
if (auto why = programs_from_environment(named)) {
6336+
mcpp::ui::error(std::format("--archive {}: the {} leg: {}", testOpts.archive.string(),
6337+
leg.triple, *why));
6338+
return 2;
6339+
}
6340+
legEnv.insert(legEnv.end(), named.begin(), named.end());
6341+
}
63296342
// THE LEG'S TESTS, RUN AS A BUILD'S ARE: through the runner, the
63306343
// protocol each implements, a process per file of its cases, the
63316344
// workers, the store (SPEC-015 §4; docs/08).
@@ -6352,8 +6365,7 @@ export int run_test_archive(std::span<const std::string> passthrough, BuildOverr
63526365
// (runner_handoff_env): the files the program carries, each named
63536366
// by its place beside the program, as the archive keeps it. The
63546367
// records are written in the archive's run directory, beside the
6355-
// programs they describe: the checkout's output tree is not
6356-
// touched by a run that builds nothing.
6368+
// programs they describe, not among the checkout's build outputs.
63576369
if (!tb.runnerTmpl.empty() || !tb.runUnderPrefix.empty()) {
63586370
std::vector<std::pair<std::string, fs::path>> carried;
63596371
for (auto const& f : t.files) {

‎src/build/prepare.cppm‎

Lines changed: 36 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -448,6 +448,38 @@ export struct DepSourceRoot {
448448
bool operator==(const DepSourceRoot&) const = default;
449449
};
450450

451+
// WHAT A PREPARATION IS FOR. One answer, from which each phase reads what it may
452+
// do: whether it compiles, whether it runs the package's programs, whether it
453+
// writes the project. Three switches that grew one per caller had answered it
454+
// before, each phase asking the ones it knew of (2026-11-14).
455+
export enum class PrepareIntent {
456+
// Plan, then build.
457+
Build,
458+
// PLANNING TO DESCRIBE, NOT TO BUILD (`mcpp emit build-database`, publish,
459+
// the doctor). With `work_dir` pointed outside the project, three things
460+
// still reached it or ran a compiler, and this intent settles each: the std
461+
// module is described (mcpp::toolchain::describe_std_module) instead of
462+
// compiled; the root package's `[build] generated_files`, which are sources
463+
// and live in the source tree, are compared instead of written, and a
464+
// missing or stale one is recorded in BuildContext::planNotes; and mcpp.lock
465+
// is READ from the project root, as the resolution input it is, while the
466+
// lock this planning produces is written under `work_dir`. Build programs
467+
// still run.
468+
Describe,
469+
// THE CONFIGURATION, NOT THE SOURCES (`prepare_configuration`, SPEC-013
470+
// §9): what the project's sources would be refused for -- `import std`
471+
// with no C++ run-time in the graph -- is a note of the report, and the
472+
// configuration is still reported.
473+
Configure,
474+
// THE CONFIGURATION TESTS BUILT ELSEWHERE RUN IN (`mcpp test --archive`,
475+
// SPEC-015 §4): a configuration that compiles nothing. A toolchain this
476+
// machine cannot compile with -- the MSVC ABI with no Visual Studio -- is
477+
// no refusal, and no build program or host tool is compiled or run: their
478+
// directives and outputs shape compiles, and the tests' programs and
479+
// files are the archive's.
480+
RunBuilt,
481+
};
482+
451483
export struct BuildContext;
452484

453485
// A BUILD PROGRAMS' GRAPH a prepare planned (mcpp#797), for the readers that
@@ -495,6 +527,10 @@ export struct BuildContext {
495527
// parser of one file, and because the two readers must not be able to
496528
// disagree about the machine.
497529
int globalDefaultJobs = 0;
530+
// What the preparation was for: a preparation that compiles nothing
531+
// (`PrepareIntent::RunBuilt`) provisioned no tool, and its readers find
532+
// the programs it would have built another way.
533+
PrepareIntent intent = PrepareIntent::Build;
498534
// The root's exact pins of packages every consumer shares (T3): what
499535
// `mcpp publish` refuses in a library, one line each.
500536
std::vector<std::string> sharedExactPins;
@@ -810,37 +846,6 @@ export std::string profile_override_from_flags(std::string_view profileOption,
810846
export std::expected<std::filesystem::path, std::string>
811847
package_root(const std::string& ref, bool install);
812848

813-
// WHAT A PREPARATION IS FOR. One answer, from which each phase reads what it may
814-
// do: whether it compiles, whether it runs the package's programs, whether it
815-
// writes the project. Three switches that grew one per caller had answered it
816-
// before, each phase asking the ones it knew of (2026-11-14).
817-
export enum class PrepareIntent {
818-
// Plan, then build.
819-
Build,
820-
// PLANNING TO DESCRIBE, NOT TO BUILD (`mcpp emit build-database`, publish,
821-
// the doctor). With `work_dir` pointed outside the project, three things
822-
// still reached it or ran a compiler, and this intent settles each: the std
823-
// module is described (mcpp::toolchain::describe_std_module) instead of
824-
// compiled; the root package's `[build] generated_files`, which are sources
825-
// and live in the source tree, are compared instead of written, and a
826-
// missing or stale one is recorded in BuildContext::planNotes; and mcpp.lock
827-
// is READ from the project root, as the resolution input it is, while the
828-
// lock this planning produces is written under `work_dir`. Build programs
829-
// still run.
830-
Describe,
831-
// THE CONFIGURATION, NOT THE SOURCES (`prepare_configuration`, SPEC-013
832-
// §9): what the project's sources would be refused for -- `import std`
833-
// with no C++ run-time in the graph -- is a note of the report, and the
834-
// configuration is still reported.
835-
Configure,
836-
// THE CONFIGURATION TESTS BUILT ELSEWHERE RUN IN (`mcpp test --archive`,
837-
// SPEC-015 §4): a configuration that compiles nothing. A toolchain this
838-
// machine cannot compile with -- the MSVC ABI with no Visual Studio -- is
839-
// no refusal, and no build program or host tool is compiled or run: their
840-
// directives and outputs shape compiles, and the tests' programs and
841-
// files are the archive's.
842-
RunBuilt,
843-
};
844849

845850
export struct BuildOverrides {
846851
// Where the package being built LIVES (its mcpp.toml). Empty = walk up from

‎src/build/prepare/plan.cpp‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1021,6 +1021,7 @@ static void step13_graph_and_schedule(PrepareState& state, BuildContext& ctx) {
10211021
if (auto c = state.get_cfg(/*requireBootstrap=*/false))
10221022
globalDefaultJobs = static_cast<int>((*c)->defaultJobs);
10231023
ctx.globalDefaultJobs = globalDefaultJobs;
1024+
ctx.intent = state.overrides.intent;
10241025

10251026
// Resolve the module-edge schedule ONCE, here, where both the toolchain and
10261027
// the manifest are in hand. The backend writes the graph in this shape, the

‎src/toolchain/clang.cpp‎

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -147,13 +147,15 @@ void enrich_toolchain(Toolchain& tc, const mcpp::run::Env& env) {
147147
// std.cppm carries no __cplusplus guard. Verified on clang 22.1.8 +
148148
// libc++ (std and std.compat) at -std=c++20 (design §2.2).
149149
tc.importStdMinLevel = 20;
150-
} else if (auto r = mcpp::toolchain::run_capture(
151-
{ tc.binaryPath.string(), "--print-file-name=libc++.a" }, env,
152-
/*withErrors=*/true); !r) {
150+
} else if (!msvTarget) {
153151
// Not an answer: the driver failed the question the second probe
154152
// asks (a compiler that does not start, a broken payload). Said by
155153
// the refusal of `import std`, which otherwise names only its absence.
156-
tc.stdModuleUnanswered = r.error().message;
154+
// A driver for the MSVC ABI is not asked: its std module is the STL's,
155+
// looked for below.
156+
if (auto r = mcpp::toolchain::run_capture(
157+
{ tc.binaryPath.string(), "--print-file-name=libc++.a" }, env, /*withErrors=*/true); !r)
158+
tc.stdModuleUnanswered = r.error().message;
157159
}
158160

159161
if constexpr (mcpplibs::os::is_windows) {

0 commit comments

Comments
 (0)