@feigi/fleet-ctl 3.23.36 → 3.23.38
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/cell-readout.mjs +38 -11
- 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,1640 +0,0 @@
|
|
|
1
|
-
import { test } from "node:test";
|
|
2
|
-
import assert from "node:assert/strict";
|
|
3
|
-
import { spawnSync } from "node:child_process";
|
|
4
|
-
import { mkdtempSync, mkdirSync, writeFileSync, readFileSync, chmodSync, symlinkSync, realpathSync } from "node:fs";
|
|
5
|
-
import { tempDir } from "./temp-dir.mjs";
|
|
6
|
-
import { join, dirname, relative } from "node:path";
|
|
7
|
-
import { writeExecStub } from "./exec-stub.mjs";
|
|
8
|
-
|
|
9
|
-
// This repository's own test runner, `./agent-test` at the repo root: the
|
|
10
|
-
// `node --test` argument shim that left claim-ticket.sh's emitter for a
|
|
11
|
-
// repo-local runner (ADR 0015). These cases moved here with it, unchanged in
|
|
12
|
-
// what they assert; only the fixture changed — the runner is copied into a
|
|
13
|
-
// fixture tree rather than emitted by a claim.
|
|
14
|
-
const RUNNER = join(import.meta.dirname, "..", "..", "agent-test");
|
|
15
|
-
// Installed through `writeExecStub`, never copied: a copy is a new executable
|
|
16
|
-
// inode per fixture, and macOS scans each one on its first exec.
|
|
17
|
-
const RUNNER_BODY = readFileSync(RUNNER, "utf8");
|
|
18
|
-
|
|
19
|
-
// `node --test` marks the processes it spawns, and an inherited mark makes
|
|
20
|
-
// the runner's own `node --test` report to a parent that is not listening —
|
|
21
|
-
// status 0 and not a byte of stdout. An artifact of testing a test runner
|
|
22
|
-
// from inside one; strip it so these assertions see what a member sees.
|
|
23
|
-
// FORCE_COLOR is stripped for the same reason: it reaches the runner's own
|
|
24
|
-
// `node --test`, which then SGR-wraps its summary even into a pipe
|
|
25
|
-
// (`\x1b[34mℹ pass 3\x1b[39m`), breaking every `run`/`runFrom` assertion
|
|
26
|
-
// that reads that summary literally. A developer with FORCE_COLOR set is
|
|
27
|
-
// exactly what these assertions have to survive, not exercise.
|
|
28
|
-
function runnerEnv() {
|
|
29
|
-
const env = { ...process.env };
|
|
30
|
-
delete env.NODE_TEST_CONTEXT;
|
|
31
|
-
delete env.NODE_TEST_WORKER_ID;
|
|
32
|
-
delete env.FORCE_COLOR;
|
|
33
|
-
return env;
|
|
34
|
-
}
|
|
35
|
-
|
|
36
|
-
// Lays `files` out the way a claim does — once in the repository's own
|
|
37
|
-
// checkout `<parent>/claim-XXXX` and once in its worktree
|
|
38
|
-
// `.worktrees/42-slug` under it — and puts the runner in the worktree. The
|
|
39
|
-
// layout is load-bearing: the runner judges an argument by where its
|
|
40
|
-
// resolution DIVERGES from the runner's own location, so the ancestry above
|
|
41
|
-
// it (and the copy of the suite sitting in it) is part of what the
|
|
42
|
-
// vendored-path guards have to ignore, and only a fixture built under a
|
|
43
|
-
// `node_modules` parent can pin that.
|
|
44
|
-
function apply(files, parent = null) {
|
|
45
|
-
const dir = parent === null ? tempDir("claim-") : mkdtempSync(join(parent, "claim-"));
|
|
46
|
-
const wt = join(dir, ".worktrees", "42-slug");
|
|
47
|
-
for (const root of [dir, wt]) {
|
|
48
|
-
mkdirSync(root, { recursive: true });
|
|
49
|
-
for (const [name, body] of Object.entries(files)) {
|
|
50
|
-
mkdirSync(dirname(join(root, name)), { recursive: true });
|
|
51
|
-
writeFileSync(join(root, name), body);
|
|
52
|
-
}
|
|
53
|
-
}
|
|
54
|
-
writeExecStub(join(wt, "agent-test"), RUNNER_BODY);
|
|
55
|
-
const env = runnerEnv();
|
|
56
|
-
return {
|
|
57
|
-
wt,
|
|
58
|
-
env,
|
|
59
|
-
run: (...args) => spawnSync(join(wt, "agent-test"), args, { cwd: wt, encoding: "utf8", env }),
|
|
60
|
-
// The same runner invoked from a subdirectory. Node resolves argv against
|
|
61
|
-
// the cwd, so where a member stands is part of what an argument means.
|
|
62
|
-
runFrom: (sub, ...args) =>
|
|
63
|
-
spawnSync(join(wt, "agent-test"), args, { cwd: join(wt, sub), encoding: "utf8", env }),
|
|
64
|
-
};
|
|
65
|
-
}
|
|
66
|
-
|
|
67
|
-
const PASSES = 'import { test } from "node:test";\ntest("ok", () => {});\n';
|
|
68
|
-
// `root.test.mjs` exists so no assertion below can be satisfied by the argv
|
|
69
|
-
// being dropped: bare `node --test` discovers the whole fixture, and every
|
|
70
|
-
// count asserted here differs from that. Without it the two-file cases and
|
|
71
|
-
// discovery both landed on `pass 2`, and a test that cannot tell "argv was
|
|
72
|
-
// honoured" from "argv was discarded" pins nothing.
|
|
73
|
-
const SUITE = {
|
|
74
|
-
"t/a.test.mjs": PASSES,
|
|
75
|
-
"t/b.test.mjs": PASSES,
|
|
76
|
-
"t/nested/c.test.mjs": PASSES,
|
|
77
|
-
"root.test.mjs": PASSES,
|
|
78
|
-
"with space/s.test.mjs": PASSES,
|
|
79
|
-
"br[a]cket/g.test.mjs": PASSES,
|
|
80
|
-
"empty/README.md": "",
|
|
81
|
-
};
|
|
82
|
-
|
|
83
|
-
// `node --test <dir>` resolves the directory as a module specifier and dies
|
|
84
|
-
// with MODULE_NOT_FOUND before a single test runs. A directory is the
|
|
85
|
-
// ergonomic way to say "run this suite", and the red it produced was read as
|
|
86
|
-
// a finding against the diff under review rather than against the invocation.
|
|
87
|
-
// `pass 3` also pins the recursion: `t/` holds two files and `t/nested/` a
|
|
88
|
-
// third, so a `find` capped at one level reads as a red here.
|
|
89
|
-
test("runner: a directory argument runs the test files under it", () => {
|
|
90
|
-
const r = apply(SUITE).run("t");
|
|
91
|
-
assert.equal(r.status, 0, r.stdout + r.stderr);
|
|
92
|
-
// Bounded rather than line-anchored: a bare `pass 3` is a substring of
|
|
93
|
-
// `pass 3<n>` and stops discriminating once a fixture reaches 30, but a
|
|
94
|
-
// `^…$/m` anchor buys that at the cost of the line's raw edges — under a
|
|
95
|
-
// colored reporter the summary comes back SGR-wrapped (`\x1b[34mℹ pass 3…`),
|
|
96
|
-
// so it neither starts with the prefix nor ends with the digit. The reporter
|
|
97
|
-
// prefix plus a `(?!\d)` lookahead rejects `pass 30`-`pass 39` either way.
|
|
98
|
-
// Both prefixes because `node --test`'s default reporter is
|
|
99
|
-
// version-dependent — spec (`ℹ pass 3`) on newer node, tap (`# pass 3`) on
|
|
100
|
-
// older.
|
|
101
|
-
assert.match(r.stdout, /(?:ℹ|#) pass 3(?!\d)/);
|
|
102
|
-
});
|
|
103
|
-
|
|
104
|
-
// `set -f` and IFS only settle how the *shell* splits the expansion. Node
|
|
105
|
-
// globs its own argv afterwards, where a literal `[` is a bracket expression
|
|
106
|
-
// that cannot match itself — so an unescaped path matches nothing, node runs
|
|
107
|
-
// nothing, and it exits 0. That is the vacuous pass this shim exists to
|
|
108
|
-
// refuse, reached past the guard because `find` did match the file.
|
|
109
|
-
test("runner: a directory whose path holds a glob character still runs its tests", () => {
|
|
110
|
-
const r = apply(SUITE).run("br[a]cket");
|
|
111
|
-
assert.equal(r.status, 0, r.stdout + r.stderr);
|
|
112
|
-
// Bounded, same reason as above: a bare `pass 1` is the worst offender — it
|
|
113
|
-
// matches every count whose leading digit is 1: `pass 1` itself, 10-19, 100+.
|
|
114
|
-
assert.match(r.stdout, /(?:ℹ|#) pass 1(?!\d)/);
|
|
115
|
-
});
|
|
116
|
-
|
|
117
|
-
// The other half of the same claim: IFS pinned to a newline is what keeps a
|
|
118
|
-
// path with a space in it one word. On the default IFS it splits into two
|
|
119
|
-
// words node cannot resolve, and node drops unresolvable arguments silently.
|
|
120
|
-
test("runner: a directory whose path holds a space still runs its tests", () => {
|
|
121
|
-
const r = apply(SUITE).run("with space");
|
|
122
|
-
assert.equal(r.status, 0, r.stdout + r.stderr);
|
|
123
|
-
// Bounded, same reason as the glob-character case above.
|
|
124
|
-
assert.match(r.stdout, /(?:ℹ|#) pass 1(?!\d)/);
|
|
125
|
-
});
|
|
126
|
-
|
|
127
|
-
// #600: a filename is bytes, and the two tools that read find's output are told
|
|
128
|
-
// which only by the ambient locale. Under en_US.UTF-8 with a name holding \377,
|
|
129
|
-
// measured on macOS: `grep` drops that line silently — a green over a smaller
|
|
130
|
-
// suite, #582's own false-green — and BSD `sed`, fed that byte directly, abandons
|
|
131
|
-
// the whole stream ("RE error: illegal byte sequence", exit 1), which empties
|
|
132
|
-
// $files and refuses a suite that is right there. `LC_ALL=C` on each command is
|
|
133
|
-
// the fix.
|
|
134
|
-
//
|
|
135
|
-
// Two stubs, because neither half of the fixture can be built for real. APFS
|
|
136
|
-
// refuses the name outright (`Illegal byte sequence`), so no filesystem this
|
|
137
|
-
// suite can create holds it — `find` is stubbed to emit what a filesystem that
|
|
138
|
-
// does would. And node cannot be asked what it ran, so it is stubbed to report
|
|
139
|
-
// how many arguments survived discovery: `--test` plus both paths is 3, and the
|
|
140
|
-
// unpinned runner reaches this assertion with one of them (`2` — `--test` plus
|
|
141
|
-
// the one path grep's own silent drop lets through; `sed`'s abort never enters
|
|
142
|
-
// into it, since grep already dropped the bad line before sed would see it).
|
|
143
|
-
//
|
|
144
|
-
// LC_ALL is set on the child rather than inherited: the ambient locale is the
|
|
145
|
-
// hostile input here, so pre-seeding it is what makes the test discriminate at
|
|
146
|
-
// all instead of depending on the operator's environment.
|
|
147
|
-
//
|
|
148
|
-
// THE CEILING, inherited from locale-pin-prose.test.mjs: this kills its mutant
|
|
149
|
-
// on macOS only. GNU grep and sed are byte-oriented and pass every line through
|
|
150
|
-
// whatever the locale says, so on ubuntu-latest — the one platform ci.yml runs —
|
|
151
|
-
// deleting both pins keeps this test green.
|
|
152
|
-
test("runner: an invalid UTF-8 byte in a discovered path does not drop it", () => {
|
|
153
|
-
const a = apply(SUITE);
|
|
154
|
-
const bin = tempDir("claim-locale-");
|
|
155
|
-
// The byte cannot be spelled in JS — node re-encodes every string as UTF-8 on
|
|
156
|
-
// the way to argv, turning `\xFF` into the two valid bytes `\303\277`. POSIX
|
|
157
|
-
// `printf` interprets the octal escape, so the fixture stays pure ASCII and
|
|
158
|
-
// the shell makes the byte.
|
|
159
|
-
writeExecStub(join(bin, "find"), "#!/bin/sh\nprintf 't/b\\377ad.test.mjs\\nt/ok.test.mjs\\n'\n");
|
|
160
|
-
writeExecStub(join(bin, "node"), '#!/bin/sh\nprintf %s "$#"\n');
|
|
161
|
-
const r = spawnSync(join(a.wt, "agent-test"), ["t"], {
|
|
162
|
-
cwd: a.wt,
|
|
163
|
-
encoding: "utf8",
|
|
164
|
-
env: { ...a.env, PATH: `${bin}:${a.env.PATH}`, LC_ALL: "en_US.UTF-8" },
|
|
165
|
-
});
|
|
166
|
-
assert.equal(r.status, 0, r.stdout + r.stderr);
|
|
167
|
-
assert.equal(r.stdout, "3", "discovery lost a path holding an invalid UTF-8 byte");
|
|
168
|
-
});
|
|
169
|
-
|
|
170
|
-
// The source-assertion half of #600, on both pins — same shape as
|
|
171
|
-
// locale-pin-prose.test.mjs, whose list covers plugin/scripts only; this
|
|
172
|
-
// runner is a repo-root file, so the decision is made here instead.
|
|
173
|
-
//
|
|
174
|
-
// This is the ONLY regression coverage the file-argument branch's own pin gets
|
|
175
|
-
// (`arg=$(printf '%s\n' "$arg" | LC_ALL=C sed …)`, below). A behavioural twin of
|
|
176
|
-
// the test above is not constructable for it, on either platform this suite
|
|
177
|
-
// runs on: `[ -e "$arg" ]` gates that line, and it needs a REAL file — APFS
|
|
178
|
-
// refuses to create one whose name holds an invalid UTF-8 byte at all (measured:
|
|
179
|
-
// `touch` on such a name exits "Illegal byte sequence", not just Node's own
|
|
180
|
-
// fs), and `[` is a shell builtin, not a PATH-resolved command, so it can't be
|
|
181
|
-
// stubbed the way `find` and `node` are above. Where the filesystem WOULD allow
|
|
182
|
-
// the name (ext4, ubuntu-latest — the platform CI actually runs), GNU sed's own
|
|
183
|
-
// byte-orientation makes the pin invisible anyway, same ceiling as the
|
|
184
|
-
// directory branch. Nothing behavioural can fail if this pin goes missing, on
|
|
185
|
-
// any platform available here — only a source check can.
|
|
186
|
-
test("agent-test still pins the locale on both find-output commands", () => {
|
|
187
|
-
const src = readFileSync(RUNNER, "utf8");
|
|
188
|
-
assert.equal((src.match(/LC_ALL=C grep\b/g) ?? []).length, 1,
|
|
189
|
-
"the directory branch's grep pin (find's output, above) went missing or moved");
|
|
190
|
-
assert.equal((src.match(/LC_ALL=C sed\b/g) ?? []).length, 2,
|
|
191
|
-
"one of the two sed pins (directory branch above, file-argument branch below) went missing");
|
|
192
|
-
});
|
|
193
|
-
|
|
194
|
-
// Why the trailing slash, and why not `-L`: agent-test, above `found=`.
|
|
195
|
-
// The symlink is written into the worktree rather than through `apply()` because
|
|
196
|
-
// the runner only ever stats a path in its cwd — whether a commit or a local
|
|
197
|
-
// `ln -s` put it there is invisible to it — and keeping it out of the shared
|
|
198
|
-
// fixture leaves every other count assertion in this file measuring what it
|
|
199
|
-
// measured before.
|
|
200
|
-
test("runner: a symlink to a directory runs the test files under it", () => {
|
|
201
|
-
const a = apply(SUITE);
|
|
202
|
-
symlinkSync("t", join(a.wt, "tlink"));
|
|
203
|
-
// `t/vendor` is the shape neither exclusion can see: a symlink into
|
|
204
|
-
// `node_modules` under another name — `-prune` matches the directory's own
|
|
205
|
-
// name and this one is called `vendor`, and the `case` guard reads the
|
|
206
|
-
// argument, which neither spells nor resolves into one. Measured: it
|
|
207
|
-
// is exactly as blind as the `-not -path` filter it replaced, both legs.
|
|
208
|
-
// The slash form does not descend it and reads 3; `find -L`
|
|
209
|
-
// sweeps the vendored test in and reads 4. Without this every test passes
|
|
210
|
-
// under `-L`, leaving the reasoning in agent-test as the only thing
|
|
211
|
-
// between a future tidy-up and a suite resting on third-party code.
|
|
212
|
-
mkdirSync(join(a.wt, "node_modules"), { recursive: true });
|
|
213
|
-
writeFileSync(join(a.wt, "node_modules", "v.test.mjs"), PASSES);
|
|
214
|
-
symlinkSync("../node_modules", join(a.wt, "t", "vendor"));
|
|
215
|
-
const r = a.run("tlink");
|
|
216
|
-
assert.equal(r.status, 0, r.stdout + r.stderr);
|
|
217
|
-
// Anchored for the same reason as the vendored-test count below: bare
|
|
218
|
-
// `pass 3` is a substring of `pass 3<n>` and stops discriminating once a
|
|
219
|
-
// fixture grows. 3 is `t/`'s own two files plus the one under `t/nested/`,
|
|
220
|
-
// so a `find` capped at one level reads as a red here too.
|
|
221
|
-
assert.match(r.stdout, /^(?:ℹ|#) pass 3$/m);
|
|
222
|
-
});
|
|
223
|
-
|
|
224
|
-
// #186: the argument itself is a symlink whose TARGET lies inside a vendored
|
|
225
|
-
// tree. Spelling can't see it — `vendlink` carries no `node_modules` in its
|
|
226
|
-
// own name — and `-prune` only fires on a dirent the walk descends THROUGH
|
|
227
|
-
// named `node_modules`; here the walk starts at the symlink's target,
|
|
228
|
-
// already past the vendored component, so neither existing guard sees it.
|
|
229
|
-
// Measured on the unfixed shim: `agent-test vendlink` exits 0 and reports
|
|
230
|
-
// the vendored test as a pass — the same green-over-third-party-code #109's
|
|
231
|
-
// prune exists to refuse, reached by a route neither mechanism covers.
|
|
232
|
-
test("runner: a symlink whose target is inside a vendored tree refuses", () => {
|
|
233
|
-
const a = apply(SUITE);
|
|
234
|
-
const vendor = join(a.wt, "node_modules", "pkg");
|
|
235
|
-
mkdirSync(vendor, { recursive: true });
|
|
236
|
-
writeFileSync(join(vendor, "v.test.mjs"), PASSES);
|
|
237
|
-
symlinkSync(join("node_modules", "pkg"), join(a.wt, "vendlink"));
|
|
238
|
-
const r = a.run("vendlink");
|
|
239
|
-
assert.notEqual(r.status, 0, r.stdout + r.stderr);
|
|
240
|
-
assert.match(r.stderr, /is under node_modules — excluded from the run/);
|
|
241
|
-
});
|
|
242
|
-
|
|
243
|
-
// The false-positive class of the same fix: a symlink to a directory that
|
|
244
|
-
// merely CONTAINS a vendored tree, rather than one whose own resolution ends
|
|
245
|
-
// inside it, must still run that directory's own tests and still exclude the
|
|
246
|
-
// real `node_modules` beneath it. Already true pre-fix (find's own prune
|
|
247
|
-
// handles it once the walk is inside), and must stay true — a resolved-path
|
|
248
|
-
// guard that widens into refusing every symlinked directory with
|
|
249
|
-
// `node_modules` somewhere underneath would regress this ordinary case.
|
|
250
|
-
test("runner: a symlink to a directory containing a vendored tree still runs its own tests", () => {
|
|
251
|
-
const a = apply(SUITE);
|
|
252
|
-
mkdirSync(join(a.wt, "proj"), { recursive: true });
|
|
253
|
-
writeFileSync(join(a.wt, "proj", "ok.test.mjs"), PASSES);
|
|
254
|
-
const vendor = join(a.wt, "proj", "node_modules", "pkg");
|
|
255
|
-
mkdirSync(vendor, { recursive: true });
|
|
256
|
-
writeFileSync(
|
|
257
|
-
join(vendor, "v.test.mjs"),
|
|
258
|
-
'import { test } from "node:test";\ntest("VENDOR", () => { throw new Error("not ours"); });\n',
|
|
259
|
-
);
|
|
260
|
-
symlinkSync("proj", join(a.wt, "projlink"));
|
|
261
|
-
const r = a.run("projlink");
|
|
262
|
-
assert.equal(r.status, 0, r.stdout + r.stderr);
|
|
263
|
-
assert.match(r.stdout, /^(?:ℹ|#) pass 1$/m);
|
|
264
|
-
});
|
|
265
|
-
|
|
266
|
-
// The vendored tree the symlink lands in need not be inside the worktree.
|
|
267
|
-
// Judging the resolution RELATIVE TO THE WORKTREE ROOT passes every other test
|
|
268
|
-
// in this file and still runs this one green — the resolution lands outside, so
|
|
269
|
-
// there is nothing left to compare — which is #186's own class one input over.
|
|
270
|
-
// Both directions are here because the cheap over-correction (refuse anything
|
|
271
|
-
// resolving outside) also passes the refusal leg alone.
|
|
272
|
-
test("runner: a symlink to a vendored tree outside the worktree refuses", () => {
|
|
273
|
-
const a = apply(SUITE);
|
|
274
|
-
const outside = tempDir("outside-");
|
|
275
|
-
const vendor = join(outside, "node_modules", "pkg");
|
|
276
|
-
mkdirSync(vendor, { recursive: true });
|
|
277
|
-
writeFileSync(join(vendor, "v.test.mjs"), PASSES);
|
|
278
|
-
symlinkSync(vendor, join(a.wt, "extlink"));
|
|
279
|
-
const r = a.run("extlink");
|
|
280
|
-
assert.notEqual(r.status, 0, r.stdout + r.stderr);
|
|
281
|
-
assert.match(r.stderr, /is under node_modules — excluded from the run/);
|
|
282
|
-
const plain = join(outside, "lib");
|
|
283
|
-
mkdirSync(plain, { recursive: true });
|
|
284
|
-
writeFileSync(join(plain, "o.test.mjs"), PASSES);
|
|
285
|
-
symlinkSync(plain, join(a.wt, "oklink"));
|
|
286
|
-
const ok = a.run("oklink");
|
|
287
|
-
assert.equal(ok.status, 0, ok.stdout + ok.stderr);
|
|
288
|
-
assert.match(ok.stdout, /^(?:ℹ|#) pass 1$/m);
|
|
289
|
-
});
|
|
290
|
-
|
|
291
|
-
// The opposite error, and the one that actually shipped: `pwd -P` is absolute,
|
|
292
|
-
// so matching `*/node_modules/*` against it refuses on a `node_modules` in the
|
|
293
|
-
// WORKTREE'S OWN ANCESTRY — which is shared with the runner and says nothing
|
|
294
|
-
// about the argument. Measured on the unfixed shim: a worktree under such a
|
|
295
|
-
// parent refused every directory argument, the bare invocation's implicit `.`
|
|
296
|
-
// included, so the whole suite became unrunnable. No other fixture in this file
|
|
297
|
-
// is built under a `node_modules` parent, so nothing else can see it.
|
|
298
|
-
//
|
|
299
|
-
// The absolute spellings are the half that outlived the first fix (#230). An
|
|
300
|
-
// argument spelled absolutely carries the shared ancestor's `node_modules`
|
|
301
|
-
// inside its own text, so a guard term that reads the caller's spelling
|
|
302
|
-
// unanchored matches on it however the anchored term ruled — and the same
|
|
303
|
-
// directory reached two verdicts depending only on how it was named. Spelled
|
|
304
|
-
// and resolved forms are asserted side by side here because agreement between
|
|
305
|
-
// them, not any single row, is the property.
|
|
306
|
-
test("runner: a node_modules in the worktree's own ancestry refuses nothing", () => {
|
|
307
|
-
const under = join(tempDir("anc-"), "node_modules");
|
|
308
|
-
mkdirSync(under, { recursive: true });
|
|
309
|
-
const a = apply(SUITE, under);
|
|
310
|
-
for (const [args, count] of [
|
|
311
|
-
[[], 6],
|
|
312
|
-
[["."], 6],
|
|
313
|
-
[[a.wt], 6],
|
|
314
|
-
[["t"], 3],
|
|
315
|
-
[[join(a.wt, "t")], 3],
|
|
316
|
-
// File arguments too: the file branch grew its own resolved-path check
|
|
317
|
-
// (#424), so the ancestor that must stay unread is now read by both arms.
|
|
318
|
-
[["t/a.test.mjs"], 1],
|
|
319
|
-
[[join(a.wt, "t", "a.test.mjs")], 1],
|
|
320
|
-
]) {
|
|
321
|
-
const r = a.run(...args);
|
|
322
|
-
assert.equal(r.status, 0, `${JSON.stringify(args)}: ${r.stdout}${r.stderr}`);
|
|
323
|
-
assert.match(r.stdout, new RegExp(`^(?:ℹ|#) pass ${count}$`, "m"));
|
|
324
|
-
}
|
|
325
|
-
// ...and the guard still bites inside such a worktree.
|
|
326
|
-
const vendor = join(a.wt, "node_modules", "pkg");
|
|
327
|
-
mkdirSync(vendor, { recursive: true });
|
|
328
|
-
writeFileSync(join(vendor, "v.test.mjs"), PASSES);
|
|
329
|
-
symlinkSync(join("node_modules", "pkg"), join(a.wt, "vendlink"));
|
|
330
|
-
const r = a.run("vendlink");
|
|
331
|
-
assert.notEqual(r.status, 0, r.stdout + r.stderr);
|
|
332
|
-
assert.match(r.stderr, /is under node_modules — excluded from the run/);
|
|
333
|
-
// A DIRECTORY argument and a FILE argument in one argv, diverging from the
|
|
334
|
-
// runner at different depths. Both arms share one `diverge` walk writing one
|
|
335
|
-
// global `$shared` (POSIX sh has no `local`), so the file arm's verdict must
|
|
336
|
-
// not inherit the directory's: `t` diverges at the worktree, `outlink`
|
|
337
|
-
// resolves two levels above it, and reusing the deeper answer strips nothing
|
|
338
|
-
// — leaving the ANCESTRY's own `node_modules` inside the string the file arm
|
|
339
|
-
// scans, so the worktree refuses a file that is not vendored at all.
|
|
340
|
-
// Every other row here passes one argument, where `$shared` is empty before
|
|
341
|
-
// the call and dropping the call outright still reds. This row is the only
|
|
342
|
-
// one that catches reusing a STALE value: `[ -n "$shared" ] || diverge …`,
|
|
343
|
-
// the plausible optimization, left the whole file green before it existed
|
|
344
|
-
// (measured) and reds here now.
|
|
345
|
-
symlinkSync(join("..", "..", "root.test.mjs"), join(a.wt, "outlink.test.mjs"));
|
|
346
|
-
const mixed = a.run("t", "outlink.test.mjs");
|
|
347
|
-
assert.equal(mixed.status, 0, mixed.stdout + mixed.stderr);
|
|
348
|
-
assert.match(mixed.stdout, /(?:ℹ|#) pass 4(?!\d)/);
|
|
349
|
-
// The MIRROR order: a FILE argument first, then a DIRECTORY argument that
|
|
350
|
-
// diverges ABOVE the worktree, still under this ancestor's own
|
|
351
|
-
// `node_modules` — the shape the "resolution outside the worktree" test
|
|
352
|
-
// below proves correct when the directory arm's own `diverge` call runs.
|
|
353
|
-
// `t/a.test.mjs` diverges no further than the worktree, so the file arm
|
|
354
|
-
// leaves `$shared` sitting at `$root` itself; if the DIRECTORY arm's own
|
|
355
|
-
// `diverge` call were skipped in favour of that stale, narrower value,
|
|
356
|
-
// stripping it from the directory's resolution would strip nothing —
|
|
357
|
-
// leaving the ancestor's own `node_modules` in the string the directory arm
|
|
358
|
-
// scans, refusing an ordinary directory outside the worktree that is not
|
|
359
|
-
// vendored at all. Every row above passes a single argument in this order;
|
|
360
|
-
// this is the only one that catches the DIRECTORY arm reusing a stale
|
|
361
|
-
// value left behind by a FILE argument run first.
|
|
362
|
-
const outside2 = join(mkdtempSync(join(under, "out2-")), "lib");
|
|
363
|
-
mkdirSync(outside2, { recursive: true });
|
|
364
|
-
writeFileSync(join(outside2, "o2.test.mjs"), PASSES);
|
|
365
|
-
symlinkSync(outside2, join(a.wt, "outlink2"));
|
|
366
|
-
const mixed2 = a.run("t/a.test.mjs", "outlink2");
|
|
367
|
-
assert.equal(mixed2.status, 0, mixed2.stdout + mixed2.stderr);
|
|
368
|
-
assert.match(mixed2.stdout, /(?:ℹ|#) pass 2(?!\d)/);
|
|
369
|
-
});
|
|
370
|
-
|
|
371
|
-
// The spelling term's own reason to exist, and the only input in this repo that
|
|
372
|
-
// isolates it: a cwd OUTSIDE the worktree, from which a relative argument
|
|
373
|
-
// descends through the shared ancestor's `node_modules` and so names it in its
|
|
374
|
-
// own text, while resolving to an ordinary directory the divergence walk has
|
|
375
|
-
// already cleared. Measured: delete `${arg##/*}` from the guard and every other
|
|
376
|
-
// test in the repo stays green, so without this row the term reads as dead code
|
|
377
|
-
// to the next simplifier — and it is not, since node excludes an argv entry
|
|
378
|
-
// whose normalized relative form opens with `node_modules/` and says nothing
|
|
379
|
-
// about it (#100). The message is asserted, not just the status: without the
|
|
380
|
-
// term the argument reaches node, which reports its own `Could not find`, and
|
|
381
|
-
// the two exits are indistinguishable by status alone. The absolute leg is the
|
|
382
|
-
// control — the same directory named absolutely is exempt from that term and
|
|
383
|
-
// must still run, which is #230's property and what separates this test from
|
|
384
|
-
// one that merely refuses everything spelled from outside.
|
|
385
|
-
test("runner: a relative argument through the shared ancestor is refused from outside the worktree", () => {
|
|
386
|
-
const under = join(tempDir("anc-"), "node_modules");
|
|
387
|
-
mkdirSync(under, { recursive: true });
|
|
388
|
-
const a = apply(SUITE, under);
|
|
389
|
-
// Four levels up from the worktree: `42-slug` -> `.worktrees` -> `claim-XXXX`
|
|
390
|
-
// -> `node_modules` -> the ancestor holding it, so a path relative to that cwd
|
|
391
|
-
// opens with the `node_modules` segment the guard has to read.
|
|
392
|
-
const up = join("..", "..", "..", "..");
|
|
393
|
-
const outside = a.runFrom(up, relative(join(a.wt, up), join(a.wt, "t")));
|
|
394
|
-
assert.notEqual(outside.status, 0, outside.stdout + outside.stderr);
|
|
395
|
-
assert.match(outside.stderr, /is under node_modules — excluded from the run/);
|
|
396
|
-
const ok = a.runFrom(up, join(a.wt, "t"));
|
|
397
|
-
assert.equal(ok.status, 0, ok.stdout + ok.stderr);
|
|
398
|
-
assert.match(ok.stdout, /^(?:ℹ|#) pass 3$/m);
|
|
399
|
-
});
|
|
400
|
-
|
|
401
|
-
// The divergence WALK itself (#797). Every row above names an argument that
|
|
402
|
-
// resolves under the worktree, where `$shared` and `$root` strip the same text
|
|
403
|
-
// and the walk does no work — measured, substituting `$root` for `$shared` in
|
|
404
|
-
// `${resolved#"$shared"}` is green on all 1873 tests. What separates the two is
|
|
405
|
-
// a resolution landing OUTSIDE the runner's own directory while still under the
|
|
406
|
-
// `node_modules` ancestor they share: `$root` is no prefix of it, so nothing is
|
|
407
|
-
// stripped, the ancestor's own `node_modules` stays in the text being matched,
|
|
408
|
-
// and an ordinary directory out there is refused as vendored. That is the
|
|
409
|
-
// "opposite error" the guard's comment names, reached from its false-refusal
|
|
410
|
-
// side rather than its false-green one.
|
|
411
|
-
// One row per guard arm, no absolute spelling of either, and that is measured
|
|
412
|
-
// rather than an omission. Directory: `$resolved` comes from `pwd -P`, which
|
|
413
|
-
// erases the spelling, so an absolute argument reaches the case with
|
|
414
|
-
// `$root`/`$resolved`/`$shared` byte-identical to the relative row's and can
|
|
415
|
-
// differ only in the spelling term `${arg##/*}` — which the test directly above
|
|
416
|
-
// already pins as its control leg, and which the unreadable-directory test below
|
|
417
|
-
// pins again through a symlinked ancestor. Measured over nine mutations of this
|
|
418
|
-
// guard: none reds an absolute row here while leaving the relative row and those
|
|
419
|
-
// two green. File: an absolute `$arg` carrying a `node_modules` segment is
|
|
420
|
-
// exempted from the file arm's resolved check by design (#401), so that row
|
|
421
|
-
// would pin nothing here either.
|
|
422
|
-
// The file arm runs the same walk via `diverge`, writing the shared `$shared`
|
|
423
|
-
// (#424), so the file row here holds that anchor with the same fixture; the
|
|
424
|
-
// vendored legs it must keep refusing are the two tests above, which this one
|
|
425
|
-
// deliberately does not repeat.
|
|
426
|
-
test("runner: a resolution outside the worktree is judged from the divergence, not the runner's own root", () => {
|
|
427
|
-
const ancestor = join(tempDir("anc-"), "node_modules");
|
|
428
|
-
mkdirSync(ancestor, { recursive: true });
|
|
429
|
-
const a = apply(SUITE, ancestor);
|
|
430
|
-
// A sibling of the repo, so the argument diverges ABOVE the worktree while
|
|
431
|
-
// still sitting under the shared `node_modules` — the one shape that makes
|
|
432
|
-
// `$root` and `$shared` name different directories.
|
|
433
|
-
const outside = join(mkdtempSync(join(ancestor, "outside-")), "lib");
|
|
434
|
-
mkdirSync(outside, { recursive: true });
|
|
435
|
-
writeFileSync(join(outside, "o.test.mjs"), PASSES);
|
|
436
|
-
symlinkSync(outside, join(a.wt, "outlink"));
|
|
437
|
-
symlinkSync(join(outside, "o.test.mjs"), join(a.wt, "outlink.test.mjs"));
|
|
438
|
-
for (const arg of ["outlink", "outlink.test.mjs"]) {
|
|
439
|
-
const r = a.run(arg);
|
|
440
|
-
assert.equal(r.status, 0, `${arg}: ${r.stdout}${r.stderr}`);
|
|
441
|
-
assert.match(r.stdout, /^(?:ℹ|#) pass 1$/m, arg);
|
|
442
|
-
}
|
|
443
|
-
});
|
|
444
|
-
|
|
445
|
-
// The walk's EXACT-MATCH arm, `| "$shared"` (#1327). The test above pins the
|
|
446
|
-
// anchor the walk produces; nothing pinned the arm that ENDS the walk when the
|
|
447
|
-
// argument resolves TO an ancestor rather than under it. Deleting it reads as a
|
|
448
|
-
// no-op — the next iteration's `"$shared"/*` matches the same path — and is not
|
|
449
|
-
// one: it matches against a `$shared` one segment shorter, so
|
|
450
|
-
// `${resolved#"$shared"}` gains a leading `/<basename of $resolved>`, and where
|
|
451
|
-
// that basename is literally `node_modules` the guard refuses the shared
|
|
452
|
-
// ancestor itself. That is the false refusal the walk's own comment already
|
|
453
|
-
// names in prose — "a worktree living under one refused every directory
|
|
454
|
-
// argument, including the bare invocation's implicit `.`" — asserted there and
|
|
455
|
-
// unnoticed here: measured, deleting the arm left the rest of this file green.
|
|
456
|
-
//
|
|
457
|
-
// Two fixtures, because the arm is reached on two different iterations and the
|
|
458
|
-
// mutations that reach them are disjoint. V1 breaks on the FIRST iteration
|
|
459
|
-
// ($resolved IS $root); V2 on a later one ($resolved is a proper ancestor of
|
|
460
|
-
// $root). Measured over five template variants, every cell run against an
|
|
461
|
-
// emitted runner:
|
|
462
|
-
// V1 bare V1 vendored V2 ../../..
|
|
463
|
-
// `| "$shared"` deleted RED pass RED
|
|
464
|
-
// `case "$1"/ in "$shared"/*` pass pass pass
|
|
465
|
-
// `shared=${root%/*}` RED pass pass
|
|
466
|
-
// `shared=${shared%/*/*}` pass pass RED
|
|
467
|
-
// guard skipped when $root is vendored pass RED pass
|
|
468
|
-
// Row two is the behaviour-preserving rewrite of the same `case` — the equality
|
|
469
|
-
// spelled as a slash-bound subject instead of its own alternative — and it has
|
|
470
|
-
// to stay green, or these rows pin the spelling rather than the behaviour.
|
|
471
|
-
// The vendored row is asserted on the MESSAGE, not the status: under the
|
|
472
|
-
// over-exempt variant it still exits 1, with node's own `Could not find`, so
|
|
473
|
-
// status alone cannot tell a guard that refused from one that was skipped and
|
|
474
|
-
// handed node a path it drops (#100's silent shape — the same reason the
|
|
475
|
-
// relative-spelling test above asserts its message too).
|
|
476
|
-
//
|
|
477
|
-
// The file arm needs no row of its own, and that is measured rather than
|
|
478
|
-
// assumed. #1016 left ONE walk holding ONE such arm: it occurs exactly once in
|
|
479
|
-
// this template, and deleting that occurrence changes exactly one line of the
|
|
480
|
-
// emitted runner, so these rows pin it for both callers — and the mixed-argv
|
|
481
|
-
// rows above already pin that the file arm re-runs the walk rather than reading
|
|
482
|
-
// a stale `$shared`. The file caller cannot reach the arm in any case: it runs
|
|
483
|
-
// only from the `else` of `[ -d "$arg" ]`, over `realpath`'s answer for a path
|
|
484
|
-
// that is NOT a directory, while every value `$shared` can hold is `$root` or
|
|
485
|
-
// one of its ancestors — all directories, so the equality can never hold.
|
|
486
|
-
test("runner: the divergence walk ends on an argument that resolves TO the shared ancestor", () => {
|
|
487
|
-
// V1 — the runner's own directory is named `node_modules`, so a bare
|
|
488
|
-
// invocation's implicit `.` resolves to `$root` itself and the walk's first
|
|
489
|
-
// iteration is the equality. No claim can put a runner there: the worktree
|
|
490
|
-
// is always `.worktrees/<issue>-<slug>`, which cannot be that name. So the
|
|
491
|
-
// runner is copied straight into a `node_modules` directory instead — same
|
|
492
|
-
// bytes, and no worktree the assertions below never inspect.
|
|
493
|
-
const home = join(tempDir("nm-"), "node_modules");
|
|
494
|
-
mkdirSync(home, { recursive: true });
|
|
495
|
-
writeExecStub(join(home, "agent-test"), RUNNER_BODY);
|
|
496
|
-
writeFileSync(join(home, "a.test.mjs"), PASSES);
|
|
497
|
-
// Vendored content one level in, where the exemption is at its widest: the
|
|
498
|
-
// runner's own directory name IS the excluded word, and the guard still has
|
|
499
|
-
// to bite on a path that genuinely descends through another.
|
|
500
|
-
const vendor = join(home, "node_modules", "pkg");
|
|
501
|
-
mkdirSync(vendor, { recursive: true });
|
|
502
|
-
writeFileSync(join(vendor, "v.test.mjs"), PASSES);
|
|
503
|
-
const v1 = (...args) =>
|
|
504
|
-
spawnSync(join(home, "agent-test"), args, { cwd: home, encoding: "utf8", env: runnerEnv() });
|
|
505
|
-
// `pass 1`, not merely exit 0: the fixture holds two test files and one of
|
|
506
|
-
// them is vendored, so a count is what says the vendored one stayed out.
|
|
507
|
-
// It does NOT say the argument was honoured rather than dropped — measured,
|
|
508
|
-
// discarding the runner's own file-list handoff (`set -- "$@"` in place of
|
|
509
|
-
// `set -- "$@" $files`) leaves this row byte-identical
|
|
510
|
-
// at `pass 1`, because node's own default discovery from this cwd
|
|
511
|
-
// independently excludes the same vendored file too. V2's `pass 12` below
|
|
512
|
-
// is what pins the argument being honoured; this row does not.
|
|
513
|
-
const bare = v1();
|
|
514
|
-
assert.equal(bare.status, 0, bare.stdout + bare.stderr);
|
|
515
|
-
assert.match(bare.stdout, /^(?:ℹ|#) pass 1$/m);
|
|
516
|
-
const vendored = v1(join("node_modules", "pkg"));
|
|
517
|
-
assert.notEqual(vendored.status, 0, vendored.stdout + vendored.stderr);
|
|
518
|
-
assert.match(vendored.stderr, /is under node_modules — excluded from the run/);
|
|
519
|
-
|
|
520
|
-
// V2 — the runner where the claim actually put it, under a `node_modules`
|
|
521
|
-
// ancestor, with an argument naming that ancestor exactly:
|
|
522
|
-
// `42-slug` -> `.worktrees` -> `claim-XXXX` -> the `node_modules` itself.
|
|
523
|
-
// The walk reaches the equality three iterations down rather than on the
|
|
524
|
-
// first, and the runner is unmoved, so this row cannot be dismissed as an
|
|
525
|
-
// artifact of relocating one.
|
|
526
|
-
const under = join(tempDir("anc-"), "node_modules");
|
|
527
|
-
mkdirSync(under, { recursive: true });
|
|
528
|
-
const a = apply(SUITE, under);
|
|
529
|
-
// 12: the six test files of the committed fixture, once in the repo's own
|
|
530
|
-
// checkout and once in the worktree built from it, both under the named
|
|
531
|
-
// ancestor. Bare discovery from the worktree reports 6, so the count also
|
|
532
|
-
// says the argument reached node instead of being dropped.
|
|
533
|
-
const r = a.run(join("..", "..", ".."));
|
|
534
|
-
assert.equal(r.status, 0, r.stdout + r.stderr);
|
|
535
|
-
assert.match(r.stdout, /^(?:ℹ|#) pass 12$/m);
|
|
536
|
-
});
|
|
537
|
-
|
|
538
|
-
// The guard resolves `$arg` against the process cwd, but `$root` against the
|
|
539
|
-
// runner's own location, so the two are no longer the same anchor and a
|
|
540
|
-
// subdirectory invocation exercises a different path than a root one. Measured:
|
|
541
|
-
// anchoring the argument at `$root` instead (`cd -- "$root/$arg"`, a one-token
|
|
542
|
-
// slip on the argument alone — the runner's `root=` assignment and its
|
|
543
|
-
// `resolved=` one now sit 171 lines apart, not side by side) is green on
|
|
544
|
-
// every OTHER test in this file while reporting
|
|
545
|
-
// the vendored test as a pass from one directory down.
|
|
546
|
-
// Second leg stops the fix degenerating into "refuse everything named from a
|
|
547
|
-
// subdirectory"; the stderr assert is load-bearing, since status alone cannot
|
|
548
|
-
// tell a refusal from a vendored test that threw.
|
|
549
|
-
test("runner: the resolved-path guard resolves against the cwd, from a subdirectory too", () => {
|
|
550
|
-
const a = apply(SUITE);
|
|
551
|
-
const vendor = join(a.wt, "node_modules", "pkg");
|
|
552
|
-
mkdirSync(vendor, { recursive: true });
|
|
553
|
-
writeFileSync(join(vendor, "v.test.mjs"), PASSES);
|
|
554
|
-
symlinkSync(join("..", "node_modules", "pkg"), join(a.wt, "t", "vendlink"));
|
|
555
|
-
const refused = a.runFrom("t", "vendlink");
|
|
556
|
-
assert.notEqual(refused.status, 0, refused.stdout + refused.stderr);
|
|
557
|
-
assert.match(refused.stderr, /is under node_modules — excluded from the run/);
|
|
558
|
-
const ran = a.runFrom("t", "nested");
|
|
559
|
-
assert.equal(ran.status, 0, ran.stdout + ran.stderr);
|
|
560
|
-
assert.match(ran.stdout, /^(?:ℹ|#) pass 1$/m);
|
|
561
|
-
});
|
|
562
|
-
|
|
563
|
-
// The false-positive leg of the resolved-path guard. The nested-node_modules
|
|
564
|
-
// test below pins `-prune`'s immunity to a `node_modules_old` lookalike, not
|
|
565
|
-
// this guard's: its argument is `t`, so neither half of the composed
|
|
566
|
-
// `"/$arg/ /…/"` string ever carries the lookalike and the `case` never sees
|
|
567
|
-
// one. Here only the RESOLUTION does — `vlink` is clean in spelling — which is
|
|
568
|
-
// the leg #186 added. Measured: relaxing the slash-bounding to `*node_modules*`
|
|
569
|
-
// leaves every other test in this file green and reddens only this one.
|
|
570
|
-
test("runner: a symlink resolving into a node_modules lookalike still runs", () => {
|
|
571
|
-
const a = apply(SUITE);
|
|
572
|
-
const lookalike = join(a.wt, "node_modules_old", "pkg");
|
|
573
|
-
mkdirSync(lookalike, { recursive: true });
|
|
574
|
-
writeFileSync(join(lookalike, "k.test.mjs"), PASSES);
|
|
575
|
-
symlinkSync(join("node_modules_old", "pkg"), join(a.wt, "vlink"));
|
|
576
|
-
const r = a.run("vlink");
|
|
577
|
-
assert.equal(r.status, 0, r.stdout + r.stderr);
|
|
578
|
-
assert.match(r.stdout, /^(?:ℹ|#) pass 1$/m);
|
|
579
|
-
});
|
|
580
|
-
|
|
581
|
-
// The sharp edge. `node --test` with zero files exits 0, so an expansion that
|
|
582
|
-
// matched nothing and shrugged would smuggle back the vacuous pass the emit
|
|
583
|
-
// guard refuses — this time past it, at run time.
|
|
584
|
-
test("runner: a directory with no test files refuses instead of exiting 0", () => {
|
|
585
|
-
const r = apply(SUITE).run("empty");
|
|
586
|
-
assert.notEqual(r.status, 0);
|
|
587
|
-
assert.match(r.stderr, /no test files under empty/);
|
|
588
|
-
});
|
|
589
|
-
|
|
590
|
-
// #1628: grep's and sed's own exit codes used to go unread in the
|
|
591
|
-
// directory-scan pipe — only whether `$files` ended up non-empty was
|
|
592
|
-
// checked — so a scan failure inside either tool (rc 2+, distinct from
|
|
593
|
-
// grep's normal rc-1 "no match") read through the emptiness test above as
|
|
594
|
-
// an indistinguishable "no test files", even though real test files sit
|
|
595
|
-
// right there. Stubbing `grep` itself to die outright (rc 2) is the
|
|
596
|
-
// cleanest reproduction of a scan tool breaking mid-run, and must be
|
|
597
|
-
// reported as ITS failure, not folded into the empty-directory message.
|
|
598
|
-
test("runner: a grep failure mid-scan is reported distinctly from an empty result", () => {
|
|
599
|
-
const a = apply(SUITE);
|
|
600
|
-
const bin = tempDir("claim-grepfail-");
|
|
601
|
-
writeExecStub(join(bin, "grep"), "#!/bin/sh\nexit 2\n");
|
|
602
|
-
const r = spawnSync(join(a.wt, "agent-test"), ["t"], {
|
|
603
|
-
cwd: a.wt,
|
|
604
|
-
encoding: "utf8",
|
|
605
|
-
env: { ...a.env, PATH: `${bin}:${a.env.PATH}` },
|
|
606
|
-
});
|
|
607
|
-
assert.notEqual(r.status, 0, r.stdout + r.stderr);
|
|
608
|
-
assert.match(r.stderr, /could not scan for test files under t \(grep exited 2\)/);
|
|
609
|
-
assert.doesNotMatch(r.stderr, /no test files under/);
|
|
610
|
-
});
|
|
611
|
-
|
|
612
|
-
// The other half: sed sits downstream of grep in the same pipe, and its own
|
|
613
|
-
// rc was just as unread. Stubbing `sed` alone (grep runs for real, matches
|
|
614
|
-
// `t`'s two files, then hands them to the dying stub) isolates sed's status
|
|
615
|
-
// from grep's — the failure must still name sed, not grep or "no test files".
|
|
616
|
-
test("runner: a sed failure mid-scan is reported distinctly from an empty result", () => {
|
|
617
|
-
const a = apply(SUITE);
|
|
618
|
-
const bin = tempDir("claim-sedfail-");
|
|
619
|
-
writeExecStub(join(bin, "sed"), "#!/bin/sh\nexit 2\n");
|
|
620
|
-
const r = spawnSync(join(a.wt, "agent-test"), ["t"], {
|
|
621
|
-
cwd: a.wt,
|
|
622
|
-
encoding: "utf8",
|
|
623
|
-
env: { ...a.env, PATH: `${bin}:${a.env.PATH}` },
|
|
624
|
-
});
|
|
625
|
-
assert.notEqual(r.status, 0, r.stdout + r.stderr);
|
|
626
|
-
assert.match(r.stderr, /could not scan for test files under t \(sed exited 2\)/);
|
|
627
|
-
assert.doesNotMatch(r.stderr, /no test files under/);
|
|
628
|
-
});
|
|
629
|
-
|
|
630
|
-
// BSD sed (this machine's actual /usr/bin/sed) exits rc 1 for EVERY error it
|
|
631
|
-
// reports — illegal byte sequence, malformed regex, missing file — there is
|
|
632
|
-
// no BSD sed error path that ever reaches rc 2+. A guard that tolerated
|
|
633
|
-
// `sed_rc -le 1` (mirroring grep's real "no match is rc 1" case) could NEVER
|
|
634
|
-
// catch a genuine BSD sed failure: the stub below reproduces that exact
|
|
635
|
-
// shape — always exit 1, the way real BSD sed does on a bad invocation —
|
|
636
|
-
// and must still be reported as a sed failure, not silently folded into "no
|
|
637
|
-
// test files" the way an unread rc would. (Reverting the guard to
|
|
638
|
-
// `-le 1` reproduces the pre-fix bug: this test goes green on silence,
|
|
639
|
-
// asserting `no test files under t` instead of a reported sed failure.)
|
|
640
|
-
test("runner: a BSD-style sed rc-1 failure is reported, not tolerated as a no-match analog", () => {
|
|
641
|
-
const a = apply(SUITE);
|
|
642
|
-
const bin = tempDir("claim-sedrc1-");
|
|
643
|
-
writeExecStub(join(bin, "sed"), "#!/bin/sh\nexit 1\n");
|
|
644
|
-
const r = spawnSync(join(a.wt, "agent-test"), ["t"], {
|
|
645
|
-
cwd: a.wt,
|
|
646
|
-
encoding: "utf8",
|
|
647
|
-
env: { ...a.env, PATH: `${bin}:${a.env.PATH}` },
|
|
648
|
-
});
|
|
649
|
-
assert.notEqual(r.status, 0, r.stdout + r.stderr);
|
|
650
|
-
assert.match(r.stderr, /could not scan for test files under t \(sed exited 1\)/);
|
|
651
|
-
assert.doesNotMatch(r.stderr, /no test files under/);
|
|
652
|
-
});
|
|
653
|
-
|
|
654
|
-
// grep's rc 1 ("no match") must NOT be swept into the same failure this pins
|
|
655
|
-
// above — that is the genuinely-empty case the pre-existing "no test files"
|
|
656
|
-
// test (above) already covers end to end. This is the narrower unit-level
|
|
657
|
-
// half: a stub that always exits 1, never touching `find` or the real test
|
|
658
|
-
// files, pins that a bare "no match" alone still reaches the ORIGINAL
|
|
659
|
-
// "no test files" message, not the new "grep exited" one.
|
|
660
|
-
test("runner: grep's plain no-match rc still reads as no test files, not a grep failure", () => {
|
|
661
|
-
const a = apply(SUITE);
|
|
662
|
-
const bin = tempDir("claim-grepnomatch-");
|
|
663
|
-
writeExecStub(join(bin, "grep"), "#!/bin/sh\nexit 1\n");
|
|
664
|
-
const r = spawnSync(join(a.wt, "agent-test"), ["t"], {
|
|
665
|
-
cwd: a.wt,
|
|
666
|
-
encoding: "utf8",
|
|
667
|
-
env: { ...a.env, PATH: `${bin}:${a.env.PATH}` },
|
|
668
|
-
});
|
|
669
|
-
assert.notEqual(r.status, 0, r.stdout + r.stderr);
|
|
670
|
-
assert.match(r.stderr, /no test files under t/);
|
|
671
|
-
assert.doesNotMatch(r.stderr, /grep exited/);
|
|
672
|
-
});
|
|
673
|
-
|
|
674
|
-
test("runner: a file argument still works", () => {
|
|
675
|
-
const r = apply(SUITE).run("t/a.test.mjs");
|
|
676
|
-
assert.equal(r.status, 0, r.stdout + r.stderr);
|
|
677
|
-
// Bounded, same reason as the other bare `pass 1` cases above.
|
|
678
|
-
assert.match(r.stdout, /(?:ℹ|#) pass 1(?!\d)/);
|
|
679
|
-
});
|
|
680
|
-
|
|
681
|
-
// The shell expands a glob before the runner is entered, so the glob form
|
|
682
|
-
// reaches it as the plain multi-file argv this asserts on. Only the *matching*
|
|
683
|
-
// glob, though: one that matches nothing is handed over unexpanded, is not a
|
|
684
|
-
// directory, and so misses the shim entirely — node globs it, matches nothing
|
|
685
|
-
// and exits 0. That path is #100, not this test.
|
|
686
|
-
test("runner: the expanded glob form still works", () => {
|
|
687
|
-
const r = apply(SUITE).run("t/a.test.mjs", "t/b.test.mjs");
|
|
688
|
-
assert.equal(r.status, 0, r.stdout + r.stderr);
|
|
689
|
-
// Bounded, same reason as above: a bare `pass 2` is a substring of
|
|
690
|
-
// `pass 2<n>` and stops discriminating once a fixture reaches 20.
|
|
691
|
-
assert.match(r.stdout, /(?:ℹ|#) pass 2(?!\d)/);
|
|
692
|
-
});
|
|
693
|
-
|
|
694
|
-
// A subtree find cannot descend is the quiet version of the same hazard: find
|
|
695
|
-
// still prints what it reached, grep still matches it, and the count guard
|
|
696
|
-
// still passes — so the suite goes green having silently skipped whatever the
|
|
697
|
-
// unreadable directory held. Root can read anything, so it cannot see this.
|
|
698
|
-
test("runner: a directory it cannot fully read refuses instead of running a partial suite", (t) => {
|
|
699
|
-
if (process.getuid?.() === 0) return t.skip("root reads every directory");
|
|
700
|
-
const a = apply({ ...SUITE, "t/locked/z.test.mjs": PASSES });
|
|
701
|
-
chmodSync(join(a.wt, "t", "locked"), 0o000);
|
|
702
|
-
try {
|
|
703
|
-
const r = a.run("t");
|
|
704
|
-
assert.notEqual(r.status, 0, r.stdout + r.stderr);
|
|
705
|
-
assert.match(r.stderr, /cannot read every path under t/);
|
|
706
|
-
} finally {
|
|
707
|
-
chmodSync(join(a.wt, "t", "locked"), 0o755);
|
|
708
|
-
}
|
|
709
|
-
});
|
|
710
|
-
|
|
711
|
-
// #960 case 1: `find "-dir/" ...` — the old spelling — is read by both BSD
|
|
712
|
-
// find (macOS) and GNU find (Linux CI) as the start of an option cluster,
|
|
713
|
-
// trailing slash and all, and dies before reading a single path: measured
|
|
714
|
-
// directly, "illegal option -- i" (BSD) / "unknown predicate `-dir/'"
|
|
715
|
-
// (GNU), neither rescued by a POSIX `--`. The runner used to report that as
|
|
716
|
-
// `cannot read every path under -dir`, blaming the subtree's readability
|
|
717
|
-
// for what was find's own argument parser losing to the caller's spelling.
|
|
718
|
-
// `-dir` is written into the worktree directly rather than through
|
|
719
|
-
// `apply()`: a leading-dash directory NAME is a shell/CLI-argument concern,
|
|
720
|
-
// not something a git commit needs to reproduce.
|
|
721
|
-
// Node's own `--test` CLI turns out to share the same parser confusion one
|
|
722
|
-
// layer down — measured, a relative file spec that starts with `-` after
|
|
723
|
-
// node's own normalisation is read as a bad option too, `./`-prefixed or
|
|
724
|
-
// not — so this fixture cannot be made to actually run without rewriting
|
|
725
|
-
// every file this arm hands to node into an absolute path, a much larger
|
|
726
|
-
// change than this bug. The runner refuses instead, naming ITS cause
|
|
727
|
-
// rather than reporting a suite that never got to node as unreadable.
|
|
728
|
-
test("runner: a dash-named directory refuses naming the parsing hazard, not unreadability", () => {
|
|
729
|
-
const a = apply(SUITE);
|
|
730
|
-
mkdirSync(join(a.wt, "-dir"), { recursive: true });
|
|
731
|
-
writeFileSync(join(a.wt, "-dir", "z.test.mjs"), PASSES);
|
|
732
|
-
const r = a.run("-dir");
|
|
733
|
-
assert.notEqual(r.status, 0, r.stdout + r.stderr);
|
|
734
|
-
assert.match(r.stderr, /holds tests, but node reads a relative dash-led path as an option/);
|
|
735
|
-
assert.doesNotMatch(r.stderr, /cannot read every path under/);
|
|
736
|
-
});
|
|
737
|
-
|
|
738
|
-
// The other half of the same fixture: a dash-named directory that is
|
|
739
|
-
// GENUINELY unreadable must still report that real fault, not the parsing
|
|
740
|
-
// refusal's message. `./` only routes the argument around find's OWN
|
|
741
|
-
// parser (pinned above); once find actually descends, a permission denied
|
|
742
|
-
// down there is what `cannot read every path under` is for, and this pins
|
|
743
|
-
// that the parsing fix did not also swallow real unreadability.
|
|
744
|
-
// The wrapper text alone (`cannot read every path under -locked`) does not
|
|
745
|
-
// discriminate: it is byte-identical whether find died on the dash before
|
|
746
|
-
// reading anything, or genuinely hit this fixture's chmod 0 `sub`. find's
|
|
747
|
-
// OWN stderr is never redirected by the runner, so it reaches this test
|
|
748
|
-
// alongside the wrapper — measured, the two causes leave distinct text
|
|
749
|
-
// there: `find: .../sub: Permission denied` for the real fault this test
|
|
750
|
-
// means to pin, versus `find: illegal option -- i` (BSD) / `find: unknown
|
|
751
|
-
// predicate '...'` (GNU) for the argument-parsing failure this PR's `./`
|
|
752
|
-
// routing prevents. Asserting on find's message too, and ruling out the
|
|
753
|
-
// parsing signature, is what makes this test fail if the `./` routing
|
|
754
|
-
// this PR adds is reverted — checked directly: reverting it leaves this
|
|
755
|
-
// test green under the wrapper-only assertion alone.
|
|
756
|
-
test("runner: an unreadable dash-named directory still reports the real read fault", (t) => {
|
|
757
|
-
if (process.getuid?.() === 0) return t.skip("root reads every directory");
|
|
758
|
-
const a = apply(SUITE);
|
|
759
|
-
const locked = join(a.wt, "-locked");
|
|
760
|
-
mkdirSync(join(locked, "sub"), { recursive: true });
|
|
761
|
-
writeFileSync(join(locked, "sub", "z.test.mjs"), PASSES);
|
|
762
|
-
chmodSync(join(locked, "sub"), 0o000);
|
|
763
|
-
try {
|
|
764
|
-
const r = a.run("-locked");
|
|
765
|
-
assert.notEqual(r.status, 0, r.stdout + r.stderr);
|
|
766
|
-
assert.match(r.stderr, /cannot read every path under -locked/);
|
|
767
|
-
assert.doesNotMatch(r.stderr, /holds tests, but node reads/);
|
|
768
|
-
assert.match(r.stderr, /Permission denied/, `find must have actually descended into -locked rather than dying on its dash: ${r.stderr}`);
|
|
769
|
-
assert.doesNotMatch(r.stderr, /illegal option|unknown predicate/i,
|
|
770
|
-
`find's own argument-parsing failure text must not be present, or this is the parsing hazard, not the read fault: ${r.stderr}`);
|
|
771
|
-
} finally {
|
|
772
|
-
chmodSync(join(locked, "sub"), 0o755);
|
|
773
|
-
}
|
|
774
|
-
});
|
|
775
|
-
|
|
776
|
-
// Node's own discovery excludes `node_modules`; `find` does not, so a vendored
|
|
777
|
-
// test ran and the suite's result hung on third-party code passing. The live
|
|
778
|
-
// shape is a *real* nested `node_modules` — an install that did not hoist, or
|
|
779
|
-
// a bundled dependency. Not pnpm's: its per-package `node_modules` is a
|
|
780
|
-
// symlink farm, and `find` without `-L` never descends it.
|
|
781
|
-
// The vendor test fails on purpose: the count alone cannot tell "vendor was
|
|
782
|
-
// pruned" from "vendor ran and failed", and the exit status alone cannot tell
|
|
783
|
-
// "pruned" from "the expansion dropped some of ours" — losing all of them
|
|
784
|
-
// refuses with `no test files`, losing a few still exits 0. Both, or neither.
|
|
785
|
-
// `node_modules_old/` pins the other direction. Over-pruning is the worse
|
|
786
|
-
// bug — it deletes real tests and still exits 0 — and this is its only
|
|
787
|
-
// coverage in the fleet suite: an over-broad `*node_modules*` passes every
|
|
788
|
-
// other test in this file.
|
|
789
|
-
// It is written into the worktree rather than through `apply()` because that is
|
|
790
|
-
// where `node_modules` actually comes from — the install step, not a commit —
|
|
791
|
-
// and committing it would rest this test on whatever `core.excludesFile` the
|
|
792
|
-
// machine happens to have.
|
|
793
|
-
test("runner: a vendored test under a nested node_modules does not run", () => {
|
|
794
|
-
const a = apply(SUITE);
|
|
795
|
-
const vendor = join(a.wt, "t", "node_modules", "vendor");
|
|
796
|
-
mkdirSync(vendor, { recursive: true });
|
|
797
|
-
writeFileSync(
|
|
798
|
-
join(vendor, "v.test.mjs"),
|
|
799
|
-
'import { test } from "node:test";\ntest("VENDOR", () => { throw new Error("not ours"); });\n',
|
|
800
|
-
);
|
|
801
|
-
const lookalike = join(a.wt, "t", "node_modules_old");
|
|
802
|
-
mkdirSync(lookalike, { recursive: true });
|
|
803
|
-
writeFileSync(join(lookalike, "k.test.mjs"), PASSES);
|
|
804
|
-
const r = a.run("t");
|
|
805
|
-
assert.equal(r.status, 0, r.stdout + r.stderr);
|
|
806
|
-
// Anchored: a bare `pass 4` is a substring and matches `pass 41`, so the pin
|
|
807
|
-
// would dissolve the moment the fixture grows past 40. Both prefixes because
|
|
808
|
-
// `node --test`'s default reporter is version- and TTY-dependent — spec
|
|
809
|
-
// (`ℹ pass 4`) on a terminal and on newer node, tap (`# pass 4`) when older
|
|
810
|
-
// node writes to a pipe, which is every CI run.
|
|
811
|
-
assert.match(r.stdout, /^(?:ℹ|#) pass 4$/m);
|
|
812
|
-
});
|
|
813
|
-
|
|
814
|
-
// The point of `-prune` over a path filter: content under `node_modules` is
|
|
815
|
-
// excluded from the run either way, so its readability cannot change the
|
|
816
|
-
// verdict. An unreadable directory *in* it used to still fail `find` and trip
|
|
817
|
-
// the guard above — a loud but pointless stall. Pruning skips descending
|
|
818
|
-
// `node_modules` entirely, so this directory's permissions are never even
|
|
819
|
-
// read. `pass 3` — the same count as the bare "t" case — pins that: the
|
|
820
|
-
// locked directory is empty and is never descended, so nothing about it can
|
|
821
|
-
// move the count or the status. Mutation-checked: reverting the walk to the
|
|
822
|
-
// `-not -path` filter, or typoing the prune's name, fails this test.
|
|
823
|
-
test("runner: an unreadable directory under node_modules no longer refuses the suite", (t) => {
|
|
824
|
-
if (process.getuid?.() === 0) return t.skip("root reads every directory");
|
|
825
|
-
const a = apply(SUITE);
|
|
826
|
-
const locked = join(a.wt, "t", "node_modules", "locked");
|
|
827
|
-
mkdirSync(locked, { recursive: true });
|
|
828
|
-
chmodSync(locked, 0o000);
|
|
829
|
-
try {
|
|
830
|
-
const r = a.run("t");
|
|
831
|
-
assert.equal(r.status, 0, r.stdout + r.stderr);
|
|
832
|
-
assert.match(r.stdout, /^(?:ℹ|#) pass 3$/m);
|
|
833
|
-
} finally {
|
|
834
|
-
chmodSync(locked, 0o755);
|
|
835
|
-
}
|
|
836
|
-
});
|
|
837
|
-
|
|
838
|
-
// Same directories, six spellings of the argument. The top-level pair alone
|
|
839
|
-
// is not coverage of "a vendored argument": `-prune` fires only where the
|
|
840
|
-
// walk DESCENDS through a `node_modules` dirent, so an argument at or under
|
|
841
|
-
// one prunes nothing and prints every file beneath it. Measured against the
|
|
842
|
-
// prune alone, the four spellings below the top level all ran their vendored
|
|
843
|
-
// test and exited 0 — the vacuous vendored green this shim exists to refuse.
|
|
844
|
-
// Only the `case` guard covers them, which is why every spelling is here.
|
|
845
|
-
// The message is asserted too, not just the status: falling through to the
|
|
846
|
-
// emptiness guard would report a deliberate exclusion as an absence and send
|
|
847
|
-
// a reader after a discovery bug that does not exist.
|
|
848
|
-
test("runner: a vendored directory argument refuses however it is spelled", () => {
|
|
849
|
-
const a = apply(SUITE);
|
|
850
|
-
mkdirSync(join(a.wt, "node_modules", "pkg"), { recursive: true });
|
|
851
|
-
mkdirSync(join(a.wt, "t", "node_modules", "pkg"), { recursive: true });
|
|
852
|
-
writeFileSync(join(a.wt, "node_modules", "v.test.mjs"), PASSES);
|
|
853
|
-
writeFileSync(join(a.wt, "node_modules", "pkg", "v.test.mjs"), PASSES);
|
|
854
|
-
writeFileSync(join(a.wt, "t", "node_modules", "v.test.mjs"), PASSES);
|
|
855
|
-
writeFileSync(join(a.wt, "t", "node_modules", "pkg", "v.test.mjs"), PASSES);
|
|
856
|
-
for (const spelling of [
|
|
857
|
-
"node_modules",
|
|
858
|
-
"./node_modules",
|
|
859
|
-
"node_modules/pkg",
|
|
860
|
-
"t/node_modules",
|
|
861
|
-
"t/node_modules/pkg",
|
|
862
|
-
join(a.wt, "node_modules", "pkg"),
|
|
863
|
-
]) {
|
|
864
|
-
const r = a.run(spelling);
|
|
865
|
-
assert.notEqual(r.status, 0, `${spelling}: ${r.stdout}${r.stderr}`);
|
|
866
|
-
assert.match(r.stderr, /is under node_modules — excluded from the run/, spelling);
|
|
867
|
-
assert.doesNotMatch(r.stderr, /no test files under/, spelling);
|
|
868
|
-
}
|
|
869
|
-
});
|
|
870
|
-
|
|
871
|
-
// The vendored half of the no-search-bit case: `cd` fails on a directory
|
|
872
|
-
// `[ -d ]` admits but that carries no search bit, so unless the resolution is
|
|
873
|
-
// recovered from somewhere the divergence walk has nothing to measure and this
|
|
874
|
-
// argument stops being refused as vendored at all. Measured against this file:
|
|
875
|
-
// remove the recovery entirely and this is the one test that reds. What the
|
|
876
|
-
// recovery is ANCHORED on is a separate property and this test is blind to it —
|
|
877
|
-
// give it back the argument's raw text and this row stays green — which is why
|
|
878
|
-
// the ancestor-spelling test below exists as well as this one.
|
|
879
|
-
// One spelling, not two. The relative one was measured redundant across every
|
|
880
|
-
// mutation of both halves of the guard: with a recovery in place the resolved
|
|
881
|
-
// term reaches it unaided, and with none the spelling term does, so no mutation
|
|
882
|
-
// moves it. The absolute spelling is the row that carries this test.
|
|
883
|
-
// The readability message is asserted absent — `find` refuses a starting point
|
|
884
|
-
// it cannot open as well, so a bare non-zero cannot tell the guard's refusal
|
|
885
|
-
// from find's, and which cause the reader is sent after is the point.
|
|
886
|
-
// Root can read anything, so it cannot see this.
|
|
887
|
-
test("runner: a vendored directory with no search bit is refused as vendored, not as unreadable", (t) => {
|
|
888
|
-
if (process.getuid?.() === 0) return t.skip("root searches every directory");
|
|
889
|
-
const a = apply(SUITE);
|
|
890
|
-
const vendor = join(a.wt, "node_modules", "pkg");
|
|
891
|
-
mkdirSync(vendor, { recursive: true });
|
|
892
|
-
writeFileSync(join(vendor, "v.test.mjs"), PASSES);
|
|
893
|
-
chmodSync(vendor, 0o000);
|
|
894
|
-
try {
|
|
895
|
-
const r = a.run(vendor);
|
|
896
|
-
assert.notEqual(r.status, 0, r.stdout + r.stderr);
|
|
897
|
-
assert.match(r.stderr, /is under node_modules — excluded from the run/);
|
|
898
|
-
assert.doesNotMatch(r.stderr, /cannot read every path under/);
|
|
899
|
-
} finally {
|
|
900
|
-
chmodSync(vendor, 0o755);
|
|
901
|
-
}
|
|
902
|
-
});
|
|
903
|
-
|
|
904
|
-
// #230's own criterion in the one case the spelling exemption does not reach: a
|
|
905
|
-
// directory `[ -d ]` admits but that carries no search bit resolves to nothing,
|
|
906
|
-
// so what the guard falls back to is what decides the verdict. Anchored on the
|
|
907
|
-
// parent, every spelling of the directory agrees; anchored on the argument's raw
|
|
908
|
-
// text it did not — `$root` comes from `pwd -P`, so an absolute spelling routed
|
|
909
|
-
// through a symlinked ancestor shares no literal prefix with it, `$shared` walks
|
|
910
|
-
// down to empty, and the ancestor's own `node_modules` is left sitting in the
|
|
911
|
-
// text being matched. One directory, two absolute names, opposite verdicts.
|
|
912
|
-
// The symlinked ancestor is built here rather than borrowed from `$TMPDIR`:
|
|
913
|
-
// macOS resolves `/var/folders/...` to `/private/var/...` and would supply one
|
|
914
|
-
// for free, Linux would not, and a fixture that reproduces on one platform only
|
|
915
|
-
// stops discriminating on the other without saying so.
|
|
916
|
-
// NON-vendored on purpose. A vendored directory has to keep being refused (the
|
|
917
|
-
// test above pins that), so only a directory the guard has no business refusing
|
|
918
|
-
// can tell an anchored fallback from an unanchored one.
|
|
919
|
-
// Root can read anything, so it cannot see this.
|
|
920
|
-
test("runner: an unreadable directory under a node_modules ancestor names the read fault in every spelling", (t) => {
|
|
921
|
-
if (process.getuid?.() === 0) return t.skip("root searches every directory");
|
|
922
|
-
const base = tempDir("anc-");
|
|
923
|
-
const real = join(base, "real");
|
|
924
|
-
const spelled = join(base, "link");
|
|
925
|
-
mkdirSync(real);
|
|
926
|
-
symlinkSync(real, spelled);
|
|
927
|
-
mkdirSync(join(real, "node_modules"), { recursive: true });
|
|
928
|
-
const a = apply(SUITE, join(spelled, "node_modules"));
|
|
929
|
-
const locked = join(a.wt, "t");
|
|
930
|
-
chmodSync(locked, 0o000);
|
|
931
|
-
try {
|
|
932
|
-
for (const spelling of ["t", locked, join(realpathSync(a.wt), "t")]) {
|
|
933
|
-
const r = a.run(spelling);
|
|
934
|
-
assert.notEqual(r.status, 0, `${spelling}: ${r.stdout}${r.stderr}`);
|
|
935
|
-
assert.match(r.stderr, /cannot read every path under/, spelling);
|
|
936
|
-
assert.doesNotMatch(r.stderr, /is under node_modules/, spelling);
|
|
937
|
-
}
|
|
938
|
-
} finally {
|
|
939
|
-
chmodSync(locked, 0o755);
|
|
940
|
-
}
|
|
941
|
-
});
|
|
942
|
-
|
|
943
|
-
// #100: node counts argv separately from the runner's own `find`, and a file
|
|
944
|
-
// or glob argument reaches node with no check of its own. Node drops an
|
|
945
|
-
// argument it cannot resolve and exits non-zero only when it refuses every
|
|
946
|
-
// argument in argv — mixed with anything valid, the discard is silent and
|
|
947
|
-
// the runner used to exit 0 having run less than it was asked. These pin the
|
|
948
|
-
// shapes node discards: a typo, a file under `node_modules` however it is
|
|
949
|
-
// spelled, a path holding a `[`, and (the one deliberately left alone) an
|
|
950
|
-
// unmatched glob — plus the two it does NOT discard, a flag and a vendored
|
|
951
|
-
// spelling node runs anyway, which the guard must not refuse in their place.
|
|
952
|
-
|
|
953
|
-
// The repro from the issue itself: alone a typo is loud (node's own
|
|
954
|
-
// `Could not find`, exit 1) — mixed with a real file, node ran the one file
|
|
955
|
-
// and exited 0, and the runner reported a pass for a suite that only half
|
|
956
|
-
// ran. Named, not just refused: `no test files under` or a bare non-zero
|
|
957
|
-
// would both send a reader after the wrong bug.
|
|
958
|
-
test("runner: a typo'd path mixed with a valid one refuses and names the typo", () => {
|
|
959
|
-
const r = apply(SUITE).run("t/a.test.mjs", "t/typo.test.mjs");
|
|
960
|
-
assert.notEqual(r.status, 0, r.stdout + r.stderr);
|
|
961
|
-
assert.match(r.stderr, /t\/typo\.test\.mjs does not exist/);
|
|
962
|
-
});
|
|
963
|
-
|
|
964
|
-
test("runner: a typo'd path alone still refuses", () => {
|
|
965
|
-
const r = apply(SUITE).run("t/typo.test.mjs");
|
|
966
|
-
assert.notEqual(r.status, 0, r.stdout + r.stderr);
|
|
967
|
-
assert.match(r.stderr, /t\/typo\.test\.mjs does not exist/);
|
|
968
|
-
});
|
|
969
|
-
|
|
970
|
-
// #960 case 2: `[ -e "$arg" ]` cannot tell "not there" from "could not
|
|
971
|
-
// look" — stat() answers the same false whether $arg is genuinely absent
|
|
972
|
-
// or a directory in its path lacks the search bit needed to resolve the
|
|
973
|
-
// rest. A file behind an unsearchable parent used to fall straight through
|
|
974
|
-
// to the typo arm above and get called missing, though it is right there.
|
|
975
|
-
// The directory arm already gets the IDENTICAL fixture right (see "a
|
|
976
|
-
// directory it cannot fully read refuses instead of running a partial
|
|
977
|
-
// suite" above): both arms are run here on one `locked` directory to pin
|
|
978
|
-
// the asymmetry the ticket names directly — same cause, and now the same
|
|
979
|
-
// kind of answer from both, not just the directory arm's.
|
|
980
|
-
// Root can search anything, so it cannot see this.
|
|
981
|
-
test("runner: a file behind an unsearchable parent refuses naming the permission fault, not a typo", (t) => {
|
|
982
|
-
if (process.getuid?.() === 0) return t.skip("root searches every directory");
|
|
983
|
-
const a = apply({ ...SUITE, "locked/a.test.mjs": PASSES });
|
|
984
|
-
const locked = join(a.wt, "locked");
|
|
985
|
-
chmodSync(locked, 0o600);
|
|
986
|
-
try {
|
|
987
|
-
const asFile = a.run("locked/a.test.mjs");
|
|
988
|
-
assert.notEqual(asFile.status, 0, asFile.stdout + asFile.stderr);
|
|
989
|
-
assert.match(asFile.stderr, /cannot read locked\/a\.test\.mjs — locked is not searchable/);
|
|
990
|
-
assert.doesNotMatch(asFile.stderr, /does not exist/);
|
|
991
|
-
|
|
992
|
-
const asDir = a.run("locked");
|
|
993
|
-
assert.notEqual(asDir.status, 0, asDir.stdout + asDir.stderr);
|
|
994
|
-
assert.match(asDir.stderr, /cannot read every path under locked/);
|
|
995
|
-
} finally {
|
|
996
|
-
chmodSync(locked, 0o755);
|
|
997
|
-
}
|
|
998
|
-
});
|
|
999
|
-
|
|
1000
|
-
// The fix above checks $fparent alone, which is the immediate parent —
|
|
1001
|
-
// an unsearchable GRANDparent leaves `[ -d $fparent ]` itself false
|
|
1002
|
-
// (resolving `t/u` needs search on `t`, the bit actually missing), so a
|
|
1003
|
-
// single-level check falls through to "does not exist" one level further
|
|
1004
|
-
// up than the fixture above pins. This walks the fixture one directory
|
|
1005
|
-
// deeper: `t` (not `u`) is chmod'd 0600, so `t/u` can never be
|
|
1006
|
-
// resolved at all, and the ancestor actually blocking it — `t`, not
|
|
1007
|
-
// `t/u` — is what the message must name.
|
|
1008
|
-
test("runner: a file behind an unsearchable grandparent refuses naming that ancestor, not a typo", (t) => {
|
|
1009
|
-
if (process.getuid?.() === 0) return t.skip("root searches every directory");
|
|
1010
|
-
const a = apply({ ...SUITE, "t/u/a.test.mjs": PASSES });
|
|
1011
|
-
const tdir = join(a.wt, "t");
|
|
1012
|
-
chmodSync(tdir, 0o600);
|
|
1013
|
-
try {
|
|
1014
|
-
const r = a.run("t/u/a.test.mjs");
|
|
1015
|
-
assert.notEqual(r.status, 0, r.stdout + r.stderr);
|
|
1016
|
-
assert.match(r.stderr, /cannot read t\/u\/a\.test\.mjs — t is not searchable/);
|
|
1017
|
-
assert.doesNotMatch(r.stderr, /does not exist/);
|
|
1018
|
-
} finally {
|
|
1019
|
-
chmodSync(tdir, 0o755);
|
|
1020
|
-
}
|
|
1021
|
-
});
|
|
1022
|
-
|
|
1023
|
-
// The bound on the fix above: a PARENT that is simply missing
|
|
1024
|
-
// (`nosuchdir/x.test.mjs`) is the ordinary typo this arm already reported
|
|
1025
|
-
// correctly, and the permission-fault check must not swallow it — `-x` on
|
|
1026
|
-
// a nonexistent parent is false too, so without the `-d` term this input
|
|
1027
|
-
// would misreport as a permission fault it does not have.
|
|
1028
|
-
test("runner: a typo'd path with a missing parent still says it does not exist", () => {
|
|
1029
|
-
const r = apply(SUITE).run("nosuchdir/x.test.mjs");
|
|
1030
|
-
assert.notEqual(r.status, 0, r.stdout + r.stderr);
|
|
1031
|
-
assert.match(r.stderr, /nosuchdir\/x\.test\.mjs does not exist/);
|
|
1032
|
-
assert.doesNotMatch(r.stderr, /cannot read/);
|
|
1033
|
-
});
|
|
1034
|
-
|
|
1035
|
-
// #125's surviving case, per the issue's "Agent Brief": a vendored *file*
|
|
1036
|
-
// argument bypasses the directory branch entirely (that guard only ever sees
|
|
1037
|
-
// what `[ -d ]` is true for), so node — not this shim — is what would drop
|
|
1038
|
-
// it, and only when something else in argv resolves. Written into the
|
|
1039
|
-
// worktree rather than through `apply()` for the same reason as the nested
|
|
1040
|
-
// node_modules test above: this is what an unhoisted install produces, not
|
|
1041
|
-
// something anyone commits.
|
|
1042
|
-
// Four spellings, because one is not the class. `./` is the second literal
|
|
1043
|
-
// form, and dropping either alternative from a prefix match would go
|
|
1044
|
-
// uncaught with only the first pinned. `t/../node_modules/…` is why the
|
|
1045
|
-
// guard resolves the argument's own directory rather than matching a prefix
|
|
1046
|
-
// at all: node normalizes before applying its rule, so that spelling is
|
|
1047
|
-
// excluded too (measured directly against node v26.5.0 — `tests 1` for a
|
|
1048
|
-
// two-file argv) and a literal prefix misses it. And the `*` spelling is why
|
|
1049
|
-
// the vendored check runs BEFORE the glob classification: a metacharacter
|
|
1050
|
-
// anywhere in a vendored path used to route it into the passthrough arm and
|
|
1051
|
-
// out of this refusal entirely.
|
|
1052
|
-
test("runner: a vendored file argument refuses however it is spelled", () => {
|
|
1053
|
-
const a = apply(SUITE);
|
|
1054
|
-
const vendor = join(a.wt, "node_modules", "pkg");
|
|
1055
|
-
mkdirSync(vendor, { recursive: true });
|
|
1056
|
-
writeFileSync(join(vendor, "v.test.mjs"), PASSES);
|
|
1057
|
-
for (const spelling of [
|
|
1058
|
-
"node_modules/pkg/v.test.mjs",
|
|
1059
|
-
"./node_modules/pkg/v.test.mjs",
|
|
1060
|
-
"t/../node_modules/pkg/v.test.mjs",
|
|
1061
|
-
"node_modules/pkg/*.test.mjs",
|
|
1062
|
-
]) {
|
|
1063
|
-
const r = a.run("t/a.test.mjs", spelling);
|
|
1064
|
-
assert.notEqual(r.status, 0, `${spelling}: ${r.stdout}${r.stderr}`);
|
|
1065
|
-
assert.match(r.stderr, /is under node_modules — node discards it silently/, spelling);
|
|
1066
|
-
}
|
|
1067
|
-
});
|
|
1068
|
-
|
|
1069
|
-
// The same guard under an inherited CDPATH, which nothing else in this suite
|
|
1070
|
-
// varies. `cd` consults CDPATH before the cwd, so with a decoy on it that
|
|
1071
|
-
// holds a same-named `node_modules/plain`, a bare `cd "$argdir"` resolves
|
|
1072
|
-
// into the DECOY: the guard's `"$PWD"/node_modules/*` pattern misses, it
|
|
1073
|
-
// falls through without refusing, and the vendored file reaches node — which
|
|
1074
|
-
// drops it silently at exit 0, #100 back with the refusal removed. `apply()`
|
|
1075
|
-
// hands the runner `{...process.env}`, so a developer's CDPATH reaches it.
|
|
1076
|
-
// The decoy shape is deliberate over a bare `CDPATH=/tmp`: /bin/sh on macOS
|
|
1077
|
-
// (bash 3.2) fails the `cd` outright when no CDPATH entry matches, while
|
|
1078
|
-
// /bin/dash falls back to the cwd per POSIX and stays immune — so a
|
|
1079
|
-
// non-matching decoy would pin this on the dev platform only. A MATCHING
|
|
1080
|
-
// entry diverts both shells, which is what makes this row portable.
|
|
1081
|
-
// The sibling directory branch already carries `CDPATH=` for this reason
|
|
1082
|
-
// (see agent-test, above `root=`); this pins the file branch's copy.
|
|
1083
|
-
// Mutation-tested both ways: dropping `CDPATH= ` from the file branch's `cd`
|
|
1084
|
-
// reds this row alone, and adding `-P` to it — the mutation the #401 row
|
|
1085
|
-
// below pins — leaves this one green.
|
|
1086
|
-
// Re-measured after #1005 collapsed that branch's unreachable `argdir` arm,
|
|
1087
|
-
// because the collapse is exactly the edit that could drop the `CDPATH= `
|
|
1088
|
-
// silently: stripping it from the collapsed line still reds this row and only
|
|
1089
|
-
// it (17/18 of the vendored rows green), and forcing `argdir` back to the
|
|
1090
|
-
// removed arm's `.` value reds five rows including this one — so the pin
|
|
1091
|
-
// discriminates the guard's behaviour, not the shape it is written in.
|
|
1092
|
-
test("runner: a vendored file argument refuses under an inherited CDPATH", () => {
|
|
1093
|
-
const a = apply(SUITE);
|
|
1094
|
-
const vendor = join(a.wt, "node_modules", "plain");
|
|
1095
|
-
mkdirSync(vendor, { recursive: true });
|
|
1096
|
-
writeFileSync(join(vendor, "v.test.mjs"), PASSES);
|
|
1097
|
-
const decoy = tempDir("cdpath-decoy-");
|
|
1098
|
-
mkdirSync(join(decoy, "node_modules", "plain"), { recursive: true });
|
|
1099
|
-
const r = spawnSync(join(a.wt, "agent-test"), ["t/a.test.mjs", "node_modules/plain/v.test.mjs"], {
|
|
1100
|
-
cwd: a.wt,
|
|
1101
|
-
encoding: "utf8",
|
|
1102
|
-
env: { ...a.env, CDPATH: decoy },
|
|
1103
|
-
});
|
|
1104
|
-
assert.notEqual(r.status, 0, r.stdout + r.stderr);
|
|
1105
|
-
assert.match(r.stderr, /is under node_modules — node discards it silently/);
|
|
1106
|
-
});
|
|
1107
|
-
|
|
1108
|
-
// The file-branch counterpart of the no-search-bit case pinned above for the
|
|
1109
|
-
// directory branch: `arg` here is a FILE, so `[ -d $arg ]` never runs at
|
|
1110
|
-
// all — this guard reads $argdir, the file's own parent, and it is $argdir
|
|
1111
|
-
// that loses its search bit. Before the fix, `cd`'s failure on $argdir was
|
|
1112
|
-
// discarded outright (`2>/dev/null`, nothing read from the pipeline), the
|
|
1113
|
-
// vendored `case` fell through unrefused, `[ -e $arg ]` downstream read
|
|
1114
|
-
// false because the parent could not be traversed, and the typo arm far
|
|
1115
|
-
// below reported a permission fault as `does not exist` — measured directly
|
|
1116
|
-
// against the unfixed shim. Root can read anything, so it cannot see this.
|
|
1117
|
-
test("runner: a vendored file behind an unreadable directory names the permission fault, not a typo", (t) => {
|
|
1118
|
-
if (process.getuid?.() === 0) return t.skip("root reads every directory");
|
|
1119
|
-
const a = apply(SUITE);
|
|
1120
|
-
const vendor = join(a.wt, "node_modules", "pkg");
|
|
1121
|
-
mkdirSync(vendor, { recursive: true });
|
|
1122
|
-
writeFileSync(join(vendor, "v.test.mjs"), PASSES);
|
|
1123
|
-
chmodSync(vendor, 0o000);
|
|
1124
|
-
try {
|
|
1125
|
-
const r = a.run("t/a.test.mjs", "node_modules/pkg/v.test.mjs");
|
|
1126
|
-
assert.notEqual(r.status, 0, r.stdout + r.stderr);
|
|
1127
|
-
assert.match(r.stderr, /cannot read node_modules\/pkg — check its permissions/);
|
|
1128
|
-
assert.doesNotMatch(r.stderr, /does not exist/);
|
|
1129
|
-
assert.doesNotMatch(r.stderr, /is under node_modules — node discards it silently/);
|
|
1130
|
-
} finally {
|
|
1131
|
-
chmodSync(vendor, 0o755);
|
|
1132
|
-
}
|
|
1133
|
-
});
|
|
1134
|
-
|
|
1135
|
-
// #1006's own warning about its remedy sketch: `[ -d $argdir ]` reads false
|
|
1136
|
-
// not only when $argdir is missing, but also whenever $argdir's OWN PARENT
|
|
1137
|
-
// is unreadable — so the guard above must not fire the permission message on
|
|
1138
|
-
// a fixture it cannot actually back up. Here `node_modules` (the file's
|
|
1139
|
-
// GRANDparent) loses its search bit, not `pkg` (the immediate parent): the
|
|
1140
|
-
// guard can no longer even confirm `pkg` exists, so it has to stay silent
|
|
1141
|
-
// and let the argument fall through exactly as an unmeasured path already
|
|
1142
|
-
// did, rather than assert a fault it cannot name. Measured directly: `-d`
|
|
1143
|
-
// reads false here where it read true in the row above, on the same
|
|
1144
|
-
// $argdir. The downstream message this falls through to belongs to the
|
|
1145
|
-
// general typo arm (#960/PR #1387), not this guard, and is deliberately
|
|
1146
|
-
// left unpinned here — its exact wording is that ticket's to change; this
|
|
1147
|
-
// row only pins that THIS guard neither over-fires nor claims the wrong
|
|
1148
|
-
// verdict. Root can read anything, so it cannot see this.
|
|
1149
|
-
test("runner: a vendored file whose ancestor is unreadable does not claim a permission fault it cannot confirm", (t) => {
|
|
1150
|
-
if (process.getuid?.() === 0) return t.skip("root reads every directory");
|
|
1151
|
-
const a = apply(SUITE);
|
|
1152
|
-
const vendor = join(a.wt, "node_modules", "pkg");
|
|
1153
|
-
mkdirSync(vendor, { recursive: true });
|
|
1154
|
-
writeFileSync(join(vendor, "v.test.mjs"), PASSES);
|
|
1155
|
-
const modules = join(a.wt, "node_modules");
|
|
1156
|
-
chmodSync(modules, 0o000);
|
|
1157
|
-
try {
|
|
1158
|
-
const r = a.run("t/a.test.mjs", "node_modules/pkg/v.test.mjs");
|
|
1159
|
-
assert.notEqual(r.status, 0, r.stdout + r.stderr);
|
|
1160
|
-
assert.doesNotMatch(r.stderr, /cannot read node_modules\/pkg — check its permissions/);
|
|
1161
|
-
assert.doesNotMatch(r.stderr, /is under node_modules — node discards it silently/);
|
|
1162
|
-
} finally {
|
|
1163
|
-
chmodSync(modules, 0o755);
|
|
1164
|
-
}
|
|
1165
|
-
});
|
|
1166
|
-
|
|
1167
|
-
// #401: nothing above pins the RESOLUTION MODE this guard uses, only its
|
|
1168
|
-
// spelling coverage. `cd`/`pwd` without `-P` is logical — it never resolves a
|
|
1169
|
-
// symlinked path component — and that is deliberate: it is the same textual
|
|
1170
|
-
// resolution node applies to its own argv, so the guard and node agree on
|
|
1171
|
-
// which files count as vendored. The ordinary npm/pnpm workspace shape is
|
|
1172
|
-
// where the two resolution modes diverge: `node_modules/pkg` is itself a
|
|
1173
|
-
// symlink to a sibling real directory (`pkg` hoisted or linked from
|
|
1174
|
-
// `packages/`). `pwd -P` there resolves `pkg` OUT of `node_modules`, so the
|
|
1175
|
-
// pattern below stops matching, this guard falls through without refusing,
|
|
1176
|
-
// and the argument reaches node unrefused — where it is excluded anyway, on
|
|
1177
|
-
// its own unresolved spelling, silently, at exit 0. That is #100's silent
|
|
1178
|
-
// drop back, minus the loud refusal that is supposed to catch it first.
|
|
1179
|
-
// Measured against a scratch copy of this script with `cd`/`pwd` mutated to
|
|
1180
|
-
// `cd -P`/`pwd -P` on this guard alone: this is the row that reds, and it
|
|
1181
|
-
// stayed red for both `/bin/sh` (bash on macOS) and `/bin/dash` — the two
|
|
1182
|
-
// disagree on many things but not on this.
|
|
1183
|
-
test("runner: a vendored file behind a symlinked node_modules entry refuses", () => {
|
|
1184
|
-
const a = apply(SUITE);
|
|
1185
|
-
const real = join(a.wt, "packages", "pkg");
|
|
1186
|
-
mkdirSync(real, { recursive: true });
|
|
1187
|
-
writeFileSync(join(real, "v.test.mjs"), PASSES);
|
|
1188
|
-
mkdirSync(join(a.wt, "node_modules"), { recursive: true });
|
|
1189
|
-
symlinkSync(join("..", "packages", "pkg"), join(a.wt, "node_modules", "pkg"));
|
|
1190
|
-
const r = a.run("t/a.test.mjs", "node_modules/pkg/v.test.mjs");
|
|
1191
|
-
assert.notEqual(r.status, 0, r.stdout + r.stderr);
|
|
1192
|
-
assert.match(r.stderr, /is under node_modules — node discards it silently/);
|
|
1193
|
-
});
|
|
1194
|
-
|
|
1195
|
-
// The other half of the same rule, and the guard against over-widening it.
|
|
1196
|
-
// Node's exclusion fires only when the argument's normalized RELATIVE form
|
|
1197
|
-
// starts with `node_modules/`: a deeper segment and an absolute path are NOT
|
|
1198
|
-
// excluded — node runs both and counts them, so there is no silent drop to
|
|
1199
|
-
// refuse and refusing them would reject argv node handles fine. `pass 2` is
|
|
1200
|
-
// what says the vendored file ran rather than being dropped, so borrowing
|
|
1201
|
-
// the directory branch's own `*/node_modules/*` pattern here reddens this.
|
|
1202
|
-
test("runner: the vendored file spellings node runs are not refused", () => {
|
|
1203
|
-
const a = apply(SUITE);
|
|
1204
|
-
const vendor = join(a.wt, "node_modules", "pkg");
|
|
1205
|
-
mkdirSync(vendor, { recursive: true });
|
|
1206
|
-
writeFileSync(join(vendor, "v.test.mjs"), PASSES);
|
|
1207
|
-
const nested = join(a.wt, "t", "node_modules", "pkg");
|
|
1208
|
-
mkdirSync(nested, { recursive: true });
|
|
1209
|
-
writeFileSync(join(nested, "n.test.mjs"), PASSES);
|
|
1210
|
-
for (const spelling of [
|
|
1211
|
-
"t/node_modules/pkg/n.test.mjs",
|
|
1212
|
-
join(a.wt, "node_modules", "pkg", "v.test.mjs"),
|
|
1213
|
-
]) {
|
|
1214
|
-
const r = a.run("t/a.test.mjs", spelling);
|
|
1215
|
-
assert.equal(r.status, 0, `${spelling}: ${r.stdout}${r.stderr}`);
|
|
1216
|
-
assert.match(r.stdout, /^(?:ℹ|#) pass 2$/m, spelling);
|
|
1217
|
-
}
|
|
1218
|
-
});
|
|
1219
|
-
|
|
1220
|
-
// Node's exclusion is anchored at the cwd its arguments are relative to —
|
|
1221
|
-
// that is what "relative form" means, and it is what separates mirroring the
|
|
1222
|
-
// rule from matching a prefix. The two fixture files below swap verdicts on
|
|
1223
|
-
// nothing but where the runner is invoked from: at the worktree root
|
|
1224
|
-
// `node_modules/pkg/v.test.mjs` is the dropped one and `t/node_modules/…`
|
|
1225
|
-
// runs, while from inside `t/` the polarity inverts — `node_modules/pkg/…`
|
|
1226
|
-
// now names the nested file and is dropped, `../node_modules/pkg/…` names
|
|
1227
|
-
// the root one and runs. Measured against node itself, both ways. A guard
|
|
1228
|
-
// anchored at the worktree root rather than the cwd gets both backwards and
|
|
1229
|
-
// no other test in this file would see it.
|
|
1230
|
-
test("runner: the vendored rule is anchored at the cwd, as node's is", () => {
|
|
1231
|
-
const a = apply(SUITE);
|
|
1232
|
-
for (const p of ["node_modules/pkg", "t/node_modules/pkg"]) {
|
|
1233
|
-
mkdirSync(join(a.wt, p), { recursive: true });
|
|
1234
|
-
writeFileSync(join(a.wt, p, "v.test.mjs"), PASSES);
|
|
1235
|
-
}
|
|
1236
|
-
const refused = a.runFrom("t", "a.test.mjs", "node_modules/pkg/v.test.mjs");
|
|
1237
|
-
assert.notEqual(refused.status, 0, refused.stdout + refused.stderr);
|
|
1238
|
-
assert.match(refused.stderr, /is under node_modules — node discards it silently/);
|
|
1239
|
-
const ran = a.runFrom("t", "a.test.mjs", "../node_modules/pkg/v.test.mjs");
|
|
1240
|
-
assert.equal(ran.status, 0, ran.stdout + ran.stderr);
|
|
1241
|
-
assert.match(ran.stdout, /^(?:ℹ|#) pass 2$/m);
|
|
1242
|
-
});
|
|
1243
|
-
|
|
1244
|
-
// #424: the file-branch sibling of #186. The guard above judges the argument's
|
|
1245
|
-
// own SPELLING, and the logical directory that spelling names — which is what
|
|
1246
|
-
// node's silent-discard rule reads. A symlink whose name carries no
|
|
1247
|
-
// `node_modules` but whose TARGET is vendored passes it untouched, and node
|
|
1248
|
-
// then RUNS the vendored file rather than discarding it. So the hazard here is
|
|
1249
|
-
// not #100's: there is no silent drop left to make loud. It is #186's —
|
|
1250
|
-
// third-party code deciding this suite's result — one `-d` away, and it takes
|
|
1251
|
-
// #186's remedy: judge where the argument RESOLVES.
|
|
1252
|
-
//
|
|
1253
|
-
// Physical resolution, and only where the spelling does not already name
|
|
1254
|
-
// `node_modules`. Those spellings are the guard above's own input, the two it
|
|
1255
|
-
// deliberately lets run included, and re-judging them from a second place would
|
|
1256
|
-
// overturn that ruling; the two checks cover disjoint arguments instead, which
|
|
1257
|
-
// is what lets this one be physical while #401's stays logical.
|
|
1258
|
-
//
|
|
1259
|
-
// Anchored at the divergence from the runner's own location, as the directory
|
|
1260
|
-
// branch is: a `node_modules` ABOVE that point is an ancestor of the runner too
|
|
1261
|
-
// and says nothing about the argument. The absolute spelling is here because
|
|
1262
|
-
// resolution, unlike the directory branch's lexical spelling term, is immune to
|
|
1263
|
-
// how the caller named the file — a macOS $TMPDIR reaches the worktree through
|
|
1264
|
-
// a symlinked ancestor, so the two spellings share no literal prefix and only
|
|
1265
|
-
// the resolved form puts them on the same footing. The outside-the-worktree
|
|
1266
|
-
// target is the leg that separates anchoring at the divergence from anchoring
|
|
1267
|
-
// at the worktree root: its resolution lands outside the worktree entirely, so
|
|
1268
|
-
// a root-anchored guard has nothing left to compare and runs it green — #186's
|
|
1269
|
-
// own class, one input over.
|
|
1270
|
-
test("runner: a symlink to a vendored file refuses however it is spelled", () => {
|
|
1271
|
-
const a = apply(SUITE);
|
|
1272
|
-
const vendor = join(a.wt, "node_modules", "pkg");
|
|
1273
|
-
mkdirSync(vendor, { recursive: true });
|
|
1274
|
-
writeFileSync(join(vendor, "v.test.mjs"), PASSES);
|
|
1275
|
-
symlinkSync(join("node_modules", "pkg", "v.test.mjs"), join(a.wt, "vendlink.test.mjs"));
|
|
1276
|
-
// A chain of file symlinks: node follows it to the vendored file, so a guard
|
|
1277
|
-
// that resolves only one hop reports a clean path node never used.
|
|
1278
|
-
symlinkSync("vendlink.test.mjs", join(a.wt, "chainlink.test.mjs"));
|
|
1279
|
-
// The vendored component reached through a symlinked DIRECTORY, with a real
|
|
1280
|
-
// file as the final component — the half `cd`/`pwd -P` on the argument's own
|
|
1281
|
-
// directory would already have caught, kept so the fix is not narrowed to
|
|
1282
|
-
// final-component links alone.
|
|
1283
|
-
symlinkSync(join("node_modules", "pkg"), join(a.wt, "dirlink"));
|
|
1284
|
-
const outside = tempDir("outside-");
|
|
1285
|
-
mkdirSync(join(outside, "node_modules", "pkg"), { recursive: true });
|
|
1286
|
-
writeFileSync(join(outside, "node_modules", "pkg", "o.test.mjs"), PASSES);
|
|
1287
|
-
symlinkSync(join(outside, "node_modules", "pkg", "o.test.mjs"), join(a.wt, "extlink.test.mjs"));
|
|
1288
|
-
// A directory whose name merely ENDS in the word, spelled both ways — the
|
|
1289
|
-
// merged `case` judges the two on different arms. The relative spelling is
|
|
1290
|
-
// held out of the logical arm by that arm's own segment bound. The absolute
|
|
1291
|
-
// one is held out by the FIRST arm, whose job is the single shape both
|
|
1292
|
-
// guards decline (absolute AND naming a real `node_modules` segment) and
|
|
1293
|
-
// which therefore has to carry the bound too: written as the one glob that
|
|
1294
|
-
// looks equivalent, `/*node_modules/*`, it swallows this spelling into the
|
|
1295
|
-
// skip and node runs the vendored file. Measured — that collapse reds this
|
|
1296
|
-
// row and nothing else in the file, so the relative row alone did not pin
|
|
1297
|
-
// it. Unbounded, `*node_modules/*` claimed the argument for the logical
|
|
1298
|
-
// guard instead, whose own inner test is anchored at `$PWD/node_modules/`
|
|
1299
|
-
// and never fired: the argument left both guards unjudged, same result.
|
|
1300
|
-
mkdirSync(join(a.wt, "vendor_node_modules"), { recursive: true });
|
|
1301
|
-
symlinkSync(join("..", "node_modules", "pkg", "v.test.mjs"), join(a.wt, "vendor_node_modules", "link.test.mjs"));
|
|
1302
|
-
for (const spelling of [
|
|
1303
|
-
"vendlink.test.mjs",
|
|
1304
|
-
"./vendlink.test.mjs",
|
|
1305
|
-
join(a.wt, "vendlink.test.mjs"),
|
|
1306
|
-
"chainlink.test.mjs",
|
|
1307
|
-
"dirlink/v.test.mjs",
|
|
1308
|
-
"extlink.test.mjs",
|
|
1309
|
-
"vendor_node_modules/link.test.mjs",
|
|
1310
|
-
join(a.wt, "vendor_node_modules", "link.test.mjs"),
|
|
1311
|
-
]) {
|
|
1312
|
-
const r = a.run("t/a.test.mjs", spelling);
|
|
1313
|
-
assert.notEqual(r.status, 0, `${spelling}: ${r.stdout}${r.stderr}`);
|
|
1314
|
-
// The resolved target is named, not just the argument: the refusal states
|
|
1315
|
-
// what was applied to THIS path — a caller who spelled a name carrying no
|
|
1316
|
-
// `node_modules` otherwise has to re-run `realpath` to see which link went
|
|
1317
|
-
// where, and reads the bare clause as a rule the runner does not apply to
|
|
1318
|
-
// every spelling (a literal `t/node_modules/pkg/x.test.mjs` still runs,
|
|
1319
|
-
// #401's ruling, deliberately).
|
|
1320
|
-
assert.match(r.stderr, /resolves to \S+, inside node_modules — excluded from the run/, spelling);
|
|
1321
|
-
}
|
|
1322
|
-
});
|
|
1323
|
-
|
|
1324
|
-
// The control, and what stops the fix above becoming a blanket refusal of
|
|
1325
|
-
// symlinks: the refusal leg alone passes just as well under a guard that
|
|
1326
|
-
// refuses every symlinked argument, or every argument with `node_modules`
|
|
1327
|
-
// anywhere in its resolution.
|
|
1328
|
-
//
|
|
1329
|
-
// `sidelink` is the second half: a target that merely SITS BESIDE a vendored
|
|
1330
|
-
// tree rather than inside one. `packages/pkg/w.test.mjs` is the ordinary
|
|
1331
|
-
// npm/pnpm workspace shape, named by its REAL path — there is no symlinked
|
|
1332
|
-
// spelling of it to grep for, because that is the point: `node_modules/pkg`
|
|
1333
|
-
// is a symlink OUT to `packages/pkg`, so a caller naming `packages/pkg/…`
|
|
1334
|
-
// names a file that is not vendored at all, and physical resolution is
|
|
1335
|
-
// exactly what has to agree. The
|
|
1336
|
-
// same tree spelled `node_modules/pkg/…` is #401's row above, refused by the
|
|
1337
|
-
// logical guard this one is deliberately blind to.
|
|
1338
|
-
test("runner: a symlink to a non-vendored file still runs", () => {
|
|
1339
|
-
const a = apply(SUITE);
|
|
1340
|
-
symlinkSync(join("t", "b.test.mjs"), join(a.wt, "oklink.test.mjs"));
|
|
1341
|
-
const outside = tempDir("outside-ok-");
|
|
1342
|
-
mkdirSync(join(outside, "lib", "node_modules"), { recursive: true });
|
|
1343
|
-
writeFileSync(join(outside, "lib", "o.test.mjs"), PASSES);
|
|
1344
|
-
symlinkSync(join(outside, "lib", "o.test.mjs"), join(a.wt, "sidelink.test.mjs"));
|
|
1345
|
-
const real = join(a.wt, "packages", "pkg");
|
|
1346
|
-
mkdirSync(real, { recursive: true });
|
|
1347
|
-
writeFileSync(join(real, "w.test.mjs"), PASSES);
|
|
1348
|
-
mkdirSync(join(a.wt, "node_modules"), { recursive: true });
|
|
1349
|
-
symlinkSync(join("..", "packages", "pkg"), join(a.wt, "node_modules", "pkg"));
|
|
1350
|
-
for (const spelling of [
|
|
1351
|
-
"oklink.test.mjs",
|
|
1352
|
-
"sidelink.test.mjs",
|
|
1353
|
-
"packages/pkg/w.test.mjs",
|
|
1354
|
-
]) {
|
|
1355
|
-
const r = a.run("t/a.test.mjs", spelling);
|
|
1356
|
-
assert.equal(r.status, 0, `${spelling}: ${r.stdout}${r.stderr}`);
|
|
1357
|
-
assert.match(r.stdout, /^(?:ℹ|#) pass 2$/m, spelling);
|
|
1358
|
-
}
|
|
1359
|
-
});
|
|
1360
|
-
|
|
1361
|
-
// The resolved check is asked only of an argument that EXISTS, and that gate is
|
|
1362
|
-
// the whole platform pin. BSD `realpath` fails on a nonexistent final component
|
|
1363
|
-
// and GNU's succeeds on it, so one input drew opposite verdicts: this spelling
|
|
1364
|
-
// reported `does not exist` on macOS and `resolves inside node_modules — not
|
|
1365
|
-
// missing` on ubuntu-latest, asserting a missing file was not missing and
|
|
1366
|
-
// pre-empting the arm that names it. The whole file ran 77/77 under both
|
|
1367
|
-
// semantics, so nothing discriminated them — measured. This row does: green on
|
|
1368
|
-
// BSD with the gate or without it, red on GNU without it.
|
|
1369
|
-
test("runner: a missing file under a symlinked vendored directory is reported missing", () => {
|
|
1370
|
-
const a = apply(SUITE);
|
|
1371
|
-
const vendor = join(a.wt, "node_modules", "pkg");
|
|
1372
|
-
mkdirSync(vendor, { recursive: true });
|
|
1373
|
-
writeFileSync(join(vendor, "v.test.mjs"), PASSES);
|
|
1374
|
-
symlinkSync(join("node_modules", "pkg"), join(a.wt, "dirlink"));
|
|
1375
|
-
const r = a.run("t/a.test.mjs", "dirlink/nope.test.mjs");
|
|
1376
|
-
assert.notEqual(r.status, 0, r.stdout + r.stderr);
|
|
1377
|
-
assert.match(r.stderr, /dirlink\/nope\.test\.mjs does not exist/);
|
|
1378
|
-
assert.doesNotMatch(r.stderr, /node_modules/);
|
|
1379
|
-
});
|
|
1380
|
-
|
|
1381
|
-
// `realpath` is the one utility this runner reaches for that POSIX does not
|
|
1382
|
-
// mandate, so the runner dies rather than guessing when it is missing. Absent,
|
|
1383
|
-
// this guard disarmed whole: the vendored file ran, the run exited 0 reporting
|
|
1384
|
-
// `pass 2`, and not one byte reached stderr — #424's own defect restored with no
|
|
1385
|
-
// notice. Absence is not a fallback case, it is a question this cannot answer,
|
|
1386
|
-
// so it refuses. A stub that exits 127 rather than an emptied PATH, so `sed`,
|
|
1387
|
-
// `dirname` and `node` still work and the resolver is the only thing missing.
|
|
1388
|
-
test("runner: an unresolvable argument refuses rather than running unchecked", () => {
|
|
1389
|
-
const a = apply(SUITE);
|
|
1390
|
-
const vendor = join(a.wt, "node_modules", "pkg");
|
|
1391
|
-
mkdirSync(vendor, { recursive: true });
|
|
1392
|
-
writeFileSync(join(vendor, "v.test.mjs"), PASSES);
|
|
1393
|
-
symlinkSync(join("node_modules", "pkg", "v.test.mjs"), join(a.wt, "vendlink.test.mjs"));
|
|
1394
|
-
const bin = tempDir("no-realpath-");
|
|
1395
|
-
writeExecStub(join(bin, "realpath"), "#!/bin/sh\nexit 127\n");
|
|
1396
|
-
// The vendored spelling goes FIRST: every file argument is judged, so the
|
|
1397
|
-
// refusal names whichever one the loop reaches first, and naming this one is
|
|
1398
|
-
// what shows the guard is still armed rather than merely dying early.
|
|
1399
|
-
const r = spawnSync(join(a.wt, "agent-test"), ["vendlink.test.mjs", "t/a.test.mjs"], {
|
|
1400
|
-
cwd: a.wt,
|
|
1401
|
-
encoding: "utf8",
|
|
1402
|
-
env: { ...a.env, PATH: `${bin}:${a.env.PATH}` },
|
|
1403
|
-
});
|
|
1404
|
-
assert.notEqual(r.status, 0, r.stdout + r.stderr);
|
|
1405
|
-
assert.match(r.stderr, /cannot resolve vendlink\.test\.mjs — refusing rather than running it unchecked/);
|
|
1406
|
-
assert.doesNotMatch(r.stdout, /(?:ℹ|#) pass/);
|
|
1407
|
-
});
|
|
1408
|
-
|
|
1409
|
-
// The issue's own second case, verbatim: "and, before PR #75's escape,
|
|
1410
|
-
// bracketed paths". Node globs its own argv, where a literal `[` is a bracket
|
|
1411
|
-
// expression that cannot match itself — so the path matches nothing, node
|
|
1412
|
-
// drops it, and mixed with a resolvable file that drop is silent: the runner
|
|
1413
|
-
// reported `pass 1` for a two-file argv and exited 0. The escape is the same
|
|
1414
|
-
// `sed 's/\[/[[]/g'` the directory branch already applies to find's output,
|
|
1415
|
-
// and asking whether the path EXISTS before reading it as a glob is what
|
|
1416
|
-
// gets the argument to it. Both invocations are here because they fail
|
|
1417
|
-
// differently without the escape: mixed goes quiet, alone exits 1 because
|
|
1418
|
-
// node then has nothing left to run.
|
|
1419
|
-
test("runner: a bracketed file argument runs, alone and mixed with a valid one", () => {
|
|
1420
|
-
const a = apply(SUITE);
|
|
1421
|
-
const mixed = a.run("t/a.test.mjs", "br[a]cket/g.test.mjs");
|
|
1422
|
-
assert.equal(mixed.status, 0, mixed.stdout + mixed.stderr);
|
|
1423
|
-
assert.match(mixed.stdout, /^(?:ℹ|#) pass 2$/m);
|
|
1424
|
-
const alone = a.run("br[a]cket/g.test.mjs");
|
|
1425
|
-
assert.equal(alone.status, 0, alone.stdout + alone.stderr);
|
|
1426
|
-
assert.match(alone.stdout, /^(?:ℹ|#) pass 1$/m);
|
|
1427
|
-
});
|
|
1428
|
-
|
|
1429
|
-
// A flag is not a path, and only node can judge one. Reading an argument
|
|
1430
|
-
// that does not exist as a typo refused every documented `node --test` flag
|
|
1431
|
-
// as a missing file — argv that ran fine before this guard existed, and
|
|
1432
|
-
// nothing else in this suite passes a flag. Node takes flag values with `=`
|
|
1433
|
-
// (measured: the space-separated form exits 9 at node itself), so a flag is
|
|
1434
|
-
// always one argv entry and passing it through cannot swallow a path. A
|
|
1435
|
-
// typo'd flag stays loud without this runner's help: node rejects it and
|
|
1436
|
-
// exits 9, which is why the last assertion insists the refusal is NOT
|
|
1437
|
-
// `agent-test:`-prefixed.
|
|
1438
|
-
test("runner: a node --test flag reaches node instead of being read as a path", () => {
|
|
1439
|
-
const a = apply(SUITE);
|
|
1440
|
-
for (const flag of [
|
|
1441
|
-
"--test-name-pattern=ok",
|
|
1442
|
-
"--test-only",
|
|
1443
|
-
"--test-reporter=tap",
|
|
1444
|
-
"--test-concurrency=1",
|
|
1445
|
-
"--",
|
|
1446
|
-
]) {
|
|
1447
|
-
const r = a.run(flag, "t/a.test.mjs");
|
|
1448
|
-
assert.equal(r.status, 0, `${flag}: ${r.stdout}${r.stderr}`);
|
|
1449
|
-
assert.doesNotMatch(r.stderr, /does not exist/, flag);
|
|
1450
|
-
}
|
|
1451
|
-
const typo = a.run("--test-nmae-pattern=ok", "t/a.test.mjs");
|
|
1452
|
-
assert.notEqual(typo.status, 0, typo.stdout + typo.stderr);
|
|
1453
|
-
assert.doesNotMatch(typo.stderr, /agent-test:/, typo.stdout + typo.stderr);
|
|
1454
|
-
});
|
|
1455
|
-
|
|
1456
|
-
// #352: a flag counts toward `$#`, so an argv of flags alone cleared the
|
|
1457
|
-
// bare-form default, contributed no path operand, and reached node holding
|
|
1458
|
-
// only flags. That is node's own default discovery — which does not recognise
|
|
1459
|
-
// the `.spec.` form — so this fixture reported zero tests run at exit 0, the
|
|
1460
|
-
// vacuous pass this runner exists to refuse. It refuses here too rather
|
|
1461
|
-
// than defaulting: prepending the default AHEAD of node's own flags reorders
|
|
1462
|
-
// argv, and no briefed workflow passes flags alone.
|
|
1463
|
-
//
|
|
1464
|
-
// `--` is in the list because POSIX's end-of-options marker reaches the same
|
|
1465
|
-
// pass-through arm as a flag, and is no more a path than one.
|
|
1466
|
-
//
|
|
1467
|
-
// `-v` is in the list because a corpus spelled entirely with double dashes
|
|
1468
|
-
// cannot tell the classification pattern `-*` from `--*`. That classification
|
|
1469
|
-
// now lives in the dispatch's own arm order (the flag-detection arm, `-*) ;;`):
|
|
1470
|
-
// narrow it to `--*` and every double-dash entry here is still refused
|
|
1471
|
-
// exactly as before, while a lone `-v` no longer matches that arm and falls
|
|
1472
|
-
// through to the default/typo arm instead, refused there as `-v does not
|
|
1473
|
-
// exist` (exit 1) rather than reaching node. The row still discriminates the
|
|
1474
|
-
// mutation — it pins the refusal's wording now, not a vacuous exit 0 — but
|
|
1475
|
-
// the exit-0-after-printing-its-version failure mode this paragraph used to
|
|
1476
|
-
// describe no longer applies to this code shape.
|
|
1477
|
-
// Measured in both directions against that one-token mutation.
|
|
1478
|
-
//
|
|
1479
|
-
// Both directions, because a suite that only feeds a new refusal invalid input
|
|
1480
|
-
// pins neither: the ACCEPT case below rides the same flag alongside a real
|
|
1481
|
-
// operand, on the same fixture, so a refusal that swallowed the flag
|
|
1482
|
-
// pass-through would be red here rather than invisible. The bare form — the
|
|
1483
|
-
// other thing this guard could wrongly refuse — is pinned by the `.spec.`
|
|
1484
|
-
// cases below.
|
|
1485
|
-
//
|
|
1486
|
-
// The fixture is the issue's own repro, and it is what discriminates: under
|
|
1487
|
-
// node's discovery a `.spec.` file is not a test, so the pre-fix runner exited
|
|
1488
|
-
// 0. A `.test.mjs` fixture would have run green both ways and pinned nothing.
|
|
1489
|
-
test("runner: an argv of flags alone refuses instead of reaching node's own discovery", () => {
|
|
1490
|
-
const a = apply({ "t/a.spec.mjs": PASSES });
|
|
1491
|
-
for (const argv of [["--test-concurrency=1"], ["-v"], ["--"], ["--test-only", "--test-reporter=tap"]]) {
|
|
1492
|
-
const r = a.run(...argv);
|
|
1493
|
-
assert.notEqual(r.status, 0, `${argv.join(" ")}: ${r.stdout}${r.stderr}`);
|
|
1494
|
-
assert.match(r.stderr, /agent-test: no test file or directory/, argv.join(" "));
|
|
1495
|
-
}
|
|
1496
|
-
const ok = a.run("--test-concurrency=1", "t/a.spec.mjs");
|
|
1497
|
-
assert.equal(ok.status, 0, ok.stdout + ok.stderr);
|
|
1498
|
-
assert.match(ok.stdout, /^(?:ℹ|#) pass 1$/m);
|
|
1499
|
-
});
|
|
1500
|
-
|
|
1501
|
-
// #961. The corpus above is spelled entirely with arguments that do not
|
|
1502
|
-
// exist, so it pins one row of the classification and leaves the rule that
|
|
1503
|
-
// produces it unpinned: a dash-led argument is an operand where it EXISTS,
|
|
1504
|
-
// and a flag otherwise. Both rows below are dash-led, and they answer
|
|
1505
|
-
// oppositely — which is what makes the rule, rather than the shape, the
|
|
1506
|
-
// thing being pinned. Measured on a runner built from this emitter.
|
|
1507
|
-
//
|
|
1508
|
-
// `-dash.test.mjs` exists, so it is an operand. The runner never gets it to
|
|
1509
|
-
// run — node reads a relative dash-led spec as an option and dies in ITS own
|
|
1510
|
-
// voice, the same ceiling the dash-named directory test above already
|
|
1511
|
-
// carries one level up (measured on node v26.8.1 and on the v26.5.0 the
|
|
1512
|
-
// `.nvmrc` pins; `./`-prefixing does not escape it, node strips that
|
|
1513
|
-
// prefix first). Which refusal a caller sees is the whole of what the
|
|
1514
|
-
// classification buys here, and it is exactly what discriminates: classify
|
|
1515
|
-
// this argument as a flag instead and the runner refuses in its own voice,
|
|
1516
|
-
// at exit 1, before node is reached. The positive `node:` match is
|
|
1517
|
-
// load-bearing beside the negative — a nonzero exit with nothing on stderr
|
|
1518
|
-
// satisfies the negative on its own.
|
|
1519
|
-
//
|
|
1520
|
-
// `-t/*.test.mjs` does not exist and holds a glob metacharacter, so it
|
|
1521
|
-
// reaches the arm order where dash-ness is read BEFORE glob-ness: a flag,
|
|
1522
|
-
// not a glob, contributing no operand. Read it the other way round — "a
|
|
1523
|
-
// glob is a glob whatever it starts with" — and this argv reaches node,
|
|
1524
|
-
// which drops the unmatched pattern silently and exits 0 having run
|
|
1525
|
-
// nothing: the vacuous pass the guard exists to refuse, one argv shape past
|
|
1526
|
-
// the corpus above. The dash-led file is written straight into the worktree
|
|
1527
|
-
// rather than through `apply()`, for the reason the dash-named directory
|
|
1528
|
-
// test above gives.
|
|
1529
|
-
test("runner: a dash-led argument counts as an operand only where it exists", () => {
|
|
1530
|
-
const a = apply(SUITE);
|
|
1531
|
-
writeFileSync(join(a.wt, "-dash.test.mjs"), PASSES);
|
|
1532
|
-
|
|
1533
|
-
const exists = a.run("-dash.test.mjs");
|
|
1534
|
-
assert.notEqual(exists.status, 0, exists.stdout + exists.stderr);
|
|
1535
|
-
assert.doesNotMatch(exists.stderr, /agent-test: no test file or directory/, exists.stdout + exists.stderr);
|
|
1536
|
-
assert.match(exists.stderr, /node: bad option/, exists.stdout + exists.stderr);
|
|
1537
|
-
|
|
1538
|
-
const missing = a.run("-t/*.test.mjs");
|
|
1539
|
-
assert.notEqual(missing.status, 0, missing.stdout + missing.stderr);
|
|
1540
|
-
assert.match(missing.stderr, /agent-test: no test file or directory/, missing.stdout + missing.stderr);
|
|
1541
|
-
});
|
|
1542
|
-
|
|
1543
|
-
// The deliberately preserved escape hatch: `set -f` above stops the *shell*
|
|
1544
|
-
// from touching this, so a literal `*` reaches the runner exactly as the
|
|
1545
|
-
// glob-detection guard requires — spawnSync never invokes a shell, so this
|
|
1546
|
-
// is the same argv a member's own shell produces for a quoted glob. Only
|
|
1547
|
-
// node can expand it, and here it matches real files, so it must still run
|
|
1548
|
-
// them rather than being refused as "does not exist".
|
|
1549
|
-
test("runner: a quoted glob argument still runs, unexpanded by the shell", () => {
|
|
1550
|
-
const r = apply(SUITE).run("t/*.test.mjs");
|
|
1551
|
-
assert.equal(r.status, 0, r.stdout + r.stderr);
|
|
1552
|
-
assert.match(r.stdout, /^(?:ℹ|#) pass 2$/m);
|
|
1553
|
-
});
|
|
1554
|
-
|
|
1555
|
-
// A valid mix of both argument shapes the passthrough branch and the
|
|
1556
|
-
// directory branch each handle — neither new guard may refuse an argument
|
|
1557
|
-
// that was never in question.
|
|
1558
|
-
test("runner: a mixed argv of files and directories still runs everything", () => {
|
|
1559
|
-
const r = apply(SUITE).run("t/a.test.mjs", "t/nested");
|
|
1560
|
-
assert.equal(r.status, 0, r.stdout + r.stderr);
|
|
1561
|
-
assert.match(r.stdout, /^(?:ℹ|#) pass 2$/m);
|
|
1562
|
-
});
|
|
1563
|
-
|
|
1564
|
-
// #97: a bare invocation must go through the same expansion as an explicit
|
|
1565
|
-
// ".", not fall through to node's own default discovery. `for arg do` with no
|
|
1566
|
-
// `in` clause iterates "$@", so on an empty argv the loop body never ran and
|
|
1567
|
-
// the runner fell straight to bare `node --test`. Mixing a `.spec.` file into
|
|
1568
|
-
// the plain SUITE is what makes `pass 7` discriminate: SUITE alone is *not* a
|
|
1569
|
-
// counter-example, since node's own default discovery happens to match every
|
|
1570
|
-
// `.test.mjs` name in it too — a fixture that pinned "6" against SUITE would
|
|
1571
|
-
// stay green under the pre-fix bare `node --test` and prove nothing.
|
|
1572
|
-
test("runner: a bare invocation runs the same suite as an explicit \".\"", () => {
|
|
1573
|
-
const a = apply({ ...SUITE, "t/d.spec.mjs": PASSES });
|
|
1574
|
-
const dot = a.run(".");
|
|
1575
|
-
assert.equal(dot.status, 0, dot.stdout + dot.stderr);
|
|
1576
|
-
assert.match(dot.stdout, /^(?:ℹ|#) pass 7$/m);
|
|
1577
|
-
const bare = a.run();
|
|
1578
|
-
assert.equal(bare.status, 0, bare.stdout + bare.stderr);
|
|
1579
|
-
assert.match(bare.stdout, /^(?:ℹ|#) pass 7$/m);
|
|
1580
|
-
});
|
|
1581
|
-
|
|
1582
|
-
// The sharpest edge of #97: node's own default discovery does not recognise
|
|
1583
|
-
// the `.spec.` form, so a repo whose only test file uses it went green over
|
|
1584
|
-
// zero tests run under the pre-fix bare invocation. This is the exact
|
|
1585
|
-
// fixture from the issue's own repro.
|
|
1586
|
-
test("runner: a bare invocation runs .spec. files, which node's own discovery does not", () => {
|
|
1587
|
-
const r = apply({ "t/a.spec.mjs": PASSES }).run();
|
|
1588
|
-
assert.equal(r.status, 0, r.stdout + r.stderr);
|
|
1589
|
-
assert.match(r.stdout, /^(?:ℹ|#) pass 1$/m);
|
|
1590
|
-
});
|
|
1591
|
-
|
|
1592
|
-
// A repo with zero test files anywhere never reaches this runner at all —
|
|
1593
|
-
// derive-testcmd.sh refuses at emit time before a runner is written, pinned
|
|
1594
|
-
// by "runner: no scripts.test and no test files refuses rather than passing
|
|
1595
|
-
// vacuously" below. Nothing about that guard changes here — and where the two
|
|
1596
|
-
// disagree, they disagree safely: the emit guard greps `git ls-tree`, which
|
|
1597
|
-
// excludes neither `node_modules` nor symlinks, while this walk prunes the
|
|
1598
|
-
// first and `-type f` drops the second. A repo whose only committed test files
|
|
1599
|
-
// are vendored or symlinked therefore does reach the runner, and gets the
|
|
1600
|
-
// emptiness guard's `no test files under .` at exit 1 — a loud refusal, never
|
|
1601
|
-
// a vacuous pass. Pinned here rather than asserted: the block above used to
|
|
1602
|
-
// claim this state was unreachable, and the only `no test files under` pins in
|
|
1603
|
-
// the file were an explicit directory argument and two `doesNotMatch`. Vendored
|
|
1604
|
-
// is the cheaper of the two shapes to build — the symlink one needs a mode
|
|
1605
|
-
// 120000 entry that `apply()` cannot express — and both end in the same guard.
|
|
1606
|
-
// Pre-fix this is the vacuous green #97 exists to refuse: node's own discovery
|
|
1607
|
-
// skips `node_modules`, finds nothing, and exits 0 over `tests 0`.
|
|
1608
|
-
test("runner: a bare invocation refuses a repo whose only test files are vendored", () => {
|
|
1609
|
-
const r = apply({ "node_modules/pkg/v.test.mjs": PASSES }).run();
|
|
1610
|
-
assert.notEqual(r.status, 0, r.stdout + r.stderr);
|
|
1611
|
-
assert.match(r.stderr, /no test files under \./);
|
|
1612
|
-
});
|
|
1613
|
-
|
|
1614
|
-
// The blocker named in the issue body (defaulting to "." would sweep vendored
|
|
1615
|
-
// tests) was discharged by #109's node_modules exclusion before this landed.
|
|
1616
|
-
// Confirm the defaulted path actually goes through that prune rather than
|
|
1617
|
-
// bypassing it some other way.
|
|
1618
|
-
// Both fixture choices carry the pin; neither is decoration. The `.spec.`
|
|
1619
|
-
// file is what makes the count discriminate #97 — SUITE alone reads `pass 6`
|
|
1620
|
-
// under the pre-fix bare `node --test` too, since node's own discovery
|
|
1621
|
-
// matches every `.test.mjs` name in it and already skips node_modules, so a
|
|
1622
|
-
// fixture pinning "6" here is exactly the hollow one the comment above
|
|
1623
|
-
// warns about. And the vendored file is NESTED rather than sitting at the
|
|
1624
|
-
// worktree root because node refuses an argv entry whose relative path
|
|
1625
|
-
// starts with `node_modules/`, dropping it silently while the rest of argv
|
|
1626
|
-
// resolves (#100). At the root that refusal stands in for the prune:
|
|
1627
|
-
// measured with the prune deleted, a root-level fixture still reads
|
|
1628
|
-
// `pass 7` and still exits 0, so the assertion cannot tell this shim's walk
|
|
1629
|
-
// from node's own behaviour. Nested, only the prune keeps the file out.
|
|
1630
|
-
// `pass 7` rather than `pass 8`, over a vendored test that fails on
|
|
1631
|
-
// purpose, is what says it ran.
|
|
1632
|
-
test("runner: a bare invocation excludes vendored tests under node_modules", () => {
|
|
1633
|
-
const a = apply({ ...SUITE, "t/d.spec.mjs": PASSES });
|
|
1634
|
-
const vendor = join(a.wt, "t", "node_modules");
|
|
1635
|
-
mkdirSync(vendor, { recursive: true });
|
|
1636
|
-
writeFileSync(join(vendor, "v.test.mjs"), 'import { test } from "node:test";\ntest("VENDOR", () => { throw new Error("not ours"); });\n');
|
|
1637
|
-
const r = a.run();
|
|
1638
|
-
assert.equal(r.status, 0, r.stdout + r.stderr);
|
|
1639
|
-
assert.match(r.stdout, /^(?:ℹ|#) pass 7$/m);
|
|
1640
|
-
});
|