@feigi/fleet-ctl 3.23.35 → 3.23.37
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/package.json +1 -1
- package/scripts/main-checkout.mjs +1 -1
- package/scripts/member-write-guard.mjs +1 -1
- package/scripts/repo-root.mjs +1 -1
- package/skills/run-team/references/reaping.md +1 -1
- package/scripts/agent-test-dir-prose.test.mjs +0 -59
- package/scripts/agent-test.test.mjs +0 -1640
- package/scripts/ambient-git-vars-mjs-prose.test.mjs +0 -397
- package/scripts/ambient-git-vars-prose.test.mjs +0 -192
- package/scripts/ancestry-check-position-prose.test.mjs +0 -175
- package/scripts/apply-ruleset.test.mjs +0 -421
- package/scripts/arg-header-probes-prose.test.mjs +0 -394
- package/scripts/arg.test.mjs +0 -1354
- package/scripts/board-cli.test.mjs +0 -710
- package/scripts/board-identity.test.mjs +0 -429
- package/scripts/board-liveness-banner.test.mjs +0 -119
- package/scripts/board-prev-shape.test.mjs +0 -228
- package/scripts/board-tryparse-null.test.mjs +0 -119
- package/scripts/board.test.mjs +0 -3121
- package/scripts/brief-after-cut-prose.test.mjs +0 -53
- package/scripts/candidates-exit3-prose.test.mjs +0 -302
- package/scripts/candidates.test.mjs +0 -2312
- package/scripts/caveat-unification-prose.test.mjs +0 -98
- package/scripts/cell-readout.test.mjs +0 -615
- package/scripts/ci-comment-rot-prose.test.mjs +0 -2025
- package/scripts/ci-completes-premise-prose.test.mjs +0 -257
- package/scripts/ci-state-prose.test.mjs +0 -113
- package/scripts/ci-state.test.mjs +0 -1933
- package/scripts/ci-vacuous-green.test.mjs +0 -368
- package/scripts/citation-sweep-prose.test.mjs +0 -1712
- package/scripts/claim-lifecycle.test.mjs +0 -187
- package/scripts/claim-ticket.test.mjs +0 -1122
- package/scripts/closing-keyword-prose.test.mjs +0 -193
- package/scripts/cockpit-launch-idempotent-prose.test.mjs +0 -165
- package/scripts/cockpit-tick-nonblocking.test.mjs +0 -210
- package/scripts/compute-board.test.mjs +0 -1214
- package/scripts/compute-spend.test.mjs +0 -517
- package/scripts/consumer-technology-prose.test.mjs +0 -126
- package/scripts/cross-repo-citation-prose.test.mjs +0 -155
- package/scripts/cwd-isolation-pins.mjs +0 -83
- package/scripts/dedupe-guard-prose.test.mjs +0 -243
- package/scripts/delete-merged-branch.test.mjs +0 -576
- package/scripts/derive-testcmd.test.mjs +0 -595
- package/scripts/diff-stats.test.mjs +0 -404
- package/scripts/dispatch-block-golden-prose.test.mjs +0 -1130
- package/scripts/dispatch-block-pins-prose.test.mjs +0 -615
- package/scripts/dispositions-check.test.mjs +0 -936
- package/scripts/dispositions-gate-prose.test.mjs +0 -129
- package/scripts/drop-merged-label.test.mjs +0 -479
- package/scripts/exec-stub.mjs +0 -93
- package/scripts/exec-stub.test.mjs +0 -69
- package/scripts/expected-jobs-prose.test.mjs +0 -80
- package/scripts/fan-out-authorization-prose.test.mjs +0 -80
- package/scripts/filing-bar-seat-prose.test.mjs +0 -242
- package/scripts/filing-claim-bar-prose.test.mjs +0 -166
- package/scripts/finisher-died-prose.test.mjs +0 -31
- package/scripts/finisher-dispatch-premise-prose.test.mjs +0 -312
- package/scripts/finisher-halt-prose.test.mjs +0 -106
- package/scripts/finisher-name-prose.test.mjs +0 -134
- package/scripts/finisher-own-tree-prose.test.mjs +0 -299
- package/scripts/finisher-pin-race-prose.test.mjs +0 -339
- package/scripts/finisher-test-verdict-prose.test.mjs +0 -102
- package/scripts/fix-applier-correction-rules-prose.test.mjs +0 -202
- package/scripts/fix-applier-result-file-prose.test.mjs +0 -149
- package/scripts/fleet-bootstrap.test.mjs +0 -75
- package/scripts/fleet-heartbeat.test.mjs +0 -450
- package/scripts/fleet-provenance.test.mjs +0 -138
- package/scripts/fleet-run.test.mjs +0 -90
- package/scripts/fleet-state.test.mjs +0 -460
- package/scripts/fleet-tick-prose.test.mjs +0 -300
- package/scripts/fleet-tick.test.mjs +0 -2444
- package/scripts/force-with-lease-reason-prose.test.mjs +0 -184
- package/scripts/frontmatter-check.test.mjs +0 -436
- package/scripts/git-env.test.mjs +0 -149
- package/scripts/git-status-untracked-mode-sweep.test.mjs +0 -216
- package/scripts/gone-walk.test.mjs +0 -213
- package/scripts/gp-sep-invariant-prose.test.mjs +0 -188
- package/scripts/head-moved-after-label-prose.test.mjs +0 -233
- package/scripts/immutable-body-claim-prose.test.mjs +0 -204
- package/scripts/implementer-model-tier.test.mjs +0 -235
- package/scripts/inflight-citation-prose.test.mjs +0 -144
- package/scripts/inflight-exit2-prose.test.mjs +0 -81
- package/scripts/inflight-probe-guard-prose.test.mjs +0 -109
- package/scripts/inflight-scan-scope-prose.test.mjs +0 -57
- package/scripts/inflight.test.mjs +0 -2882
- package/scripts/injection-control-prose.test.mjs +0 -404
- package/scripts/install-root-audit.test.mjs +0 -464
- package/scripts/instrument-check-prose.test.mjs +0 -235
- package/scripts/instruments.test.mjs +0 -787
- package/scripts/is-cli.test.mjs +0 -99
- package/scripts/issue-tracker-prose.test.mjs +0 -71
- package/scripts/json.test.mjs +0 -364
- package/scripts/ledger-dispatch.test.mjs +0 -927
- package/scripts/ledger-grammar.test.mjs +0 -227
- package/scripts/ledger-read-require-file.test.mjs +0 -197
- package/scripts/ledger-rotate.test.mjs +0 -142
- package/scripts/ledger.test.mjs +0 -3436
- package/scripts/line-distance-prose.test.mjs +0 -245
- package/scripts/liveness-rationale-prose.test.mjs +0 -83
- package/scripts/locale-pin-prose.test.mjs +0 -189
- package/scripts/main-checkout.test.mjs +0 -332
- package/scripts/member-outcome-prose.test.mjs +0 -167
- package/scripts/member-outcomes-header.test.mjs +0 -129
- package/scripts/member-outcomes-prose.test.mjs +0 -63
- package/scripts/member-outcomes.test.mjs +0 -638
- package/scripts/member-prompt-prose.test.mjs +0 -165
- package/scripts/member-record.test.mjs +0 -541
- package/scripts/member-write-guard.test.mjs +0 -214
- package/scripts/merge-commit-probe-prose.test.mjs +0 -122
- package/scripts/merge-gate.test.mjs +0 -613
- package/scripts/muted-git-guard-sweep.test.mjs +0 -493
- package/scripts/net-ssh-precedence-prose.test.mjs +0 -91
- package/scripts/net-watchdog-prose.test.mjs +0 -79
- package/scripts/net.test.mjs +0 -211
- package/scripts/no-ci-gate-prose.test.mjs +0 -108
- package/scripts/no-undo-audit.test.mjs +0 -3961
- package/scripts/no-wave.test.mjs +0 -138
- package/scripts/node-floor-sweep.test.mjs +0 -611
- package/scripts/pointer-target-prose.test.mjs +0 -186
- package/scripts/pr-cost.test.mjs +0 -521
- package/scripts/pr-overlap.test.mjs +0 -692
- package/scripts/printf-die-sweep.test.mjs +0 -384
- package/scripts/prompt-renderer.mjs +0 -40
- package/scripts/prompt-renderer.test.mjs +0 -68
- package/scripts/prose-pin.mjs +0 -807
- package/scripts/prose-pin.test.mjs +0 -1034
- package/scripts/prove-merge.test.mjs +0 -995
- package/scripts/pull-table-relabel-prose.test.mjs +0 -60
- package/scripts/quiet-payload-prose.test.mjs +0 -222
- package/scripts/reap-cherry-check-prose.test.mjs +0 -80
- package/scripts/reap.test.mjs +0 -4432
- package/scripts/reaping-prose.test.mjs +0 -239
- package/scripts/reaping-reap-authorizers-prose.test.mjs +0 -112
- package/scripts/reaping-release-authorizers-prose.test.mjs +0 -85
- package/scripts/recipe-derivation-prose.test.mjs +0 -112
- package/scripts/recipe-prove.test.mjs +0 -1042
- package/scripts/refuter-scratch-prose.test.mjs +0 -135
- package/scripts/release-label-required-prose.test.mjs +0 -71
- package/scripts/release-label-split-prose.test.mjs +0 -184
- package/scripts/release-ticket-reap-pairing-prose.test.mjs +0 -63
- package/scripts/release-ticket.test.mjs +0 -5099
- package/scripts/renovate-release-contract.test.mjs +0 -379
- package/scripts/repo-root.test.mjs +0 -873
- package/scripts/reporter-output-rule-prose.test.mjs +0 -208
- package/scripts/review-agent-report-only.test.mjs +0 -49
- package/scripts/review-core-booking.test.mjs +0 -35
- package/scripts/review-core-cwd-isolation.test.mjs +0 -374
- package/scripts/review-core-reads.test.mjs +0 -478
- package/scripts/review-core-refuter-scratch.test.mjs +0 -148
- package/scripts/review-core-scratch-refusal.test.mjs +0 -64
- package/scripts/review-core-shared-test-run.test.mjs +0 -275
- package/scripts/review-core-snapshot-path.test.mjs +0 -830
- package/scripts/review-core-specialist-scratch.test.mjs +0 -191
- package/scripts/review-core-testcmd.test.mjs +0 -335
- package/scripts/review-core-unrun.test.mjs +0 -566
- package/scripts/review-core-unverified-discriminant.test.mjs +0 -208
- package/scripts/review-eval-resolver-path.test.mjs +0 -55
- package/scripts/review-host-fixture.mjs +0 -89
- package/scripts/review-in-run-retry.test.mjs +0 -211
- package/scripts/review-no-vendor-dispatch.test.mjs +0 -45
- package/scripts/review-path-default.test.mjs +0 -796
- package/scripts/review-runner-spawns.test.mjs +0 -95
- package/scripts/review-runner.test.mjs +0 -166
- package/scripts/review-tier-audit.test.mjs +0 -140
- package/scripts/run-artifact-pr-prose.test.mjs +0 -341
- package/scripts/run-merge-bot-prose.test.mjs +0 -1413
- package/scripts/run-team-local-hook.test.mjs +0 -442
- package/scripts/scratch-partition-invariant-prose.test.mjs +0 -74
- package/scripts/scripts-path-citation-sweep.test.mjs +0 -73
- package/scripts/section-between-guard-prose.test.mjs +0 -379
- package/scripts/select-dimensions.test.mjs +0 -674
- package/scripts/shared-refusal.test.mjs +0 -388
- package/scripts/shell-traps-prose.test.mjs +0 -504
- package/scripts/shortlist.test.mjs +0 -380
- package/scripts/slow-transport.mjs +0 -72
- package/scripts/snapshot-repo.test.mjs +0 -1006
- package/scripts/snapshot-runner-audience-prose.test.mjs +0 -130
- package/scripts/spend-view.test.mjs +0 -312
- package/scripts/staleness-qualifier-prose.test.mjs +0 -251
- package/scripts/staleness-verdict-prose.test.mjs +0 -142
- package/scripts/staleness.test.mjs +0 -893
- package/scripts/stalled-member-liveness-prose.test.mjs +0 -219
- package/scripts/stash-prohibition-prose.test.mjs +0 -313
- package/scripts/strip-comments.mjs +0 -44
- package/scripts/temp-dir.mjs +0 -47
- package/scripts/ticket-router.test.mjs +0 -981
- package/scripts/tier-check.test.mjs +0 -828
- package/scripts/tier-outcomes-header.test.mjs +0 -518
- package/scripts/tier-outcomes.test.mjs +0 -572
- package/scripts/tier-roles.test.mjs +0 -535
- package/scripts/tracker-block-copy-prose.test.mjs +0 -288
- package/scripts/triage-labels-gloss-prose.test.mjs +0 -97
- package/scripts/unattended-git-sweep.test.mjs +0 -142
- package/scripts/verify-sha-exit2-prose.test.mjs +0 -269
- package/scripts/verify-sha.test.mjs +0 -692
- package/scripts/watcher-degraded-block.test.mjs +0 -369
- package/scripts/watcher-key-prose.test.mjs +0 -106
- package/scripts/within-run-pair-prose.test.mjs +0 -212
- package/scripts/worktree-audit.test.mjs +0 -1408
- package/scripts/worktree-head-prose.test.mjs +0 -276
- package/scripts/worktree-listing-sweep.test.mjs +0 -217
- package/scripts/worktree-model-prose.test.mjs +0 -216
- package/scripts/worktree-porcelain.mjs +0 -35
- package/scripts/worktree-porcelain.test.mjs +0 -102
|
@@ -1,595 +0,0 @@
|
|
|
1
|
-
import { test } from "node:test";
|
|
2
|
-
import assert from "node:assert/strict";
|
|
3
|
-
import { execFileSync, spawnSync } from "node:child_process";
|
|
4
|
-
import { mkdirSync, writeFileSync, symlinkSync, chmodSync, readFileSync } from "node:fs";
|
|
5
|
-
import { tmpdir } from "node:os";
|
|
6
|
-
import { tempDir } from "./temp-dir.mjs";
|
|
7
|
-
import { join } from "node:path";
|
|
8
|
-
import { writeExecStub } from "./exec-stub.mjs";
|
|
9
|
-
|
|
10
|
-
// derive-testcmd.sh is the ONE reader of a repository's Recipe cache (ADR
|
|
11
|
-
// 0015) — reused by claim-ticket.sh and review-core.mjs's snapshot agent. It
|
|
12
|
-
// infers nothing: no fixture here carries a package.json, a lockfile or a
|
|
13
|
-
// test-file naming convention, because none of them can change its answer.
|
|
14
|
-
const SCRIPT = join(import.meta.dirname, "derive-testcmd.sh");
|
|
15
|
-
|
|
16
|
-
// The frame markers, read from the script itself rather than copied here: a
|
|
17
|
-
// behavior-preserving rename of derive-testcmd.sh's `open`/`close` values
|
|
18
|
-
// must not break a test whose only job is to prove the guard around them.
|
|
19
|
-
const FRAME_MATCH = readFileSync(SCRIPT, "utf8").match(/^open='([^']*)' close='([^']*)'/m);
|
|
20
|
-
if (!FRAME_MATCH) throw new Error("could not find the open/close frame markers in derive-testcmd.sh");
|
|
21
|
-
const [, FRAME_OPEN, FRAME_CLOSE] = FRAME_MATCH;
|
|
22
|
-
|
|
23
|
-
// Fixture construction must not inherit an ambient GIT_DIR (the #1020 case
|
|
24
|
-
// below sets one deliberately, for the SCRIPT only): under one, `git init`
|
|
25
|
-
// re-inits whatever it names and the fixture is built nowhere.
|
|
26
|
-
const FIXTURE_ENV = { ...process.env, GIT_DIR: undefined, GIT_WORK_TREE: undefined };
|
|
27
|
-
|
|
28
|
-
function repo(files = {}) {
|
|
29
|
-
const dir = tempDir("derive-testcmd-");
|
|
30
|
-
const git = (...a) => execFileSync("git", a, { cwd: dir, stdio: "pipe", env: FIXTURE_ENV, encoding: "utf8" });
|
|
31
|
-
git("init", "-q");
|
|
32
|
-
git("config", "user.email", "t@t");
|
|
33
|
-
git("config", "user.name", "t");
|
|
34
|
-
for (const [name, body] of Object.entries(files)) writeFileSync(join(dir, name), body);
|
|
35
|
-
git("commit", "-q", "--allow-empty", "-m", "x");
|
|
36
|
-
git("add", "-A");
|
|
37
|
-
git("commit", "-q", "--allow-empty", "-m", "files");
|
|
38
|
-
return { dir, head: git("rev-parse", "HEAD").trim() };
|
|
39
|
-
}
|
|
40
|
-
|
|
41
|
-
// A proven Recipe: every field the reader requires, the proof included.
|
|
42
|
-
const recipe = (head, over = {}) => ({
|
|
43
|
-
install: "true",
|
|
44
|
-
test: "sh ./run-tests.sh",
|
|
45
|
-
derivedAt: head,
|
|
46
|
-
installClean: true,
|
|
47
|
-
testCount: 3,
|
|
48
|
-
...over,
|
|
49
|
-
});
|
|
50
|
-
|
|
51
|
-
function cache(dir, body) {
|
|
52
|
-
mkdirSync(join(dir, ".fleet"), { recursive: true });
|
|
53
|
-
writeFileSync(join(dir, ".fleet", "recipe.json"), typeof body === "string" ? body : JSON.stringify(body));
|
|
54
|
-
}
|
|
55
|
-
|
|
56
|
-
function derive(dir, field = "test", env = process.env, cwd = tmpdir()) {
|
|
57
|
-
const r = spawnSync("sh", [SCRIPT, dir, field], { encoding: "utf8", env, cwd, timeout: 30_000 });
|
|
58
|
-
return { status: r.status, out: r.stdout.replace(/\n$/, ""), err: r.stderr };
|
|
59
|
-
}
|
|
60
|
-
|
|
61
|
-
// Every refusal that sends its reader to re-derive must say WHICH step does
|
|
62
|
-
// that — the controller or reviewer reading it has no other pointer.
|
|
63
|
-
const NAMES_STEP = /run the Recipe derivation step \(run-team phase 0, before the first claim — ADR 0015\)/;
|
|
64
|
-
|
|
65
|
-
test("a proven cache yields the requested command, verbatim, and nothing on stderr", () => {
|
|
66
|
-
const { dir, head } = repo();
|
|
67
|
-
cache(dir, recipe(head, { install: "true", test: `sh -c 'echo "a b"'` }));
|
|
68
|
-
const t = derive(dir, "test");
|
|
69
|
-
assert.equal(t.status, 0, t.err);
|
|
70
|
-
assert.equal(t.out, `sh -c 'echo "a b"'`, "quotes and spaces reach the caller untouched");
|
|
71
|
-
assert.equal(t.err, "");
|
|
72
|
-
const i = derive(dir, "install");
|
|
73
|
-
assert.equal(i.status, 0, i.err);
|
|
74
|
-
assert.equal(i.out, "true");
|
|
75
|
-
});
|
|
76
|
-
|
|
77
|
-
test("an absent cache refuses, naming the derivation step — never an inference", () => {
|
|
78
|
-
// A tree that the pre-ADR-0015 inference would have ACCEPTED (a Node test
|
|
79
|
-
// file) is refused all the same: nothing about the tree is consulted.
|
|
80
|
-
const { dir } = repo({ "t.test.mjs": "" });
|
|
81
|
-
const r = derive(dir);
|
|
82
|
-
assert.equal(r.status, 1);
|
|
83
|
-
assert.equal(r.out, "", "no command it could not read");
|
|
84
|
-
assert.match(r.err, /^derive-testcmd: no Recipe cache at .*\/\.fleet\/recipe\.json — refusing to infer/);
|
|
85
|
-
assert.match(r.err, NAMES_STEP);
|
|
86
|
-
});
|
|
87
|
-
|
|
88
|
-
test("a linked worktree reads the main checkout's cache, not a private one", () => {
|
|
89
|
-
// The two consumers both hand a WORKTREE in: review-core's snapshot agent
|
|
90
|
-
// passes the PR's worktree, and a claim's tree is one. The cache lives
|
|
91
|
-
// once, beside the common git dir, like the ledger.
|
|
92
|
-
const { dir, head } = repo();
|
|
93
|
-
cache(dir, recipe(head, { test: "true" }));
|
|
94
|
-
const wt = join(tempDir("derive-wt-"), "wt");
|
|
95
|
-
execFileSync("git", ["worktree", "add", "-q", "--detach", wt], { cwd: dir, stdio: "pipe", env: FIXTURE_ENV });
|
|
96
|
-
const r = derive(wt);
|
|
97
|
-
assert.equal(r.status, 0, r.err);
|
|
98
|
-
assert.equal(r.out, "true");
|
|
99
|
-
});
|
|
100
|
-
|
|
101
|
-
test("wrong argument count and an unknown field refuse with a usage message", () => {
|
|
102
|
-
const { dir, head } = repo();
|
|
103
|
-
cache(dir, recipe(head));
|
|
104
|
-
for (const argv of [[], [dir], [dir, "test", "extra"]]) {
|
|
105
|
-
const r = spawnSync("sh", [SCRIPT, ...argv], { encoding: "utf8" });
|
|
106
|
-
assert.equal(r.status, 1, JSON.stringify(argv));
|
|
107
|
-
assert.match(r.stderr, /usage: derive-testcmd\.sh <repo> <install\|test>/);
|
|
108
|
-
}
|
|
109
|
-
const r = derive(dir, "derivedAt");
|
|
110
|
-
assert.equal(r.status, 1);
|
|
111
|
-
assert.match(r.err, /unknown Recipe field 'derivedAt' — expected install or test/);
|
|
112
|
-
});
|
|
113
|
-
|
|
114
|
-
test("a non-repository directory refuses cleanly", () => {
|
|
115
|
-
const dir = tempDir("derive-testcmd-not-a-repo-");
|
|
116
|
-
const r = derive(dir);
|
|
117
|
-
assert.equal(r.status, 1);
|
|
118
|
-
assert.match(r.err, /is not a git repository/);
|
|
119
|
-
});
|
|
120
|
-
|
|
121
|
-
// Each row breaks exactly one requirement of a PROVEN Recipe; each must be
|
|
122
|
-
// refused with its own reason and the derivation step, and none may leak a
|
|
123
|
-
// command out of a cache the checks did not pass.
|
|
124
|
-
test("an unparseable or unproven cache refuses, naming what is missing", (t) => {
|
|
125
|
-
const { dir, head } = repo();
|
|
126
|
-
const rows = [
|
|
127
|
-
["{not json", /it does not parse/],
|
|
128
|
-
["[]", /it is not a JSON object/],
|
|
129
|
-
[recipe(head, { install: undefined }), /`install` is not a non-empty command string/],
|
|
130
|
-
[recipe(head, { test: " " }), /`test` is not a non-empty command string/],
|
|
131
|
-
[recipe(head, { test: 7 }), /`test` is not a non-empty command string/],
|
|
132
|
-
[recipe(head, { derivedAt: "main" }), /`derivedAt` is not a full commit id/],
|
|
133
|
-
[recipe(head, { derivedAt: head.slice(0, 12) }), /`derivedAt` is not a full commit id/],
|
|
134
|
-
[recipe(head, { installClean: undefined }), /`installClean` is not true/],
|
|
135
|
-
[recipe(head, { installClean: "true" }), /`installClean` is not true/],
|
|
136
|
-
[recipe(head, { testCount: 0 }), /no proof of real tests/],
|
|
137
|
-
[recipe(head, { testCount: 2.5 }), /no proof of real tests/],
|
|
138
|
-
[recipe(head, { testCount: undefined, mutation: "" }), /no proof of real tests/],
|
|
139
|
-
];
|
|
140
|
-
for (const [body, why] of rows) {
|
|
141
|
-
cache(dir, body);
|
|
142
|
-
for (const field of ["test", "install"]) {
|
|
143
|
-
const r = derive(dir, field);
|
|
144
|
-
const label = `${field} from ${typeof body === "string" ? body : JSON.stringify(body)}`;
|
|
145
|
-
assert.equal(r.status, 1, label);
|
|
146
|
-
assert.equal(r.out, "", label);
|
|
147
|
-
assert.match(r.err, /the Recipe cache at .* is unusable: /, label);
|
|
148
|
-
assert.match(r.err, why, label);
|
|
149
|
-
assert.match(r.err, NAMES_STEP, label);
|
|
150
|
-
}
|
|
151
|
-
}
|
|
152
|
-
});
|
|
153
|
-
|
|
154
|
-
// The must-ACCEPT half of the proof rules: either proof alone is enough, and
|
|
155
|
-
// a sha256 repository's 64-hex commit id is a full id too.
|
|
156
|
-
test("either proof alone is accepted, and so is a 64-hex commit id", () => {
|
|
157
|
-
const { dir, head } = repo();
|
|
158
|
-
for (const over of [
|
|
159
|
-
{ testCount: undefined, mutation: "flipped assert in t/a.test.js; suite went red" },
|
|
160
|
-
{ testCount: 1 },
|
|
161
|
-
{ derivedAt: head.padEnd(64, "0") },
|
|
162
|
-
]) {
|
|
163
|
-
cache(dir, recipe(head, { ...over, test: "true" }));
|
|
164
|
-
const r = derive(dir);
|
|
165
|
-
assert.equal(r.status, 0, `${JSON.stringify(over)}: ${r.err}`);
|
|
166
|
-
assert.equal(r.out, "true");
|
|
167
|
-
}
|
|
168
|
-
});
|
|
169
|
-
|
|
170
|
-
// Invalid on failure to RUN (ADR 0015): a leading word that does not resolve
|
|
171
|
-
// from the repo is a stale Recipe, refused with the invalidation message.
|
|
172
|
-
test("a command whose binary is missing or not executable refuses as an invalid cache", () => {
|
|
173
|
-
const { dir, head } = repo({ "run.sh": "#!/bin/sh\n" });
|
|
174
|
-
chmodSync(join(dir, "run.sh"), 0o644);
|
|
175
|
-
for (const [field, over, word] of [
|
|
176
|
-
["test", { test: "no-such-binary-2117 --all" }, "no-such-binary-2117"],
|
|
177
|
-
["install", { install: "no-such-installer-2117 ci" }, "no-such-installer-2117"],
|
|
178
|
-
["test", { test: "./run.sh" }, "./run.sh"],
|
|
179
|
-
["test", { test: "./missing.sh" }, "./missing.sh"],
|
|
180
|
-
["test", { test: "CI=1 LANG=C no-such-binary-2117" }, "no-such-binary-2117"],
|
|
181
|
-
]) {
|
|
182
|
-
cache(dir, recipe(head, over));
|
|
183
|
-
const r = derive(dir, field);
|
|
184
|
-
assert.equal(r.status, 1, `${JSON.stringify(over)} must refuse`);
|
|
185
|
-
assert.equal(r.out, "");
|
|
186
|
-
assert.match(r.err, new RegExp(`is invalid: its ${field} command '${word.replace(/[.*]/g, "\\$&")}' is not found or not executable`));
|
|
187
|
-
assert.match(r.err, NAMES_STEP);
|
|
188
|
-
}
|
|
189
|
-
});
|
|
190
|
-
|
|
191
|
-
// The must-ACCEPT half of the run probe, which is where a guard like this
|
|
192
|
-
// goes wrong: every one of these RUNS, so refusing any would strand a repo on
|
|
193
|
-
// a Recipe that is fine. A failing suite (`false`) is a finding, not a stale
|
|
194
|
-
// Recipe — this script never runs the command, so it cannot tell and must
|
|
195
|
-
// not try. A relative script resolves from <repo>, not from the caller's cwd.
|
|
196
|
-
test("a runnable command is accepted, however it is spelled — and a failing suite is not a stale Recipe", () => {
|
|
197
|
-
const { dir, head } = repo({ "run.sh": "#!/bin/sh\nexit 0\n" });
|
|
198
|
-
chmodSync(join(dir, "run.sh"), 0o755);
|
|
199
|
-
for (const cmd of [
|
|
200
|
-
"./run.sh",
|
|
201
|
-
"sh ./run-tests.sh",
|
|
202
|
-
"false",
|
|
203
|
-
"FOO=1 BAR=x ./run.sh --flag",
|
|
204
|
-
"cd sub && make test",
|
|
205
|
-
`"./my tests.sh"`,
|
|
206
|
-
"$HOME/bin/runner",
|
|
207
|
-
"node --test plugin/scripts/*.test.mjs",
|
|
208
|
-
]) {
|
|
209
|
-
cache(dir, recipe(head, { test: cmd }));
|
|
210
|
-
const r = derive(dir, "test", process.env, tmpdir());
|
|
211
|
-
assert.equal(r.status, 0, `${cmd}: ${r.err}`);
|
|
212
|
-
assert.equal(r.out, cmd);
|
|
213
|
-
}
|
|
214
|
-
});
|
|
215
|
-
|
|
216
|
-
// Both consumers append the runner's own arguments after this string
|
|
217
|
-
// textually (`exec sh -c '<cmd> "$@"' agent-test "$@"`), so a command ending
|
|
218
|
-
// in `;` or `&` lets a real shell read those arguments as an unrelated
|
|
219
|
-
// top-level command, and a `#`-led word swallows everything after it,
|
|
220
|
-
// arguments included, as a comment — neither failure is about whether the
|
|
221
|
-
// command runs, so it is refused here rather than left to fail at claim time.
|
|
222
|
-
test("a command ending in ';' or '&', or carrying a '#' word, refuses — a runner-appended argument would never reach it", () => {
|
|
223
|
-
const { dir, head } = repo({ "run.sh": "#!/bin/sh\nexit 0\n" });
|
|
224
|
-
chmodSync(join(dir, "run.sh"), 0o755);
|
|
225
|
-
for (const cmd of ["sh ./run-tests.sh;", "sh ./run-tests.sh &", "sh ./run-tests.sh # all suites"]) {
|
|
226
|
-
cache(dir, recipe(head, { test: cmd }));
|
|
227
|
-
const r = derive(dir, "test", process.env, tmpdir());
|
|
228
|
-
assert.equal(r.status, 1, `${cmd} must refuse: ${r.out}`);
|
|
229
|
-
assert.match(r.err, /a runner-appended argument/, `${cmd}: ${r.err}`);
|
|
230
|
-
}
|
|
231
|
-
});
|
|
232
|
-
|
|
233
|
-
// --- #2217: the frame above lets a value keep a trailing newline that an
|
|
234
|
-
// unframed `$(…)` capture always stripped silently, so a command that used
|
|
235
|
-
// to read as `true;` (caught above) now reads as `true;\n` inside the
|
|
236
|
-
// frame and must still be caught the same way.
|
|
237
|
-
test("a command ending in ';' or '&' followed by a newline still refuses (#2217)", () => {
|
|
238
|
-
const { dir, head } = repo();
|
|
239
|
-
for (const cmd of ["true;\n", "true &\n"]) {
|
|
240
|
-
cache(dir, recipe(head, { test: cmd }));
|
|
241
|
-
const r = derive(dir, "test", process.env, tmpdir());
|
|
242
|
-
assert.equal(r.status, 1, `${JSON.stringify(cmd)} must refuse: ${r.out}`);
|
|
243
|
-
assert.match(r.err, /a runner-appended argument/, `${JSON.stringify(cmd)}: ${r.err}`);
|
|
244
|
-
}
|
|
245
|
-
});
|
|
246
|
-
|
|
247
|
-
test("a command of assignments alone names nothing to run and refuses", () => {
|
|
248
|
-
const { dir, head } = repo();
|
|
249
|
-
cache(dir, recipe(head, { test: "CI=1 FOO=2" }));
|
|
250
|
-
const r = derive(dir);
|
|
251
|
-
assert.equal(r.status, 1);
|
|
252
|
-
assert.match(r.err, /its test command names no command, only assignments/);
|
|
253
|
-
});
|
|
254
|
-
|
|
255
|
-
// The assignment-skip loop above only accepts `NAME=value` prefixes whose
|
|
256
|
-
// name is a valid shell identifier (`[A-Za-z0-9_]` only) — a hyphen breaks
|
|
257
|
-
// the inner guard, so `a-b=c` is never skipped as an assignment and is read
|
|
258
|
-
// as the leading command word itself instead.
|
|
259
|
-
test("an assignment-shaped word with an invalid variable name is read as the command, not skipped", () => {
|
|
260
|
-
const { dir, head } = repo();
|
|
261
|
-
cache(dir, recipe(head, { test: "a-b=c ./run.sh" }));
|
|
262
|
-
const r = derive(dir);
|
|
263
|
-
assert.equal(r.status, 1);
|
|
264
|
-
assert.match(r.err, /its test command 'a-b=c' is not found or not executable/);
|
|
265
|
-
});
|
|
266
|
-
|
|
267
|
-
// --- #1020: the ambient GIT_DIR that outranks `-C "$repo"`. Under it,
|
|
268
|
-
// `--git-common-dir` answers for the OTHER repository, and the cache read is
|
|
269
|
-
// that repository's Recipe reported as this one's.
|
|
270
|
-
test("an ambient GIT_DIR does not read another repository's Recipe (#1020)", () => {
|
|
271
|
-
const here = repo();
|
|
272
|
-
cache(here.dir, recipe(here.head, { test: "true" }));
|
|
273
|
-
const elsewhere = repo();
|
|
274
|
-
cache(elsewhere.dir, recipe(elsewhere.head, { test: "false" }));
|
|
275
|
-
assert.equal(derive(elsewhere.dir).out, "false", "fixture: the other repo must answer differently");
|
|
276
|
-
|
|
277
|
-
const r = derive(here.dir, "test", { ...process.env, GIT_DIR: join(elsewhere.dir, ".git") });
|
|
278
|
-
assert.equal(r.status, 0, r.err);
|
|
279
|
-
assert.equal(r.out, "true", "an ambient GIT_DIR must not answer for another repository");
|
|
280
|
-
});
|
|
281
|
-
|
|
282
|
-
// --- #1175: the cross-file invariant claim-ticket.sh's captures rest on. It
|
|
283
|
-
// captures THIS script with stderr merged and runs the result on its success
|
|
284
|
-
// path, so any byte this script writes to stderr on success becomes part of
|
|
285
|
-
// the Install step it runs and the Test entrypoint it bakes into the runner.
|
|
286
|
-
// NODE_DEBUG makes the validator's own interpreter chatty; the positive
|
|
287
|
-
// control proves the env is not inert.
|
|
288
|
-
test("the success path writes nothing to stderr, even when node is chatty (#1175)", () => {
|
|
289
|
-
const CHATTY = { ...process.env, NODE_DEBUG: "module" };
|
|
290
|
-
const control = spawnSync("node", ["-e", "0"], { encoding: "utf8", env: CHATTY });
|
|
291
|
-
assert.ok(control.stderr.length > 0, "fixture: NODE_DEBUG=module must make node write to stderr");
|
|
292
|
-
|
|
293
|
-
const { dir, head } = repo();
|
|
294
|
-
cache(dir, recipe(head, { install: "true", test: "true" }));
|
|
295
|
-
for (const field of ["install", "test"]) {
|
|
296
|
-
const r = derive(dir, field, CHATTY);
|
|
297
|
-
assert.equal(r.status, 0, r.err);
|
|
298
|
-
assert.equal(r.out, "true");
|
|
299
|
-
assert.equal(r.err, "", `the ${field} success path must write nothing to stderr`);
|
|
300
|
-
}
|
|
301
|
-
});
|
|
302
|
-
|
|
303
|
-
// --- #1141: an unusable interpreter is named as itself, never as a corrupt
|
|
304
|
-
// cache. PATH is REPLACED with links to exactly what the script runs, so the
|
|
305
|
-
// interpreter is really unreachable rather than shadowed.
|
|
306
|
-
const SHIMMED = ["sh", "git", "mktemp", "cat", "rm"];
|
|
307
|
-
function shimPath({ node, omit }) {
|
|
308
|
-
const bin = tempDir("derive-path-");
|
|
309
|
-
for (const name of SHIMMED) {
|
|
310
|
-
if (name === omit) continue;
|
|
311
|
-
const real = execFileSync("sh", ["-c", `command -v ${name}`], { encoding: "utf8" }).trim();
|
|
312
|
-
symlinkSync(real, join(bin, name));
|
|
313
|
-
}
|
|
314
|
-
if (node) symlinkSync(process.execPath, join(bin, "node"));
|
|
315
|
-
return bin;
|
|
316
|
-
}
|
|
317
|
-
|
|
318
|
-
// Exit 3, where every refusal about the cache, the repository or the arguments
|
|
319
|
-
// is exit 1: the reader read nothing, so a caller can tell its own
|
|
320
|
-
// environment's fault from a verdict on the cache.
|
|
321
|
-
test("an unusable interpreter refuses in this script's own voice, never the cache's", () => {
|
|
322
|
-
const { dir, head } = repo();
|
|
323
|
-
cache(dir, recipe(head, { test: "true" }));
|
|
324
|
-
const absent = derive(dir, "test", { ...process.env, PATH: shimPath({ node: false }) });
|
|
325
|
-
assert.equal(absent.status, 3);
|
|
326
|
-
assert.equal(absent.out, "");
|
|
327
|
-
assert.match(absent.err, /^derive-testcmd: node is unusable/);
|
|
328
|
-
assert.doesNotMatch(absent.err, /is unusable: it does not parse/);
|
|
329
|
-
|
|
330
|
-
// The false-positive control: the same stripped PATH with the interpreter
|
|
331
|
-
// present reads the cache to completion, so the refusal above is about node
|
|
332
|
-
// and not about a PATH too thin for the script to run at all.
|
|
333
|
-
const present = derive(dir, "test", { ...process.env, PATH: shimPath({ node: true }) });
|
|
334
|
-
assert.equal(present.status, 0, present.err);
|
|
335
|
-
assert.equal(present.out, "true");
|
|
336
|
-
});
|
|
337
|
-
|
|
338
|
-
// The reader's other tools, taken away the same way. The control above is the
|
|
339
|
-
// same stripped PATH with every tool present.
|
|
340
|
-
for (const [tool, reason] of [
|
|
341
|
-
["mktemp", /^derive-testcmd: cannot create a temporary file to read the Recipe cache$/m],
|
|
342
|
-
["cat", /^derive-testcmd: cat could not be started \(exit 127\), so the Recipe cache cannot be read$/m],
|
|
343
|
-
]) {
|
|
344
|
-
test(`a ${tool} that cannot be started is the environment's refusal, exit 3, never the cache's`, () => {
|
|
345
|
-
const { dir, head } = repo();
|
|
346
|
-
cache(dir, recipe(head, { test: "true" }));
|
|
347
|
-
const r = derive(dir, "test", { ...process.env, PATH: shimPath({ node: true, omit: tool }) });
|
|
348
|
-
assert.equal(r.status, 3, r.err);
|
|
349
|
-
assert.equal(r.out, "");
|
|
350
|
-
assert.match(r.err, reason);
|
|
351
|
-
assert.doesNotMatch(r.err, /is unusable|byte-count/);
|
|
352
|
-
});
|
|
353
|
-
}
|
|
354
|
-
|
|
355
|
-
// The reader asks mktemp twice, and a mktemp that starts and then fails — a
|
|
356
|
-
// full or unwritable temp directory — is the same environment fault as one
|
|
357
|
-
// that is missing, on either call.
|
|
358
|
-
test("a mktemp that runs and fails on its second call is exit 3, never the cache's", () => {
|
|
359
|
-
const { dir, head } = repo();
|
|
360
|
-
cache(dir, recipe(head, { test: "true" }));
|
|
361
|
-
const bin = shimPath({ node: true, omit: "mktemp" });
|
|
362
|
-
const real = execFileSync("sh", ["-c", "command -v mktemp"], { encoding: "utf8" }).trim();
|
|
363
|
-
const mark = join(bin, "called");
|
|
364
|
-
writeExecStub(join(bin, "mktemp"), `#!/bin/sh\nif [ -e '${mark}' ]; then echo 'mktemp: no space left' >&2; exit 1; fi\n: > '${mark}'\nexec '${real}' "$@"\n`);
|
|
365
|
-
const r = derive(dir, "test", { ...process.env, PATH: bin });
|
|
366
|
-
assert.equal(r.status, 3, r.err);
|
|
367
|
-
assert.match(r.err, /^derive-testcmd: cannot create a temporary file to read the Recipe cache$/m);
|
|
368
|
-
});
|
|
369
|
-
|
|
370
|
-
// The reader's `node -e 0` probe passes, and then the interpreter dies during
|
|
371
|
-
// the real read — killed, or no longer runnable. Nothing was read, so that is
|
|
372
|
-
// exit 3 as well. Node's own refusal of the cache (its exit 2) and an uncaught
|
|
373
|
-
// fault of its own (exit 1) are still the cache's exit 1, with node's reason.
|
|
374
|
-
// The stripped PATH has no cat: node's reason is read back WITHOUT it, so every
|
|
375
|
-
// refusal row also proves that. The rows that give a reason a shape (several
|
|
376
|
-
// lines, no final newline, trailing newlines, a backslash and leading space)
|
|
377
|
-
// pin what the read-back must still do as cat did.
|
|
378
|
-
for (const [what, body, status, reason] of [
|
|
379
|
-
["is killed", "kill -9 $$", 3, /^derive-testcmd: node did not finish reading the Recipe cache \(exit 137\)/m],
|
|
380
|
-
["can no longer be run", "exit 127", 3, /^derive-testcmd: node did not finish reading the Recipe cache \(exit 127\)/m],
|
|
381
|
-
["refuses the cache itself", "echo 'it does not parse: boom' >&2; exit 2", 1, /is unusable: it does not parse: boom/],
|
|
382
|
-
["faults on its own", "echo 'TypeError: boom' >&2; exit 1", 1, /is unusable: TypeError: boom/],
|
|
383
|
-
["refuses with a multi-line reason", "echo 'first line' >&2; echo 'second line' >&2; exit 2", 1, /is unusable: first line\nsecond line — run the Recipe/],
|
|
384
|
-
["refuses with a last line without a newline", "printf 'no newline' >&2; exit 2", 1, /is unusable: no newline — run the Recipe/],
|
|
385
|
-
["refuses with trailing newlines", "printf 'reason\\n\\n\\n' >&2; exit 2", 1, /is unusable: reason — run the Recipe/],
|
|
386
|
-
["refuses with a backslash and leading space", "printf ' a\\\\nb\\n' >&2; exit 2", 1, /is unusable: a\\nb — run the Recipe/],
|
|
387
|
-
]) {
|
|
388
|
-
test(`a node that passes the probe and then ${what} is exit ${status}`, () => {
|
|
389
|
-
const { dir, head } = repo();
|
|
390
|
-
cache(dir, recipe(head, { test: "true" }));
|
|
391
|
-
const bin = shimPath({ node: false, omit: "cat" });
|
|
392
|
-
writeExecStub(join(bin, "node"), `#!/bin/sh\nif [ "$1" = -e ] && [ "$2" = 0 ]; then exit 0; fi\n${body}\n`);
|
|
393
|
-
const r = derive(dir, "test", { ...process.env, PATH: bin });
|
|
394
|
-
assert.equal(r.status, status, r.err);
|
|
395
|
-
assert.equal(r.out, "");
|
|
396
|
-
assert.match(r.err, reason);
|
|
397
|
-
});
|
|
398
|
-
}
|
|
399
|
-
|
|
400
|
-
// A cat that exits 126 — the status a shell gives a command it found but could
|
|
401
|
-
// not execute — is the environment's fault like one that is missing (127). The
|
|
402
|
-
// stub exits 126 itself: whether a shell reports an unexecutable file as 126
|
|
403
|
-
// depends on the shell and its options, and this pins the reader's reading of
|
|
404
|
-
// the status, not the shell's.
|
|
405
|
-
test("a cat that exits 126 is exit 3, never the cache's", () => {
|
|
406
|
-
const { dir, head } = repo();
|
|
407
|
-
cache(dir, recipe(head, { test: "true" }));
|
|
408
|
-
const bin = shimPath({ node: true, omit: "cat" });
|
|
409
|
-
writeExecStub(join(bin, "cat"), "#!/bin/sh\nexit 126\n");
|
|
410
|
-
const r = derive(dir, "test", { ...process.env, PATH: bin });
|
|
411
|
-
assert.equal(r.status, 3, r.err);
|
|
412
|
-
assert.equal(r.out, "");
|
|
413
|
-
assert.match(r.err, /^derive-testcmd: cat could not be started \(exit 126\), so the Recipe cache cannot be read$/m);
|
|
414
|
-
});
|
|
415
|
-
|
|
416
|
-
// A cat that starts and fails while reading node's byte-count file is the
|
|
417
|
-
// cache refusal, exit 1, and carries cat's own reason.
|
|
418
|
-
test("a cat that runs and fails on the byte-count file is exit 1, carrying its reason", () => {
|
|
419
|
-
const { dir, head } = repo();
|
|
420
|
-
cache(dir, recipe(head, { test: "true" }));
|
|
421
|
-
const bin = shimPath({ node: true, omit: "cat" });
|
|
422
|
-
const real = execFileSync("sh", ["-c", "command -v cat"], { encoding: "utf8" }).trim();
|
|
423
|
-
const mark = join(bin, "called");
|
|
424
|
-
writeExecStub(join(bin, "cat"), `#!/bin/sh\nif [ ! -e '${mark}' ]; then : > '${mark}'; echo 'cat: I/O error' >&2; exit 1; fi\nexec '${real}' "$@"\n`);
|
|
425
|
-
const r = derive(dir, "test", { ...process.env, PATH: bin });
|
|
426
|
-
assert.equal(r.status, 1, r.err);
|
|
427
|
-
assert.equal(r.out, "");
|
|
428
|
-
assert.match(r.err, /cat failed reading node's byte-count file \(exit 1\): cat: I\/O error/);
|
|
429
|
-
assert.doesNotMatch(r.err, /could not be started/);
|
|
430
|
-
});
|
|
431
|
-
|
|
432
|
-
// node's refusal of the cache is read back WITHOUT cat: a cat that cannot be
|
|
433
|
-
// started must not turn a cache node really refuses into a refusal with an
|
|
434
|
-
// empty reason. The cache is refused either way (exit 1), and node's own reason
|
|
435
|
-
// survives, with no shell complaint about cat.
|
|
436
|
-
const REFUSED = /is unusable: `installClean` is not true — the Install step was never proven to leave the tree clean — run the Recipe derivation step/;
|
|
437
|
-
for (const [what, stub] of [
|
|
438
|
-
["is missing", null],
|
|
439
|
-
["exits 127", "exit 127"],
|
|
440
|
-
["exits 126", "exit 126"],
|
|
441
|
-
]) {
|
|
442
|
-
test(`a cat that ${what} still lets a refused cache carry node's reason, exit 1`, () => {
|
|
443
|
-
const { dir, head } = repo();
|
|
444
|
-
cache(dir, recipe(head, { installClean: false }));
|
|
445
|
-
const bin = shimPath({ node: true, omit: "cat" });
|
|
446
|
-
if (stub) writeExecStub(join(bin, "cat"), `#!/bin/sh\n${stub}\n`);
|
|
447
|
-
const r = derive(dir, "test", { ...process.env, PATH: bin });
|
|
448
|
-
assert.equal(r.status, 1, r.err);
|
|
449
|
-
assert.equal(r.out, "");
|
|
450
|
-
assert.match(r.err, REFUSED);
|
|
451
|
-
assert.doesNotMatch(r.err, /command not found|could not be started/);
|
|
452
|
-
});
|
|
453
|
-
}
|
|
454
|
-
|
|
455
|
-
// The control: the same stripped PATH with every tool present, same cache.
|
|
456
|
-
test("the same refused cache with cat present carries the same reason", () => {
|
|
457
|
-
const { dir, head } = repo();
|
|
458
|
-
cache(dir, recipe(head, { installClean: false }));
|
|
459
|
-
const r = derive(dir, "test", { ...process.env, PATH: shimPath({ node: true }) });
|
|
460
|
-
assert.equal(r.status, 1, r.err);
|
|
461
|
-
assert.match(r.err, REFUSED);
|
|
462
|
-
});
|
|
463
|
-
|
|
464
|
-
// A cache holding a NUL byte is quoted back, NUL and all, in node's parse
|
|
465
|
-
// error. A `read` loop stops at a NUL where cat kept the rest, so the reason
|
|
466
|
-
// must reach the shell without one. Only a sh whose `read` stops there (the
|
|
467
|
-
// bash 3.2 that is /bin/sh on macOS) loses the tail without that, so the pin
|
|
468
|
-
// bites on such a host and passes elsewhere.
|
|
469
|
-
test("a NUL byte in the cache does not cut node's parse reason short", () => {
|
|
470
|
-
const { dir } = repo();
|
|
471
|
-
cache(dir, '{"install":\u0000"x"}');
|
|
472
|
-
const r = derive(dir, "test");
|
|
473
|
-
assert.equal(r.status, 1, r.err);
|
|
474
|
-
assert.match(r.err, /is unusable: it does not parse: [^\n]*JSON[^\n]* — run the Recipe/);
|
|
475
|
-
assert.doesNotMatch(r.err, /\0/);
|
|
476
|
-
});
|
|
477
|
-
|
|
478
|
-
// Nothing on the way to the refusal may end the script before it: the file
|
|
479
|
-
// node's reason was written to is the script's own mktemp, and one that cannot
|
|
480
|
-
// be read back must still end in this script's refusal (exit 1, naming the
|
|
481
|
-
// Recipe derivation step), not in the shell's own redirect error — which under
|
|
482
|
-
// dash is an exit outside the documented 0/1/3.
|
|
483
|
-
function mktempShim(bin, { firstArgs = "" } = {}) {
|
|
484
|
-
const real = execFileSync("sh", ["-c", "command -v mktemp"], { encoding: "utf8" }).trim();
|
|
485
|
-
const mark = join(bin, "errf-path");
|
|
486
|
-
writeExecStub(join(bin, "mktemp"), `#!/bin/sh\nif [ ! -e '${mark}' ]; then p=$('${real}' ${firstArgs} "$@") || exit $?; printf '%s' "$p" > '${mark}'; printf '%s\\n' "$p"; exit 0; fi\nexec '${real}' "$@"\n`);
|
|
487
|
-
return mark;
|
|
488
|
-
}
|
|
489
|
-
|
|
490
|
-
test("a stderr file that cannot be opened for the read-back still reaches the refusal", () => {
|
|
491
|
-
const { dir, head } = repo();
|
|
492
|
-
cache(dir, recipe(head, { test: "true" }));
|
|
493
|
-
const bin = shimPath({ node: false, omit: "mktemp" });
|
|
494
|
-
const mark = mktempShim(bin);
|
|
495
|
-
// node writes its reason and then removes the file it wrote it to.
|
|
496
|
-
writeExecStub(join(bin, "node"), `#!/bin/sh\nif [ "$1" = -e ] && [ "$2" = 0 ]; then exit 0; fi\necho 'real reason' >&2\nread -r f < '${mark}'\nrm -f "$f"\nexit 2\n`);
|
|
497
|
-
const r = derive(dir, "test", { ...process.env, PATH: bin });
|
|
498
|
-
assert.equal(r.status, 1, r.err);
|
|
499
|
-
assert.equal(r.out, "");
|
|
500
|
-
assert.match(r.err, /^derive-testcmd: the Recipe cache at .* is unusable: \(node's reason could not be read back from [^)]+\) — /m);
|
|
501
|
-
assert.match(r.err, NAMES_STEP);
|
|
502
|
-
assert.doesNotMatch(r.err, /No such file|cannot open/);
|
|
503
|
-
});
|
|
504
|
-
|
|
505
|
-
// A stderr file that is a directory: bash's `read` fails there without
|
|
506
|
-
// assigning `line`, and `set -u` then trips on the unbound variable inside the
|
|
507
|
-
// read-back. The refusal must still be reached, with no complaint about it.
|
|
508
|
-
test("a stderr file that is a directory still reaches the refusal", () => {
|
|
509
|
-
const { dir, head } = repo();
|
|
510
|
-
cache(dir, recipe(head, { test: "true" }));
|
|
511
|
-
const bin = shimPath({ node: true, omit: "mktemp" });
|
|
512
|
-
mktempShim(bin, { firstArgs: "-d" });
|
|
513
|
-
const r = derive(dir, "test", { ...process.env, PATH: bin });
|
|
514
|
-
assert.equal(r.status, 1, r.err);
|
|
515
|
-
assert.equal(r.out, "");
|
|
516
|
-
assert.match(r.err, /^derive-testcmd: the Recipe cache at .* is unusable: /m);
|
|
517
|
-
assert.match(r.err, NAMES_STEP);
|
|
518
|
-
assert.doesNotMatch(r.err, /unbound variable/);
|
|
519
|
-
});
|
|
520
|
-
|
|
521
|
-
// `rm` is the reader's cleanup only, so it must not decide the outcome: with
|
|
522
|
-
// it gone a good cache still reads cleanly — status 0 and nothing on stderr,
|
|
523
|
-
// the success-path invariant claim-ticket.sh relies on — and a refused cache
|
|
524
|
-
// keeps its own status.
|
|
525
|
-
test("an rm that cannot be started changes neither the value read nor the refusal's status", () => {
|
|
526
|
-
const { dir, head } = repo();
|
|
527
|
-
cache(dir, recipe(head, { test: "true" }));
|
|
528
|
-
const ok = derive(dir, "test", { ...process.env, PATH: shimPath({ node: true, omit: "rm" }) });
|
|
529
|
-
assert.equal(ok.status, 0, ok.err);
|
|
530
|
-
assert.equal(ok.out, "true");
|
|
531
|
-
assert.equal(ok.err, "");
|
|
532
|
-
|
|
533
|
-
cache(dir, "not json");
|
|
534
|
-
const refused = derive(dir, "test", { ...process.env, PATH: shimPath({ node: true, omit: "rm" }) });
|
|
535
|
-
assert.equal(refused.status, 1, refused.err);
|
|
536
|
-
});
|
|
537
|
-
|
|
538
|
-
// The false-positive class: a cache the reader really refuses stays exit 1
|
|
539
|
-
// under the same stripped PATH, so exit 3 is not "any refusal".
|
|
540
|
-
test("a cache that is refused stays exit 1 under the stripped PATH", () => {
|
|
541
|
-
const { dir } = repo();
|
|
542
|
-
cache(dir, "not json");
|
|
543
|
-
const r = derive(dir, "test", { ...process.env, PATH: shimPath({ node: true }) });
|
|
544
|
-
assert.equal(r.status, 1, r.err);
|
|
545
|
-
assert.match(r.err, /is unusable/);
|
|
546
|
-
});
|
|
547
|
-
|
|
548
|
-
// --- #2217: node's STDOUT is the capture itself, so the stream split above
|
|
549
|
-
// does nothing for it. A version-manager or proxy shim prints before exec'ing
|
|
550
|
-
// the real node, or — not exec'ing — after it exits, and unframed that chatter
|
|
551
|
-
// became part of the command: refused as a stale cache when its first word
|
|
552
|
-
// did not resolve, handed on when it did. Every stub runs the real interpreter
|
|
553
|
-
// by ABSOLUTE path: re-running `node` through PATH would find the stub again.
|
|
554
|
-
function nodeStub(body) {
|
|
555
|
-
const bin = tempDir("derive-stub-");
|
|
556
|
-
writeExecStub(join(bin, "node"), `#!/bin/sh\n${body.replaceAll("NODE", `'${process.execPath}'`)}\n`);
|
|
557
|
-
return { ...process.env, PATH: `${bin}:${process.env.PATH}` };
|
|
558
|
-
}
|
|
559
|
-
|
|
560
|
-
test("stdout chatter around the Recipe value refuses, blaming node's output and never the cache (#2217)", (t) => {
|
|
561
|
-
const { dir, head } = repo();
|
|
562
|
-
cache(dir, recipe(head));
|
|
563
|
-
const stubs = {
|
|
564
|
-
"a banner before exec": ['echo "Now using node v22.0.0"; exec NODE "$@"', "Now using node v22.0.0"],
|
|
565
|
-
"a digit prefix with no newline": ['printf 1; exec NODE "$@"', `1${FRAME_OPEN}`],
|
|
566
|
-
"trailing output from a shim that does not exec": ['NODE "$@"; st=$?; printf done; exit $st', `${FRAME_CLOSE}done`],
|
|
567
|
-
"a shim whose own chatter spells out the sentinel": [`printf "${FRAME_OPEN}SNEAKY-INJECTED"; exec NODE "$@"`, `${FRAME_OPEN}SNEAKY-INJECTED${FRAME_OPEN}`],
|
|
568
|
-
};
|
|
569
|
-
for (const [name, [body, shown]] of Object.entries(stubs)) {
|
|
570
|
-
const env = nodeStub(body);
|
|
571
|
-
for (const field of ["install", "test"]) {
|
|
572
|
-
t.diagnostic(`${name}, ${field}`);
|
|
573
|
-
const r = derive(dir, field, env);
|
|
574
|
-
assert.equal(r.status, 1, `${name}/${field}: ${r.err}`);
|
|
575
|
-
assert.equal(r.out, "", `${name}/${field}: nothing may reach the caller`);
|
|
576
|
-
assert.match(r.err, /^derive-testcmd: node's stdout carried more than the framed Recipe value/);
|
|
577
|
-
assert.ok(r.err.includes(shown), `${name}/${field}: the refusal shows the capture: ${r.err}`);
|
|
578
|
-
assert.doesNotMatch(r.err, /Recipe cache .* is invalid/);
|
|
579
|
-
assert.doesNotMatch(r.err, /Recipe derivation step/);
|
|
580
|
-
}
|
|
581
|
-
}
|
|
582
|
-
});
|
|
583
|
-
|
|
584
|
-
// The must-ACCEPT half: with no stub the frame is invisible, and a value with
|
|
585
|
-
// an embedded newline crosses it byte for byte.
|
|
586
|
-
test("the framed read hands on the exact value, an embedded newline included (#2217)", () => {
|
|
587
|
-
const { dir, head } = repo();
|
|
588
|
-
cache(dir, recipe(head, { install: "true\ntrue", test: "sh ./run-tests.sh\n: second line" }));
|
|
589
|
-
const i = derive(dir, "install");
|
|
590
|
-
assert.equal(i.status, 0, i.err);
|
|
591
|
-
assert.equal(i.out, "true\ntrue");
|
|
592
|
-
const t = derive(dir, "test");
|
|
593
|
-
assert.equal(t.status, 0, t.err);
|
|
594
|
-
assert.equal(t.out, "sh ./run-tests.sh\n: second line");
|
|
595
|
-
});
|