Skip to content

Commit de6e321

Browse files
a macOS leg's tests start from an archive: the loader variable is stated only where the system has one (e2e 989)
runtime_library_path_key() is empty on macOS, whose programs keep their rpaths; `mcpp test --archive` stated it regardless, and openkal-macos refuses an environment entry of an empty name, so every test program of an aarch64-macos leg was "invalid argument" -- reported as "error 5" before the spawn detail. e2e 989 archives the host leg's tests and runs them from a checkout on every system, with no llvm; 964's openkal legs run on Linux only. Co-authored-by: speak-agent <248744407+speak-agent@users.noreply.github.com>
1 parent 32cb9fa commit de6e321

4 files changed

Lines changed: 77 additions & 6 deletions

File tree

‎CHANGELOG.md‎

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,10 @@
2121
writes every leg's tests with `mcpp-tests.json`; `mcpp test --archive <file>`
2222
in a checkout runs what this machine reaches and builds nothing. The archive
2323
is a tar compressed as its name states (`.tar.gz`, `.tgz`, `.tar.zst`,
24-
`.tar.xz`, `.tar`); another name is refused before the build (e2e 964).
24+
`.tar.xz`, `.tar`); another name is refused before the build (e2e 964). A
25+
leg of the host's own system runs from an archive as an openkal leg does
26+
(e2e 989, on every system); on macOS the first build of this release started
27+
none of them, giving each an environment entry of an empty name.
2528
- **The build's contract, `${mcpp.contract}`.** Every configuration writes
2629
`mcpp-contract.json` beside its compile database: the compiler of each
2730
language with the words every unit is compiled with (target, sysroot,

‎docs/specs/target-sets.md‎

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -113,7 +113,8 @@
113113
7. 腿的规划串行、构建一起、作业分摊与第一条失败的腿(unit `BuildLegs`)。
114114
8. `--no-run --archive` 写出的归档含两条腿与清单;在没有 `target/` 的检出中 `--archive` 运行本机的腿、不构建;失败的
115115
测试使退出码为 1;没有一条腿能到达的归档不运行任何测试且退出码为 1;`.tar.zst` 写为 zstd 帧并同样运行,不表明 tar
116-
归档的名称在构建前以退出码 2 拒绝(e2e 964);文件名与压缩方式互逆(unit `PackCompress`)。
116+
归档的名称在构建前以退出码 2 拒绝(e2e 964);本机系统的腿(由系统直接启动的测试程序)同样从归档运行,不需要
117+
llvm(e2e 989);文件名与压缩方式互逆(unit `PackCompress`)。
117118

118119
## 变更记录
119120

‎src/build/execute.cppm‎

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4749,11 +4749,13 @@ export int run_test_archive(std::span<const std::string> passthrough, BuildOverr
47494749
argv.insert(argv.begin(), tb.runUnderPrefix.begin(), tb.runUnderPrefix.end());
47504750
auto env = legEnv;
47514751
// The files beside the program are its own: the loader searches its
4752-
// directory, and a runner reads the list it is handed.
4752+
// directory, and a runner reads the list it is handed. macOS names
4753+
// no such variable (its programs keep their rpaths); an entry of an
4754+
// empty name is refused by the system, and every program of a macOS
4755+
// leg was "invalid argument" (e2e 989).
47534756
std::array<fs::path, 1> dir{exe.parent_path()};
4754-
env.emplace_back(mcpp::runtime::launch_env::runtime_library_path_key(),
4755-
mcpp::runtime::launch_env::prepend_path_list(
4756-
mcpp::runtime::launch_env::runtime_library_path_key(), dir));
4757+
if (const auto key = mcpp::runtime::launch_env::runtime_library_path_key(); !key.empty())
4758+
env.emplace_back(key, mcpp::runtime::launch_env::prepend_path_list(key, dir));
47574759
{
47584760
const auto list = exe.parent_path() / ".mcpp-runtime-files.tsv";
47594761
std::ofstream os(list, std::ios::binary | std::ios::trunc);
Lines changed: 65 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,65 @@
1+
#!/usr/bin/env bash
2+
# 989 -- a native leg's tests run from an archive (SPEC-015 §4; design
3+
# 2026-10-29 rev 2 §3.4).
4+
#
5+
# e2e 964 archives the legs of the openkal set, which run through the
6+
# platform's runner and need llvm; a leg of the host's own system, whose test
7+
# programs the system starts directly, was archived and run on no runner. On
8+
# macOS such a program, unpacked from an archive written on Linux, was not
9+
# started ("invalid argument", mcppls CI 2026-10-30). This test needs nothing
10+
# but the host's toolchain, so every system's shards run it.
11+
#
12+
# Criteria:
13+
# A. `mcpp test --no-run --archive t.tar.gz` writes the host leg's tests.
14+
# B. In a copy of the project without target/, `mcpp test --archive` starts
15+
# them, passes, and builds nothing.
16+
set -e
17+
18+
TMP=$(mktemp -d)
19+
trap 'rm -rf "$TMP"' EXIT
20+
fail() { echo "FAIL: $1"; shift; for f in "$@"; do echo "--- $f ---"; cat "$f" 2>/dev/null; done; exit 1; }
21+
22+
# What the system says about an archived program it would not start.
23+
evidence() {
24+
local program
25+
program=$(find "$TMP/co/target/.test-archive" -type f -name 'smoke*' ! -name '*.tsv' 2>/dev/null | head -1)
26+
[ -n "$program" ] || { echo "--- no unpacked program ---"; return; }
27+
echo "--- $program ---"
28+
file "$program" 2>&1 || true
29+
ls -l "$program" 2>&1 || true
30+
if [ "$(uname -s)" = Darwin ]; then
31+
ls -l@ "$program" 2>&1 || true
32+
xattr -l "$program" 2>&1 || true
33+
codesign -dvvv "$program" 2>&1 | head -20 || true
34+
fi
35+
echo "--- started directly ---"
36+
"$program"; echo "exit $?"
37+
cp "$program" "$TMP/copy" && "$TMP/copy"; echo "a copy: exit $?"
38+
}
39+
40+
mkdir -p "$TMP/app/src" "$TMP/app/tests"
41+
cd "$TMP/app"
42+
printf '[package]\nname = "app"\nversion = "0.1.0"\n' > mcpp.toml
43+
printf 'import std;\nint main() { std::println("app"); }\n' > src/main.cpp
44+
cat > tests/smoke.cpp <<'CPP'
45+
import std;
46+
int main() { std::vector<int> v{2, 1}; std::ranges::sort(v); return v.front() == 1 ? 0 : 1; }
47+
CPP
48+
49+
# A
50+
"$MCPP" test --no-run --archive "$TMP/t.tar.gz" > a.log 2>&1 || fail "A: --no-run --archive" a.log
51+
[ -s "$TMP/t.tar.gz" ] || fail "A: no archive written" a.log
52+
echo "ok: the host leg's tests are archived"
53+
54+
# B: a checkout with nothing built.
55+
mkdir -p "$TMP/co" && cp -R "$TMP/app/src" "$TMP/app/tests" "$TMP/app/mcpp.toml" "$TMP/co/"
56+
cd "$TMP/co"
57+
if ! "$MCPP" test --archive "$TMP/t.tar.gz" > b.log 2>&1 || ! grep -q "smoke ... ok" b.log; then
58+
evidence > ev.log 2>&1
59+
fail "B: the host leg's archived test did not pass" b.log ev.log
60+
fi
61+
[ -z "$(find target -path '*/.test-archive' -prune -o -name 'smoke*' -print 2>/dev/null)" ] \
62+
|| fail "B: the archive's tests were built again" b.log
63+
echo "ok: the host leg's tests run from the archive"
64+
65+
echo "PASS: 989 a native leg's tests run from an archive"

0 commit comments

Comments
 (0)