|
| 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