|
| 1 | +#!/usr/bin/env bash |
| 2 | +# requires: macos |
| 3 | +# 666 -- on the one host that produces a Mach-O program, `mcpp pack` stages |
| 4 | +# the program and its declared files and hands the tree to a dispatched |
| 5 | +# format with `closure = not-walked` and a reason (#630, item 3a). Before |
| 6 | +# this, the Mach-O refusal preceded staging, and a bundler reached its action |
| 7 | +# with no tree at all. The negative direction stays: `--format dir` and |
| 8 | +# `--format tar`, whose product is the closure, still refuse. |
| 9 | +set -e |
| 10 | + |
| 11 | +TMP=$(mktemp -d) |
| 12 | +trap "rm -rf $TMP" EXIT |
| 13 | +export MCPP_HOME=$HOME/.mcpp |
| 14 | + |
| 15 | +fail() { echo "FAIL: $1"; shift; for f in "$@"; do echo "--- $f ---"; cat "$f" 2>/dev/null; done; exit 1; } |
| 16 | + |
| 17 | +cd "$TMP" |
| 18 | +"$MCPP" new zapapp > /dev/null |
| 19 | +cd zapapp |
| 20 | +mkdir -p share |
| 21 | +printf 'notes\n' > share/notes.txt |
| 22 | +cat >> mcpp.toml <<'EOF' |
| 23 | +
|
| 24 | +[runtime] |
| 25 | +deploy = [ { from = "share/notes.txt", to = "data" } ] |
| 26 | +EOF |
| 27 | +cat > dist.sh <<'EOF' |
| 28 | +set -e |
| 29 | +stage="$1"; manifest="$2"; out="$3" |
| 30 | +{ |
| 31 | + echo "staged:" |
| 32 | + ( cd "$stage" && find . -type f | sort ) |
| 33 | + echo "manifest:" |
| 34 | + sed -n '1,2p' "$manifest" |
| 35 | +} > "$out" |
| 36 | +EOF |
| 37 | +chmod +x dist.sh |
| 38 | +cat > build.mcpp <<'EOF' |
| 39 | +import mcpp; |
| 40 | +int main() { |
| 41 | + mcpp::provides_pack_format("zap"); |
| 42 | + if (std::string_view(mcpp::pack_format()) != "zap") return 0; |
| 43 | + const std::string root = mcpp::manifest_dir(); |
| 44 | + const std::string stage = std::string("${mcpp.stage_dir}"); |
| 45 | + const std::string out = std::string(mcpp::out_dir()) + "/app.zap"; |
| 46 | + mcpp::action a; |
| 47 | + a.id = "zap"; |
| 48 | + a.role = "artifact"; |
| 49 | + a.description = "zap"; |
| 50 | + a.arg((root + "/dist.sh").c_str()) |
| 51 | + .arg(stage.c_str()) |
| 52 | + .arg((stage + ".stage-manifest").c_str()) |
| 53 | + .arg(out.c_str()) |
| 54 | + .input("${mcpp.target_file:zapapp}") |
| 55 | + .output(out.c_str()) |
| 56 | + .submit(); |
| 57 | + return 0; |
| 58 | +} |
| 59 | +EOF |
| 60 | + |
| 61 | +# The negative direction first: the built-in archive still refuses, since |
| 62 | +# its product IS the closure. |
| 63 | +if "$MCPP" pack --format dir > dir.log 2>&1; then |
| 64 | + fail "--format dir of a Mach-O program was accepted" dir.log |
| 65 | +fi |
| 66 | +grep -q 'Mach-O' dir.log || fail "the refusal does not name the format" dir.log |
| 67 | +echo " negative: --format dir still refuses a Mach-O program" |
| 68 | + |
| 69 | +"$MCPP" pack --format zap > zap.log 2>&1 || fail "mcpp pack --format zap failed" zap.log |
| 70 | +grep -q 'staged without its dependency closure' zap.log \ |
| 71 | + || fail "pack did not report the tree as staged without its closure" zap.log |
| 72 | +Z=$(find target -name 'app.zap' | head -1) |
| 73 | +[ -n "$Z" ] || fail "--format zap produced nothing" zap.log |
| 74 | +grep -qx './bin/zapapp' "$Z" || fail "the action's view of the tree lacks bin/zapapp" "$Z" zap.log |
| 75 | +grep -qx './bin/data/notes.txt' "$Z" || fail "the action's view of the tree lacks the deployed file" "$Z" zap.log |
| 76 | +grep -qx 'closure = not-walked' "$Z" || fail "the manifest does not say closure = not-walked" "$Z" zap.log |
| 77 | +grep -q '^reason = ' "$Z" || fail "the manifest carries no reason line" "$Z" zap.log |
| 78 | +echo " positive: the dispatched format sees the program, the deployed file, and closure = not-walked" |
| 79 | +echo "PASS: 666_a_macho_program_is_staged_without_its_closure" |
0 commit comments