@feigi/fleet-ctl 3.23.35 → 3.23.37
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/package.json +1 -1
- package/scripts/main-checkout.mjs +1 -1
- package/scripts/member-write-guard.mjs +1 -1
- package/scripts/repo-root.mjs +1 -1
- package/skills/run-team/references/reaping.md +1 -1
- package/scripts/agent-test-dir-prose.test.mjs +0 -59
- package/scripts/agent-test.test.mjs +0 -1640
- package/scripts/ambient-git-vars-mjs-prose.test.mjs +0 -397
- package/scripts/ambient-git-vars-prose.test.mjs +0 -192
- package/scripts/ancestry-check-position-prose.test.mjs +0 -175
- package/scripts/apply-ruleset.test.mjs +0 -421
- package/scripts/arg-header-probes-prose.test.mjs +0 -394
- package/scripts/arg.test.mjs +0 -1354
- package/scripts/board-cli.test.mjs +0 -710
- package/scripts/board-identity.test.mjs +0 -429
- package/scripts/board-liveness-banner.test.mjs +0 -119
- package/scripts/board-prev-shape.test.mjs +0 -228
- package/scripts/board-tryparse-null.test.mjs +0 -119
- package/scripts/board.test.mjs +0 -3121
- package/scripts/brief-after-cut-prose.test.mjs +0 -53
- package/scripts/candidates-exit3-prose.test.mjs +0 -302
- package/scripts/candidates.test.mjs +0 -2312
- package/scripts/caveat-unification-prose.test.mjs +0 -98
- package/scripts/cell-readout.test.mjs +0 -615
- package/scripts/ci-comment-rot-prose.test.mjs +0 -2025
- package/scripts/ci-completes-premise-prose.test.mjs +0 -257
- package/scripts/ci-state-prose.test.mjs +0 -113
- package/scripts/ci-state.test.mjs +0 -1933
- package/scripts/ci-vacuous-green.test.mjs +0 -368
- package/scripts/citation-sweep-prose.test.mjs +0 -1712
- package/scripts/claim-lifecycle.test.mjs +0 -187
- package/scripts/claim-ticket.test.mjs +0 -1122
- package/scripts/closing-keyword-prose.test.mjs +0 -193
- package/scripts/cockpit-launch-idempotent-prose.test.mjs +0 -165
- package/scripts/cockpit-tick-nonblocking.test.mjs +0 -210
- package/scripts/compute-board.test.mjs +0 -1214
- package/scripts/compute-spend.test.mjs +0 -517
- package/scripts/consumer-technology-prose.test.mjs +0 -126
- package/scripts/cross-repo-citation-prose.test.mjs +0 -155
- package/scripts/cwd-isolation-pins.mjs +0 -83
- package/scripts/dedupe-guard-prose.test.mjs +0 -243
- package/scripts/delete-merged-branch.test.mjs +0 -576
- package/scripts/derive-testcmd.test.mjs +0 -595
- package/scripts/diff-stats.test.mjs +0 -404
- package/scripts/dispatch-block-golden-prose.test.mjs +0 -1130
- package/scripts/dispatch-block-pins-prose.test.mjs +0 -615
- package/scripts/dispositions-check.test.mjs +0 -936
- package/scripts/dispositions-gate-prose.test.mjs +0 -129
- package/scripts/drop-merged-label.test.mjs +0 -479
- package/scripts/exec-stub.mjs +0 -93
- package/scripts/exec-stub.test.mjs +0 -69
- package/scripts/expected-jobs-prose.test.mjs +0 -80
- package/scripts/fan-out-authorization-prose.test.mjs +0 -80
- package/scripts/filing-bar-seat-prose.test.mjs +0 -242
- package/scripts/filing-claim-bar-prose.test.mjs +0 -166
- package/scripts/finisher-died-prose.test.mjs +0 -31
- package/scripts/finisher-dispatch-premise-prose.test.mjs +0 -312
- package/scripts/finisher-halt-prose.test.mjs +0 -106
- package/scripts/finisher-name-prose.test.mjs +0 -134
- package/scripts/finisher-own-tree-prose.test.mjs +0 -299
- package/scripts/finisher-pin-race-prose.test.mjs +0 -339
- package/scripts/finisher-test-verdict-prose.test.mjs +0 -102
- package/scripts/fix-applier-correction-rules-prose.test.mjs +0 -202
- package/scripts/fix-applier-result-file-prose.test.mjs +0 -149
- package/scripts/fleet-bootstrap.test.mjs +0 -75
- package/scripts/fleet-heartbeat.test.mjs +0 -450
- package/scripts/fleet-provenance.test.mjs +0 -138
- package/scripts/fleet-run.test.mjs +0 -90
- package/scripts/fleet-state.test.mjs +0 -460
- package/scripts/fleet-tick-prose.test.mjs +0 -300
- package/scripts/fleet-tick.test.mjs +0 -2444
- package/scripts/force-with-lease-reason-prose.test.mjs +0 -184
- package/scripts/frontmatter-check.test.mjs +0 -436
- package/scripts/git-env.test.mjs +0 -149
- package/scripts/git-status-untracked-mode-sweep.test.mjs +0 -216
- package/scripts/gone-walk.test.mjs +0 -213
- package/scripts/gp-sep-invariant-prose.test.mjs +0 -188
- package/scripts/head-moved-after-label-prose.test.mjs +0 -233
- package/scripts/immutable-body-claim-prose.test.mjs +0 -204
- package/scripts/implementer-model-tier.test.mjs +0 -235
- package/scripts/inflight-citation-prose.test.mjs +0 -144
- package/scripts/inflight-exit2-prose.test.mjs +0 -81
- package/scripts/inflight-probe-guard-prose.test.mjs +0 -109
- package/scripts/inflight-scan-scope-prose.test.mjs +0 -57
- package/scripts/inflight.test.mjs +0 -2882
- package/scripts/injection-control-prose.test.mjs +0 -404
- package/scripts/install-root-audit.test.mjs +0 -464
- package/scripts/instrument-check-prose.test.mjs +0 -235
- package/scripts/instruments.test.mjs +0 -787
- package/scripts/is-cli.test.mjs +0 -99
- package/scripts/issue-tracker-prose.test.mjs +0 -71
- package/scripts/json.test.mjs +0 -364
- package/scripts/ledger-dispatch.test.mjs +0 -927
- package/scripts/ledger-grammar.test.mjs +0 -227
- package/scripts/ledger-read-require-file.test.mjs +0 -197
- package/scripts/ledger-rotate.test.mjs +0 -142
- package/scripts/ledger.test.mjs +0 -3436
- package/scripts/line-distance-prose.test.mjs +0 -245
- package/scripts/liveness-rationale-prose.test.mjs +0 -83
- package/scripts/locale-pin-prose.test.mjs +0 -189
- package/scripts/main-checkout.test.mjs +0 -332
- package/scripts/member-outcome-prose.test.mjs +0 -167
- package/scripts/member-outcomes-header.test.mjs +0 -129
- package/scripts/member-outcomes-prose.test.mjs +0 -63
- package/scripts/member-outcomes.test.mjs +0 -638
- package/scripts/member-prompt-prose.test.mjs +0 -165
- package/scripts/member-record.test.mjs +0 -541
- package/scripts/member-write-guard.test.mjs +0 -214
- package/scripts/merge-commit-probe-prose.test.mjs +0 -122
- package/scripts/merge-gate.test.mjs +0 -613
- package/scripts/muted-git-guard-sweep.test.mjs +0 -493
- package/scripts/net-ssh-precedence-prose.test.mjs +0 -91
- package/scripts/net-watchdog-prose.test.mjs +0 -79
- package/scripts/net.test.mjs +0 -211
- package/scripts/no-ci-gate-prose.test.mjs +0 -108
- package/scripts/no-undo-audit.test.mjs +0 -3961
- package/scripts/no-wave.test.mjs +0 -138
- package/scripts/node-floor-sweep.test.mjs +0 -611
- package/scripts/pointer-target-prose.test.mjs +0 -186
- package/scripts/pr-cost.test.mjs +0 -521
- package/scripts/pr-overlap.test.mjs +0 -692
- package/scripts/printf-die-sweep.test.mjs +0 -384
- package/scripts/prompt-renderer.mjs +0 -40
- package/scripts/prompt-renderer.test.mjs +0 -68
- package/scripts/prose-pin.mjs +0 -807
- package/scripts/prose-pin.test.mjs +0 -1034
- package/scripts/prove-merge.test.mjs +0 -995
- package/scripts/pull-table-relabel-prose.test.mjs +0 -60
- package/scripts/quiet-payload-prose.test.mjs +0 -222
- package/scripts/reap-cherry-check-prose.test.mjs +0 -80
- package/scripts/reap.test.mjs +0 -4432
- package/scripts/reaping-prose.test.mjs +0 -239
- package/scripts/reaping-reap-authorizers-prose.test.mjs +0 -112
- package/scripts/reaping-release-authorizers-prose.test.mjs +0 -85
- package/scripts/recipe-derivation-prose.test.mjs +0 -112
- package/scripts/recipe-prove.test.mjs +0 -1042
- package/scripts/refuter-scratch-prose.test.mjs +0 -135
- package/scripts/release-label-required-prose.test.mjs +0 -71
- package/scripts/release-label-split-prose.test.mjs +0 -184
- package/scripts/release-ticket-reap-pairing-prose.test.mjs +0 -63
- package/scripts/release-ticket.test.mjs +0 -5099
- package/scripts/renovate-release-contract.test.mjs +0 -379
- package/scripts/repo-root.test.mjs +0 -873
- package/scripts/reporter-output-rule-prose.test.mjs +0 -208
- package/scripts/review-agent-report-only.test.mjs +0 -49
- package/scripts/review-core-booking.test.mjs +0 -35
- package/scripts/review-core-cwd-isolation.test.mjs +0 -374
- package/scripts/review-core-reads.test.mjs +0 -478
- package/scripts/review-core-refuter-scratch.test.mjs +0 -148
- package/scripts/review-core-scratch-refusal.test.mjs +0 -64
- package/scripts/review-core-shared-test-run.test.mjs +0 -275
- package/scripts/review-core-snapshot-path.test.mjs +0 -830
- package/scripts/review-core-specialist-scratch.test.mjs +0 -191
- package/scripts/review-core-testcmd.test.mjs +0 -335
- package/scripts/review-core-unrun.test.mjs +0 -566
- package/scripts/review-core-unverified-discriminant.test.mjs +0 -208
- package/scripts/review-eval-resolver-path.test.mjs +0 -55
- package/scripts/review-host-fixture.mjs +0 -89
- package/scripts/review-in-run-retry.test.mjs +0 -211
- package/scripts/review-no-vendor-dispatch.test.mjs +0 -45
- package/scripts/review-path-default.test.mjs +0 -796
- package/scripts/review-runner-spawns.test.mjs +0 -95
- package/scripts/review-runner.test.mjs +0 -166
- package/scripts/review-tier-audit.test.mjs +0 -140
- package/scripts/run-artifact-pr-prose.test.mjs +0 -341
- package/scripts/run-merge-bot-prose.test.mjs +0 -1413
- package/scripts/run-team-local-hook.test.mjs +0 -442
- package/scripts/scratch-partition-invariant-prose.test.mjs +0 -74
- package/scripts/scripts-path-citation-sweep.test.mjs +0 -73
- package/scripts/section-between-guard-prose.test.mjs +0 -379
- package/scripts/select-dimensions.test.mjs +0 -674
- package/scripts/shared-refusal.test.mjs +0 -388
- package/scripts/shell-traps-prose.test.mjs +0 -504
- package/scripts/shortlist.test.mjs +0 -380
- package/scripts/slow-transport.mjs +0 -72
- package/scripts/snapshot-repo.test.mjs +0 -1006
- package/scripts/snapshot-runner-audience-prose.test.mjs +0 -130
- package/scripts/spend-view.test.mjs +0 -312
- package/scripts/staleness-qualifier-prose.test.mjs +0 -251
- package/scripts/staleness-verdict-prose.test.mjs +0 -142
- package/scripts/staleness.test.mjs +0 -893
- package/scripts/stalled-member-liveness-prose.test.mjs +0 -219
- package/scripts/stash-prohibition-prose.test.mjs +0 -313
- package/scripts/strip-comments.mjs +0 -44
- package/scripts/temp-dir.mjs +0 -47
- package/scripts/ticket-router.test.mjs +0 -981
- package/scripts/tier-check.test.mjs +0 -828
- package/scripts/tier-outcomes-header.test.mjs +0 -518
- package/scripts/tier-outcomes.test.mjs +0 -572
- package/scripts/tier-roles.test.mjs +0 -535
- package/scripts/tracker-block-copy-prose.test.mjs +0 -288
- package/scripts/triage-labels-gloss-prose.test.mjs +0 -97
- package/scripts/unattended-git-sweep.test.mjs +0 -142
- package/scripts/verify-sha-exit2-prose.test.mjs +0 -269
- package/scripts/verify-sha.test.mjs +0 -692
- package/scripts/watcher-degraded-block.test.mjs +0 -369
- package/scripts/watcher-key-prose.test.mjs +0 -106
- package/scripts/within-run-pair-prose.test.mjs +0 -212
- package/scripts/worktree-audit.test.mjs +0 -1408
- package/scripts/worktree-head-prose.test.mjs +0 -276
- package/scripts/worktree-listing-sweep.test.mjs +0 -217
- package/scripts/worktree-model-prose.test.mjs +0 -216
- package/scripts/worktree-porcelain.mjs +0 -35
- package/scripts/worktree-porcelain.test.mjs +0 -102
package/scripts/is-cli.test.mjs
DELETED
|
@@ -1,99 +0,0 @@
|
|
|
1
|
-
// is-cli.mjs: the "was this module run as the CLI?" guard every script ends
|
|
2
|
-
// with. A string comparison of import.meta.url against argv[1] skipped main()
|
|
3
|
-
// whenever the script was reached through a symlinked path (on macOS `/tmp` is
|
|
4
|
-
// one) and exited 0 with no output — the code that reads as "nothing to do".
|
|
5
|
-
// The second half of this file runs every CLI script through a symlinked
|
|
6
|
-
// directory, one case per script, because the helper being right says nothing
|
|
7
|
-
// about a script that does not call it.
|
|
8
|
-
|
|
9
|
-
import { test } from "node:test";
|
|
10
|
-
import assert from "node:assert/strict";
|
|
11
|
-
import { spawnSync } from "node:child_process";
|
|
12
|
-
import { symlinkSync, writeFileSync } from "node:fs";
|
|
13
|
-
import { join, relative } from "node:path";
|
|
14
|
-
import { fileURLToPath, pathToFileURL } from "node:url";
|
|
15
|
-
import { tempDir } from "./temp-dir.mjs";
|
|
16
|
-
import { isCLI } from "./is-cli.mjs";
|
|
17
|
-
|
|
18
|
-
const SCRIPTS_DIR = fileURLToPath(new URL(".", import.meta.url));
|
|
19
|
-
|
|
20
|
-
function fixture() {
|
|
21
|
-
const dir = tempDir("is-cli-");
|
|
22
|
-
const file = join(dir, "real.mjs");
|
|
23
|
-
writeFileSync(file, "export {};\n");
|
|
24
|
-
return { dir, file, url: pathToFileURL(file).href };
|
|
25
|
-
}
|
|
26
|
-
|
|
27
|
-
test("isCLI accepts the module's own path, a relative path to it and a symlink to it", () => {
|
|
28
|
-
const { dir, file, url } = fixture();
|
|
29
|
-
const link = join(dir, "link.mjs");
|
|
30
|
-
symlinkSync(file, link);
|
|
31
|
-
assert.equal(isCLI(url, file), true);
|
|
32
|
-
assert.equal(isCLI(url, relative(process.cwd(), file)), true);
|
|
33
|
-
assert.equal(isCLI(url, link), true);
|
|
34
|
-
});
|
|
35
|
-
|
|
36
|
-
test("isCLI accepts a module reached through a symlinked directory", () => {
|
|
37
|
-
const { dir, file, url } = fixture();
|
|
38
|
-
const linkDir = join(dir, "dir-link");
|
|
39
|
-
symlinkSync(dir, linkDir);
|
|
40
|
-
assert.equal(isCLI(url, join(linkDir, "real.mjs")), true);
|
|
41
|
-
assert.equal(isCLI(pathToFileURL(join(linkDir, "real.mjs")).href, file), true);
|
|
42
|
-
});
|
|
43
|
-
|
|
44
|
-
test("isCLI refuses another module — an import, not a run", () => {
|
|
45
|
-
const { dir, url } = fixture();
|
|
46
|
-
const other = join(dir, "other.mjs");
|
|
47
|
-
writeFileSync(other, "export {};\n");
|
|
48
|
-
assert.equal(isCLI(url, other), false);
|
|
49
|
-
});
|
|
50
|
-
|
|
51
|
-
test("isCLI refuses, rather than throws, when argv[1] is missing or names nothing", () => {
|
|
52
|
-
const { dir, url } = fixture();
|
|
53
|
-
assert.equal(isCLI(url, null), false);
|
|
54
|
-
assert.equal(isCLI(url, ""), false);
|
|
55
|
-
assert.equal(isCLI(url, join(dir, "gone.mjs")), false);
|
|
56
|
-
assert.equal(isCLI(url, "-"), false);
|
|
57
|
-
});
|
|
58
|
-
|
|
59
|
-
test("isCLI defaults to the live process.argv[1]", () => {
|
|
60
|
-
const { url } = fixture();
|
|
61
|
-
assert.equal(isCLI(url), false);
|
|
62
|
-
assert.equal(isCLI(pathToFileURL(process.argv[1]).href), true);
|
|
63
|
-
});
|
|
64
|
-
|
|
65
|
-
// Each script refuses an unknown flag with exit 2 before it reads or writes
|
|
66
|
-
// anything; a skipped main() exits 0. The real-path run is the control: the
|
|
67
|
-
// symlinked run must match it, not merely be non-zero.
|
|
68
|
-
const CLI_SCRIPTS = [
|
|
69
|
-
"diff-stats", "fleet-heartbeat", "fleet-tick", "frontmatter-check", "main-checkout",
|
|
70
|
-
"member-outcomes", "tier-check", "tier-outcomes", "tier-roles", "board", "dispositions-check", "recipe-prove",
|
|
71
|
-
];
|
|
72
|
-
|
|
73
|
-
for (const name of CLI_SCRIPTS) {
|
|
74
|
-
test(`${name}.mjs run through a symlinked path still runs main()`, () => {
|
|
75
|
-
const dir = tempDir("is-cli-run-");
|
|
76
|
-
const linkDir = join(dir, "scripts-link");
|
|
77
|
-
symlinkSync(SCRIPTS_DIR, linkDir);
|
|
78
|
-
const run = (script) => spawnSync(process.execPath, [script, "--bogus"], { cwd: dir, encoding: "utf8" });
|
|
79
|
-
const real = run(join(SCRIPTS_DIR, `${name}.mjs`));
|
|
80
|
-
const linked = run(join(linkDir, `${name}.mjs`));
|
|
81
|
-
assert.equal(real.status, 2, real.stderr);
|
|
82
|
-
assert.equal(linked.status, real.status, `via symlink: ${linked.stderr}`);
|
|
83
|
-
assert.equal(linked.stderr, real.stderr);
|
|
84
|
-
});
|
|
85
|
-
}
|
|
86
|
-
|
|
87
|
-
// The other direction: the control above cannot tell a guard that tests the
|
|
88
|
-
// path from one that is always true — both run main() under --bogus. Loading
|
|
89
|
-
// the script as a module must leave main() unrun: no output, exit 0.
|
|
90
|
-
for (const name of CLI_SCRIPTS) {
|
|
91
|
-
test(`${name}.mjs imported as a module does not run main()`, () => {
|
|
92
|
-
const dir = tempDir("is-cli-import-");
|
|
93
|
-
const url = pathToFileURL(join(SCRIPTS_DIR, `${name}.mjs`)).href;
|
|
94
|
-
const run = spawnSync(process.execPath, ["--input-type=module", "-e", `await import(${JSON.stringify(url)});`], { cwd: dir, encoding: "utf8" });
|
|
95
|
-
assert.equal(run.status, 0, run.stderr);
|
|
96
|
-
assert.equal(run.stdout, "");
|
|
97
|
-
assert.equal(run.stderr, "");
|
|
98
|
-
});
|
|
99
|
-
}
|
|
@@ -1,71 +0,0 @@
|
|
|
1
|
-
// Pins the rule that `docs/agents/issue-tracker.md` states nowhere else.
|
|
2
|
-
// #79: the section reproduced the issue-read command and its bare `--comments`
|
|
3
|
-
// caveat verbatim but carried neither of the (then two) WHICH-TEXT-WINS rules,
|
|
4
|
-
// so the copy read as complete while they were absent. #25 later dropped the
|
|
5
|
-
// second of those rules — the `Respec` block was instructed nowhere else and
|
|
6
|
-
// never defined, in this doc or in any real issue — leaving the
|
|
7
|
-
// brief-outranks-body rule pinned here alone.
|
|
8
|
-
//
|
|
9
|
-
// No SKILL.md instructs an agent to READ this doc as its entry point for
|
|
10
|
-
// the fetch-the-relevant-ticket rule: the rule reaches agents through three
|
|
11
|
-
// SKILL.md files that each carry their own copy — run-team word-for-word
|
|
12
|
-
// inside its verbatim implementer prompt, next-ticket and sizing-a-ticket
|
|
13
|
-
// paraphrased — not by deferring here. (run-team/SKILL.md does link this
|
|
14
|
-
// doc once, at its closing-keyword exemption — an unrelated rule, not a
|
|
15
|
-
// hand-off to this section.) #79 brought the doc into sync with those three
|
|
16
|
-
// copies; it is the catch-up copy, not their source, so this pin keeps the
|
|
17
|
-
// doc from drifting back out, nothing more.
|
|
18
|
-
//
|
|
19
|
-
// What DEPENDS on this doc is settled by MUTATION, never by grepping for
|
|
20
|
-
// `issue-tracker`: the string matches many more paths than read the doc,
|
|
21
|
-
// and a match cannot tell a mention from a dependency. Write `MUTATED` over
|
|
22
|
-
// `docs/agents/issue-tracker.md` in a scratch copy of the tree and run
|
|
23
|
-
// `node --test plugin/scripts/*.test.mjs` (every test file lives there);
|
|
24
|
-
// what reddens against that copy's own green baseline is what reads it.
|
|
25
|
-
// Measured on this commit: this file, `closing-keyword-prose.test.mjs` and
|
|
26
|
-
// `tracker-block-copy-prose.test.mjs`, no other suite. Re-run the mutation
|
|
27
|
-
// rather than trusting that list — a grep result frozen into a header is
|
|
28
|
-
// the defect #1119 names.
|
|
29
|
-
//
|
|
30
|
-
// This mutation only catches PRESENCE pins: a test asserting the doc LACKS
|
|
31
|
-
// some phrase reads `MUTATED` as still lacking it and stays green, invisible
|
|
32
|
-
// to this method. None of the three files above pins an absence today, but
|
|
33
|
-
// a future one needs a different check.
|
|
34
|
-
//
|
|
35
|
-
// The full `plugin/scripts/*.test.mjs` glob is 140+ files; a loaded machine
|
|
36
|
-
// can leave dozens uncompleted instead of green, so the "own green
|
|
37
|
-
// baseline" precondition can itself fail before the mutation ever runs.
|
|
38
|
-
// Confirm against the three files named above first — that trio settles in
|
|
39
|
-
// under a second — before trusting a run against the full glob.
|
|
40
|
-
//
|
|
41
|
-
// THE CEILING, same as fleet-tick-prose.test.mjs: this proves a phrase is
|
|
42
|
-
// PRESENT. It cannot prove it is not negated by a sentence added beside it.
|
|
43
|
-
import { test } from "node:test";
|
|
44
|
-
import assert from "node:assert/strict";
|
|
45
|
-
import { readFileSync } from "node:fs";
|
|
46
|
-
import { join } from "node:path";
|
|
47
|
-
|
|
48
|
-
const REPO = join(import.meta.dirname, "..", "..");
|
|
49
|
-
const TRACKER = readFileSync(join(REPO, "docs", "agents", "issue-tracker.md"), "utf8");
|
|
50
|
-
|
|
51
|
-
// Sliced to this section alone. Unbounded to EOF the slice runs through the
|
|
52
|
-
// wayfinding operations, and a `## Agent Brief` mention anywhere past here
|
|
53
|
-
// would satisfy the assertions with the section itself deleted. Stops at the
|
|
54
|
-
// next `#` or `##` — either one closes this section — and falls back to EOF
|
|
55
|
-
// rather than bailing, so a correct doc still passes once this is the last
|
|
56
|
-
// section. Not `indexOf("\n## ")` alone: that runs the slice through a later
|
|
57
|
-
// `# ` h1, and the rules relocated under one then read as still present.
|
|
58
|
-
function fetchSection() {
|
|
59
|
-
const start = '## When a skill says "fetch the relevant ticket"';
|
|
60
|
-
const at = TRACKER.indexOf(start);
|
|
61
|
-
assert.notEqual(at, -1, `'${start}' moved — update this test`);
|
|
62
|
-
const rest = TRACKER.slice(at + start.length);
|
|
63
|
-
const next = rest.match(/\n#{1,2} /);
|
|
64
|
-
return start + (next ? rest.slice(0, next.index) : rest);
|
|
65
|
-
}
|
|
66
|
-
|
|
67
|
-
test("the fetch section says the Agent Brief comment outranks the issue body", () => {
|
|
68
|
-
// Without it an agent that reads the documented entry point takes the body as
|
|
69
|
-
// authoritative and never learns a brief can overrule it.
|
|
70
|
-
assert.match(fetchSection(), /`## Agent Brief` comment\s+is\s+authoritative over the issue body/);
|
|
71
|
-
});
|
package/scripts/json.test.mjs
DELETED
|
@@ -1,364 +0,0 @@
|
|
|
1
|
-
// Regression gate for json.sh, the JSON-escaping library every fleet script
|
|
2
|
-
// that emits a payload now sources. Zero deps:
|
|
3
|
-
// `node --test plugin/scripts/json.test.mjs`.
|
|
4
|
-
//
|
|
5
|
-
// The library exists because the same ~40 lines were copy-pasted into
|
|
6
|
-
// inflight.sh, release-ticket.sh and no-undo-audit.sh, and every fix to the
|
|
7
|
-
// rule list had to be written out three times (five, counting jarr and
|
|
8
|
-
// jarr_rewritten). #119.
|
|
9
|
-
//
|
|
10
|
-
// The load-bearing case here is `a failing sed makes jstr report failure`.
|
|
11
|
-
// Measured on PR #425 and recorded on #119: `printf | sed | tr` returns only
|
|
12
|
-
// the LAST stage's status, so forcing `sed` to fail left jstr exiting 0 with a
|
|
13
|
-
// truncated or empty value while forcing `tr` — the actual tail — worked. A
|
|
14
|
-
// test that only forces the tail stage passes against the unfixed helper and
|
|
15
|
-
// pins nothing, which is exactly why both stages are forced below and why the
|
|
16
|
-
// sed case asserts on the OUTPUT as well as the status: an assertion that only
|
|
17
|
-
// reads the status cannot tell "the shim fired and jstr caught it" from "the
|
|
18
|
-
// shim never ran at all".
|
|
19
|
-
//
|
|
20
|
-
// Its opposite number is `a healthy call is silent and exits 0`. A guard that
|
|
21
|
-
// reports failure on a string it should have escaped fine is a different bug
|
|
22
|
-
// from the one above, not the same bug inverted, so the accept path is pinned
|
|
23
|
-
// on its own rather than left implied by the escaping table.
|
|
24
|
-
|
|
25
|
-
import { test } from "node:test";
|
|
26
|
-
import assert from "node:assert/strict";
|
|
27
|
-
import { spawnSync } from "node:child_process";
|
|
28
|
-
import { mkdtempSync, rmSync, writeFileSync } from "node:fs";
|
|
29
|
-
import { tmpdir } from "node:os";
|
|
30
|
-
import { join } from "node:path";
|
|
31
|
-
import { fileURLToPath } from "node:url";
|
|
32
|
-
import { writeExecStub } from "./exec-stub.mjs";
|
|
33
|
-
|
|
34
|
-
const LIB = fileURLToPath(new URL("./json.sh", import.meta.url));
|
|
35
|
-
|
|
36
|
-
/**
|
|
37
|
-
* Run `body` in a fresh /bin/sh that has sourced the library.
|
|
38
|
-
*
|
|
39
|
-
* No `set -e` in the driver, deliberately: these tests measure the status a
|
|
40
|
-
* helper RETURNS, and under -e a non-zero return would abort the driver before
|
|
41
|
-
* it could print that status. The scripts that source this library do run under
|
|
42
|
-
* -e; that interaction is pinned in each script's own suite, not here.
|
|
43
|
-
*
|
|
44
|
-
* `break` names a tool to shadow with a failing stub — the only way to observe
|
|
45
|
-
* a stage failing without editing the library under test.
|
|
46
|
-
*
|
|
47
|
-
* `raw` skips Node's own UTF-8 decoding of stdout, returning a Buffer instead
|
|
48
|
-
* of a string. Required for any test asserting on a raw invalid-UTF-8 byte
|
|
49
|
-
* (#613): `encoding: "utf8"` makes Node itself silently substitute U+FFFD on
|
|
50
|
-
* the way OUT, which would hide the exact bug under test — a caller (`jq`,
|
|
51
|
-
* `python3 json.load`) that does not launder the bytes first.
|
|
52
|
-
*/
|
|
53
|
-
function drive(body, { args = [], input, break: broken, raw = false } = {}) {
|
|
54
|
-
const dir = mkdtempSync(join(tmpdir(), "json-sh-"));
|
|
55
|
-
try {
|
|
56
|
-
const env = { ...process.env };
|
|
57
|
-
if (broken) {
|
|
58
|
-
const stub = join(dir, broken);
|
|
59
|
-
// Exit 1 and emit nothing — how BSD `tr` behaves on a byte that is not
|
|
60
|
-
// valid UTF-8, the real-world failure this stands in for (#582).
|
|
61
|
-
writeExecStub(stub, "#!/bin/sh\nexit 1\n");
|
|
62
|
-
env.PATH = `${dir}:${process.env.PATH}`;
|
|
63
|
-
}
|
|
64
|
-
const f = join(dir, "drive.sh");
|
|
65
|
-
writeFileSync(f, `. ${JSON.stringify(LIB)}\n${body}\n`);
|
|
66
|
-
return spawnSync("sh", [f, ...args], { env, input, encoding: raw ? "buffer" : "utf8" });
|
|
67
|
-
} finally {
|
|
68
|
-
rmSync(dir, { recursive: true, force: true });
|
|
69
|
-
}
|
|
70
|
-
}
|
|
71
|
-
|
|
72
|
-
/** Call a one-argument helper; returns {rc, out}. */
|
|
73
|
-
function call(fn, arg, opts = {}) {
|
|
74
|
-
const r = drive(`${fn} "$1"; printf '\\nRC=%s' "$?"`, { args: [arg], ...opts });
|
|
75
|
-
assert.equal(r.status, 0, `driver itself failed: ${r.stderr}`);
|
|
76
|
-
const at = r.stdout.lastIndexOf("\nRC=");
|
|
77
|
-
return { out: r.stdout.slice(0, at), rc: Number(r.stdout.slice(at + 4)) };
|
|
78
|
-
}
|
|
79
|
-
|
|
80
|
-
/** Call a stdin helper; returns {rc, out}. */
|
|
81
|
-
function pipe(fn, input, opts = {}) {
|
|
82
|
-
const r = drive(`${fn}; printf '\\nRC=%s' "$?"`, { input, ...opts });
|
|
83
|
-
assert.equal(r.status, 0, `driver itself failed: ${r.stderr}`);
|
|
84
|
-
const at = r.stdout.lastIndexOf("\nRC=");
|
|
85
|
-
return { out: r.stdout.slice(0, at), rc: Number(r.stdout.slice(at + 4)) };
|
|
86
|
-
}
|
|
87
|
-
|
|
88
|
-
// ---------------------------------------------------------------- jstr
|
|
89
|
-
|
|
90
|
-
// The escaping table. Each row is a string a fleet script can genuinely be
|
|
91
|
-
// handed — git accepts `"` in a ref, a worktree path is a filename and accepts
|
|
92
|
-
// `\` too — and the expectation is what makes `"<out>"` parse back to it.
|
|
93
|
-
const ESCAPES = [
|
|
94
|
-
["plain", "feature/ordinary-branch", "feature/ordinary-branch"],
|
|
95
|
-
["a double quote", 'evil"branch', 'evil\\"branch'],
|
|
96
|
-
["a backslash", "a\\b", "a\\\\b"],
|
|
97
|
-
["backslash before quote", '\\"', '\\\\\\"'],
|
|
98
|
-
["a tab", "a\tb", "a\\tb"],
|
|
99
|
-
["a newline", "a\nb", "a\\nb"],
|
|
100
|
-
["a carriage return", "a\rb", "a\\rb"],
|
|
101
|
-
["a backspace", "a\bb", "a\\bb"],
|
|
102
|
-
["a form feed", "a\fb", "a\\fb"],
|
|
103
|
-
["UTF-8, untouched", "brée/ünïcode", "brée/ünïcode"],
|
|
104
|
-
];
|
|
105
|
-
|
|
106
|
-
for (const [name, input, expected] of ESCAPES) {
|
|
107
|
-
test(`jstr escapes ${name}`, () => {
|
|
108
|
-
const { rc, out } = call("jstr", input);
|
|
109
|
-
assert.equal(rc, 0);
|
|
110
|
-
assert.equal(out, expected);
|
|
111
|
-
assert.equal(JSON.parse(`"${out}"`), input, "must round-trip through a real JSON parser");
|
|
112
|
-
});
|
|
113
|
-
}
|
|
114
|
-
|
|
115
|
-
test("jstr replaces a C0 byte with no JSON short form, rather than emitting it raw", () => {
|
|
116
|
-
// \013 (VT) is the example RFC 8259 does not give a short form. Emitted raw
|
|
117
|
-
// it is a control character in a JSON string, which no parser accepts.
|
|
118
|
-
const { rc, out } = call("jstr", "a\x0bb");
|
|
119
|
-
assert.equal(rc, 0);
|
|
120
|
-
assert.equal(out, "a b");
|
|
121
|
-
assert.doesNotThrow(() => JSON.parse(`"${out}"`));
|
|
122
|
-
});
|
|
123
|
-
|
|
124
|
-
test("jstr leaves DEL alone — \\177 is not a C0 byte and JSON permits it", () => {
|
|
125
|
-
const { rc, out } = call("jstr", "a\x7fb");
|
|
126
|
-
assert.equal(rc, 0);
|
|
127
|
-
assert.equal(out, "a\x7fb");
|
|
128
|
-
assert.equal(JSON.parse(`"${out}"`), "a\x7fb");
|
|
129
|
-
});
|
|
130
|
-
|
|
131
|
-
// A byte that is not valid UTF-8 at all — not merely a C0 control byte, a
|
|
132
|
-
// byte no UTF-8 sequence starts or continues with. Built as a raw Buffer
|
|
133
|
-
// rather than a JS string: `execFileSync`/`spawnSync` re-encode a JS string
|
|
134
|
-
// argv as UTF-8, so a JS `"\xFF"` (U+00FF) would arrive as the two-byte
|
|
135
|
-
// sequence \303\277 — valid UTF-8, which reproduces nothing (same pitfall
|
|
136
|
-
// no-undo-audit.test.mjs's `byteConflictRepo` comment names). Piped to stdin
|
|
137
|
-
// as a Buffer and captured inside the driven script with `$(cat)` sidesteps
|
|
138
|
-
// it: Node writes a Buffer to a child's stdin unchanged, and shell command
|
|
139
|
-
// substitution is byte-transparent.
|
|
140
|
-
const INVALID_UTF8 = Buffer.concat([Buffer.from("b"), Buffer.from([0xff]), Buffer.from("ad")]);
|
|
141
|
-
|
|
142
|
-
test("jstr replaces an invalid UTF-8 byte with U+FFFD rather than emitting it raw, and the result is valid UTF-8 JSON (#613)", () => {
|
|
143
|
-
const r = drive(`x=$(cat); jstr "$x"`, { input: INVALID_UTF8, raw: true });
|
|
144
|
-
assert.equal(r.status, 0, `driver failed: ${r.stderr}`);
|
|
145
|
-
const wrapped = Buffer.concat([Buffer.from('"'), r.stdout, Buffer.from('"')]);
|
|
146
|
-
const decoded = wrapped.toString("utf8");
|
|
147
|
-
// Strict UTF-8 validity via round-trip: Node's decoder is itself lossy —
|
|
148
|
-
// it substitutes U+FFFD for a raw invalid byte on the way IN — so
|
|
149
|
-
// re-encoding the decoded string reproduces the same bytes only when the
|
|
150
|
-
// buffer was already valid UTF-8. A raw invalid byte that jstr failed to
|
|
151
|
-
// repair shows up here as a length/content mismatch, not a thrown error.
|
|
152
|
-
assert.deepEqual(Buffer.from(decoded, "utf8"), wrapped,
|
|
153
|
-
"jstr's output is not valid UTF-8 — a raw invalid byte reached the JSON body");
|
|
154
|
-
assert.equal(JSON.parse(decoded), "b�ad",
|
|
155
|
-
"the fault must render as U+FFFD, not vanish or truncate the string");
|
|
156
|
-
});
|
|
157
|
-
|
|
158
|
-
test("a failing python3 makes jstr report failure", () => {
|
|
159
|
-
const { rc, out } = call("jstr", 'evil"branch', { break: "python3" });
|
|
160
|
-
assert.notEqual(out, 'evil\\"branch', "the python3 stub did not shadow the real python3 — this test proves nothing");
|
|
161
|
-
assert.notEqual(rc, 0);
|
|
162
|
-
});
|
|
163
|
-
|
|
164
|
-
test("jstr on an empty string is empty at exit 0, forking nothing", () => {
|
|
165
|
-
const { rc, out } = call("jstr", "");
|
|
166
|
-
assert.equal(rc, 0);
|
|
167
|
-
assert.equal(out, "");
|
|
168
|
-
});
|
|
169
|
-
|
|
170
|
-
test("jstr on an empty string survives a broken sed and tr — it never calls them", () => {
|
|
171
|
-
// The short circuit is what lets a field that legitimately found nothing stay
|
|
172
|
-
// empty during the PATH-wide tool outage inflight.sh measures at its own top:
|
|
173
|
-
// that field never runs the broken tool, so it cannot observe the failure.
|
|
174
|
-
for (const broken of ["sed", "tr", "python3"]) {
|
|
175
|
-
const { rc, out } = call("jstr", "", { break: broken });
|
|
176
|
-
assert.equal(rc, 0, `empty jstr must not fail on a broken ${broken}`);
|
|
177
|
-
assert.equal(out, "");
|
|
178
|
-
}
|
|
179
|
-
});
|
|
180
|
-
|
|
181
|
-
// ------------------------------------------------- the internal-status half
|
|
182
|
-
|
|
183
|
-
test("a failing sed makes jstr report failure", () => {
|
|
184
|
-
const { rc, out } = call("jstr", 'evil"branch', { break: "sed" });
|
|
185
|
-
// The shim really engaged: with sed working this is `evil\"branch`.
|
|
186
|
-
assert.notEqual(out, 'evil\\"branch', "the sed stub did not shadow the real sed — this test proves nothing");
|
|
187
|
-
assert.notEqual(rc, 0,
|
|
188
|
-
"jstr swallowed a failed sed. `printf | sed | tr` reports only tr's status, so the caller gets a truncated value at exit 0 and its `|| die` never fires (#119, measured on PR #425).");
|
|
189
|
-
});
|
|
190
|
-
|
|
191
|
-
test("a failing tr makes jstr report failure", () => {
|
|
192
|
-
const { rc, out } = call("jstr", 'evil"branch', { break: "tr" });
|
|
193
|
-
assert.notEqual(out, 'evil\\"branch', "the tr stub did not shadow the real tr — this test proves nothing");
|
|
194
|
-
assert.notEqual(rc, 0);
|
|
195
|
-
});
|
|
196
|
-
|
|
197
|
-
test("a healthy jstr exits 0 and is not caught by its own guard", () => {
|
|
198
|
-
// The false-positive half. The status fix above must not start refusing
|
|
199
|
-
// strings it has always escaped correctly, and every one of these is ordinary
|
|
200
|
-
// input a fleet script sees on its healthy path.
|
|
201
|
-
for (const s of ["fix/119-json-sh-extract", ".worktrees/119-json-sh-extract", "no-rebase", "npm ci", "brée", "a\tb", "x".repeat(4096)]) {
|
|
202
|
-
const { rc, out } = call("jstr", s);
|
|
203
|
-
assert.equal(rc, 0, `jstr wrongly refused ${JSON.stringify(s)}`);
|
|
204
|
-
assert.equal(JSON.parse(`"${out}"`), s);
|
|
205
|
-
}
|
|
206
|
-
});
|
|
207
|
-
|
|
208
|
-
// ---------------------------------------------------------- jrewritten
|
|
209
|
-
|
|
210
|
-
test("jrewritten is false when every byte was escaped rather than replaced", () => {
|
|
211
|
-
for (const s of ["", "plain", 'a"b', "a\\b", "a\tb", "a\nb", "a\rb", "a\bb", "a\fb", "a\x7fb"]) {
|
|
212
|
-
const { rc, out } = call("jrewritten", s);
|
|
213
|
-
assert.equal(rc, 0);
|
|
214
|
-
assert.equal(out, "false", `${JSON.stringify(s)} loses no bytes, so nothing was rewritten`);
|
|
215
|
-
}
|
|
216
|
-
});
|
|
217
|
-
|
|
218
|
-
test("jrewritten is true when a byte was replaced", () => {
|
|
219
|
-
const { rc, out } = call("jrewritten", "a\x0bb");
|
|
220
|
-
assert.equal(rc, 0);
|
|
221
|
-
assert.equal(out, "true");
|
|
222
|
-
});
|
|
223
|
-
|
|
224
|
-
test("a failing tr makes jrewritten report failure rather than a confident answer", () => {
|
|
225
|
-
// Its last line is `[ … ] && printf false || printf true`, an AND-OR list
|
|
226
|
-
// that always exits 0. Without an explicit return, bash 5.x in every mode —
|
|
227
|
-
// every distro whose /bin/sh is bash 5 — runs on to it and hands back a
|
|
228
|
-
// confident `true` about bytes nothing ever examined.
|
|
229
|
-
const { rc } = call("jrewritten", "a\x0bb", { break: "tr" });
|
|
230
|
-
assert.notEqual(rc, 0);
|
|
231
|
-
});
|
|
232
|
-
|
|
233
|
-
test("a failing python3 makes jrewritten report failure rather than a confident answer", () => {
|
|
234
|
-
// Must hold a byte >= \200 and no C0 byte — jrewritten now short-circuits
|
|
235
|
-
// to `true` on a C0 byte alone (it already has its answer) and to `false`
|
|
236
|
-
// on pure ASCII (already valid UTF-8 by construction), and neither path
|
|
237
|
-
// reaches python3 at all, so an input that hits either would pass this
|
|
238
|
-
// test against a jrewritten that never calls python3 in the first place.
|
|
239
|
-
const { rc } = call("jrewritten", "café", { break: "python3" });
|
|
240
|
-
assert.notEqual(rc, 0);
|
|
241
|
-
});
|
|
242
|
-
|
|
243
|
-
test("jrewritten is true when a byte was not valid UTF-8, not just for the C0 replacement set (#613)", () => {
|
|
244
|
-
const r = drive(`x=$(cat); jrewritten "$x"`, { input: INVALID_UTF8 });
|
|
245
|
-
assert.equal(r.status, 0, `driver failed: ${r.stderr}`);
|
|
246
|
-
assert.equal(r.stdout, "true");
|
|
247
|
-
});
|
|
248
|
-
|
|
249
|
-
test("jrewritten stays false for valid multi-byte UTF-8 under the new UTF-8 check (#613)", () => {
|
|
250
|
-
const { rc, out } = call("jrewritten", "brée/ünïcode");
|
|
251
|
-
assert.equal(rc, 0);
|
|
252
|
-
assert.equal(out, "false");
|
|
253
|
-
});
|
|
254
|
-
|
|
255
|
-
// ---------------------------------------------------------------- jarr
|
|
256
|
-
|
|
257
|
-
test("jarr emits one quoted JSON string per line, comma-joined", () => {
|
|
258
|
-
const { rc, out } = pipe("jarr", 'a\nb"c\nd\\e\n');
|
|
259
|
-
assert.equal(rc, 0);
|
|
260
|
-
assert.deepEqual(JSON.parse(`[${out}]`), ["a", 'b"c', "d\\e"]);
|
|
261
|
-
});
|
|
262
|
-
|
|
263
|
-
test("a failing sed makes jarr report failure", () => {
|
|
264
|
-
const { rc, out } = pipe("jarr", 'a\nb"c\n', { break: "sed" });
|
|
265
|
-
assert.notEqual(out, '"a","b\\"c"', "the sed stub did not shadow the real sed — this test proves nothing");
|
|
266
|
-
assert.notEqual(rc, 0,
|
|
267
|
-
"jarr swallowed a failed sed. Its `sed | tr | paste` reports only paste's status, the same mask jstr carries (#119).");
|
|
268
|
-
});
|
|
269
|
-
|
|
270
|
-
test("a failing tr makes jarr report failure", () => {
|
|
271
|
-
const { rc } = pipe("jarr", 'a\nb"c\n', { break: "tr" });
|
|
272
|
-
assert.notEqual(rc, 0);
|
|
273
|
-
});
|
|
274
|
-
|
|
275
|
-
test("a failing python3 makes jarr report failure", () => {
|
|
276
|
-
const { rc } = pipe("jarr", 'a\nb"c\n', { break: "python3" });
|
|
277
|
-
assert.notEqual(rc, 0);
|
|
278
|
-
});
|
|
279
|
-
|
|
280
|
-
test("jarr replaces an invalid UTF-8 byte with U+FFFD rather than emitting it raw, other elements untouched (#613)", () => {
|
|
281
|
-
const input = Buffer.concat([Buffer.from("plain\n"), INVALID_UTF8]);
|
|
282
|
-
const r = drive("jarr", { input, raw: true });
|
|
283
|
-
assert.equal(r.status, 0, `driver failed: ${r.stderr}`);
|
|
284
|
-
const wrapped = Buffer.concat([Buffer.from("["), r.stdout, Buffer.from("]")]);
|
|
285
|
-
const decoded = wrapped.toString("utf8");
|
|
286
|
-
assert.deepEqual(Buffer.from(decoded, "utf8"), wrapped,
|
|
287
|
-
"jarr's output is not valid UTF-8 — a raw invalid byte reached the JSON body");
|
|
288
|
-
assert.deepEqual(JSON.parse(decoded), ["plain", "b�ad"]);
|
|
289
|
-
});
|
|
290
|
-
|
|
291
|
-
test("jarr_rewritten is a parallel boolean array, last line included", () => {
|
|
292
|
-
// `read` alone drops a final line with no trailing newline, so the last
|
|
293
|
-
// element is the one that goes missing — pinned with input that has none.
|
|
294
|
-
const { rc, out } = pipe("jarr_rewritten", "plain\na\x0bb");
|
|
295
|
-
assert.equal(rc, 0);
|
|
296
|
-
assert.deepEqual(JSON.parse(`[${out}]`), [false, true]);
|
|
297
|
-
});
|
|
298
|
-
|
|
299
|
-
test("jarr_rewritten flags a line holding an invalid UTF-8 byte, not just the C0 replacement set (#613)", () => {
|
|
300
|
-
// jarr_rewritten delegates to jrewritten per line, so this pins the
|
|
301
|
-
// delegation carries the new check rather than re-testing jrewritten itself.
|
|
302
|
-
const input = Buffer.concat([Buffer.from("plain\n"), INVALID_UTF8]);
|
|
303
|
-
const r = drive("jarr_rewritten", { input });
|
|
304
|
-
assert.equal(r.status, 0, `driver failed: ${r.stderr}`);
|
|
305
|
-
assert.deepEqual(JSON.parse(`[${r.stdout}]`), [false, true]);
|
|
306
|
-
});
|
|
307
|
-
|
|
308
|
-
test("a failing tr makes jarr_rewritten report failure, not a short array", () => {
|
|
309
|
-
// Its own last stage is `paste`, which exits 0 on whatever the aborted loop
|
|
310
|
-
// managed to hand it. Without the `|| exit 1` inside the loop and the
|
|
311
|
-
// `|| return 1` on the capture, a broken `tr` yields a SHORTER boolean array
|
|
312
|
-
// than the string array it is supposed to parallel — and the caller has no
|
|
313
|
-
// way to notice, because the two are emitted as separate JSON fields.
|
|
314
|
-
const { rc } = pipe("jarr_rewritten", "plain\na\x0bb\n", { break: "tr" });
|
|
315
|
-
assert.notEqual(rc, 0);
|
|
316
|
-
});
|
|
317
|
-
|
|
318
|
-
test("jarr keeps a trailing empty element — the same input must yield the same length as jarr_rewritten's parallel array (#613 regression)", () => {
|
|
319
|
-
// The #613 UTF-8 repair stage captured python3's output through `$()`,
|
|
320
|
-
// which strips ALL trailing newlines before jarr's own blank-line-sensitive
|
|
321
|
-
// sed/paste stages ever saw them — silently dropping trailing empty array
|
|
322
|
-
// elements. `jarr_rewritten` reads stdin line-by-line, not through a
|
|
323
|
-
// capture, so it did NOT drop them: the two arrays desynced in length,
|
|
324
|
-
// breaking the "parallel boolean array to jarr's own output" invariant
|
|
325
|
-
// both are documented to hold. Pinned here so the LENGTH match — not just
|
|
326
|
-
// the content of either array alone — is what future edits are checked
|
|
327
|
-
// against.
|
|
328
|
-
const input = "a\n\n";
|
|
329
|
-
const { rc: rc1, out: out1 } = pipe("jarr", input);
|
|
330
|
-
const { rc: rc2, out: out2 } = pipe("jarr_rewritten", input);
|
|
331
|
-
assert.equal(rc1, 0);
|
|
332
|
-
assert.equal(rc2, 0);
|
|
333
|
-
const arr1 = JSON.parse(`[${out1}]`);
|
|
334
|
-
const arr2 = JSON.parse(`[${out2}]`);
|
|
335
|
-
assert.equal(arr1.length, arr2.length,
|
|
336
|
-
`jarr produced ${arr1.length} elements but jarr_rewritten produced ${arr2.length} for the same input`);
|
|
337
|
-
assert.deepEqual(arr1, ["a", ""]);
|
|
338
|
-
assert.deepEqual(arr2, [false, false]);
|
|
339
|
-
});
|
|
340
|
-
|
|
341
|
-
test("jarr on stdin holding only a newline is a proper one-element array, not indistinguishable from zero elements (#613 regression)", () => {
|
|
342
|
-
// Same root cause as the test above: `$()` stripping the python3 stage's
|
|
343
|
-
// only trailing newline turned `[""]` (one element, an empty string) into
|
|
344
|
-
// empty output — the same shape as `jarr` on genuinely empty stdin, a
|
|
345
|
-
// distinction this file's header and the empty-stdin test below both
|
|
346
|
-
// guard explicitly.
|
|
347
|
-
const { rc, out } = pipe("jarr", "\n");
|
|
348
|
-
assert.equal(rc, 0);
|
|
349
|
-
assert.deepEqual(JSON.parse(`[${out}]`), [""]);
|
|
350
|
-
});
|
|
351
|
-
|
|
352
|
-
test("jarr on empty stdin is empty, not a one-element array holding nothing", () => {
|
|
353
|
-
// The original `sed | tr | paste` emitted nothing at all on empty input
|
|
354
|
-
// (measured). Splitting the pipeline to read each stage's status introduced a
|
|
355
|
-
// `printf '%s\n'` re-emit that would turn "no elements" into one empty line,
|
|
356
|
-
// and `paste` would answer `""` — inventing an element. The `[ -n ]` guard is
|
|
357
|
-
// what preserves the original answer.
|
|
358
|
-
const { rc, out } = pipe("jarr", "");
|
|
359
|
-
assert.equal(rc, 0);
|
|
360
|
-
assert.equal(out, "", "empty in, empty out — `[]` and `[\"\"]` are different answers");
|
|
361
|
-
const { rc: rc2, out: out2 } = pipe("jarr_rewritten", "");
|
|
362
|
-
assert.equal(rc2, 0);
|
|
363
|
-
assert.equal(out2, "");
|
|
364
|
-
});
|