@feigi/fleet-ctl 3.23.36 → 3.23.37
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/package.json +1 -1
- package/scripts/main-checkout.mjs +1 -1
- package/scripts/member-write-guard.mjs +1 -1
- package/scripts/repo-root.mjs +1 -1
- package/skills/run-team/references/reaping.md +1 -1
- package/scripts/agent-test-dir-prose.test.mjs +0 -59
- package/scripts/agent-test.test.mjs +0 -1640
- package/scripts/ambient-git-vars-mjs-prose.test.mjs +0 -397
- package/scripts/ambient-git-vars-prose.test.mjs +0 -192
- package/scripts/ancestry-check-position-prose.test.mjs +0 -175
- package/scripts/apply-ruleset.test.mjs +0 -421
- package/scripts/arg-header-probes-prose.test.mjs +0 -394
- package/scripts/arg.test.mjs +0 -1354
- package/scripts/board-cli.test.mjs +0 -710
- package/scripts/board-identity.test.mjs +0 -429
- package/scripts/board-liveness-banner.test.mjs +0 -119
- package/scripts/board-prev-shape.test.mjs +0 -228
- package/scripts/board-tryparse-null.test.mjs +0 -119
- package/scripts/board.test.mjs +0 -3121
- package/scripts/brief-after-cut-prose.test.mjs +0 -53
- package/scripts/candidates-exit3-prose.test.mjs +0 -302
- package/scripts/candidates.test.mjs +0 -2312
- package/scripts/caveat-unification-prose.test.mjs +0 -98
- package/scripts/cell-readout.test.mjs +0 -615
- package/scripts/ci-comment-rot-prose.test.mjs +0 -2025
- package/scripts/ci-completes-premise-prose.test.mjs +0 -257
- package/scripts/ci-state-prose.test.mjs +0 -113
- package/scripts/ci-state.test.mjs +0 -1933
- package/scripts/ci-vacuous-green.test.mjs +0 -368
- package/scripts/citation-sweep-prose.test.mjs +0 -1712
- package/scripts/claim-lifecycle.test.mjs +0 -187
- package/scripts/claim-ticket.test.mjs +0 -1122
- package/scripts/closing-keyword-prose.test.mjs +0 -193
- package/scripts/cockpit-launch-idempotent-prose.test.mjs +0 -165
- package/scripts/cockpit-tick-nonblocking.test.mjs +0 -210
- package/scripts/compute-board.test.mjs +0 -1214
- package/scripts/compute-spend.test.mjs +0 -517
- package/scripts/consumer-technology-prose.test.mjs +0 -126
- package/scripts/cross-repo-citation-prose.test.mjs +0 -155
- package/scripts/cwd-isolation-pins.mjs +0 -83
- package/scripts/dedupe-guard-prose.test.mjs +0 -243
- package/scripts/delete-merged-branch.test.mjs +0 -576
- package/scripts/derive-testcmd.test.mjs +0 -595
- package/scripts/diff-stats.test.mjs +0 -404
- package/scripts/dispatch-block-golden-prose.test.mjs +0 -1130
- package/scripts/dispatch-block-pins-prose.test.mjs +0 -615
- package/scripts/dispositions-check.test.mjs +0 -936
- package/scripts/dispositions-gate-prose.test.mjs +0 -129
- package/scripts/drop-merged-label.test.mjs +0 -479
- package/scripts/exec-stub.mjs +0 -93
- package/scripts/exec-stub.test.mjs +0 -69
- package/scripts/expected-jobs-prose.test.mjs +0 -80
- package/scripts/fan-out-authorization-prose.test.mjs +0 -80
- package/scripts/filing-bar-seat-prose.test.mjs +0 -242
- package/scripts/filing-claim-bar-prose.test.mjs +0 -166
- package/scripts/finisher-died-prose.test.mjs +0 -31
- package/scripts/finisher-dispatch-premise-prose.test.mjs +0 -312
- package/scripts/finisher-halt-prose.test.mjs +0 -106
- package/scripts/finisher-name-prose.test.mjs +0 -134
- package/scripts/finisher-own-tree-prose.test.mjs +0 -299
- package/scripts/finisher-pin-race-prose.test.mjs +0 -339
- package/scripts/finisher-test-verdict-prose.test.mjs +0 -102
- package/scripts/fix-applier-correction-rules-prose.test.mjs +0 -202
- package/scripts/fix-applier-result-file-prose.test.mjs +0 -149
- package/scripts/fleet-bootstrap.test.mjs +0 -75
- package/scripts/fleet-heartbeat.test.mjs +0 -450
- package/scripts/fleet-provenance.test.mjs +0 -138
- package/scripts/fleet-run.test.mjs +0 -90
- package/scripts/fleet-state.test.mjs +0 -460
- package/scripts/fleet-tick-prose.test.mjs +0 -300
- package/scripts/fleet-tick.test.mjs +0 -2444
- package/scripts/force-with-lease-reason-prose.test.mjs +0 -184
- package/scripts/frontmatter-check.test.mjs +0 -436
- package/scripts/git-env.test.mjs +0 -149
- package/scripts/git-status-untracked-mode-sweep.test.mjs +0 -216
- package/scripts/gone-walk.test.mjs +0 -213
- package/scripts/gp-sep-invariant-prose.test.mjs +0 -188
- package/scripts/head-moved-after-label-prose.test.mjs +0 -233
- package/scripts/immutable-body-claim-prose.test.mjs +0 -204
- package/scripts/implementer-model-tier.test.mjs +0 -235
- package/scripts/inflight-citation-prose.test.mjs +0 -144
- package/scripts/inflight-exit2-prose.test.mjs +0 -81
- package/scripts/inflight-probe-guard-prose.test.mjs +0 -109
- package/scripts/inflight-scan-scope-prose.test.mjs +0 -57
- package/scripts/inflight.test.mjs +0 -2882
- package/scripts/injection-control-prose.test.mjs +0 -404
- package/scripts/install-root-audit.test.mjs +0 -464
- package/scripts/instrument-check-prose.test.mjs +0 -235
- package/scripts/instruments.test.mjs +0 -787
- package/scripts/is-cli.test.mjs +0 -99
- package/scripts/issue-tracker-prose.test.mjs +0 -71
- package/scripts/json.test.mjs +0 -364
- package/scripts/ledger-dispatch.test.mjs +0 -927
- package/scripts/ledger-grammar.test.mjs +0 -227
- package/scripts/ledger-read-require-file.test.mjs +0 -197
- package/scripts/ledger-rotate.test.mjs +0 -142
- package/scripts/ledger.test.mjs +0 -3436
- package/scripts/line-distance-prose.test.mjs +0 -245
- package/scripts/liveness-rationale-prose.test.mjs +0 -83
- package/scripts/locale-pin-prose.test.mjs +0 -189
- package/scripts/main-checkout.test.mjs +0 -332
- package/scripts/member-outcome-prose.test.mjs +0 -167
- package/scripts/member-outcomes-header.test.mjs +0 -129
- package/scripts/member-outcomes-prose.test.mjs +0 -63
- package/scripts/member-outcomes.test.mjs +0 -638
- package/scripts/member-prompt-prose.test.mjs +0 -165
- package/scripts/member-record.test.mjs +0 -541
- package/scripts/member-write-guard.test.mjs +0 -214
- package/scripts/merge-commit-probe-prose.test.mjs +0 -122
- package/scripts/merge-gate.test.mjs +0 -613
- package/scripts/muted-git-guard-sweep.test.mjs +0 -493
- package/scripts/net-ssh-precedence-prose.test.mjs +0 -91
- package/scripts/net-watchdog-prose.test.mjs +0 -79
- package/scripts/net.test.mjs +0 -211
- package/scripts/no-ci-gate-prose.test.mjs +0 -108
- package/scripts/no-undo-audit.test.mjs +0 -3961
- package/scripts/no-wave.test.mjs +0 -138
- package/scripts/node-floor-sweep.test.mjs +0 -611
- package/scripts/pointer-target-prose.test.mjs +0 -186
- package/scripts/pr-cost.test.mjs +0 -521
- package/scripts/pr-overlap.test.mjs +0 -692
- package/scripts/printf-die-sweep.test.mjs +0 -384
- package/scripts/prompt-renderer.mjs +0 -40
- package/scripts/prompt-renderer.test.mjs +0 -68
- package/scripts/prose-pin.mjs +0 -807
- package/scripts/prose-pin.test.mjs +0 -1034
- package/scripts/prove-merge.test.mjs +0 -995
- package/scripts/pull-table-relabel-prose.test.mjs +0 -60
- package/scripts/quiet-payload-prose.test.mjs +0 -222
- package/scripts/reap-cherry-check-prose.test.mjs +0 -80
- package/scripts/reap.test.mjs +0 -4432
- package/scripts/reaping-prose.test.mjs +0 -239
- package/scripts/reaping-reap-authorizers-prose.test.mjs +0 -112
- package/scripts/reaping-release-authorizers-prose.test.mjs +0 -85
- package/scripts/recipe-derivation-prose.test.mjs +0 -112
- package/scripts/recipe-prove.test.mjs +0 -1042
- package/scripts/refuter-scratch-prose.test.mjs +0 -135
- package/scripts/release-label-required-prose.test.mjs +0 -71
- package/scripts/release-label-split-prose.test.mjs +0 -184
- package/scripts/release-ticket-reap-pairing-prose.test.mjs +0 -63
- package/scripts/release-ticket.test.mjs +0 -5099
- package/scripts/renovate-release-contract.test.mjs +0 -379
- package/scripts/repo-root.test.mjs +0 -873
- package/scripts/reporter-output-rule-prose.test.mjs +0 -208
- package/scripts/review-agent-report-only.test.mjs +0 -49
- package/scripts/review-core-booking.test.mjs +0 -35
- package/scripts/review-core-cwd-isolation.test.mjs +0 -374
- package/scripts/review-core-reads.test.mjs +0 -478
- package/scripts/review-core-refuter-scratch.test.mjs +0 -148
- package/scripts/review-core-scratch-refusal.test.mjs +0 -64
- package/scripts/review-core-shared-test-run.test.mjs +0 -275
- package/scripts/review-core-snapshot-path.test.mjs +0 -830
- package/scripts/review-core-specialist-scratch.test.mjs +0 -191
- package/scripts/review-core-testcmd.test.mjs +0 -335
- package/scripts/review-core-unrun.test.mjs +0 -566
- package/scripts/review-core-unverified-discriminant.test.mjs +0 -208
- package/scripts/review-eval-resolver-path.test.mjs +0 -55
- package/scripts/review-host-fixture.mjs +0 -89
- package/scripts/review-in-run-retry.test.mjs +0 -211
- package/scripts/review-no-vendor-dispatch.test.mjs +0 -45
- package/scripts/review-path-default.test.mjs +0 -796
- package/scripts/review-runner-spawns.test.mjs +0 -95
- package/scripts/review-runner.test.mjs +0 -166
- package/scripts/review-tier-audit.test.mjs +0 -140
- package/scripts/run-artifact-pr-prose.test.mjs +0 -341
- package/scripts/run-merge-bot-prose.test.mjs +0 -1413
- package/scripts/run-team-local-hook.test.mjs +0 -442
- package/scripts/scratch-partition-invariant-prose.test.mjs +0 -74
- package/scripts/scripts-path-citation-sweep.test.mjs +0 -73
- package/scripts/section-between-guard-prose.test.mjs +0 -379
- package/scripts/select-dimensions.test.mjs +0 -674
- package/scripts/shared-refusal.test.mjs +0 -388
- package/scripts/shell-traps-prose.test.mjs +0 -504
- package/scripts/shortlist.test.mjs +0 -380
- package/scripts/slow-transport.mjs +0 -72
- package/scripts/snapshot-repo.test.mjs +0 -1006
- package/scripts/snapshot-runner-audience-prose.test.mjs +0 -130
- package/scripts/spend-view.test.mjs +0 -312
- package/scripts/staleness-qualifier-prose.test.mjs +0 -251
- package/scripts/staleness-verdict-prose.test.mjs +0 -142
- package/scripts/staleness.test.mjs +0 -893
- package/scripts/stalled-member-liveness-prose.test.mjs +0 -219
- package/scripts/stash-prohibition-prose.test.mjs +0 -313
- package/scripts/strip-comments.mjs +0 -44
- package/scripts/temp-dir.mjs +0 -47
- package/scripts/ticket-router.test.mjs +0 -981
- package/scripts/tier-check.test.mjs +0 -828
- package/scripts/tier-outcomes-header.test.mjs +0 -518
- package/scripts/tier-outcomes.test.mjs +0 -572
- package/scripts/tier-roles.test.mjs +0 -535
- package/scripts/tracker-block-copy-prose.test.mjs +0 -288
- package/scripts/triage-labels-gloss-prose.test.mjs +0 -97
- package/scripts/unattended-git-sweep.test.mjs +0 -142
- package/scripts/verify-sha-exit2-prose.test.mjs +0 -269
- package/scripts/verify-sha.test.mjs +0 -692
- package/scripts/watcher-degraded-block.test.mjs +0 -369
- package/scripts/watcher-key-prose.test.mjs +0 -106
- package/scripts/within-run-pair-prose.test.mjs +0 -212
- package/scripts/worktree-audit.test.mjs +0 -1408
- package/scripts/worktree-head-prose.test.mjs +0 -276
- package/scripts/worktree-listing-sweep.test.mjs +0 -217
- package/scripts/worktree-model-prose.test.mjs +0 -216
- package/scripts/worktree-porcelain.mjs +0 -35
- package/scripts/worktree-porcelain.test.mjs +0 -102
|
@@ -1,2025 +0,0 @@
|
|
|
1
|
-
// #348. Three claims in `.github/workflows/ci.yml`'s comments went stale
|
|
2
|
-
// against the tree they describe, and nothing here noticed:
|
|
3
|
-
// - the Shellcheck comment named two info-level hits and called them the only
|
|
4
|
-
// ones, then told the next maintainer to raise the gate "after silencing
|
|
5
|
-
// those two";
|
|
6
|
-
// - the Tests comment sized `scripts/` in flat files;
|
|
7
|
-
// - the same paragraph put quotation marks around a sentence it attributed to
|
|
8
|
-
// `claim-ticket.sh`, and the quoted words were not that file's words.
|
|
9
|
-
//
|
|
10
|
-
// All three share one shape: prose that pins a measurable property of a file it
|
|
11
|
-
// does not own. The fixes are the two durable forms — delete the measurement
|
|
12
|
-
// where it carries no argument, and anchor the quotation on text that has to
|
|
13
|
-
// still exist. This file is what keeps them that way.
|
|
14
|
-
//
|
|
15
|
-
// What it deliberately does NOT do is pin any count. `run-team`'s tier
|
|
16
|
-
// paragraph learned that in PR #554: a pin coupling prose to a moving figure
|
|
17
|
-
// goes red on every legitimate edit, so it gets deleted or routed around. The
|
|
18
|
-
// Shellcheck assertion below bans the exhaustive FORM, not any number, and the
|
|
19
|
-
// citation assertion accepts a paraphrase — dropping the quotation marks is one
|
|
20
|
-
// of the two fixes #348 named, so a test that refused it would refuse the fix.
|
|
21
|
-
|
|
22
|
-
import { test } from "node:test";
|
|
23
|
-
import assert from "node:assert/strict";
|
|
24
|
-
import { readFileSync } from "node:fs";
|
|
25
|
-
import { fileURLToPath } from "node:url";
|
|
26
|
-
import { sentences } from "./prose-pin.mjs";
|
|
27
|
-
|
|
28
|
-
const read = (rel) => readFileSync(fileURLToPath(new URL(rel, import.meta.url)), "utf8");
|
|
29
|
-
|
|
30
|
-
// Comment prose only, wrap-invisible. Every claim below spans a hard wrap, so a
|
|
31
|
-
// fragment only matches once the `#` markers and the line breaks are gone —
|
|
32
|
-
// same convention as the other *-prose tests. A comment line is one whose
|
|
33
|
-
// FIRST non-space character is `#` — which excludes a trailing `# …` on a code
|
|
34
|
-
// line and a `#` inside a `run:` string alike, and sweeps in the whole-line
|
|
35
|
-
// shell comments inside `run:` blocks. Prose meant to be pinned here therefore
|
|
36
|
-
// has to live in a whole-line comment.
|
|
37
|
-
const prose = (src) =>
|
|
38
|
-
src
|
|
39
|
-
.split("\n")
|
|
40
|
-
.filter((l) => /^\s*#/.test(l))
|
|
41
|
-
.map((l) => l.replace(/^\s*#\s?/, ""))
|
|
42
|
-
.join(" ")
|
|
43
|
-
.replace(/\s+/g, " ");
|
|
44
|
-
|
|
45
|
-
const CI = prose(read("../../.github/workflows/ci.yml"));
|
|
46
|
-
// The vendored-tree sentence moved with the runner it describes: the `find`
|
|
47
|
-
// walk left claim-ticket.sh's emitter for the repo-local `agent-test` (ADR
|
|
48
|
-
// 0015), so that file is the one ci.yml has to quote.
|
|
49
|
-
const RUNNER = prose(read("../../agent-test"));
|
|
50
|
-
|
|
51
|
-
/**
|
|
52
|
-
* The citation rule, as a function so the accept case can be fed input this
|
|
53
|
-
* repo does not contain. Returns null when the pair is sound, else the reason.
|
|
54
|
-
*/
|
|
55
|
-
export function citationFault(citing, cited) {
|
|
56
|
-
if (!citing.includes("agent-test")) {
|
|
57
|
-
return "ci.yml no longer names agent-test — the vendored-tree argument lost the source it rests on";
|
|
58
|
-
}
|
|
59
|
-
// The citing SENTENCE, and EVERY quoted span in it. Two separate traps.
|
|
60
|
-
// Scanning unbounded (`[^"]*"([^"]+)"`) runs to the next quote anywhere later
|
|
61
|
-
// in the prose, so the moment the citation is paraphrased — one of the two
|
|
62
|
-
// fixes #348 sanctions — the rule re-attaches to an unrelated quoted phrase
|
|
63
|
-
// further down ci.yml and demands agent-test contain that. Taking only
|
|
64
|
-
// the FIRST span is the silent direction: an aside that does quote the file
|
|
65
|
-
// stands in front of a misquote and absorbs the whole check.
|
|
66
|
-
//
|
|
67
|
-
// The sentence runs from the name to its real end as sentences() finds it,
|
|
68
|
-
// never to the first period: "e.g.", "ci.yml" and a period inside the
|
|
69
|
-
// quotation itself each came before the quoted span, cut the sentence short
|
|
70
|
-
// of it, and let a misquote read as a paraphrase (#1898). Quoted spans are
|
|
71
|
-
// blanked to same-length filler before splitting — straight quotes are
|
|
72
|
-
// assumed to come in proper, non-empty pairs, and the check below refuses a
|
|
73
|
-
// citing sentence where they don't — so a period inside a quotation can't
|
|
74
|
-
// end the sentence, and the cut lands at the same offset in the real text.
|
|
75
|
-
// That holds for a quotation's closing period too (`…out." Next`): the
|
|
76
|
-
// sentence then runs on to the next real end, which can only add spans to
|
|
77
|
-
// check — the loud direction. Ending it at the closing mark instead would
|
|
78
|
-
// also end `says "…out." and adds "…"` before its second quotation, unread.
|
|
79
|
-
// Parenthesized spans are blanked the same way, after the quoted ones: since
|
|
80
|
-
// #1940 sentences() ends a sentence at a closing mark behind a terminator, so
|
|
81
|
-
// a whole sentence in parentheses between the name and its quotation
|
|
82
|
-
// (`agent-test (as it says.) says "…"`) would otherwise end the citing
|
|
83
|
-
// sentence at its `.)` and hide the quotation — the short direction here.
|
|
84
|
-
// A bold `.**`, an underscore-italic `._`, or a single-quoted `.'` still
|
|
85
|
-
// ends it unblanked: ci.yml's comments are not markdown, and a straight
|
|
86
|
-
// single quote there is an apostrophe as often as not, so neither is a
|
|
87
|
-
// reliably paired delimiter worth chasing. Curly quotes ARE reliably
|
|
88
|
-
// paired (an opener and a closer are different characters, unlike a
|
|
89
|
-
// straight quote or `*`/`_`), so they get the same blanking as a straight
|
|
90
|
-
// quotation — left out of a first pass here would have been the same
|
|
91
|
-
// silent gap the parenthesis fix above closes, just spelled `.”`/`.’`.
|
|
92
|
-
// The early return above is what keeps indexOf off -1.
|
|
93
|
-
const from = citing.slice(citing.indexOf("agent-test"));
|
|
94
|
-
const blankQuotes = (s) =>
|
|
95
|
-
s
|
|
96
|
-
.replace(/"[^"]+"/g, (span) => `"${"x".repeat(span.length - 2)}"`)
|
|
97
|
-
.replace(/\u201c[^\u201d]+\u201d/g, (span) => `\u201c${"x".repeat(span.length - 2)}\u201d`)
|
|
98
|
-
.replace(/\u2018[^\u2019]+\u2019/g, (span) => `\u2018${"x".repeat(span.length - 2)}\u2019`);
|
|
99
|
-
// UTF-16 units, not code points (`[...s]`): the cut below measures in units,
|
|
100
|
-
// and an astral character blanked to one "x" left the real sentence a unit
|
|
101
|
-
// short per character (#1999).
|
|
102
|
-
const blankParens = (s) => {
|
|
103
|
-
let depth = 0;
|
|
104
|
-
return s
|
|
105
|
-
.split("")
|
|
106
|
-
.map((ch) => {
|
|
107
|
-
if (ch === "(") return depth++, ch;
|
|
108
|
-
if (ch === ")") return (depth = Math.max(depth - 1, 0)), ch;
|
|
109
|
-
return depth > 0 ? "x" : ch;
|
|
110
|
-
})
|
|
111
|
-
.join("");
|
|
112
|
-
};
|
|
113
|
-
// A single regex pass (`/\([^()]*\)/g`) only strips the INNERMOST paren:
|
|
114
|
-
// nested parens (`(as it says itself (in section 2).)`) leave the outer
|
|
115
|
-
// `)` — and the real period right before it — untouched, so the outer
|
|
116
|
-
// `.)` still ends the sentence early and hides a misquote past it
|
|
117
|
-
// (measured: a regex pass here let a misquote inside a nested aside read
|
|
118
|
-
// as a paraphrase). `blankParens` tracks depth across the WHOLE string
|
|
119
|
-
// instead: every character between any `(` and its matching `)` is
|
|
120
|
-
// blanked regardless of nesting, while depth returns to 0 between two
|
|
121
|
-
// SEPARATE (non-nested) parenthetical asides, so real prose sitting
|
|
122
|
-
// between them is not swept in with them.
|
|
123
|
-
const opaque = blankParens(blankQuotes(from));
|
|
124
|
-
const sentence = from.slice(0, sentences(opaque)[0].length);
|
|
125
|
-
// Straight quotes pair by position alone — opener and closer are the same
|
|
126
|
-
// character — so an empty `""` (never a span to either regex), a stray
|
|
127
|
-
// unpaired `"`, or a backslash "escape" (none exists in a YAML `#`
|
|
128
|
-
// comment) shifts the pairing of every quote after it: the real quotation
|
|
129
|
-
// then pairs with its neighbours' gaps and a misquote reads as a
|
|
130
|
-
// paraphrase (#1962). Which words the sentence quotes is then unknowable,
|
|
131
|
-
// so it is refused, never taken for a paraphrase.
|
|
132
|
-
//
|
|
133
|
-
// An odd count only catches the shift while the sentence still ends where
|
|
134
|
-
// it really does. The shifted pairing can blank the citing sentence's own
|
|
135
|
-
// terminator (`node". The install"` is one span), running `sentence` on
|
|
136
|
-
// into later ci.yml prose until the count is even again (#2013) — or
|
|
137
|
-
// expose a period inside the real quotation and end it early, or nest
|
|
138
|
-
// quotes unescaped; every one of those pairs evenly. What gives all of
|
|
139
|
-
// them away is which side of its word each mark sits on: a shift makes a
|
|
140
|
-
// real closing mark open a span and a real opening mark close one. So
|
|
141
|
-
// every span must open with a mark that can open and close with one that
|
|
142
|
-
// can close, by CommonMark's flanking rule — an opener not followed by
|
|
143
|
-
// whitespace, nor by punctuation unless whitespace or punctuation precedes
|
|
144
|
-
// it; a closer the mirror image. A mark glued to a word on BOTH sides
|
|
145
|
-
// (`don"t`, `x"this`) can play either role, so a shift through one is
|
|
146
|
-
// still out of reach; every span it produces is still checked below.
|
|
147
|
-
// `from` indexes by UTF-16 unit, so a neighbour outside the BMP (an
|
|
148
|
-
// astral symbol — many emoji are `\p{S}`) is split across two units, and
|
|
149
|
-
// testing `\p{P}`/`\p{S}` against just the half next to the mark never
|
|
150
|
-
// matches even though the whole code point does — the same trap #1999
|
|
151
|
-
// fixed for blankParens's length, here for the flanking read. `at`
|
|
152
|
-
// reassembles the pair regardless of which half sits next to the mark.
|
|
153
|
-
const isHighSurrogate = (ch) => ch !== undefined && ch >= "\uD800" && ch <= "\uDBFF";
|
|
154
|
-
const isLowSurrogate = (ch) => ch !== undefined && ch >= "\uDC00" && ch <= "\uDFFF";
|
|
155
|
-
const at = (i) => {
|
|
156
|
-
const ch = from[i];
|
|
157
|
-
if (ch === undefined) return " ";
|
|
158
|
-
if (isHighSurrogate(ch) && isLowSurrogate(from[i + 1])) return ch + from[i + 1];
|
|
159
|
-
if (isLowSurrogate(ch) && isHighSurrogate(from[i - 1])) return from[i - 1] + ch;
|
|
160
|
-
return ch;
|
|
161
|
-
};
|
|
162
|
-
const space = (ch) => /\s/.test(ch);
|
|
163
|
-
const punct = (ch) => /[\p{P}\p{S}]/u.test(ch);
|
|
164
|
-
const canOpen = (i) => !space(at(i + 1)) && (!punct(at(i + 1)) || space(at(i - 1)) || punct(at(i - 1)));
|
|
165
|
-
const canClose = (i) => !space(at(i - 1)) && (!punct(at(i - 1)) || space(at(i + 1)) || punct(at(i + 1)));
|
|
166
|
-
const spans = [...sentence.matchAll(/"([^"]+)"/g)];
|
|
167
|
-
const malformed = sentence.includes('""')
|
|
168
|
-
? 'an empty ""'
|
|
169
|
-
: sentence.includes('\\"')
|
|
170
|
-
? 'a backslash-escaped \\"'
|
|
171
|
-
: sentence.split('"').length % 2 === 0
|
|
172
|
-
? 'an unpaired "'
|
|
173
|
-
: spans.some((m) => !canOpen(m.index) || !canClose(m.index + m[0].length - 1))
|
|
174
|
-
? 'a mis-paired " (a mark opening or closing a span from the wrong side of its word)'
|
|
175
|
-
: null;
|
|
176
|
-
if (malformed) {
|
|
177
|
-
return `ci.yml's sentence citing agent-test has ${malformed}, so which words it quotes is ambiguous — pair every quotation mark, or paraphrase`;
|
|
178
|
-
}
|
|
179
|
-
// No quoted span at all is a paraphrase: nothing claims to be verbatim, and
|
|
180
|
-
// dropping the quotation marks is the other of the two fixes #348 sanctions.
|
|
181
|
-
for (const [, quoted] of spans) {
|
|
182
|
-
if (!cited.includes(quoted)) {
|
|
183
|
-
return `ci.yml quotes agent-test as saying "${quoted}", and that file does not say it`;
|
|
184
|
-
}
|
|
185
|
-
}
|
|
186
|
-
return null;
|
|
187
|
-
}
|
|
188
|
-
|
|
189
|
-
test("ci.yml's quotation of agent-test is that file's own words", () => {
|
|
190
|
-
assert.equal(citationFault(CI, RUNNER), null);
|
|
191
|
-
});
|
|
192
|
-
|
|
193
|
-
// The other half. A guard that only ever sees the one input this tree holds
|
|
194
|
-
// pins nothing about what it REFUSES, and #348's own fix section offered two
|
|
195
|
-
// remedies — fix the words, or drop the quotation marks and paraphrase. The
|
|
196
|
-
// second one has no quoted span at all, so a rule keyed on finding one would
|
|
197
|
-
// red on a sanctioned fix.
|
|
198
|
-
test("a paraphrase is accepted; a deleted citation and a misquote are not", () => {
|
|
199
|
-
const cited = "so this walk, not node, is what keeps vendored tests out.";
|
|
200
|
-
|
|
201
|
-
assert.equal(citationFault('see agent-test, which says so itself: "walk, not node"', cited), null);
|
|
202
|
-
assert.equal(citationFault("agent-test makes the same point about its own walk", cited), null);
|
|
203
|
-
|
|
204
|
-
assert.match(citationFault("the find in the emitted runner is what does it", cited), /no longer names/);
|
|
205
|
-
assert.match(citationFault('agent-test says: "this filter, not node"', cited), /does not say it/);
|
|
206
|
-
});
|
|
207
|
-
|
|
208
|
-
// #1898. The citing sentence used to end at the FIRST period after the name, so
|
|
209
|
-
// a period that ends no sentence cut it short of its quotation: an abbreviation
|
|
210
|
-
// ("e.g.", or any other sentences() skips), a period inside a word ("ci.yml",
|
|
211
|
-
// "v1.2"), or a period inside the quoted span itself. The quotation then fell
|
|
212
|
-
// outside the sentence, and the misquote read as a paraphrase — the silent
|
|
213
|
-
// direction. Each input below is the misquote the test above refuses.
|
|
214
|
-
test("an abbreviation sentences() exempts, mid-word, in-quotation, or quote/paren-closing period cannot hide a misquote from citationFault (#1898)", () => {
|
|
215
|
-
const cited = "so this walk, not node, is what keeps vendored tests out.";
|
|
216
|
-
|
|
217
|
-
for (const abbr of ["e.g.", "i.e.", "cf.", "viz.", "vs."]) {
|
|
218
|
-
assert.match(
|
|
219
|
-
citationFault(`agent-test says, ${abbr} "this filter, not node"`, cited),
|
|
220
|
-
/does not say it/,
|
|
221
|
-
`${abbr} ended the citing sentence before its quotation`,
|
|
222
|
-
);
|
|
223
|
-
}
|
|
224
|
-
assert.match(citationFault('agent-test, unlike ci.yml (v1.2), says "this filter, not node"', cited), /does not say it/);
|
|
225
|
-
assert.match(citationFault('agent-test says "this filter. Not node"', cited), /does not say it/);
|
|
226
|
-
assert.match(citationFault('agent-test says "this filter, not node."', cited), /does not say it/);
|
|
227
|
-
// A quotation's own closing period is not a stop either: an implementation that
|
|
228
|
-
// ended the sentence right there — reasonable-looking, since the quote already
|
|
229
|
-
// carries its own terminator — would silently let a second, misquoted span right
|
|
230
|
-
// after it hide as though it were the next sentence this function's own comment
|
|
231
|
-
// says it may not answer for (verified: such an implementation passes every
|
|
232
|
-
// other assertion in this file and still accepts this one).
|
|
233
|
-
assert.match(
|
|
234
|
-
citationFault('agent-test says "is what keeps vendored tests out." and adds "this filter, not node"', cited),
|
|
235
|
-
/does not say it/,
|
|
236
|
-
);
|
|
237
|
-
// #1940: sentences() now ends a sentence at `.)`, so a whole sentence in
|
|
238
|
-
// parentheses ahead of the quotation is a stop unless it is blanked too.
|
|
239
|
-
assert.match(citationFault('agent-test (as it says itself.) says "this filter, not node"', cited), /does not say it/);
|
|
240
|
-
// A NESTED parenthetical, one level deep: a single un-repeated blanking pass
|
|
241
|
-
// strips only the inner `(in section 2)`, leaving the outer `.)` — a real,
|
|
242
|
-
// now-unblanked terminator-plus-closing-mark — to end the sentence early and
|
|
243
|
-
// hide the quotation past it exactly as the unnested case above would without
|
|
244
|
-
// any blanking at all.
|
|
245
|
-
assert.match(
|
|
246
|
-
citationFault('agent-test (as it says itself (in section 2).) says "this filter, not node"', cited),
|
|
247
|
-
/does not say it/,
|
|
248
|
-
);
|
|
249
|
-
// Curly quotes are a reliably paired delimiter too (opener and closer are
|
|
250
|
-
// different characters), so an aside set off by them gets the same
|
|
251
|
-
// protection as one set off by straight quotes or parens — a `.”`/`.’`
|
|
252
|
-
// ahead of the real quotation must not cut the sentence short either.
|
|
253
|
-
assert.match(
|
|
254
|
-
citationFault('agent-test \u201cas it says itself.\u201d says "this filter, not node"', cited),
|
|
255
|
-
/does not say it/,
|
|
256
|
-
);
|
|
257
|
-
assert.match(
|
|
258
|
-
citationFault('agent-test \u2018as it says itself.\u2019 says "this filter, not node"', cited),
|
|
259
|
-
/does not say it/,
|
|
260
|
-
);
|
|
261
|
-
// Deliberately NOT tested here: a NON-EXEMPT abbreviation ("etc.", or any
|
|
262
|
-
// other word ending in a period sentences() does not name — the exempt
|
|
263
|
-
// list is fixed, not "abbreviation" in general), a SPACED abbreviation
|
|
264
|
-
// ("e. g." — the space keeps sentences() from ever matching the "e.g" it
|
|
265
|
-
// exempts), a mid-sentence ellipsis ("..." — its own last period is a
|
|
266
|
-
// real, unexempted terminator), and a misquote reachable only via a
|
|
267
|
-
// SECOND, separate mention of agent-test (out of scope regardless of
|
|
268
|
-
// sentences(): this function only ever reads the first sentence). Each
|
|
269
|
-
// still lets a misquote read as a paraphrase; none is a regression, and
|
|
270
|
-
// none is a form #1898's own remedy promised to close.
|
|
271
|
-
});
|
|
272
|
-
|
|
273
|
-
// The other half of #1898: the sentence still ends at its REAL end. Once
|
|
274
|
-
// sentences() actually lands a boundary there, a quoted span past it is not
|
|
275
|
-
// agent-test's to answer for — reading on past the end is the unbounded
|
|
276
|
-
// scan citationFault's own comment forbids — and a true quotation reached
|
|
277
|
-
// across "e.g.", or carrying its own period, still passes. A quotation's own
|
|
278
|
-
// closing period is not that boundary, though: the previous test pins the
|
|
279
|
-
// loud direction that falls out when it stands in for one instead.
|
|
280
|
-
test("citationFault reads past 'e.g.' but not past the sentence's end (#1898)", () => {
|
|
281
|
-
const cited = "so this walk, not node, is what keeps vendored tests out.";
|
|
282
|
-
|
|
283
|
-
assert.equal(citationFault('see agent-test, e.g. "walk, not node"', cited), null);
|
|
284
|
-
assert.equal(citationFault('agent-test says "is what keeps vendored tests out."', cited), null);
|
|
285
|
-
assert.equal(
|
|
286
|
-
citationFault('agent-test makes the same point, e.g. about its own walk. The runner\'s "find" was the defect.', cited),
|
|
287
|
-
null,
|
|
288
|
-
);
|
|
289
|
-
// #1898: sentences() already ends a sentence at a bare `?` or `!`, not
|
|
290
|
-
// only at `.` — see its own comment in prose-pin.mjs (where #1940 later
|
|
291
|
-
// moved this shared definition) for why that swaps which direction is
|
|
292
|
-
// silent for a checker like this one. A quote past either is just as
|
|
293
|
-
// unanswerable as one past a period.
|
|
294
|
-
assert.equal(
|
|
295
|
-
citationFault('Does agent-test agree? It says "this filter, not node".', cited),
|
|
296
|
-
null,
|
|
297
|
-
);
|
|
298
|
-
assert.equal(
|
|
299
|
-
citationFault('agent-test agrees! It also says "this filter, not node".', cited),
|
|
300
|
-
null,
|
|
301
|
-
);
|
|
302
|
-
});
|
|
303
|
-
|
|
304
|
-
// #1962. Both quote regexes need one or more characters between two straight
|
|
305
|
-
// quotes, so an empty `""` is never a span: it shifts the pairing of every
|
|
306
|
-
// quote after it instead. That is not a harmless no-citation — the real
|
|
307
|
-
// quotation behind it pairs with its neighbours' gaps, and a misquote there
|
|
308
|
-
// read as a paraphrase (reproduced: the first two inputs below returned null).
|
|
309
|
-
// A stray unpaired `"` shifts the pairing the same way, and a backslash
|
|
310
|
-
// "escape" is no escape in a YAML `#` comment, just a third quote mark. None
|
|
311
|
-
// of the three can be read as a citation, so each is refused as one, never
|
|
312
|
-
// let through as a paraphrase — even where the words happen to be right.
|
|
313
|
-
test("citationFault refuses an empty, unpaired or backslash-escaped straight quote in the citing sentence (#1962)", () => {
|
|
314
|
-
const cited = "so this walk, not node, is what keeps vendored tests out.";
|
|
315
|
-
|
|
316
|
-
assert.match(citationFault('agent-test says "" "this filter, not node"', cited), /empty ""/);
|
|
317
|
-
assert.match(citationFault('agent-test says "" "walk" "this filter, not node"', cited), /empty ""/);
|
|
318
|
-
assert.match(citationFault('agent-test says ""', cited), /empty ""/);
|
|
319
|
-
assert.match(citationFault('agent-test says "walk, \\"not node"', cited), /backslash-escaped \\"/);
|
|
320
|
-
assert.match(citationFault('agent-test, 6" wide, says "walk, not node"', cited), /unpaired "/);
|
|
321
|
-
// Precedence, pinned: an empty "" and a backslash-escaped \" can both be
|
|
322
|
-
// true of the same sentence at once (the escape's own closing quote can
|
|
323
|
-
// complete an unrelated empty pair) — the empty check runs first, so that
|
|
324
|
-
// reason wins, not the backslash one.
|
|
325
|
-
assert.match(citationFault('agent-test says "" then "walk, \\"not node"', cited), /empty ""/);
|
|
326
|
-
});
|
|
327
|
-
|
|
328
|
-
// The other half of #1962: only the citing sentence's own quote marks count.
|
|
329
|
-
// ci.yml's later prose is free to mention an empty string or a stray inch
|
|
330
|
-
// mark, and a sentence quoting the file twice, or setting an empty curly pair
|
|
331
|
-
// beside the quotation (distinct opener and closer, so it shifts nothing),
|
|
332
|
-
// is still a well-formed citation.
|
|
333
|
-
test("citationFault accepts well-paired quotations, and malformed quotes outside the citing sentence (#1962)", () => {
|
|
334
|
-
const cited = "so this walk, not node, is what keeps vendored tests out.";
|
|
335
|
-
|
|
336
|
-
assert.equal(citationFault('agent-test says "walk, not node". Here "" is an empty string.', cited), null);
|
|
337
|
-
assert.equal(citationFault('agent-test says "walk, not node". The pipe is 6" wide.', cited), null);
|
|
338
|
-
assert.equal(citationFault('agent-test says "walk, not node" and "vendored tests out"', cited), null);
|
|
339
|
-
assert.equal(citationFault('agent-test says \u201c\u201d then "walk, not node"', cited), null);
|
|
340
|
-
// A backslash with no quote next to it is not the escape check's target —
|
|
341
|
-
// only a backslash-quote adjacency is (#1962 gap: not pinned by the
|
|
342
|
-
// original two tests, since every backslash they carry sits beside a
|
|
343
|
-
// quote already).
|
|
344
|
-
assert.equal(citationFault('agent-test says the \\d pattern matches "walk, not node"', cited), null);
|
|
345
|
-
// A backslash-escaped quote in a LATER sentence is later prose too — only
|
|
346
|
-
// the citing sentence's own malformed check counts.
|
|
347
|
-
assert.equal(citationFault('agent-test says "walk, not node". A shell writes \\" here.', cited), null);
|
|
348
|
-
});
|
|
349
|
-
|
|
350
|
-
// #2013. The #1962 checks catch a shifted pairing only while the quote count
|
|
351
|
-
// the citing sentence ends up with is odd. A stray `"` can instead pair its
|
|
352
|
-
// way past the citing sentence's own terminator — `node". The install"` is
|
|
353
|
-
// one blanked span — so the sentence runs on into later prose, the count
|
|
354
|
-
// comes out even again, and the gap spans are what gets checked while the
|
|
355
|
-
// real (here fabricated) quotation never is. Reproduced: the first input
|
|
356
|
-
// returned null against a cited text holding those gap spans, and the second
|
|
357
|
-
// returned a fault naming ". The install", the wrong span. The same shifted
|
|
358
|
-
// pairing reads as two adjacent quotations when it ends the sentence EARLY
|
|
359
|
-
// (a period inside the real quotation) or when quotes are nested unescaped;
|
|
360
|
-
// both returned null here too, since the one gap span left is a bare space
|
|
361
|
-
// or a phrase the cited text holds.
|
|
362
|
-
test("citationFault refuses a straight-quote pairing that opens or closes a span from the wrong side of its word (#2013)", () => {
|
|
363
|
-
const cited = "so this walk, not node, is what keeps vendored tests out.";
|
|
364
|
-
const misPaired = /mis-paired "/;
|
|
365
|
-
|
|
366
|
-
assert.match(
|
|
367
|
-
citationFault(
|
|
368
|
-
'agent-test says a" "this filter, not node". The install" step runs later.',
|
|
369
|
-
`${cited} The install step runs later.`,
|
|
370
|
-
),
|
|
371
|
-
misPaired,
|
|
372
|
-
);
|
|
373
|
-
assert.match(
|
|
374
|
-
citationFault('agent-test says a" "this filter, not node". The install" rest of the later sentence.', cited),
|
|
375
|
-
misPaired,
|
|
376
|
-
);
|
|
377
|
-
assert.match(citationFault('agent-test says 6" "this filter. Not node"', cited), misPaired);
|
|
378
|
-
assert.match(citationFault('agent-test says "so this "walk" not node"', cited), misPaired);
|
|
379
|
-
// A span whose closer sits after an opening parenthesis is opener-shaped
|
|
380
|
-
// even with no whitespace beside it: the punctuation half of the rule.
|
|
381
|
-
assert.match(
|
|
382
|
-
citationFault('agent-test says a"b ("this filter, not node"). Later ("x") 6" end.', cited),
|
|
383
|
-
misPaired,
|
|
384
|
-
);
|
|
385
|
-
// One half of the rule each, with the other half blind: a mark glued to a
|
|
386
|
-
// word on both sides (`k"b`, `a"l`) passes as either role, so only the
|
|
387
|
-
// stray's own side gives the shift away. Both returned null before #2013.
|
|
388
|
-
assert.match(citationFault('agent-test says a" walk"b "not node"', cited), misPaired);
|
|
389
|
-
assert.match(citationFault('agent-test says "so this "wa"lk, not node"', cited), misPaired);
|
|
390
|
-
});
|
|
391
|
-
|
|
392
|
-
// The other half of #2013: a quotation mark counts as correctly placed from
|
|
393
|
-
// either side of punctuation, not only of whitespace — an opener behind a
|
|
394
|
-
// parenthesis or a colon, a closer after the quotation's own comma or period
|
|
395
|
-
// — and a quotation's own period still does not end the citing sentence.
|
|
396
|
-
test("citationFault accepts quotation marks set against punctuation (#2013)", () => {
|
|
397
|
-
const cited = "so this walk, not node, is what keeps vendored tests out.";
|
|
398
|
-
|
|
399
|
-
assert.equal(citationFault('agent-test says ("walk, not node").', cited), null);
|
|
400
|
-
assert.equal(citationFault('agent-test says:"walk, not node"', cited), null);
|
|
401
|
-
assert.equal(citationFault('agent-test says "walk, not node," and more', cited), null);
|
|
402
|
-
assert.equal(citationFault('agent-test\'s "walk, not node"', cited), null);
|
|
403
|
-
assert.equal(
|
|
404
|
-
citationFault('agent-test says "is what keeps vendored tests out." and "walk, not node". Later "a" b.', cited),
|
|
405
|
-
null,
|
|
406
|
-
);
|
|
407
|
-
// A backtick is punctuation too (CommonMark counts Unicode symbols), so a
|
|
408
|
-
// quotation set in a code span closes cleanly after its own period.
|
|
409
|
-
assert.equal(citationFault('agent-test says `"is what keeps vendored tests out."`', cited), null);
|
|
410
|
-
// Every opener above is followed by a word character, so `canOpen` never
|
|
411
|
-
// needs its "or preceded by whitespace" half — the quoted content's own
|
|
412
|
-
// leading mark is punctuation here, so the opener is let through only
|
|
413
|
-
// because ordinary whitespace, not punctuation, precedes it.
|
|
414
|
-
assert.equal(citationFault('agent-test says ", is what keeps vendored tests out."', cited), null);
|
|
415
|
-
});
|
|
416
|
-
|
|
417
|
-
// #1999. The blanked text has to stay the SAME length as the real text, since
|
|
418
|
-
// the real sentence is cut at the blanked sentence's length. An astral
|
|
419
|
-
// character (an emoji, two UTF-16 units) inside a parenthetical aside used to
|
|
420
|
-
// blank to ONE "x", so every one of them cut the real sentence a unit short.
|
|
421
|
-
// That fails three ways: a correct quotation loses its closing mark and is
|
|
422
|
-
// refused as unpaired; a genuine misquote behind the same short aside is ALSO
|
|
423
|
-
// refused as unpaired — the wrong reason, hiding which words it actually
|
|
424
|
-
// misquotes; and a cut that lands exactly before a short quoted span drops it
|
|
425
|
-
// whole — pairing stays even, so a misquote there read as a paraphrase
|
|
426
|
-
// (reproduced: the last input below returned null).
|
|
427
|
-
test("an astral character inside a parenthetical aside does not shorten the citing sentence (#1999)", () => {
|
|
428
|
-
const cited = "so this walk, not node, is what keeps vendored tests out.";
|
|
429
|
-
const aside = "(\u{1F600}\u{1F600}\u{1F600})";
|
|
430
|
-
|
|
431
|
-
assert.equal(citationFault(`agent-test ${aside} says "walk, not node"`, cited), null);
|
|
432
|
-
assert.match(citationFault(`agent-test ${aside} says "this filter, not node"`, cited), /does not say it/);
|
|
433
|
-
assert.match(citationFault(`agent-test ${aside} says "walk, not node" and "q"`, cited), /saying "q"/);
|
|
434
|
-
});
|
|
435
|
-
|
|
436
|
-
// #1999 follow-up. blankQuotes was never touched by that bug — span.length is
|
|
437
|
-
// already a UTF-16-unit count, not a code-point count, so an astral character
|
|
438
|
-
// INSIDE a quoted span (no parens involved) never shortened the blanked span.
|
|
439
|
-
// Pinned separately from the parenthetical case above so a future edit to
|
|
440
|
-
// either helper cannot quietly drop the other's coverage.
|
|
441
|
-
test("an astral character inside a quoted span alone does not affect blankQuotes (#1999)", () => {
|
|
442
|
-
const cited = "so this walk\u{1F600}, not node, is what keeps vendored tests out.";
|
|
443
|
-
|
|
444
|
-
assert.equal(citationFault('agent-test says "walk\u{1F600}, not node"', cited), null);
|
|
445
|
-
assert.match(citationFault('agent-test says "walk\u{1F600}, not filter"', cited), /does not say it/);
|
|
446
|
-
});
|
|
447
|
-
|
|
448
|
-
test("the Shellcheck comment does not present its examples as the complete set", () => {
|
|
449
|
-
// Not a count — a count is the thing that rotted. This bans the two phrases
|
|
450
|
-
// that made the list exhaustive, so the next edit can add or drop an example
|
|
451
|
-
// freely and only a re-closed enumeration reds.
|
|
452
|
-
assert.doesNotMatch(
|
|
453
|
-
CI,
|
|
454
|
-
/only info-level hits/,
|
|
455
|
-
"the Shellcheck comment claims an exhaustive list of info-level hits again — #348 removed that because the tree has more than the ones it names",
|
|
456
|
-
);
|
|
457
|
-
assert.doesNotMatch(
|
|
458
|
-
CI,
|
|
459
|
-
/those two at the source/,
|
|
460
|
-
"the Shellcheck comment tells the next maintainer to silence `those two` again — the set it points at is not two",
|
|
461
|
-
);
|
|
462
|
-
});
|
|
463
|
-
|
|
464
|
-
// #953. The same file, the same failure mode, one axis over: a rationale can rot
|
|
465
|
-
// by MOVING rather than by going stale. The failglob paragraph drifted above the
|
|
466
|
-
// gojq provisioning block and two steps it says nothing about, so a reader at the
|
|
467
|
-
// step it explains had to scroll past an unrelated toolchain to find it. Nothing
|
|
468
|
-
// caught that, for the reason ci.yml states about itself: no test reads its
|
|
469
|
-
// comments. Anchored on the step's name, walking UP over the whole contiguous
|
|
470
|
-
// comment run above it — never on a line number, the drift this pins is exactly
|
|
471
|
-
// a line number changing — so a fix that reunites the step's NAME with its
|
|
472
|
-
// rationale while leaving one sibling paragraph behind still reds: the failglob
|
|
473
|
-
// paragraph is not the only one this step's reader needs.
|
|
474
|
-
test("the failglob rationale sits against the Tests step it documents", () => {
|
|
475
|
-
const lines = read("../../.github/workflows/ci.yml").split("\n");
|
|
476
|
-
const step = lines.findIndex((l) => /^\s*- name: Tests$/.test(l));
|
|
477
|
-
assert.ok(step >= 0, "ci.yml no longer has a Tests step");
|
|
478
|
-
let i = step;
|
|
479
|
-
while (/^\s*#/.test(lines[i - 1])) i--;
|
|
480
|
-
const block = lines.slice(i, step).join(" ");
|
|
481
|
-
for (const claim of [/failglob/, /Explicit glob/, /stubs `gh`/]) {
|
|
482
|
-
assert.match(
|
|
483
|
-
block,
|
|
484
|
-
claim,
|
|
485
|
-
`the Tests step's rationale lost ${claim} — it has drifted away from the step it explains`,
|
|
486
|
-
);
|
|
487
|
-
}
|
|
488
|
-
});
|
|
489
|
-
|
|
490
|
-
test("the vendored-tree sentence makes a structural claim, not a size claim", () => {
|
|
491
|
-
// The sentence exists to say there is nothing to walk INTO under that
|
|
492
|
-
// directory. A file count neither supports that nor survives a commit.
|
|
493
|
-
// A fixed window, not the sentence: `[^.]*` stops at the first period, and
|
|
494
|
-
// the count reads exactly the same re-added as the NEXT sentence as it did
|
|
495
|
-
// after a semicolon, which is the form #348 deleted.
|
|
496
|
-
const span = CI.match(/no vendored tree under plugin\/scripts\/.{0,120}/);
|
|
497
|
-
assert.ok(span, "ci.yml no longer argues that plugin/scripts/ holds no vendored tree");
|
|
498
|
-
assert.doesNotMatch(
|
|
499
|
-
span[0],
|
|
500
|
-
/\d/,
|
|
501
|
-
`the vendored-tree claim sizes the directory again, and the number is stale on arrival: "${span[0]}"`,
|
|
502
|
-
);
|
|
503
|
-
});
|
|
504
|
-
|
|
505
|
-
// #1753. The comment above the setup-node step that owns `.nvmrc`'s explanation
|
|
506
|
-
// says Renovate moves the pin on a schedule. Read alone, that schedule looks
|
|
507
|
-
// like a promise about when the bump LANDS, and it never was one: the window
|
|
508
|
-
// bounds when the bot opens its PR, and the merge waits on the required checks
|
|
509
|
-
// whenever they finish — a major's on a human too, which majorMergeFault holds
|
|
510
|
-
// the comment to. The comment now says so, and this keeps it saying so.
|
|
511
|
-
//
|
|
512
|
-
// Same rule as #348's pins above. It bans the stale FORM — a schedule named with
|
|
513
|
-
// nothing saying what its window bounds (the text before #1753), or a sentence
|
|
514
|
-
// tying the merge to the window without denying it — and accepts any paraphrase
|
|
515
|
-
// that states the distinction in one sentence. It pins no count and no cron
|
|
516
|
-
// string: the window's width and timing are renovate.json's to change, and the
|
|
517
|
-
// hosted app's scheduling is not observable from this tree anyway. The ceiling:
|
|
518
|
-
// the distinction has to sit inside ONE sentence, because a block-wide scan
|
|
519
|
-
// would let an unrelated "Do not hand-edit" supply the negation for a sentence
|
|
520
|
-
// that claims the opposite.
|
|
521
|
-
export function windowClaimFault(block) {
|
|
522
|
-
if (!/\b(schedule|window)\b/i.test(block)) {
|
|
523
|
-
return "the pin's comment no longer says the bot moves .nvmrc on a schedule — the pointer to how it moves is gone";
|
|
524
|
-
}
|
|
525
|
-
const bounded = sentences(block).some((s) => {
|
|
526
|
-
if (!/\b(schedule|window)\b/i.test(s)) return false;
|
|
527
|
-
if (!/\b(open|opens|opened|opening|create|creates|created|creating|creation|raise|raises|raised|raising)\b/i.test(s)) return false;
|
|
528
|
-
if (!/\b(PRs?|pull requests?)\b/i.test(s)) return false;
|
|
529
|
-
const mergeAt = s.search(/\bmerg/i);
|
|
530
|
-
if (mergeAt === -1) return false;
|
|
531
|
-
// Once the sentence turns to talk about merging, "window"/"schedule" must not
|
|
532
|
-
// be named again — that is the tell of a sentence that TIES the merge back to
|
|
533
|
-
// the window instead of denying the tie. Without this, "whenever"/"regardless"
|
|
534
|
-
// alone satisfied the negation check even in a sentence that asserts the exact
|
|
535
|
-
// misreading #1753 exists to rule out, e.g. "the PR merges whenever the window
|
|
536
|
-
// is open" (#1838 — reproduced by direct execution against this function).
|
|
537
|
-
if (/\b(schedule|window)\b/i.test(s.slice(mergeAt))) return false;
|
|
538
|
-
// "cannot" is "can not" fused, whose two-word form already passed on "not";
|
|
539
|
-
// ’ is the apostrophe smart quotes type into "doesn’t" (#1852).
|
|
540
|
-
const NEGATION = /\b(not|cannot|never|nothing|regardless|whenever)\b|n['’]t\b/i;
|
|
541
|
-
return NEGATION.test(s.slice(0, mergeAt)) || NEGATION.test(s.slice(mergeAt));
|
|
542
|
-
});
|
|
543
|
-
return bounded
|
|
544
|
-
? null
|
|
545
|
-
: "the pin's comment names the bot's schedule but no longer says, in one sentence, that its window bounds PR creation and not merge timing — #1753";
|
|
546
|
-
}
|
|
547
|
-
|
|
548
|
-
// The indices of `lines` that are a block scalar's content (#1975): after a
|
|
549
|
-
// `key: |` or `- >-` header — chomping and indentation indicators, an anchor
|
|
550
|
-
// or tag, a quoted key and a trailing comment allowed — every line up to the
|
|
551
|
-
// first non-blank one set shallower than the content. The content's column
|
|
552
|
-
// is the header's indentation indicator past the column of its key (of its
|
|
553
|
-
// dash, for a bare `- |`, or of the document itself for a bare `--- |`), or
|
|
554
|
-
// else the first non-blank line's own, which must sit deeper than that
|
|
555
|
-
// column or the scalar is empty. A line in there is text however it is
|
|
556
|
-
// spelled, so a header inside it opens nothing. Only block scalars: a quoted
|
|
557
|
-
// or plain scalar can span lines too, but none in ci.yml does, and at a
|
|
558
|
-
// step's depth the job check below refuses any step such a string could
|
|
559
|
-
// spell — that check has no equivalent for the comment-run walk, so a
|
|
560
|
-
// multi-line quoted or plain scalar can still lend the wrong text to a
|
|
561
|
-
// step's comment; ci.yml has no such scalar today, so this is a documented,
|
|
562
|
-
// latent gap, not a live one (#2000).
|
|
563
|
-
//
|
|
564
|
-
// Two header shapes #1975 left undetected (#2000). The plain-key
|
|
565
|
-
// alternative used to exclude `#` outright; YAML only starts a comment at
|
|
566
|
-
// whitespace-then-`#`, so it now excludes `#` only when whitespace precedes
|
|
567
|
-
// it, letting a plain key contain one (`C#: |`). And a document-start
|
|
568
|
-
// marker (`--- |`) opens a scalar with no key at all — its own production,
|
|
569
|
-
// column −1, since the content it owns need only sit deeper than the
|
|
570
|
-
// document itself, never as shallow as a real job or key.
|
|
571
|
-
function blockScalarText(lines) {
|
|
572
|
-
const text = new Set();
|
|
573
|
-
for (let at = 0; at < lines.length; at++) {
|
|
574
|
-
const header =
|
|
575
|
-
/^(\s*(?:-\s+)*)((?:"(?:[^"\\]|\\.)*"|'(?:[^']|'')*'|[^\s#"'](?:[^#]|(?<!\s)#)*?)\s*:\s+)?(?:[&!]\S*\s+)*[|>]([1-9])?[-+]?([1-9])?\s*(?:#.*)?$/.exec(
|
|
576
|
-
lines[at],
|
|
577
|
-
);
|
|
578
|
-
const docHeader =
|
|
579
|
-
!header && /^---\s+(?:[&!]\S*\s+)*[|>]([1-9])?[-+]?([1-9])?\s*(?:#.*)?$/.exec(lines[at]);
|
|
580
|
-
if (!header && !docHeader) continue;
|
|
581
|
-
if (header && !header[2] && !header[1].includes("-")) continue;
|
|
582
|
-
const column = docHeader ? -1 : header[2] ? header[1].length : header[1].trimEnd().length - 1;
|
|
583
|
-
const indicator = Number((docHeader ? docHeader[1] : header[3]) ?? (docHeader ? docHeader[2] : header[4]) ?? 0);
|
|
584
|
-
let depth = indicator ? column + indicator : null;
|
|
585
|
-
let end = at + 1;
|
|
586
|
-
for (; end < lines.length; end++) {
|
|
587
|
-
if (/^\s*$/.test(lines[end])) continue;
|
|
588
|
-
// A document marker (`---`/`...`) always ends the current document —
|
|
589
|
-
// and any scalar still open in it — under both YAML 1.1 and 1.2.
|
|
590
|
-
// Without this, a document-start scalar's own indentation indicator
|
|
591
|
-
// of exactly 1 sets `depth` to 0 (column −1 plus indicator 1), a floor
|
|
592
|
-
// no real line's column can ever go under, so the scalar never closes
|
|
593
|
-
// and swallows the rest of the file — silently dropping every step in
|
|
594
|
-
// a later document. Found in review of #2005 (`--- |1` followed by a
|
|
595
|
-
// second document holding a real step); ci.yml has neither a document
|
|
596
|
-
// marker nor an explicit indentation indicator today, so this was
|
|
597
|
-
// unreachable there, but the production this file emits for `--- |1`
|
|
598
|
-
// should still match PyYAML rather than trust a floor that can go
|
|
599
|
-
// non-positive.
|
|
600
|
-
if (/^(?:---|\.\.\.)(?:\s|$)/.test(lines[end])) break;
|
|
601
|
-
const col = lines[end].search(/\S/);
|
|
602
|
-
depth ??= col;
|
|
603
|
-
if (col < depth || col <= column) break;
|
|
604
|
-
}
|
|
605
|
-
for (let k = at + 1; k < end; k++) text.add(k);
|
|
606
|
-
at = end - 1;
|
|
607
|
-
}
|
|
608
|
-
return text;
|
|
609
|
-
}
|
|
610
|
-
|
|
611
|
-
// Every setup-node step's contiguous comment run: its prose, how many comment
|
|
612
|
-
// lines it spans, and the job it sits in — anchored on the step, never a line
|
|
613
|
-
// number. A step is an entry of `steps:`, found by its
|
|
614
|
-
// `uses: actions/setup-node@` key wherever that key sits among the entry's own
|
|
615
|
-
// keys, and its comment is the run directly above the step's own `- ` opener,
|
|
616
|
-
// where a reader meets it (#1873) — a blank line ends that run, the opener's
|
|
617
|
-
// side included, so a comment with a blank line under it is not the step's
|
|
618
|
-
// (#1919). A block scalar's content is neither a step's key nor a comment,
|
|
619
|
-
// and a key read by name here may be quoted or spaced from its colon, as YAML
|
|
620
|
-
// allows (#1975). A `uses:` key's colon must still be followed by real
|
|
621
|
-
// whitespace — YAML's own rule for telling a key from a plain scalar that
|
|
622
|
-
// merely contains one (`uses:actions/…` is the latter, never a key) — and so
|
|
623
|
-
// must a job key's, before any anchor, tag or comment after it (#2006). Either
|
|
624
|
-
// key may carry an anchor or tag between its colon and its value, as YAML
|
|
625
|
-
// allows there too (#2000) — including the
|
|
626
|
-
// bare `!` non-specific tag, which has no characters of its own to require
|
|
627
|
-
// (found in review of #2005: `\S+` after `[&!]` refused it where the header
|
|
628
|
-
// regex above already used `\S*`) — and the job key and `uses:` may carry
|
|
629
|
-
// one before the key itself, as may a step right after its own `- `,
|
|
630
|
-
// whether its keys follow on that line or under it (#2006). The `steps:`
|
|
631
|
-
// key takes the same fix too, generalizing #2006's own wording to a spot
|
|
632
|
-
// the ticket never named. Exported with
|
|
633
|
-
// an optional `lines` override (same idiom as windowClaimFault's `block`
|
|
634
|
-
// param and citationFault's `citing`/`cited` params) so a test can feed it
|
|
635
|
-
// synthetic input the real ci.yml does not contain; the production call
|
|
636
|
-
// sites take no argument and read the real file. The owner pin and the
|
|
637
|
-
// pointer pin both read the steps through this, so they cannot disagree
|
|
638
|
-
// about where a step's comment starts.
|
|
639
|
-
export function setupNodeComments(lines = read("../../.github/workflows/ci.yml").split("\n")) {
|
|
640
|
-
const text = blockScalarText(lines);
|
|
641
|
-
const found = [];
|
|
642
|
-
for (let at = 0; at < lines.length; at++) {
|
|
643
|
-
const uses = /^(\s*)(-\s+)?(?:[&!]\S*\s+)*(["']?)uses\3\s*:\s+(?:[&!]\S*\s+)*["']?actions\/setup-node@/.exec(lines[at]);
|
|
644
|
-
if (!uses || text.has(at)) continue;
|
|
645
|
-
// `- uses:` opens its entry. Any other `uses:` belongs to the first line
|
|
646
|
-
// above it that sits shallower than the key — sibling keys share its
|
|
647
|
-
// column, their values sit deeper — and that line is the entry's opener
|
|
648
|
-
// only if it opens a sequence entry whose own keys start at `uses:`'s
|
|
649
|
-
// column. `with:` there, on a line of its own or after the `- `, means
|
|
650
|
-
// the match was never an entry's own key. A bare `-`, or a dash whose
|
|
651
|
-
// only remainder is anchors, tags or a comment, sets its keys under it,
|
|
652
|
-
// each of which the walk has already held at or past that column (#1920
|
|
653
|
-
// follow-up: a trailing comment's own text is not a key, so it must not
|
|
654
|
-
// set the column the way a real key would; nor is a property's, #2006).
|
|
655
|
-
let step = at;
|
|
656
|
-
if (!uses[2]) {
|
|
657
|
-
const depth = uses[1].length;
|
|
658
|
-
step--;
|
|
659
|
-
while (step >= 0 && (/^\s*(?:#|$)/.test(lines[step]) || lines[step].search(/\S/) >= depth)) step--;
|
|
660
|
-
if (step < 0) continue;
|
|
661
|
-
if (!/^\s*-(?:\s+[&!]\S*)*\s*(?:#.*)?$/.test(lines[step]) && /^\s*-\s+(?=\S)/.exec(lines[step])?.[0].length !== depth) continue;
|
|
662
|
-
}
|
|
663
|
-
// Either way the entry is a step only if it hangs from `steps:`: the first
|
|
664
|
-
// line above the opener that neither sits deeper than its `- ` nor opens a
|
|
665
|
-
// sibling entry level with it. A list nested in `with:` or a matrix
|
|
666
|
-
// `include:` has entries shaped exactly like a step's (#1920).
|
|
667
|
-
const dash = lines[step].search(/\S/);
|
|
668
|
-
let parent = step - 1;
|
|
669
|
-
for (; parent >= 0; parent--) {
|
|
670
|
-
if (/^\s*(?:#|$)/.test(lines[parent])) continue;
|
|
671
|
-
const col = lines[parent].search(/\S/);
|
|
672
|
-
if (col < dash || (col === dash && !/^\s*-(?:\s|$)/.test(lines[parent]))) break;
|
|
673
|
-
}
|
|
674
|
-
if (parent < 0 || !/^\s*(?:[&!]\S*\s+)*(["']?)steps\1\s*:(?:\s|$)/.test(lines[parent])) continue;
|
|
675
|
-
// `steps:` is just a key spelled that way — nothing above checks that it
|
|
676
|
-
// sits directly under a job, not inside some action's own config that
|
|
677
|
-
// happens to reuse the name. The line immediately shallower than it, if
|
|
678
|
-
// the walk finds one before running off the top, must open a job
|
|
679
|
-
// (` name:`, quoted or not, a comment after it allowed); anything else —
|
|
680
|
-
// another `with:`, a matrix `include:` — means this `steps:` is not the
|
|
681
|
-
// job's (#1920 follow-up). That line names the job.
|
|
682
|
-
const stepsDepth = lines[parent].search(/\S/);
|
|
683
|
-
let jobLine = parent - 1;
|
|
684
|
-
while (jobLine >= 0 && (/^\s*(?:#|$)/.test(lines[jobLine]) || lines[jobLine].search(/\S/) >= stepsDepth)) jobLine--;
|
|
685
|
-
const jobKey =
|
|
686
|
-
jobLine >= 0
|
|
687
|
-
? /^ {2}(?:[&!]\S*\s+)*(["']?)([\w-]+)\1\s*:(?:\s+(?:[&!]\S*\s*)*(?:#.*)?)?$/.exec(lines[jobLine])
|
|
688
|
-
: null;
|
|
689
|
-
if (jobLine >= 0 && !jobKey) continue;
|
|
690
|
-
let i = step;
|
|
691
|
-
while (i > 0 && /^\s*#/.test(lines[i - 1]) && !text.has(i - 1)) i--;
|
|
692
|
-
found.push({
|
|
693
|
-
block: prose(lines.slice(i, step).join("\n")),
|
|
694
|
-
lines: step - i,
|
|
695
|
-
job: jobKey?.[2] ?? null,
|
|
696
|
-
});
|
|
697
|
-
}
|
|
698
|
-
return found;
|
|
699
|
-
}
|
|
700
|
-
|
|
701
|
-
// The comment run above the setup-node step that owns ADR 0010's explanation.
|
|
702
|
-
// A candidate is a run citing "ADR 0010" over more than one line: since #1756
|
|
703
|
-
// every other setup-node step carries a one-line pointer to the same ADR, and
|
|
704
|
-
// a one-line citation is a pointer (checked by pointerFault), never a
|
|
705
|
-
// candidate. Asserts uniqueness among candidates rather than returning the
|
|
706
|
-
// first hit: a second multi-line comment that also happens to cite
|
|
707
|
-
// "ADR 0010" would otherwise let this silently validate the WRONG block while
|
|
708
|
-
// the real one rots unchecked (#1838 — reproduced: reverting the real comment
|
|
709
|
-
// to its stale pre-#1753 form while an earlier decoy step's comment cited
|
|
710
|
-
// "ADR 0010" left every test in this file green). A one-line decoy cannot
|
|
711
|
-
// reopen that: it is never a candidate, so the real paragraph is still the
|
|
712
|
-
// one checked.
|
|
713
|
-
export function pinOwnerComment(lines) {
|
|
714
|
-
const matches = setupNodeComments(lines)
|
|
715
|
-
.filter((c) => c.lines > 1 && c.block.includes("ADR 0010"))
|
|
716
|
-
.map((c) => c.block);
|
|
717
|
-
assert.ok(
|
|
718
|
-
matches.length <= 1,
|
|
719
|
-
`ci.yml has ${matches.length} setup-node comment blocks citing "ADR 0010" over more than one line — the pin can no longer tell which one owns it`,
|
|
720
|
-
);
|
|
721
|
-
return matches[0] ?? null;
|
|
722
|
-
}
|
|
723
|
-
|
|
724
|
-
test("the pin's comment says the bot's window bounds PR creation, not merge timing", () => {
|
|
725
|
-
const block = pinOwnerComment();
|
|
726
|
-
assert.ok(block, "no setup-node step in ci.yml carries a comment pointing at ADR 0010 any more");
|
|
727
|
-
assert.equal(windowClaimFault(block), null);
|
|
728
|
-
});
|
|
729
|
-
|
|
730
|
-
test("a paraphrase of the window claim is accepted; the stale form and a merge promise are not", () => {
|
|
731
|
-
const lead = ".nvmrc holds an EXACT version, and Renovate moves it on a monthly schedule rather than a human noticing: see ADR 0010.";
|
|
732
|
-
const tail = "Do not hand-edit this to float.";
|
|
733
|
-
|
|
734
|
-
assert.equal(
|
|
735
|
-
windowClaimFault(`${lead} That schedule's window bounds when the bot opens its PR, not when the PR merges. ${tail}`),
|
|
736
|
-
null,
|
|
737
|
-
);
|
|
738
|
-
assert.equal(
|
|
739
|
-
windowClaimFault(`${lead} The window only limits when Renovate raises the pull request; merging happens whenever the required checks go green. ${tail}`),
|
|
740
|
-
null,
|
|
741
|
-
);
|
|
742
|
-
|
|
743
|
-
// The text as it stood before #1753: a schedule, and nothing on what it bounds.
|
|
744
|
-
assert.match(windowClaimFault(`${lead} ${tail}`), /no longer says, in one sentence/);
|
|
745
|
-
// The misreading stated outright — the trailing "Do not" must not rescue it.
|
|
746
|
-
assert.match(windowClaimFault(`${lead} The bot opens its PR and merges it within that window. ${tail}`), /no longer says, in one sentence/);
|
|
747
|
-
assert.match(windowClaimFault(`.nvmrc holds an EXACT version: see ADR 0010. ${tail}`), /no longer says the bot moves/);
|
|
748
|
-
});
|
|
749
|
-
|
|
750
|
-
test("windowClaimFault refuses a merge promise stated via 'whenever'/'regardless' alone (#1838)", () => {
|
|
751
|
-
// Both hit every earlier condition (schedule/window, an open-class verb, PR,
|
|
752
|
-
// merg, and a word from the negation class) and both assert the exact tie
|
|
753
|
-
// #1753 exists to deny — this is the defect a peer review found and this
|
|
754
|
-
// pins the fix.
|
|
755
|
-
assert.match(
|
|
756
|
-
windowClaimFault("The bot opens its PR in the window, and the PR merges whenever the window is open."),
|
|
757
|
-
/no longer says, in one sentence/,
|
|
758
|
-
);
|
|
759
|
-
assert.match(
|
|
760
|
-
windowClaimFault("The window opens the PR, and the PR merges within that window, regardless."),
|
|
761
|
-
/no longer says, in one sentence/,
|
|
762
|
-
);
|
|
763
|
-
// The committed paraphrase that legitimately uses "whenever" still passes —
|
|
764
|
-
// the fix keys off "window"/"schedule" reappearing after the merge word, not
|
|
765
|
-
// off "whenever" itself.
|
|
766
|
-
assert.equal(
|
|
767
|
-
windowClaimFault(
|
|
768
|
-
".nvmrc holds an EXACT version, and Renovate moves it on a monthly schedule rather than a human noticing: see ADR 0010. The window only limits when Renovate raises the pull request; merging happens whenever the required checks go green. Do not hand-edit this to float.",
|
|
769
|
-
),
|
|
770
|
-
null,
|
|
771
|
-
);
|
|
772
|
-
});
|
|
773
|
-
|
|
774
|
-
test("windowClaimFault accepts a paraphrase negated by 'cannot' or a curly apostrophe, or broken by 'e.g.' (#1852)", () => {
|
|
775
|
-
const lead = ".nvmrc holds an EXACT version, and Renovate moves it on a monthly schedule rather than a human noticing: see ADR 0010.";
|
|
776
|
-
const tail = "Do not hand-edit this to float.";
|
|
777
|
-
|
|
778
|
-
// Each carries its negation in exactly the form named, and nowhere else.
|
|
779
|
-
assert.equal(
|
|
780
|
-
windowClaimFault(`${lead} That schedule's window bounds when the bot opens its PR; it doesn’t decide when the PR merges. ${tail}`),
|
|
781
|
-
null,
|
|
782
|
-
);
|
|
783
|
-
assert.equal(
|
|
784
|
-
windowClaimFault(`${lead} The window bounds when the bot opens its PR, and it cannot hurry or delay when the PR merges. ${tail}`),
|
|
785
|
-
null,
|
|
786
|
-
);
|
|
787
|
-
assert.equal(
|
|
788
|
-
windowClaimFault(`${lead} The window bounds when the bot opens its PR (e.g. once a month), not when the PR merges. ${tail}`),
|
|
789
|
-
null,
|
|
790
|
-
);
|
|
791
|
-
});
|
|
792
|
-
|
|
793
|
-
test("a period after 'etc.' still ends the sentence, so the next one's negation cannot rescue a merge promise (#1852)", () => {
|
|
794
|
-
// Read as one sentence this is accepted — the trailing "Do not" supplies the
|
|
795
|
-
// negation. "etc." ends sentences as often as not, so it is no abbreviation
|
|
796
|
-
// the splitter may skip: skipping it is the block-wide scan the ceiling bans.
|
|
797
|
-
assert.match(
|
|
798
|
-
windowClaimFault("In the window the bot opens its PR and merges it, etc. Do not hand-edit this to float."),
|
|
799
|
-
/no longer says, in one sentence/,
|
|
800
|
-
);
|
|
801
|
-
});
|
|
802
|
-
|
|
803
|
-
test("windowClaimFault's splitter skips every listed abbreviation, not only 'e.g.' (#1852)", () => {
|
|
804
|
-
const lead = ".nvmrc holds an EXACT version, and Renovate moves it on a monthly schedule rather than a human noticing: see ADR 0010.";
|
|
805
|
-
const tail = "Do not hand-edit this to float.";
|
|
806
|
-
for (const abbr of ["i.e.", "cf.", "viz.", "vs."]) {
|
|
807
|
-
assert.equal(
|
|
808
|
-
windowClaimFault(`${lead} The window bounds when the bot opens its PR (${abbr} once a month), not when the PR merges. ${tail}`),
|
|
809
|
-
null,
|
|
810
|
-
`${abbr} should not split the sentence`,
|
|
811
|
-
);
|
|
812
|
-
}
|
|
813
|
-
});
|
|
814
|
-
|
|
815
|
-
test("windowClaimFault still splits after a word that only ends in an abbreviation's letters (#1852)", () => {
|
|
816
|
-
// "devs." is not "vs." — the lookbehind's `\b` anchors the abbreviation to a
|
|
817
|
-
// whole word, or a period after any word ending in these letters would
|
|
818
|
-
// silently stop splitting there, joining two real sentences.
|
|
819
|
-
assert.match(
|
|
820
|
-
windowClaimFault("In the window the bot opens its PR and merges it for the devs. Do not hand-edit this to float."),
|
|
821
|
-
/no longer says, in one sentence/,
|
|
822
|
-
);
|
|
823
|
-
});
|
|
824
|
-
|
|
825
|
-
test("windowClaimFault still splits after a sentence-final word that only case-folds to an abbreviation (#1899)", () => {
|
|
826
|
-
// "Vs." is not "vs." — matched case-insensitively, the splitter read this
|
|
827
|
-
// proper noun as the abbreviation, joined the two sentences, and the next
|
|
828
|
-
// one's "Do not" rescued the merge promise.
|
|
829
|
-
assert.match(
|
|
830
|
-
windowClaimFault("In the window the bot opens its PR and merges it for the Vs. Do not hand-edit this to float."),
|
|
831
|
-
/no longer says, in one sentence/,
|
|
832
|
-
);
|
|
833
|
-
});
|
|
834
|
-
|
|
835
|
-
test("windowClaimFault ends a sentence at a capitalized abbreviation mid-sentence too — the cost #1899 accepted (#2021)", () => {
|
|
836
|
-
// The lowercase-only match has no notion of where in a sentence it sits, so
|
|
837
|
-
// a capitalized abbreviation inside a parenthetical ends the sentence right
|
|
838
|
-
// there, splitting the negation off from the PR-creation claim: the pin
|
|
839
|
-
// refuses a paraphrase it accepts spelled lowercase (the test above). This
|
|
840
|
-
// is the loud direction, and no file's prose spells one capitalized; the
|
|
841
|
-
// pin is here so a change to the guard meets this shape on purpose.
|
|
842
|
-
const lead = ".nvmrc holds an EXACT version, and Renovate moves it on a monthly schedule rather than a human noticing: see ADR 0010.";
|
|
843
|
-
const tail = "Do not hand-edit this to float.";
|
|
844
|
-
for (const abbr of ["E.g.", "I.e.", "Cf.", "Viz.", "Vs."]) {
|
|
845
|
-
assert.match(
|
|
846
|
-
windowClaimFault(`${lead} The window bounds when the bot opens its PR (${abbr} once a month), not when the PR merges. ${tail}`),
|
|
847
|
-
/no longer says, in one sentence/,
|
|
848
|
-
abbr,
|
|
849
|
-
);
|
|
850
|
-
}
|
|
851
|
-
});
|
|
852
|
-
|
|
853
|
-
test("windowClaimFault still refuses a negation spelled with the opening curly quote — only U+2019 is accepted (#1852)", () => {
|
|
854
|
-
// U+2018 is what smart-quote engines use to OPEN a single-quoted span, never
|
|
855
|
-
// inside a contraction, so a paraphrase relying on it for "doesn't" is not one.
|
|
856
|
-
assert.match(
|
|
857
|
-
windowClaimFault(
|
|
858
|
-
".nvmrc holds an EXACT version, and Renovate moves it on a monthly schedule rather than a human noticing: see ADR 0010. That schedule’s window bounds when the bot opens its PR; it doesn\u2018t decide when the PR merges. Do not hand-edit this to float.",
|
|
859
|
-
),
|
|
860
|
-
/no longer says, in one sentence/,
|
|
861
|
-
);
|
|
862
|
-
});
|
|
863
|
-
|
|
864
|
-
// #1956. The same comment's merge clause said the merge waits on the required
|
|
865
|
-
// checks, whenever they finish — written by #1753 as if the checks alone gate
|
|
866
|
-
// every bump, when #1752 had already narrowed that: renovate.json's `major`
|
|
867
|
-
// rule sets `automerge: false`, so a major bump's merge waits on a human as
|
|
868
|
-
// well. ADR 0010 point 3 took the same narrowing in #1906. This bans the
|
|
869
|
-
// unscoped form: a sentence that ties the merge to the checks must name both
|
|
870
|
-
// the major and the human it waits on, inside that sentence, for the reason
|
|
871
|
-
// windowClaimFault gives for its ceiling — read any wider, the lead's "rather
|
|
872
|
-
// than a human noticing" supplies the human for a merge clause that never
|
|
873
|
-
// mentions one. The ceiling's cost: a paraphrase stating the exception only
|
|
874
|
-
// in the NEXT sentence reds too. It pins the exception's presence, not its
|
|
875
|
-
// polarity — "a major merges without a human" names both and passes — and no
|
|
876
|
-
// update-type list: which types automerge is renovate.json's to say, and
|
|
877
|
-
// renovate-release-contract.test.mjs already reds a major that automerges.
|
|
878
|
-
export function majorMergeFault(block) {
|
|
879
|
-
const unscoped = sentences(block).find(
|
|
880
|
-
(s) =>
|
|
881
|
-
/\b(?:auto-?)?merg/i.test(s) &&
|
|
882
|
-
/\b(checks?|CI|green)\b/i.test(s) &&
|
|
883
|
-
!(/\bmajors?\b/i.test(s) && /\b(humans?|maintainers?|manual(?:ly)?|by hand)\b/i.test(s)),
|
|
884
|
-
);
|
|
885
|
-
return unscoped === undefined
|
|
886
|
-
? null
|
|
887
|
-
: `the pin's comment ties the merge to the checks without saying, in that sentence, that a major bump's merge waits on a human too — #1956: "${unscoped}"`;
|
|
888
|
-
}
|
|
889
|
-
|
|
890
|
-
test("the pin's comment says a major bump's merge waits on a human, not on the checks alone (#1956)", () => {
|
|
891
|
-
const block = pinOwnerComment();
|
|
892
|
-
assert.ok(block, "no setup-node step in ci.yml carries a comment pointing at ADR 0010 any more");
|
|
893
|
-
assert.equal(majorMergeFault(block), null);
|
|
894
|
-
});
|
|
895
|
-
|
|
896
|
-
test("majorMergeFault accepts a scoped merge clause or none; an unscoped one, or one scoped only in the next sentence, is refused (#1956)", () => {
|
|
897
|
-
const lead = ".nvmrc holds an EXACT version, and Renovate moves it on a monthly schedule rather than a human noticing: see ADR 0010.";
|
|
898
|
-
const tail = "Do not hand-edit this to float.";
|
|
899
|
-
const window = "That schedule's window bounds when the bot opens its PR, not when the PR merges";
|
|
900
|
-
|
|
901
|
-
assert.equal(majorMergeFault(`${lead} ${window}: the merge waits on the required checks, whenever they finish, and a major bump's waits on a human too. ${tail}`), null);
|
|
902
|
-
assert.equal(majorMergeFault(`${lead} ${window}: minor and patch bumps merge once CI goes green; a major waits for a maintainer as well. ${tail}`), null);
|
|
903
|
-
assert.equal(majorMergeFault(`${lead} ${window}. ${tail}`), null);
|
|
904
|
-
|
|
905
|
-
// The text as it stood before #1956, and the paraphrase #1753 accepted of it.
|
|
906
|
-
assert.match(majorMergeFault(`${lead} ${window}: the merge waits on the required checks, whenever they finish. ${tail}`), /#1956/);
|
|
907
|
-
assert.match(majorMergeFault(`${lead} The window only limits when Renovate raises the pull request; merging happens whenever the required checks go green. ${tail}`), /#1956/);
|
|
908
|
-
// Half the exception: a major with no human, or a human with no major.
|
|
909
|
-
assert.match(majorMergeFault(`${lead} ${window}: the merge waits on the required checks, major or not. ${tail}`), /#1956/);
|
|
910
|
-
assert.match(majorMergeFault(`${lead} ${window}: the merge waits on the required checks and a human. ${tail}`), /#1956/);
|
|
911
|
-
// "automerges"/"automerged" makes the same unscoped claim without the bare
|
|
912
|
-
// word "merge" — the trigger must catch it too, scoped or not (#1956 follow-up).
|
|
913
|
-
assert.match(majorMergeFault(`${lead} ${window}: every bump automerges once the required checks pass. ${tail}`), /#1956/);
|
|
914
|
-
assert.equal(majorMergeFault(`${lead} ${window}: every bump automerges once the required checks pass, except a major, which waits on a human. ${tail}`), null);
|
|
915
|
-
// The ceiling: the next sentence's exception does not scope this one.
|
|
916
|
-
assert.match(majorMergeFault(`${lead} ${window}: the merge waits on the required checks. A major waits on a human too. ${tail}`), /#1956/);
|
|
917
|
-
});
|
|
918
|
-
|
|
919
|
-
test("pinOwnerComment refuses to pick silently between two setup-node comments that both cite ADR 0010 (#1838)", () => {
|
|
920
|
-
const lines = [
|
|
921
|
-
" steps:",
|
|
922
|
-
" # decoy: cites ADR 0010 but is not the real pin,",
|
|
923
|
-
" # over two lines like the real one.",
|
|
924
|
-
" - uses: actions/setup-node@v5",
|
|
925
|
-
" # the real pin, citing ADR 0010 too,",
|
|
926
|
-
" # over two lines.",
|
|
927
|
-
" - uses: actions/setup-node@v5",
|
|
928
|
-
];
|
|
929
|
-
assert.throws(() => pinOwnerComment(lines), /2 setup-node comment blocks citing "ADR 0010"/);
|
|
930
|
-
});
|
|
931
|
-
|
|
932
|
-
// #1838's exploit, re-run against the pointer rule: a one-line citation of
|
|
933
|
-
// ADR 0010 at an earlier step, then the real paragraph reverted to its stale
|
|
934
|
-
// pre-#1753 form. The pointer is not a candidate, so the stale paragraph is
|
|
935
|
-
// the block checked, and it still reds.
|
|
936
|
-
test("a one-line pointer citing ADR 0010 is never taken for the owner (#1756)", () => {
|
|
937
|
-
const lines = [
|
|
938
|
-
" steps:",
|
|
939
|
-
" # Exact pin Renovate moves: see ADR 0010. Do not hand-edit this to float.",
|
|
940
|
-
" - uses: actions/setup-node@v5",
|
|
941
|
-
" # .nvmrc holds an EXACT version, and Renovate moves it on a monthly",
|
|
942
|
-
" # schedule rather than a human noticing: see ADR 0010. Do not hand-edit",
|
|
943
|
-
" # this to float.",
|
|
944
|
-
" - uses: actions/setup-node@v5",
|
|
945
|
-
];
|
|
946
|
-
const owner = pinOwnerComment(lines);
|
|
947
|
-
assert.match(owner, /monthly schedule rather than a human noticing/);
|
|
948
|
-
assert.match(windowClaimFault(owner), /no longer says, in one sentence/);
|
|
949
|
-
});
|
|
950
|
-
|
|
951
|
-
// #1756. Only the owner's comment named ADR 0010 and the do-not-hand-edit
|
|
952
|
-
// rule, so a reader who opened ci.yml at any other setup-node step met no
|
|
953
|
-
// warning at all. Each of those steps now carries a one-line pointer to both.
|
|
954
|
-
// One line is the FORM being pinned, not a figure: a copied paragraph is two
|
|
955
|
-
// copies of one rule, the drift workflow-files.mjs's header names for a
|
|
956
|
-
// discovery rule. Same rule as #348's pins — it bans the stale forms (a
|
|
957
|
-
// step with no pointer, a pointer missing the ADR or the rule, a pointer grown
|
|
958
|
-
// into a paragraph) and accepts any paraphrase. It pins no count of steps:
|
|
959
|
-
// adding or dropping a Node-setup site needs no edit here. The rule and its
|
|
960
|
-
// negation must share a sentence, for the reason windowClaimFault gives, AND
|
|
961
|
-
// sit within six words of "hand-edit" itself — co-occurrence anywhere in the
|
|
962
|
-
// sentence is not enough, because "Hand-edit this pin whenever convenient;
|
|
963
|
-
// there is no rule against it." shares a sentence with a negation that never
|
|
964
|
-
// touches the verb it is supposed to forbid (reproduced: that exact wording,
|
|
965
|
-
// and "Renovate no longer manages this on its own — hand-edit if it drifts.",
|
|
966
|
-
// both passed here undetected until the word-window check was added). The
|
|
967
|
-
// ceiling: an unrelated comment run directly above a pointer makes it a
|
|
968
|
-
// multi-line citation, a second candidate owner that pinOwnerComment refuses
|
|
969
|
-
// loudly; a blank line between the two keeps the pointer its own run.
|
|
970
|
-
export function pointerFault({ block, lines }) {
|
|
971
|
-
if (lines === 0) return "carries no comment directly above its opener — no pointer to ADR 0010 or the do-not-hand-edit rule, and a comment with a blank line under it is not the step's";
|
|
972
|
-
if (!block.includes("ADR 0010")) return "no longer points at ADR 0010";
|
|
973
|
-
const rule = sentences(block).some((s) => {
|
|
974
|
-
const m = /hand-?edit\w*/i.exec(s);
|
|
975
|
-
if (!m) return false;
|
|
976
|
-
const tokens = s.split(/\s+/);
|
|
977
|
-
let pos = 0;
|
|
978
|
-
let idx = -1;
|
|
979
|
-
for (let i = 0; i < tokens.length; i++) {
|
|
980
|
-
if (m.index >= pos && m.index < pos + tokens[i].length + 1) {
|
|
981
|
-
idx = i;
|
|
982
|
-
break;
|
|
983
|
-
}
|
|
984
|
-
pos += tokens[i].length + 1;
|
|
985
|
-
}
|
|
986
|
-
if (idx === -1) return false;
|
|
987
|
-
const WINDOW = 6;
|
|
988
|
-
const nearby = tokens.slice(Math.max(0, idx - WINDOW), idx + WINDOW + 1).join(" ");
|
|
989
|
-
// cannot and the curly apostrophe — the two forms this fix adds — match
|
|
990
|
-
// windowClaimFault's NEGATION too (#1852); the two functions' negation
|
|
991
|
-
// word lists otherwise differ intentionally (this one also accepts "no").
|
|
992
|
-
return /\b(?:not|cannot|never|no)\b/i.test(nearby) || /n['’]t\b/i.test(nearby);
|
|
993
|
-
});
|
|
994
|
-
if (!rule) return "no longer carries the do-not-hand-edit rule";
|
|
995
|
-
if (lines > 1) return "has grown past one line — a pointer that copies the owner's paragraph is the drift it exists to avoid";
|
|
996
|
-
return null;
|
|
997
|
-
}
|
|
998
|
-
|
|
999
|
-
test("every setup-node step but the owner points at ADR 0010 and the do-not-hand-edit rule in one line", () => {
|
|
1000
|
-
const owner = pinOwnerComment();
|
|
1001
|
-
for (const c of setupNodeComments().filter((c) => c.block !== owner)) {
|
|
1002
|
-
const fault = pointerFault(c);
|
|
1003
|
-
assert.equal(fault, null, `the setup-node step in ci.yml's \`${c.job}\` job ${fault}`);
|
|
1004
|
-
}
|
|
1005
|
-
});
|
|
1006
|
-
|
|
1007
|
-
// The prefix every synthetic workflow below hangs its steps from: a job, and
|
|
1008
|
-
// its `steps:` key (#1920 — a step is only an entry of `steps:`). Shapes that
|
|
1009
|
-
// vary the job or `steps:` spelling itself still spell it out.
|
|
1010
|
-
const job = [" job:", " steps:"];
|
|
1011
|
-
|
|
1012
|
-
// The comment run a bare `- uses:` step directly under `comment` gets.
|
|
1013
|
-
const at = (...comment) => setupNodeComments([...job, ...comment, " - uses: actions/setup-node@v5"])[0];
|
|
1014
|
-
|
|
1015
|
-
// #1873. A setup-node step whose `- ` opener is another key — `- name:` above
|
|
1016
|
-
// its `uses:`, a shape other steps in ci.yml already take — was never
|
|
1017
|
-
// discovered, so every pin reading steps through setupNodeComments was blind
|
|
1018
|
-
// to it: such a step with no pointer at all passed every test here. A reader
|
|
1019
|
-
// meets the step's comment above its opener, not above `uses:`, so that is
|
|
1020
|
-
// where the run is read.
|
|
1021
|
-
test("a setup-node step opened by another key is discovered, its comment read above that opener (#1873)", () => {
|
|
1022
|
-
const pointer = " # Exact pin Renovate moves: see ADR 0010. Do not hand-edit this to float.";
|
|
1023
|
-
const named = [" - name: Set up Node", " uses: actions/setup-node@v5"];
|
|
1024
|
-
|
|
1025
|
-
// The ticket's own repro: no comment, and the step used to come back unseen.
|
|
1026
|
-
assert.deepEqual(setupNodeComments([...job, ...named]), [{ block: "", lines: 0, job: "job" }]);
|
|
1027
|
-
assert.match(pointerFault(setupNodeComments([...job, ...named])[0]), /no comment directly above its opener/);
|
|
1028
|
-
|
|
1029
|
-
// What the wider match must still ACCEPT: a pointer above the opener, with
|
|
1030
|
-
// sibling keys, a nested value or a quoted scalar anywhere in between.
|
|
1031
|
-
for (const step of [
|
|
1032
|
-
named,
|
|
1033
|
-
[" - id: node", " with:", " node-version-file: .nvmrc", " uses: 'actions/setup-node@v5'"],
|
|
1034
|
-
[' - uses: "actions/setup-node@v5"'],
|
|
1035
|
-
]) {
|
|
1036
|
-
const found = setupNodeComments([...job, pointer, ...step]);
|
|
1037
|
-
assert.deepEqual(found, [{ block: pointer.replace(/^\s*#\s?/, ""), lines: 1, job: "job" }], step.join("\n"));
|
|
1038
|
-
assert.equal(pointerFault(found[0]), null);
|
|
1039
|
-
}
|
|
1040
|
-
});
|
|
1041
|
-
|
|
1042
|
-
// #1838's exploit through the same gap: with the real owner refactored into a
|
|
1043
|
-
// named step, a bare-form decoy was the only candidate pinOwnerComment could
|
|
1044
|
-
// see, so it validated the decoy while the real paragraph rotted unchecked.
|
|
1045
|
-
test("pinOwnerComment sees an owner written as a named step, so a bare-form decoy cannot stand in for it (#1873)", () => {
|
|
1046
|
-
const owner = [
|
|
1047
|
-
" # .nvmrc holds an EXACT version, and Renovate moves it on a monthly",
|
|
1048
|
-
" # schedule: see ADR 0010. Do not hand-edit this to float.",
|
|
1049
|
-
" - id: node",
|
|
1050
|
-
" with:",
|
|
1051
|
-
" node-version-file: .nvmrc",
|
|
1052
|
-
" uses: actions/setup-node@v5",
|
|
1053
|
-
];
|
|
1054
|
-
const decoy = [
|
|
1055
|
-
" # decoy: cites ADR 0010 but is not the real pin,",
|
|
1056
|
-
" # over two lines like the real one.",
|
|
1057
|
-
" - uses: actions/setup-node@v5",
|
|
1058
|
-
];
|
|
1059
|
-
assert.match(pinOwnerComment([" steps:", ...owner]), /monthly schedule: see ADR 0010/);
|
|
1060
|
-
assert.throws(() => pinOwnerComment([" steps:", ...decoy, ...owner]), /2 setup-node comment blocks citing "ADR 0010"/);
|
|
1061
|
-
});
|
|
1062
|
-
|
|
1063
|
-
// The wider match's own false-positive class: a `uses:` line is a step only
|
|
1064
|
-
// when the first shallower line above it opens a sequence entry. Under `with:`
|
|
1065
|
-
// it is not, and a phantom step there would red the pointer test over a step
|
|
1066
|
-
// that does not exist. It sits under `steps:`, so it is that first shallower
|
|
1067
|
-
// line, not #1920's parent check, refusing it. Inside a `run:` script the line
|
|
1068
|
-
// is refused the same way — `run: |` opens no sequence entry either, so the
|
|
1069
|
-
// shallower-line check above never needs #1975's block-scalar check to catch
|
|
1070
|
-
// this shape, though that check would refuse it too.
|
|
1071
|
-
test("a `uses: actions/setup-node@` line that is not a step's own key is not taken for a step (#1873)", () => {
|
|
1072
|
-
const scripted = [" - name: Print an example", " run: |", " uses: actions/setup-node@v5"];
|
|
1073
|
-
const nested = [" - uses: some/action@v1", " with:", " uses: actions/setup-node@v5"];
|
|
1074
|
-
assert.deepEqual(setupNodeComments([...job, ...scripted]), []);
|
|
1075
|
-
assert.deepEqual(setupNodeComments([...job, ...nested]), []);
|
|
1076
|
-
});
|
|
1077
|
-
|
|
1078
|
-
// #1920. That first shallower line can open a sequence entry and still not be
|
|
1079
|
-
// a step's: a list nested in `with:` or a matrix `include:` has `- ` entries of
|
|
1080
|
-
// its own, keyed at exactly the column of a `uses:` under them — or written as
|
|
1081
|
-
// `- uses:` outright — so no column check tells them from a step. What does is
|
|
1082
|
-
// the key they hang from: a step is an entry of `steps:`. And a key written on
|
|
1083
|
-
// the dash line itself (`- with:`) makes the step's opener the first shallower
|
|
1084
|
-
// line above a `uses:` nested in that key's value; there the column does tell,
|
|
1085
|
-
// because a step's own keys start where the text after its `- ` does. The
|
|
1086
|
-
// `run: |` shapes here are still refused by those same two mechanisms — the
|
|
1087
|
-
// nested one because `run: |` opens no sequence entry, the dash-line one by
|
|
1088
|
-
// the column tell just above — not because #1975's block-scalar check ran;
|
|
1089
|
-
// that check would refuse either shape too, but neither depends on it.
|
|
1090
|
-
test("a `uses: actions/setup-node@` line under an entry that is not a step's, or inside a key on a step's dash line, is not a step (#1920)", () => {
|
|
1091
|
-
for (const shape of [
|
|
1092
|
-
[...job, " - uses: some/action@v1", " with:", " items:", " - key: a", " uses: actions/setup-node@v5"],
|
|
1093
|
-
[...job, " - uses: some/action@v1", " with:", " items:", " - uses: actions/setup-node@v5"],
|
|
1094
|
-
[...job, " - name: Print an example", " run: |", " - uses: actions/setup-node@v5"],
|
|
1095
|
-
[" job:", " strategy:", " matrix:", " include:", " - node: 20", " uses: actions/setup-node@v5"],
|
|
1096
|
-
[...job, " - run: |", " uses: actions/setup-node@v5"],
|
|
1097
|
-
[...job, " - with:", " uses: actions/setup-node@v5"],
|
|
1098
|
-
[...job, " - uses: some/action@v1", " with:", " - uses: actions/setup-node@v5"],
|
|
1099
|
-
[" job:", " volumes:", " -", " uses: actions/setup-node@v5"],
|
|
1100
|
-
]) {
|
|
1101
|
-
assert.deepEqual(setupNodeComments(shape), [], shape.join("\n"));
|
|
1102
|
-
}
|
|
1103
|
-
|
|
1104
|
-
// What the two checks must still ACCEPT: entries level with `steps:`, keys
|
|
1105
|
-
// set wide of the dash or starting on the line under a bare one, a comment on
|
|
1106
|
-
// `steps:`, and an earlier step whose `with:` nests an entry of its own.
|
|
1107
|
-
const text = "Exact pin Renovate moves: see ADR 0010. Do not hand-edit this to float.";
|
|
1108
|
-
for (const shape of [
|
|
1109
|
-
[...job, ` # ${text}`, " - name: Set up Node", " uses: actions/setup-node@v5"],
|
|
1110
|
-
[...job, ` # ${text}`, " - uses: actions/setup-node@v5"],
|
|
1111
|
-
[...job, ` # ${text}`, " - name: Set up Node", " uses: actions/setup-node@v5"],
|
|
1112
|
-
[...job, ` # ${text}`, " -", " name: Set up Node", " uses: actions/setup-node@v5"],
|
|
1113
|
-
[
|
|
1114
|
-
" job:",
|
|
1115
|
-
" steps: # one entry per step",
|
|
1116
|
-
" - uses: some/action@v1",
|
|
1117
|
-
" with:",
|
|
1118
|
-
" items:",
|
|
1119
|
-
" - key: a",
|
|
1120
|
-
"",
|
|
1121
|
-
` # ${text}`,
|
|
1122
|
-
" - name: Set up Node",
|
|
1123
|
-
" uses: actions/setup-node@v5",
|
|
1124
|
-
],
|
|
1125
|
-
]) {
|
|
1126
|
-
assert.deepEqual(setupNodeComments(shape), [{ block: text, lines: 1, job: "job" }], shape.join("\n"));
|
|
1127
|
-
}
|
|
1128
|
-
});
|
|
1129
|
-
|
|
1130
|
-
// #1920 follow-up: `steps:` is only a key spelled that way — the parent check
|
|
1131
|
-
// alone never verifies it opens the JOB's list rather than some nested config
|
|
1132
|
-
// that happens to reuse the name. An action's `with:` block (or any other
|
|
1133
|
-
// nesting) can carry its own key called `steps:` several levels down; without
|
|
1134
|
-
// checking that `steps:` itself hangs from a job, that nested key passes the
|
|
1135
|
-
// parent check exactly like the real one and manufactures a phantom step.
|
|
1136
|
-
test("a nested key merely spelled `steps:` cannot own a step; only one hanging from a job can (#1920 follow-up)", () => {
|
|
1137
|
-
const collision = [
|
|
1138
|
-
...job,
|
|
1139
|
-
" - uses: some/action@v1",
|
|
1140
|
-
" with:",
|
|
1141
|
-
" config:",
|
|
1142
|
-
" steps:",
|
|
1143
|
-
" - uses: actions/setup-node@v5",
|
|
1144
|
-
];
|
|
1145
|
-
assert.deepEqual(setupNodeComments(collision), [], collision.join("\n"));
|
|
1146
|
-
});
|
|
1147
|
-
|
|
1148
|
-
// #1920 follow-up: the column check's bare-`-` exemption matched only a dash
|
|
1149
|
-
// with NOTHING after it. A dash followed by a trailing comment (a note on the
|
|
1150
|
-
// opener itself, not one of its keys) has no key text of its own either, but
|
|
1151
|
-
// the comment's own column is not its keys' column — so without the same
|
|
1152
|
-
// exemption, a real step opened that way silently dropped out of the
|
|
1153
|
-
// returned set instead of being found.
|
|
1154
|
-
test("a bare `-` opener followed only by a trailing comment does not perturb the column check; the step is still discovered (#1920 follow-up)", () => {
|
|
1155
|
-
const found = setupNodeComments([...job, " - # Set up Node", " name: Set up Node", " uses: actions/setup-node@v5"]);
|
|
1156
|
-
assert.deepEqual(found, [{ block: "", lines: 0, job: "job" }]);
|
|
1157
|
-
});
|
|
1158
|
-
|
|
1159
|
-
// #1975. A block scalar's content — a `run: |` script, a github-script body, a
|
|
1160
|
-
// heredoc writing a fixture workflow — is one string, however much of it is
|
|
1161
|
-
// spelled like keys, `- ` entries or comments. Read as structure it made a
|
|
1162
|
-
// phantom step, or lent the step under it a comment that was a line of the
|
|
1163
|
-
// script above. At a step's depth #1920's job check already refuses the
|
|
1164
|
-
// phantom, since no line of a step's scalar sits where a job key does; a
|
|
1165
|
-
// top-level scalar's content can, and the comment run has no job check at all.
|
|
1166
|
-
test("a block scalar's content is text: never a step, never a step's comment (#1975)", () => {
|
|
1167
|
-
const setup = " - uses: actions/setup-node@v5";
|
|
1168
|
-
const text = "Exact pin Renovate moves: see ADR 0010. Do not hand-edit this to float.";
|
|
1169
|
-
|
|
1170
|
-
// A job-shaped fixture as a top-level scalar, the last with an indentation
|
|
1171
|
-
// indicator setting its content shallower than its first line, which
|
|
1172
|
-
// auto-detection would miss.
|
|
1173
|
-
for (const shape of [
|
|
1174
|
-
["description: |", ...job, setup],
|
|
1175
|
-
["description: >-", ...job, setup],
|
|
1176
|
-
["description: |2", " deeper", ...job, setup],
|
|
1177
|
-
]) {
|
|
1178
|
-
assert.deepEqual(setupNodeComments(shape), [], shape.join("\n"));
|
|
1179
|
-
}
|
|
1180
|
-
|
|
1181
|
-
// Each header spelling, its script ending in a shell comment right above the
|
|
1182
|
-
// next step's opener: that line is the script's, not the step's comment. A
|
|
1183
|
-
// bare `- |` is the entry's own value, so its content need only sit deeper
|
|
1184
|
-
// than the dash, not than a key.
|
|
1185
|
-
const script = [" npm run build", " # shell note, script content"];
|
|
1186
|
-
for (const scalar of [
|
|
1187
|
-
[" - name: Build", " run: |", ...script],
|
|
1188
|
-
[" - name: Build", " run: >-", ...script],
|
|
1189
|
-
[" - name: Build", " run: |+ # keep the final newline", ...script],
|
|
1190
|
-
[" - name: Build", " run: &build |", ...script],
|
|
1191
|
-
[" - name: Build", " run: !!str |", ...script],
|
|
1192
|
-
[" - name: Build", ' "run": |2', ...script],
|
|
1193
|
-
[" - run: |", ...script],
|
|
1194
|
-
[" - |", " npm run build", " # shell note, script content"],
|
|
1195
|
-
]) {
|
|
1196
|
-
const shape = [...job, ...scalar, setup];
|
|
1197
|
-
assert.deepEqual(setupNodeComments(shape), [{ block: "", lines: 0, job: "job" }], shape.join("\n"));
|
|
1198
|
-
}
|
|
1199
|
-
|
|
1200
|
-
// What the check must still ACCEPT: a comment the scalar has ended before —
|
|
1201
|
-
// back at the dash, or deeper than `run:` but shallower than the script's
|
|
1202
|
-
// own lines, where YAML ends the scalar too — a value that merely ends in a
|
|
1203
|
-
// `|`, and a step after a top-level scalar.
|
|
1204
|
-
for (const shape of [
|
|
1205
|
-
[...job, " - name: Build", " run: |", " npm run build", ` # ${text}`, setup],
|
|
1206
|
-
[...job, " - name: Build", " run: |", " npm run build", ` # ${text}`, setup],
|
|
1207
|
-
[...job, " - name: Build", " run: npm test ||", ` # ${text}`, setup],
|
|
1208
|
-
["description: |", " text", "jobs:", ...job, ` # ${text}`, setup],
|
|
1209
|
-
]) {
|
|
1210
|
-
assert.deepEqual(setupNodeComments(shape), [{ block: text, lines: 1, job: "job" }], shape.join("\n"));
|
|
1211
|
-
}
|
|
1212
|
-
|
|
1213
|
-
// An empty scalar ends where it starts: a key level with its own is the
|
|
1214
|
-
// step's next key, whether the scalar's key sits on the dash line or not.
|
|
1215
|
-
for (const shape of [
|
|
1216
|
-
[...job, " - run: |", " uses: actions/setup-node@v5"],
|
|
1217
|
-
[...job, " - name: Build", " run: |", " uses: actions/setup-node@v5"],
|
|
1218
|
-
]) {
|
|
1219
|
-
assert.deepEqual(setupNodeComments(shape), [{ block: "", lines: 0, job: "job" }], shape.join("\n"));
|
|
1220
|
-
}
|
|
1221
|
-
|
|
1222
|
-
// Boundary precision on the depth arithmetic itself: an explicit
|
|
1223
|
-
// indentation indicator's depth is the KEY's column plus the indicator —
|
|
1224
|
-
// not the indicator alone — and a comment sitting one column shy of that
|
|
1225
|
-
// depth has already left the scalar, so it is the next step's real
|
|
1226
|
-
// comment, not swallowed script text. The chomping-then-indicator spelling
|
|
1227
|
-
// (`|-2`) carries its digit in the same place as `|2-`; a first content
|
|
1228
|
-
// line indented deeper than the indicator still leaves the depth at the
|
|
1229
|
-
// indicator's own value, not an auto-detected one, which a second,
|
|
1230
|
-
// shallower-but-still-in-scalar line below it proves. And a bare dash's
|
|
1231
|
-
// column is the dash's own position, not one past it: content one column
|
|
1232
|
-
// beyond it is swallowed, and nothing shallower is reachable without
|
|
1233
|
-
// leaving the entry.
|
|
1234
|
-
assert.deepEqual(
|
|
1235
|
-
setupNodeComments([
|
|
1236
|
-
...job,
|
|
1237
|
-
" - name: Build",
|
|
1238
|
-
" run: |2",
|
|
1239
|
-
" npm run build",
|
|
1240
|
-
" # a real comment for the next step",
|
|
1241
|
-
setup,
|
|
1242
|
-
]),
|
|
1243
|
-
[{ block: "a real comment for the next step", lines: 1, job: "job" }],
|
|
1244
|
-
);
|
|
1245
|
-
assert.deepEqual(
|
|
1246
|
-
setupNodeComments([
|
|
1247
|
-
...job,
|
|
1248
|
-
" - name: Build",
|
|
1249
|
-
" run: |-2",
|
|
1250
|
-
" npm run build",
|
|
1251
|
-
" # would-be leaked comment",
|
|
1252
|
-
setup,
|
|
1253
|
-
]),
|
|
1254
|
-
[{ block: "", lines: 0, job: "job" }],
|
|
1255
|
-
);
|
|
1256
|
-
assert.deepEqual(
|
|
1257
|
-
setupNodeComments([...job, " - |", " # inside the scalar, must not surface as a comment", setup]),
|
|
1258
|
-
[{ block: "", lines: 0, job: "job" }],
|
|
1259
|
-
);
|
|
1260
|
-
});
|
|
1261
|
-
|
|
1262
|
-
// #1975. Each key the walk reads by name was matched in its bare spelling
|
|
1263
|
-
// only, so a genuine step under a quoted `"steps":` — valid YAML — silently
|
|
1264
|
-
// dropped out of the returned set; a quoted `uses:` or job key did the same,
|
|
1265
|
-
// and so did a job key carrying a trailing comment.
|
|
1266
|
-
test("a key spelled quoted, with a space before its colon, or with a trailing comment still names it (#1975)", () => {
|
|
1267
|
-
const setup = " - uses: actions/setup-node@v5";
|
|
1268
|
-
for (const shape of [
|
|
1269
|
-
["jobs:", " job:", ' "steps":', " - name: x", " uses: actions/setup-node@v5"],
|
|
1270
|
-
["jobs:", " job:", " 'steps':", setup],
|
|
1271
|
-
["jobs:", " job:", " steps :", setup],
|
|
1272
|
-
["jobs:", ...job, ' - "uses": actions/setup-node@v5'],
|
|
1273
|
-
["jobs:", ...job, " - name: x", " 'uses' : actions/setup-node@v5"],
|
|
1274
|
-
["jobs:", ' "job":', " steps:", setup],
|
|
1275
|
-
["jobs:", " job :", " steps:", setup],
|
|
1276
|
-
["jobs:", " job: # the job's own note", " steps:", setup],
|
|
1277
|
-
]) {
|
|
1278
|
-
assert.deepEqual(setupNodeComments(shape), [{ block: "", lines: 0, job: "job" }], shape.join("\n"));
|
|
1279
|
-
}
|
|
1280
|
-
|
|
1281
|
-
// A key that only contains the name is still not it.
|
|
1282
|
-
for (const shape of [
|
|
1283
|
-
["jobs:", " job:", " pre-steps:", setup],
|
|
1284
|
-
["jobs:", " job:", ' "steps2":', setup],
|
|
1285
|
-
]) {
|
|
1286
|
-
assert.deepEqual(setupNodeComments(shape), [], shape.join("\n"));
|
|
1287
|
-
}
|
|
1288
|
-
});
|
|
1289
|
-
|
|
1290
|
-
// #2000. Four more gaps in the same two functions as #1975's, confirmed
|
|
1291
|
-
// against PyYAML and confirmed identical on PR #1995's base and head —
|
|
1292
|
-
// pre-existing, not a regression of that fix. Grouped by the ticket's own
|
|
1293
|
-
// finding numbers for traceability.
|
|
1294
|
-
test("an anchor or tag on a job key or a uses: key does not drop the step (#2000 finding 1)", () => {
|
|
1295
|
-
assert.deepEqual(setupNodeComments(["jobs:", " job: &j", " steps:", " - uses: actions/setup-node@v5"]), [
|
|
1296
|
-
{ block: "", lines: 0, job: "job" },
|
|
1297
|
-
]);
|
|
1298
|
-
assert.deepEqual(setupNodeComments(["jobs:", ...job, " - uses: &u actions/setup-node@v5"]), [
|
|
1299
|
-
{ block: "", lines: 0, job: "job" },
|
|
1300
|
-
]);
|
|
1301
|
-
});
|
|
1302
|
-
|
|
1303
|
-
test("uses: with no whitespace before its value is a plain scalar, never a step's own key (#2000 finding 2)", () => {
|
|
1304
|
-
assert.deepEqual(setupNodeComments(["jobs:", ...job, " - uses:actions/setup-node@v5"]), []);
|
|
1305
|
-
});
|
|
1306
|
-
|
|
1307
|
-
test("a plain key containing a literal # is still a block-scalar header, not read as structure (#2000 finding 3)", () => {
|
|
1308
|
-
assert.deepEqual(setupNodeComments(["C#: |", ...job, " - uses: actions/setup-node@v5"]), []);
|
|
1309
|
-
});
|
|
1310
|
-
|
|
1311
|
-
test("a document-start scalar (--- |) is still a block-scalar header, not read as structure (#2000 finding 4)", () => {
|
|
1312
|
-
assert.deepEqual(setupNodeComments(["--- |", ...job, " - uses: actions/setup-node@v5"]), []);
|
|
1313
|
-
});
|
|
1314
|
-
|
|
1315
|
-
// Found in review of #2005, alongside the ticket's own five: the bare `!`
|
|
1316
|
-
// non-specific tag (YAML's tag shorthand with no characters of its own) was
|
|
1317
|
-
// refused by the `\S+` this PR's finding-1 fix used for the anchor/tag
|
|
1318
|
-
// token, where blockScalarText's own header regex above already accepted it
|
|
1319
|
-
// via `\S*`. Confirmed against PyYAML (`compose`): both shapes hold a real
|
|
1320
|
-
// step.
|
|
1321
|
-
test("a bare ! non-specific tag on a job key or a uses: key does not drop the step", () => {
|
|
1322
|
-
assert.deepEqual(setupNodeComments(["jobs:", " job: !", " steps:", " - uses: actions/setup-node@v5"]), [
|
|
1323
|
-
{ block: "", lines: 0, job: "job" },
|
|
1324
|
-
]);
|
|
1325
|
-
assert.deepEqual(setupNodeComments(["jobs:", ...job, " - uses: ! actions/setup-node@v5"]), [
|
|
1326
|
-
{ block: "", lines: 0, job: "job" },
|
|
1327
|
-
]);
|
|
1328
|
-
});
|
|
1329
|
-
|
|
1330
|
-
// #2006 finding A. A job key's colon took an anchor, tag or comment with no
|
|
1331
|
-
// whitespace before it (`job:&j`), where a `uses:` key's already needed some
|
|
1332
|
-
// (#2000 finding 2) — YAML's own rule, and the one line with no document
|
|
1333
|
-
// behind it: PyYAML refuses every rejected shape here outright. Both halves
|
|
1334
|
-
// pinned, so the tightening cannot creep into refusing a key whose colon ends
|
|
1335
|
-
// the line or is followed by real whitespace.
|
|
1336
|
-
test("a job key's anchor, tag or comment needs whitespace after its colon, as a uses: key's does (#2006 finding A)", () => {
|
|
1337
|
-
const setup = " - uses: actions/setup-node@v5";
|
|
1338
|
-
for (const key of [" job:&j", " job:!t", " job:!", " job:#c"]) {
|
|
1339
|
-
assert.deepEqual(setupNodeComments(["jobs:", key, " steps:", setup]), [], key);
|
|
1340
|
-
}
|
|
1341
|
-
for (const key of [" job:", " job: ", " job: &j !!map # c"]) {
|
|
1342
|
-
assert.deepEqual(setupNodeComments(["jobs:", key, " steps:", setup]), [{ block: "", lines: 0, job: "job" }], key);
|
|
1343
|
-
}
|
|
1344
|
-
});
|
|
1345
|
-
|
|
1346
|
-
// #2006 finding B. An anchor or tag may also sit BEFORE a key — on the job
|
|
1347
|
-
// key or a `uses:` key — or right after a step's own `- `, on a line of its
|
|
1348
|
-
// own over the step's keys; #2000 only taught the walk the spot between a
|
|
1349
|
-
// key's colon and its value, so each of these real steps (confirmed against
|
|
1350
|
-
// PyYAML's `compose`) dropped out of the returned set. The `steps:` key
|
|
1351
|
-
// takes the same fix too, generalizing the ticket's own wording to a spot
|
|
1352
|
-
// it never named. The property still has to be its own whitespace-separated
|
|
1353
|
-
// token: glued to the key it is part of the key's text, and names some
|
|
1354
|
-
// other key.
|
|
1355
|
-
test("an anchor or tag before a key, or after a step's own `- `, does not drop the step (#2006 finding B)", () => {
|
|
1356
|
-
const setup = " - uses: actions/setup-node@v5";
|
|
1357
|
-
for (const shape of [
|
|
1358
|
-
["jobs:", " &k job:", " steps:", setup],
|
|
1359
|
-
["jobs:", " !!str job:", " steps:", setup],
|
|
1360
|
-
["jobs:", ' &k ! "job": &j', " steps:", setup],
|
|
1361
|
-
["jobs:", " job:", " &k steps:", setup],
|
|
1362
|
-
["jobs:", " job:", " !!str steps:", " - name: x", " uses: actions/setup-node@v5"],
|
|
1363
|
-
["jobs:", ...job, " - &s uses: actions/setup-node@v5"],
|
|
1364
|
-
["jobs:", ...job, " - &s !!str uses: &u actions/setup-node@v5"],
|
|
1365
|
-
["jobs:", ...job, " - name: x", " &u uses: actions/setup-node@v5"],
|
|
1366
|
-
["jobs:", ...job, " - &s", " uses: actions/setup-node@v5"],
|
|
1367
|
-
["jobs:", ...job, " - !!map # c", " name: x", " uses: actions/setup-node@v5"],
|
|
1368
|
-
]) {
|
|
1369
|
-
assert.deepEqual(setupNodeComments(shape), [{ block: "", lines: 0, job: "job" }], shape.join("\n"));
|
|
1370
|
-
}
|
|
1371
|
-
|
|
1372
|
-
for (const shape of [
|
|
1373
|
-
["jobs:", ...job, " - &suses: actions/setup-node@v5"],
|
|
1374
|
-
["jobs:", ...job, " - &s uses:actions/setup-node@v5"],
|
|
1375
|
-
["jobs:", ...job, " - &s with:", " uses: actions/setup-node@v5"],
|
|
1376
|
-
["jobs:", " job:", " with:", " &k steps:", " - uses: actions/setup-node@v5"],
|
|
1377
|
-
["jobs:", " &kjob:", " steps:", setup],
|
|
1378
|
-
["jobs:", " job:", " &ksteps:", setup],
|
|
1379
|
-
]) {
|
|
1380
|
-
assert.deepEqual(setupNodeComments(shape), [], shape.join("\n"));
|
|
1381
|
-
}
|
|
1382
|
-
});
|
|
1383
|
-
|
|
1384
|
-
// Found in review of #2005: a document-start scalar's own indentation
|
|
1385
|
-
// indicator of exactly 1 set `depth` to 0 (column −1 plus indicator 1), a
|
|
1386
|
-
// floor no real line's column can ever go under, so the scalar never closed
|
|
1387
|
-
// and swallowed every later document whole — including a real step in one.
|
|
1388
|
-
// ci.yml has no document marker today, so this was unreachable there, but
|
|
1389
|
-
// PyYAML confirms the second document's step is real.
|
|
1390
|
-
test("a document marker still ends a document-start scalar that carries an explicit indentation indicator", () => {
|
|
1391
|
-
assert.deepEqual(
|
|
1392
|
-
setupNodeComments(["--- |1", " text", "---", "jobs:", ...job, " - uses: actions/setup-node@v5"]),
|
|
1393
|
-
[{ block: "", lines: 0, job: "job" }],
|
|
1394
|
-
);
|
|
1395
|
-
});
|
|
1396
|
-
|
|
1397
|
-
// #2000 finding 5, deliberately NOT fixed here: blockScalarText's own doc
|
|
1398
|
-
// comment above says why — the comment-run walk has no job check to mirror
|
|
1399
|
-
// the one #1920 gives the phantom-step half, so a multi-line quoted or
|
|
1400
|
-
// plain scalar can still lend a step the wrong comment. ci.yml has no such
|
|
1401
|
-
// scalar today, so the gap is latent, and detecting one needs the same
|
|
1402
|
-
// column/indentation tracking this file already does for block scalars,
|
|
1403
|
-
// extended to a wholly different, unindented production — its own design
|
|
1404
|
-
// work the other four findings didn't need.
|
|
1405
|
-
|
|
1406
|
-
// #1919. A blank line ends a step's comment run wherever it falls — the rule
|
|
1407
|
-
// the failglob and Validate JSON walks in this file follow too, so no walk here
|
|
1408
|
-
// disagrees with another about where a comment stops. Above a pointer,
|
|
1409
|
-
// that is the ceiling pointerFault documents: the blank line keeps an
|
|
1410
|
-
// unrelated comment out of the pointer's run. Under a comment, it detaches the
|
|
1411
|
-
// comment from the step: ci.yml sets a blank line between each step and the
|
|
1412
|
-
// one before it, and every comment directly on the step it explains, so a
|
|
1413
|
-
// comment with a blank line under it is, by the file's own layout, not the
|
|
1414
|
-
// step's. Skipping that one gap instead would hand the step whatever floats
|
|
1415
|
-
// above it — a commented-out step, a trailing note on the step before. Pinned
|
|
1416
|
-
// in both halves and both opener forms, so the boundary is a decision, not
|
|
1417
|
-
// whatever the walk happens to do; the fault names the cause, because "no
|
|
1418
|
-
// comment at all" was false with a comment sitting right over the blank line.
|
|
1419
|
-
test("a blank line ends a setup-node step's comment run: it keeps an unrelated comment out, and detaches a comment from the step (#1919)", () => {
|
|
1420
|
-
const pointer = " # Exact pin Renovate moves: see ADR 0010. Do not hand-edit this to float.";
|
|
1421
|
-
const unrelated = " # An unrelated note that happens to sit above the step.";
|
|
1422
|
-
for (const step of [
|
|
1423
|
-
[" - uses: actions/setup-node@v5"],
|
|
1424
|
-
[" - name: Set up Node", " uses: actions/setup-node@v5"],
|
|
1425
|
-
]) {
|
|
1426
|
-
const hugging = setupNodeComments([...job, unrelated, "", pointer, ...step]);
|
|
1427
|
-
assert.deepEqual(hugging, [{ block: pointer.replace(/^\s*#\s?/, ""), lines: 1, job: "job" }], step.join("\n"));
|
|
1428
|
-
assert.equal(pointerFault(hugging[0]), null, step.join("\n"));
|
|
1429
|
-
|
|
1430
|
-
const detached = setupNodeComments([...job, pointer, "", ...step]);
|
|
1431
|
-
assert.deepEqual(detached, [{ block: "", lines: 0, job: "job" }], step.join("\n"));
|
|
1432
|
-
assert.match(pointerFault(detached[0]), /no comment directly above its opener/, step.join("\n"));
|
|
1433
|
-
}
|
|
1434
|
-
});
|
|
1435
|
-
|
|
1436
|
-
test("a paraphrased pointer is accepted; a missing one, a half one and a copied paragraph are not", () => {
|
|
1437
|
-
assert.equal(pointerFault(at(" # Exact pin Renovate moves: see ADR 0010. Do not hand-edit this to float.")), null);
|
|
1438
|
-
assert.equal(pointerFault(at(" # .nvmrc is exact and bot-moved (ADR 0010); never hand-edit it to float.")), null);
|
|
1439
|
-
assert.equal(pointerFault(at(" # Hand-editing this to float is not allowed: ADR 0010 explains why.")), null);
|
|
1440
|
-
|
|
1441
|
-
assert.match(pointerFault(at()), /no comment directly above its opener/);
|
|
1442
|
-
assert.match(pointerFault(at(" # Exact pin Renovate moves. Do not hand-edit this to float.")), /no longer points at ADR 0010/);
|
|
1443
|
-
assert.match(pointerFault(at(" # Exact pin Renovate moves: see ADR 0010.")), /do-not-hand-edit rule/);
|
|
1444
|
-
assert.match(
|
|
1445
|
-
pointerFault(at(" # Hand-edit this freely. See ADR 0010; it does not apply here.")),
|
|
1446
|
-
/do-not-hand-edit rule/,
|
|
1447
|
-
);
|
|
1448
|
-
assert.match(
|
|
1449
|
-
pointerFault(
|
|
1450
|
-
at(
|
|
1451
|
-
" # .nvmrc holds an EXACT version, and Renovate moves it on a monthly",
|
|
1452
|
-
" # schedule: see ADR 0010. Do not hand-edit this to float.",
|
|
1453
|
-
),
|
|
1454
|
-
),
|
|
1455
|
-
/grown past one line/,
|
|
1456
|
-
);
|
|
1457
|
-
});
|
|
1458
|
-
|
|
1459
|
-
test("a negation sharing hand-edit's sentence but not touching it is still a missing rule (#1868)", () => {
|
|
1460
|
-
assert.match(
|
|
1461
|
-
pointerFault(at(" # Hand-edit this pin whenever convenient; there is no rule against it. See ADR 0010.")),
|
|
1462
|
-
/do-not-hand-edit rule/,
|
|
1463
|
-
);
|
|
1464
|
-
assert.match(
|
|
1465
|
-
pointerFault(at(" # Renovate no longer manages this on its own — hand-edit if it drifts. See ADR 0010.")),
|
|
1466
|
-
/do-not-hand-edit rule/,
|
|
1467
|
-
);
|
|
1468
|
-
});
|
|
1469
|
-
|
|
1470
|
-
test("pointerFault accepts a rule negated by 'cannot' or a curly apostrophe, or broken by 'e.g.' (#1852)", () => {
|
|
1471
|
-
assert.equal(pointerFault(at(" # .nvmrc is exact and bot-moved (ADR 0010); it cannot be hand-edited to float.")), null);
|
|
1472
|
-
assert.equal(pointerFault(at(" # Exact pin Renovate moves: see ADR 0010. Don’t hand-edit this to float.")), null);
|
|
1473
|
-
assert.equal(pointerFault(at(" # Never, e.g. for a patch, hand-edit this pin: see ADR 0010.")), null);
|
|
1474
|
-
});
|
|
1475
|
-
|
|
1476
|
-
test("pointerFault still refuses a rule spelled with the opening curly quote — only U+2019 is accepted (#1852)", () => {
|
|
1477
|
-
assert.match(
|
|
1478
|
-
pointerFault(at(" # Exact pin Renovate moves: see ADR 0010. Don\u2018t hand-edit this to float.")),
|
|
1479
|
-
/no longer carries the do-not-hand-edit rule/,
|
|
1480
|
-
);
|
|
1481
|
-
});
|
|
1482
|
-
|
|
1483
|
-
// #1903. The Validate JSON step's comment opened "Exactly two tracked JSON
|
|
1484
|
-
// files, both plugin manifests" and named the two. True the day it was written
|
|
1485
|
-
// (3f9dd372, the 2026-09-08 config split); five more tracked `*.json` files
|
|
1486
|
-
// landed over the following two-plus weeks and the sentence stayed, because
|
|
1487
|
-
// nothing reads it — the step parses whatever `git ls-files '*.json'` returns.
|
|
1488
|
-
// The shape #348 fixed in the Shellcheck comment: prose measuring a set the
|
|
1489
|
-
// comment does not own.
|
|
1490
|
-
//
|
|
1491
|
-
// Same rule as #348's pins: the FORM is banned and no number is pinned, so a
|
|
1492
|
-
// JSON file added or removed needs no edit here. The form is a count sizing the
|
|
1493
|
-
// files — a digit, a spelled-out number two and up (through the nineties, plus
|
|
1494
|
-
// "dozen"), or "both" — with at most two words between it and "files" or
|
|
1495
|
-
// "manifests", none of them ending a sentence. A word ENDING in a period, or in
|
|
1496
|
-
// a period followed only by a closing quote or parenthesis ("them.)", `them."`),
|
|
1497
|
-
// is the sentence end — the old check looked only at a word's LAST character,
|
|
1498
|
-
// so a closer sitting after the period read as an ordinary word and let the
|
|
1499
|
-
// window run past the real sentence end into unrelated text (#1945). One word
|
|
1500
|
-
// merely containing a period, with no closer-after-terminator at its end, is
|
|
1501
|
-
// still a file name, not a boundary — "seven tracked `*.json` files" is the
|
|
1502
|
-
// count. No branch may start right after a hyphen, so a date fragment like
|
|
1503
|
-
// "2026-09-08" can't hand its last segment to the window as a bare count
|
|
1504
|
-
// ("08 files", #1945) — and a spelled-out compound like "twenty-two" can't
|
|
1505
|
-
// hand its OWN last segment to the window as a second, narrower match once
|
|
1506
|
-
// the whole compound has already been tested and refused: the exec-loop
|
|
1507
|
-
// restart below resumes one character past a refused match's start, and
|
|
1508
|
-
// without the guard on every branch that restart could land right after the
|
|
1509
|
-
// hyphen inside "twenty-two", find "two files" there, and have
|
|
1510
|
-
// JSON_COUNT_CLAUSE_BEFORE read the swallowed hyphen as the clause-setting
|
|
1511
|
-
// dash that sizes it (#2012 review). Plural nouns only, because the jq
|
|
1512
|
-
// rationale in the same block says the step "exits 1 on a file holding
|
|
1513
|
-
// `null`": a singular noun would read that exit status as a count. That is the
|
|
1514
|
-
// ceiling as well — "exactly one tracked JSON file" passes, and so does a bare
|
|
1515
|
-
// list of paths with no count in front of it. The block is the contiguous
|
|
1516
|
-
// comment run above the step, anchored on the step's name like the failglob
|
|
1517
|
-
// pin, so a count moved into another step's comment is outside it.
|
|
1518
|
-
const JSON_COUNT =
|
|
1519
|
-
/\b(?<!-)(?:\d+|two|three|four|five|six|seven|eight|nine|ten|eleven|twelve|(?:thir|four|fif|six|seven|eigh|nine)teen|(?:twen|thir|for|fif|six|seven|eigh|nine)ty(?:[- ]?(?:one|two|three|four|five|six|seven|eight|nine))?|dozen|both)\s+(?:(?!\S*[.!?][)\]"'\u2019\u201d]*\s)\S+\s+){0,2}?(?:files|manifests)\b/i;
|
|
1520
|
-
|
|
1521
|
-
// JSON_COUNT alone is context-blind: it flags a "<count> files" shape ANYWHERE
|
|
1522
|
-
// in the block, whether or not that particular phrase sizes the tracked set at
|
|
1523
|
-
// all — "The 2026-09-08 split removed two files that duplicated coverage"
|
|
1524
|
-
// matched exactly like a real count, which would false-positive-fail CI on a
|
|
1525
|
-
// legitimate future comment edit (#1945). Nor is a context word anywhere in the
|
|
1526
|
-
// same sentence enough: this whole block is ABOUT JSON, so "two files that
|
|
1527
|
-
// duplicated JSON coverage", "two files from plugin.json's directory",
|
|
1528
|
-
// "Renovate tracked two files there" and "both valid JSON files would
|
|
1529
|
-
// otherwise fail" all carry one without sizing anything (#1991). So the
|
|
1530
|
-
// context word has to be attached to the count phrase itself, in one of three
|
|
1531
|
-
// places — the ones every genuine sizing sentence below uses:
|
|
1532
|
-
// - as the count's own modifier, the word right after the count:
|
|
1533
|
-
// "two tracked JSON files", "seven tracked `*.json` files", "the 7 JSON
|
|
1534
|
-
// files". Only the FIRST word: "both valid JSON files" is a property of
|
|
1535
|
-
// two files, not the name of the set;
|
|
1536
|
-
// - as the clause the noun opens: "files are tracked", "files that
|
|
1537
|
-
// `git ls-files` lists", "files '*.json' names";
|
|
1538
|
-
// - as the clause the count is set off from by a comma, colon, semicolon or
|
|
1539
|
-
// dash, at most two words back: "Parses what `git ls-files` lists, both
|
|
1540
|
-
// plugin manifests among them." — the context sits a clause away from the
|
|
1541
|
-
// count, and only the punctuation says the count sizes what came before.
|
|
1542
|
-
// Between that punctuation and the count, up to two determiners, and
|
|
1543
|
-
// only a determiner, may sit — a third word past the cap, determiner or
|
|
1544
|
-
// not, is not recognized either ("lists, the two plugin manifests",
|
|
1545
|
-
// "lists, all just nine files", but not "lists, all just the nine
|
|
1546
|
-
// files"): any word past that cap, or any word not on the list at all
|
|
1547
|
-
// ("`git ls-files`, the author removed two files"), starts a clause of
|
|
1548
|
-
// its own, which the count belongs to instead (#2004).
|
|
1549
|
-
// "json" counts only as a word of its own, the `*.json` glob or a bare
|
|
1550
|
-
// `.json` — but the character right before that bare `.json` must be
|
|
1551
|
-
// whitespace, an opener, or nothing at all (string start): a stem ending in
|
|
1552
|
-
// a word character, `.`, `/` or `-` is the original exclusion
|
|
1553
|
-
// ("plugin.json", "..json", "/.json"), and a stem ending in anything else —
|
|
1554
|
-
// `}`, `)`, an accented letter — excludes it the same way, on the same
|
|
1555
|
-
// reasoning, not just the ASCII subset \w covers ("${name}.json",
|
|
1556
|
-
// "résumé.json") (#2004, tightened #2012 review). That boundary character
|
|
1557
|
-
// has to be a REAL one, too: JSON_COUNT always ends its own match on the
|
|
1558
|
-
// literal word "files" or "manifests", so a bare `.json` glued directly onto
|
|
1559
|
-
// that word with no separator at all ("Seven files.json are made up.") is
|
|
1560
|
-
// still an extension, not a name of its own, even though the clause-after
|
|
1561
|
-
// check below tests a slice starting right where the count match ends, where
|
|
1562
|
-
// there is no character left for a lookbehind to see — the check now
|
|
1563
|
-
// requires a real separator before its own context word can start, so a
|
|
1564
|
-
// glued `.json` never reaches it (#2012 review). The clause-after check
|
|
1565
|
-
// shares its allowed openers with the modifier check above so the two can't
|
|
1566
|
-
// drift apart (#2004) — but a parenthetical description is not an opener a
|
|
1567
|
-
// noun's own clause can start with: sharing the modifier's full opener set
|
|
1568
|
-
// pulled in `(`, so "two files (JSON fixtures nobody read)" read as the
|
|
1569
|
-
// clause "files" opens; the shared set carries only the backtick and quote
|
|
1570
|
-
// characters #2004's own gap needed, and the modifier check never itself
|
|
1571
|
-
// depended on `(` (#2012 review).
|
|
1572
|
-
// The ceiling: a count sentence with no context word of its own, right after
|
|
1573
|
-
// one that has it ("Every tracked `*.json` file. Seven files at last
|
|
1574
|
-
// count."), passes — sentences are the unit. So does a context word pushed
|
|
1575
|
-
// out of the first-word slot by any other word, a determiner-like one
|
|
1576
|
-
// included: "Five more tracked files landed since." passes, exactly like
|
|
1577
|
-
// "both valid JSON files" (#2004). The existing "The 2026-09-08 split
|
|
1578
|
-
// removed two of them." fixture must pass too, for a simpler reason: "two of
|
|
1579
|
-
// them" is not a JSON_COUNT match at all.
|
|
1580
|
-
const JSON_SET_WORD = String.raw`(?:\btracked\b|(?<![\w.\/-])json\b|(?<![^\s\x60'"(])\.json\b|\*\.json\b|git ls-files\b)`;
|
|
1581
|
-
const JSON_COUNT_ALL = new RegExp(JSON_COUNT.source, "gi");
|
|
1582
|
-
const JSON_CODE_OPENER = String.raw`[\x60'"]*`;
|
|
1583
|
-
const JSON_COUNT_MODIFIER = new RegExp(String.raw`^\S+\s+(?:(?:one|two|three|four|five|six|seven|eight|nine)\s+)?${JSON_CODE_OPENER}${JSON_SET_WORD}`, "i");
|
|
1584
|
-
const JSON_COUNT_CLAUSE_AFTER = new RegExp(String.raw`^\s+(?:(?:that|which)\s+)?(?:(?:are|were)\s+)?${JSON_CODE_OPENER}${JSON_SET_WORD}`, "i");
|
|
1585
|
-
const JSON_COUNT_CLAUSE_BEFORE = new RegExp(String.raw`${JSON_SET_WORD}[^\s,:;\u2013\u2014-]*(?:\s+[^\s,:;\u2013\u2014-]+){0,2}\s*[,:;\u2013\u2014-]\s*(?:(?:the|these|those|its|their|all|exactly|only|just)\s+){0,2}$`, "i");
|
|
1586
|
-
|
|
1587
|
-
function sizesTrackedSet(sentence, count) {
|
|
1588
|
-
return (
|
|
1589
|
-
JSON_COUNT_MODIFIER.test(count[0]) ||
|
|
1590
|
-
JSON_COUNT_CLAUSE_AFTER.test(sentence.slice(count.index + count[0].length)) ||
|
|
1591
|
-
JSON_COUNT_CLAUSE_BEFORE.test(sentence.slice(0, count.index))
|
|
1592
|
-
);
|
|
1593
|
-
}
|
|
1594
|
-
|
|
1595
|
-
// Where jsonCountFault re-splits a sentences() slice (see the loop there).
|
|
1596
|
-
// Its closing markup is citation-sweep-prose.test.mjs's CLOSING_MARKUP, copied
|
|
1597
|
-
// whole (#2043): the narrow `) ] " ' ’ ”` set this carried before let "Vs.**"
|
|
1598
|
-
// or "Vs.>>" end a sentence there and not here, two copies of the #2021 fix
|
|
1599
|
-
// disagreeing on the same input. Tag names spell both cases out, since this
|
|
1600
|
-
// pattern carries no `i` for them to fold under. The guard before the
|
|
1601
|
-
// abbreviation is that file's too: only a letter or digit disqualifies it, so
|
|
1602
|
-
// an italic `_vs._` is one — a `\b` there read the `_` as a word character.
|
|
1603
|
-
// Its `][ref]` closer skips a label `[^1]` reads whole, as CLOSING_MARKUP's
|
|
1604
|
-
// does (#2063).
|
|
1605
|
-
const COUNT_CLOSING_MARKUP = String.raw`(?:[*_\x60)\]}>~"'”’»›]|\]\([^()]*\)|\]\[(?!\^[^\]\s]+\])[^\]]*\]|\[\^[^\]\s]+\]|<\/[A-Za-z][A-Za-z\d-]*\s*>)`;
|
|
1606
|
-
// #2054: the guard used to be a SEPARATE lookbehind,
|
|
1607
|
-
// `(?<!(?<!...)abbr\.${COUNT_CLOSING_MARKUP}*)`, re-matched independently at
|
|
1608
|
-
// the final `\s+` position — so it could walk back over a DIFFERENT, inner
|
|
1609
|
-
// occurrence of `abbr.` than the one the first lookbehind's `[.!?]` actually
|
|
1610
|
-
// anchored on, including one supplied by a `](...)`/`][...]` closer's own
|
|
1611
|
-
// swallowed content ("`](see e.g.)`", "`][ref vs.]`"). SENTENCE_END never had
|
|
1612
|
-
// this gap: its guard sits on the single terminator character, checked once,
|
|
1613
|
-
// before its own `CLOSING_MARKUP*` ever runs. Folding the guard into the SAME
|
|
1614
|
-
// lookbehind that finds the terminator — `(?:[!?]|(?<!guard)\.)` in place of
|
|
1615
|
-
// the bare `[.!?]` — reproduces that anchoring here: the guard is now
|
|
1616
|
-
// evaluated only against the character `COUNT_CLOSING_MARKUP*`'s run is
|
|
1617
|
-
// itself anchored to, so a closer's own embedded abbreviation can no longer
|
|
1618
|
-
// stand in for it.
|
|
1619
|
-
const COUNT_SENTENCE_BOUNDARY = new RegExp(
|
|
1620
|
-
String.raw`(?<=(?:[!?]|(?<!(?<![A-Za-z\d])(?:e\.g|i\.e|cf|viz|vs))\.)${COUNT_CLOSING_MARKUP}*)\s+`,
|
|
1621
|
-
);
|
|
1622
|
-
|
|
1623
|
-
export function jsonCountFault(block) {
|
|
1624
|
-
// The coverage check, scoped to the block's FIRST sentence only. A
|
|
1625
|
-
// doesNotMatch over the WHOLE block is vacuous: this block's own cache
|
|
1626
|
-
// sentence ("gitignored, so `git ls-files` never sees them") also contains
|
|
1627
|
-
// `git ls-files`, so a stale count reintroduced as its OWN paragraph and
|
|
1628
|
-
// split from the rest by a blank line — which the walk below (the same
|
|
1629
|
-
// "blank line ends the comment run" rule the failglob pin and every other
|
|
1630
|
-
// block-walk in this file already use) treats as ending the step's comment
|
|
1631
|
-
// right there — would still leave a slice whose only surviving coverage
|
|
1632
|
-
// word is that unrelated cache sentence, reading as covered while the
|
|
1633
|
-
// actual coverage claim, and the count sitting above it, are both gone from
|
|
1634
|
-
// what this function ever sees. The real coverage sentence leads the
|
|
1635
|
-
// paragraph in the current wording, and every accepted paraphrase below
|
|
1636
|
-
// does too — measured against `sentences()`, not a raw substring search.
|
|
1637
|
-
const sents = sentences(block);
|
|
1638
|
-
const lead = sents[0] ?? "";
|
|
1639
|
-
if (!/\btracked\b|git ls-files/.test(lead)) {
|
|
1640
|
-
return "the Validate JSON comment no longer says which files the step parses — the slice this pin reads has lost its coverage paragraph";
|
|
1641
|
-
}
|
|
1642
|
-
// The count check, scoped one sentence at a time instead of the whole block
|
|
1643
|
-
// (#1945) — see sizesTrackedSet above for why. `sentences()` itself only
|
|
1644
|
-
// splits at a terminator immediately followed by whitespace, so a
|
|
1645
|
-
// parenthetical or quoted aside ending "...files.)" or `...files."` does
|
|
1646
|
-
// NOT end a sentences()-slice there — it runs on into the NEXT real
|
|
1647
|
-
// sentence, which can carry an unrelated "tracked"/"json" word of its own.
|
|
1648
|
-
// JSON_COUNT's own window already treats that identical terminator-then-
|
|
1649
|
-
// closer as a boundary (the #1945 fix above), so the loop below re-splits
|
|
1650
|
-
// each `sentences()` slice on the SAME boundary before testing context —
|
|
1651
|
-
// otherwise a count sentence borrows a following real sentence's context
|
|
1652
|
-
// word through the gap `sentences()` leaves open, and the #1942 bug
|
|
1653
|
-
// returns for any aside written in parentheses or quotes (PR #1984 review,
|
|
1654
|
-
// #1945). Its abbreviations match lowercase only, as sentences()'s do
|
|
1655
|
-
// (#1899, #2021) — with the same cost: a capitalized one anywhere, a
|
|
1656
|
-
// parenthetical "(E.g. …)" included, ends the sentence right there.
|
|
1657
|
-
for (const sentence of sents.flatMap((s) => s.split(COUNT_SENTENCE_BOUNDARY))) {
|
|
1658
|
-
// Every count-shape START, not just the first match — and not matchAll's
|
|
1659
|
-
// non-overlapping walk either: a match's window can swallow the real
|
|
1660
|
-
// count sitting inside it ("In 2026 twelve tracked files" matches as
|
|
1661
|
-
// "2026 twelve tracked files", whose context test fails on "twelve"), so
|
|
1662
|
-
// the next search resumes one character past the previous match's start
|
|
1663
|
-
// rather than at its end (#2004). A sentence can also open on an aside
|
|
1664
|
-
// ("removed two files that duplicated coverage") and size the set later.
|
|
1665
|
-
JSON_COUNT_ALL.lastIndex = 0;
|
|
1666
|
-
for (let count; (count = JSON_COUNT_ALL.exec(sentence)); JSON_COUNT_ALL.lastIndex = count.index + 1) {
|
|
1667
|
-
if (sizesTrackedSet(sentence, count)) {
|
|
1668
|
-
return `the Validate JSON comment sizes the tracked JSON set again ("${count[0]}") — a count there goes stale the next time a JSON file is added (#1903)`;
|
|
1669
|
-
}
|
|
1670
|
-
}
|
|
1671
|
-
}
|
|
1672
|
-
return null;
|
|
1673
|
-
}
|
|
1674
|
-
|
|
1675
|
-
test("the Validate JSON comment says which files it parses without counting them (#1903)", () => {
|
|
1676
|
-
const lines = read("../../.github/workflows/ci.yml").split("\n");
|
|
1677
|
-
const step = lines.findIndex((l) => /^\s*- name: Validate JSON$/.test(l));
|
|
1678
|
-
assert.ok(step >= 0, "ci.yml no longer has a Validate JSON step");
|
|
1679
|
-
let i = step;
|
|
1680
|
-
while (/^\s*#/.test(lines[i - 1])) i--;
|
|
1681
|
-
assert.equal(jsonCountFault(prose(lines.slice(i, step).join("\n"))), null);
|
|
1682
|
-
});
|
|
1683
|
-
|
|
1684
|
-
test("jsonCountFault refuses a count of the JSON files in any spelling, and a slice without its coverage paragraph (#1903)", () => {
|
|
1685
|
-
const jq = "`jq empty`, not `jq -e .`: it exits 1 on a file holding `null` or `false` — both valid JSON.";
|
|
1686
|
-
for (const count of [
|
|
1687
|
-
"Exactly two tracked JSON files, both plugin manifests: plugin/.claude-plugin/plugin.json and .claude-plugin/marketplace.json.",
|
|
1688
|
-
"Every tracked JSON file — seven tracked `*.json` files at the time of writing.",
|
|
1689
|
-
"Parses the 7 JSON files `git ls-files` lists.",
|
|
1690
|
-
"Parses what `git ls-files` lists, both plugin manifests among them.",
|
|
1691
|
-
"A dozen tracked JSON files exist today.",
|
|
1692
|
-
"Thirteen tracked JSON files, at last count.",
|
|
1693
|
-
"Twenty-one files are tracked as JSON today.",
|
|
1694
|
-
"Twenty one tracked JSON files exist today.",
|
|
1695
|
-
"Parses what `git ls-files` lists - both plugin manifests among them.",
|
|
1696
|
-
]) {
|
|
1697
|
-
assert.match(jsonCountFault(`${count} ${jq}`), /sizes the tracked JSON set again/, count);
|
|
1698
|
-
}
|
|
1699
|
-
assert.match(jsonCountFault(jq), /no longer says which files the step parses/);
|
|
1700
|
-
});
|
|
1701
|
-
|
|
1702
|
-
test("jsonCountFault accepts the block's own non-counting numbers and a count cut off by a sentence end (#1903)", () => {
|
|
1703
|
-
const jq = "`jq empty`, not `jq -e .`: it exits 1 on a file holding `null` or `false` — both valid JSON.";
|
|
1704
|
-
const cache = "The runtime caches are NOT covered — every one of them is gitignored, so `git ls-files` never sees them.";
|
|
1705
|
-
assert.equal(jsonCountFault(`Parses every file \`git ls-files '*.json'\` lists. ${cache} ${jq}`), null);
|
|
1706
|
-
assert.equal(jsonCountFault(`Every tracked \`*.json\` file. The 2026-09-08 split removed two of them. Files added since need no edit here. ${jq}`), null);
|
|
1707
|
-
});
|
|
1708
|
-
|
|
1709
|
-
// #2021: jsonCountFault's re-split carries its own copy of sentences()'s
|
|
1710
|
-
// abbreviation list, and #1899's lowercase-only fix has to reach it too. The
|
|
1711
|
-
// `]` closer here is one sentences() never splits after, so this re-split is
|
|
1712
|
-
// the only boundary between the two sentences in these fixtures.
|
|
1713
|
-
test("jsonCountFault ends a count sentence at a capitalized abbreviation lookalike, and still skips the lowercase abbreviation (#2021)", () => {
|
|
1714
|
-
const lead = "Parses every file `git ls-files '*.json'` lists.";
|
|
1715
|
-
// "[Vs.]" ends its sentence, so "tracked" is no context for the count in the
|
|
1716
|
-
// next one. Folded case, the re-split read it as "vs.", joined the two, and
|
|
1717
|
-
// refused the block as sizing the tracked set.
|
|
1718
|
-
for (const word of ["Vs.", "VS.", "E.g.", "I.e.", "Cf.", "Viz."]) {
|
|
1719
|
-
assert.equal(jsonCountFault(`${lead} The cache is tracked per [${word}] - two files sit there.`), null, word);
|
|
1720
|
-
}
|
|
1721
|
-
// The refuse side, in the same fixture shape: lowercase is the abbreviation,
|
|
1722
|
-
// one sentence, whose "tracked" sizes the count.
|
|
1723
|
-
for (const abbr of ["vs.", "e.g.", "i.e.", "cf.", "viz."]) {
|
|
1724
|
-
assert.match(
|
|
1725
|
-
jsonCountFault(`${lead} The cache is tracked per [${abbr}] - two files sit there.`),
|
|
1726
|
-
/sizes the tracked JSON set again/,
|
|
1727
|
-
abbr,
|
|
1728
|
-
);
|
|
1729
|
-
}
|
|
1730
|
-
});
|
|
1731
|
-
|
|
1732
|
-
test("jsonCountFault ends a count sentence at a capitalized abbreviation mid-sentence too — the cost #1899 accepted (#2021)", () => {
|
|
1733
|
-
// The lowercase-only match fires wherever the abbreviation sits, so a
|
|
1734
|
-
// capitalized one in a parenthetical cuts the count off from the context
|
|
1735
|
-
// word before it, and the count passes: the silent direction here, unlike
|
|
1736
|
-
// windowClaimFault's. No file's prose spells one capitalized; the pin is
|
|
1737
|
-
// here so a change to the guard meets this shape on purpose. The `]`
|
|
1738
|
-
// closer (review finding, fix-pr-2024): a plain-space closer here lets
|
|
1739
|
-
// sentences() (lowercase-only since #1899/#2018) end the sentence first,
|
|
1740
|
-
// so the fixture measured that cost instead of COUNT_SENTENCE_BOUNDARY's own
|
|
1741
|
-
// — the `]` closer is one sentences() never splits after (#2021's sibling
|
|
1742
|
-
// test above uses the same shape), so this re-split is the only boundary.
|
|
1743
|
-
const jq = "`jq empty`, not `jq -e .`: it exits 1 on a file holding `null` or `false` — both valid JSON.";
|
|
1744
|
-
const count = (abbr) => `Parses tracked JSON [${abbr}] manifests: two files at last count. ${jq}`;
|
|
1745
|
-
assert.match(jsonCountFault(count("e.g.")), /sizes the tracked JSON set again/);
|
|
1746
|
-
for (const abbr of ["E.g.", "Cf.", "Vs."]) {
|
|
1747
|
-
assert.equal(jsonCountFault(count(abbr)), null, abbr);
|
|
1748
|
-
}
|
|
1749
|
-
});
|
|
1750
|
-
|
|
1751
|
-
// #2043: the re-split's closing markup was narrower than SENTENCE_END's, so
|
|
1752
|
-
// the two copies of the #2021 fix disagreed on a capitalized lookalike
|
|
1753
|
-
// behind any closer only the latter took.
|
|
1754
|
-
test("the count re-split ends a sentence after every closing markup SENTENCE_END takes, and still skips the abbreviation behind it (#2043)", () => {
|
|
1755
|
-
const closers = ["**", ">>", "_", "\x60", "}", "~~", "»", "›", ")", "]", '"', "’", "”", "](x.md)", "][ref]", "[^1]", "</b>", "</B>", "</my-el >"];
|
|
1756
|
-
for (const closer of closers) {
|
|
1757
|
-
// The cases #2043 was filed on, "Vs.**" and "Vs.>>", and the rest of the set.
|
|
1758
|
-
assert.deepEqual(`per Vs.${closer} next`.split(COUNT_SENTENCE_BOUNDARY), [`per Vs.${closer}`, "next"], closer);
|
|
1759
|
-
// The accept side: the abbreviation behind the same closer ends nothing.
|
|
1760
|
-
assert.deepEqual(`per vs.${closer} next`.split(COUNT_SENTENCE_BOUNDARY), [`per vs.${closer} next`], closer);
|
|
1761
|
-
}
|
|
1762
|
-
// The guard: an italic abbreviation is one, a letter or digit glued on is not.
|
|
1763
|
-
assert.deepEqual("per _vs._ next".split(COUNT_SENTENCE_BOUNDARY), ["per _vs._ next"]);
|
|
1764
|
-
for (const word of ["Xvs.", "26vs.", "DEvs."]) {
|
|
1765
|
-
assert.deepEqual(`per ${word} next`.split(COUNT_SENTENCE_BOUNDARY), [`per ${word}`, "next"], word);
|
|
1766
|
-
}
|
|
1767
|
-
});
|
|
1768
|
-
|
|
1769
|
-
test("jsonCountFault ends a count sentence at a capitalized lookalike behind closing markup sentences() never splits after (#2043)", () => {
|
|
1770
|
-
// sentences() already ends one at `*`, `_`, a quote or `)`, so these are the
|
|
1771
|
-
// closers where the re-split is the only boundary between the two sentences.
|
|
1772
|
-
const lead = "Parses every file `git ls-files '*.json'` lists.";
|
|
1773
|
-
for (const closer of [">>", "\x60", "}", "~~", "»", "](x.md)", "</b>"]) {
|
|
1774
|
-
assert.equal(jsonCountFault(`${lead} The cache is tracked per Vs.${closer} - two files sit there.`), null, closer);
|
|
1775
|
-
assert.match(
|
|
1776
|
-
jsonCountFault(`${lead} The cache is tracked per vs.${closer} - two files sit there.`),
|
|
1777
|
-
/sizes the tracked JSON set again/,
|
|
1778
|
-
closer,
|
|
1779
|
-
);
|
|
1780
|
-
}
|
|
1781
|
-
});
|
|
1782
|
-
|
|
1783
|
-
// #2053: sentences() runs first here, and the re-split after it can only cut
|
|
1784
|
-
// a piece further, never rejoin two, so a split sentences() made
|
|
1785
|
-
// mid-abbreviation was final. Its guard read `_` as a word character, so an
|
|
1786
|
-
// italic abbreviation in the coverage lead cut the lead's coverage words off
|
|
1787
|
-
// into the next piece, and an intact comment read as one that lost them.
|
|
1788
|
-
test("jsonCountFault reads an italic abbreviation in the coverage lead as part of that sentence (#2053)", () => {
|
|
1789
|
-
for (const abbr of ["_e.g._", "e.g."]) {
|
|
1790
|
-
assert.equal(jsonCountFault(`# Parses ${abbr} every file \`git ls-files '*.json'\` lists. Nothing else applies here.`), null, abbr);
|
|
1791
|
-
}
|
|
1792
|
-
// The refuse side: the lead still ends at its real end, so a coverage word
|
|
1793
|
-
// in the sentence after it is no coverage for the lead.
|
|
1794
|
-
assert.match(
|
|
1795
|
-
jsonCountFault("# Parses _e.g._ every file it finds. Every tracked file is parsed."),
|
|
1796
|
-
/no longer says which files the step parses/,
|
|
1797
|
-
);
|
|
1798
|
-
});
|
|
1799
|
-
|
|
1800
|
-
// #2054: deferred from #2043's own review. A closer that embeds its OWN
|
|
1801
|
-
// abbreviation+period — `](see e.g.)`, `][ref vs.]`, `[^vs.]` — used to
|
|
1802
|
-
// survive the guard even though SENTENCE_END already split after it: the
|
|
1803
|
-
// guard was a SEPARATE lookbehind, re-matched independently at the final
|
|
1804
|
-
// whitespace, so it could match the closer's own swallowed `e.g.`/`vs.`
|
|
1805
|
-
// instead of whatever preceded the actual terminator. Confirmed not a
|
|
1806
|
-
// regression from #2043 — the pre-#2043 narrow closer set (`)]"'’”` only, no
|
|
1807
|
-
// `](...)`/`][...]` alternatives) produced the same non-split on these three
|
|
1808
|
-
// too, but not for the reason its narrowness usually mattered (#2043's own
|
|
1809
|
-
// `Vs.**`/`Vs.>>` repro, where `*`/`>` were never in that class at all): `]`
|
|
1810
|
-
// and `)` were already members of it, so the terminator-lookbehind still
|
|
1811
|
-
// found the same candidate boundary right behind the closer, and the guard —
|
|
1812
|
-
// already this same separately-re-matchable lookbehind — was independently
|
|
1813
|
-
// blocking the split there too. The gap this PR fixes predates #2043
|
|
1814
|
-
// entirely; #2043's closer-set widening never touched the guard clause.
|
|
1815
|
-
test("the count re-split still ends a sentence when the closer embeds its own abbreviation+period (#2054)", () => {
|
|
1816
|
-
for (const t of ["It shipped.[^vs.] Next one", "It shipped.](see e.g.) Next one", "It shipped.][ref vs.] Next one"]) {
|
|
1817
|
-
assert.equal(t.split(COUNT_SENTENCE_BOUNDARY).length, 2, t);
|
|
1818
|
-
}
|
|
1819
|
-
// The must-ACCEPT side of the same guard: when the OUTER terminator itself
|
|
1820
|
-
// is the abbreviation, the closer's embedded `e.g.` must not manufacture a
|
|
1821
|
-
// split the outer guard alone already refuses — same as SENTENCE_END.
|
|
1822
|
-
assert.deepEqual("per vs.](see e.g.) next".split(COUNT_SENTENCE_BOUNDARY), ["per vs.](see e.g.) next"]);
|
|
1823
|
-
// The guard is folded into the SAME lookbehind that finds the terminator
|
|
1824
|
-
// (SENTENCE_END's own shape), not applied uniformly to it — `!`/`?` never
|
|
1825
|
-
// carried a guard at all, on either side of #2054's rewrite, and a mutant
|
|
1826
|
-
// that widens the guard to cover them too must go red here.
|
|
1827
|
-
assert.deepEqual("per vs! next".split(COUNT_SENTENCE_BOUNDARY), ["per vs!", "next"]);
|
|
1828
|
-
assert.deepEqual("per vs? next".split(COUNT_SENTENCE_BOUNDARY), ["per vs?", "next"]);
|
|
1829
|
-
});
|
|
1830
|
-
|
|
1831
|
-
test("jsonCountFault does not merge a count sentence across a closer that embeds its own abbreviation (#2054)", () => {
|
|
1832
|
-
assert.equal(
|
|
1833
|
-
jsonCountFault('Parses every tracked file `git ls-files` lists. It once read [JSON.](x.md "e.g.") — two files were removed later.'),
|
|
1834
|
-
null,
|
|
1835
|
-
);
|
|
1836
|
-
});
|
|
1837
|
-
|
|
1838
|
-
// #2063. `][^1]` read two ways under COUNT_CLOSING_MARKUP — one `][ref]`
|
|
1839
|
-
// closer, or a bare `]` then a `[^1]` footnote — so a chain of n of them had
|
|
1840
|
-
// 2^n readings, and a lookbehind that ends in no split walked every one first.
|
|
1841
|
-
// #2054's folded guard put the must-accept shape on that path: a guarded
|
|
1842
|
-
// `vs.` ahead of the chain. At this n each fixture took half a second to
|
|
1843
|
-
// several seconds, doubling with every link; unambiguous, all three take well
|
|
1844
|
-
// under a millisecond, so the budget only catches a return to the blow-up,
|
|
1845
|
-
// not a slow machine.
|
|
1846
|
-
test("the count re-split stays fast on a closer chain that once read two ways (#2063)", () => {
|
|
1847
|
-
const links = 25;
|
|
1848
|
-
for (const text of [
|
|
1849
|
-
// The ticket's two post-#2054 repros: the guarded terminator ahead of
|
|
1850
|
-
// the chain, and the guarded `vs.` inside each link.
|
|
1851
|
-
"per vs." + "][^1]".repeat(links) + " y",
|
|
1852
|
-
"x" + "][^vs.]".repeat(links) + " y",
|
|
1853
|
-
// The same chain with no terminator at all, slow before #2054 too.
|
|
1854
|
-
"x" + "][^a]".repeat(links) + " y",
|
|
1855
|
-
]) {
|
|
1856
|
-
const start = performance.now();
|
|
1857
|
-
const parts = text.split(COUNT_SENTENCE_BOUNDARY);
|
|
1858
|
-
const ms = performance.now() - start;
|
|
1859
|
-
assert.deepEqual(parts, [text], text);
|
|
1860
|
-
assert.ok(ms < 100, `${ms.toFixed(0)}ms on ${text}`);
|
|
1861
|
-
}
|
|
1862
|
-
});
|
|
1863
|
-
|
|
1864
|
-
// The fix drops only the `][ref]` reading that `]` plus `[^1]` already
|
|
1865
|
-
// covers, so every closer run ends the same sentences as before. A `][^…]`
|
|
1866
|
-
// label that `[^1]` cannot read — empty, or holding a space — is still one
|
|
1867
|
-
// `][ref]` closer; a fix that refused every `][^` would lose those two.
|
|
1868
|
-
test("the count re-split ends the same sentences behind a `][^…]` closer as before #2063", () => {
|
|
1869
|
-
for (const closer of ["][^1]", "][^1]][^2]", "][^a b]", "][^]", "][^vs.]"]) {
|
|
1870
|
-
assert.deepEqual(`It shipped.${closer} Next`.split(COUNT_SENTENCE_BOUNDARY), [`It shipped.${closer}`, "Next"], closer);
|
|
1871
|
-
assert.deepEqual(`per vs.${closer} next`.split(COUNT_SENTENCE_BOUNDARY), [`per vs.${closer} next`], closer);
|
|
1872
|
-
}
|
|
1873
|
-
});
|
|
1874
|
-
|
|
1875
|
-
// Review of PR #1942 (correctness + tests dimensions, independently
|
|
1876
|
-
// corroborated 3 ways): the doesNotMatch above used to scan the WHOLE block,
|
|
1877
|
-
// so a stale count reintroduced as its own paragraph and separated from the
|
|
1878
|
-
// rest by a blank line survived undetected — the walk that slices the real
|
|
1879
|
-
// ci.yml file stops at that blank line (same rule every block-walk in this
|
|
1880
|
-
// file already follows), dropping the count-bearing line entirely, while the
|
|
1881
|
-
// truncated remainder still contained the cache sentence's OWN `git ls-files`
|
|
1882
|
-
// mention and satisfied the coverage check on that alone. Measured before the
|
|
1883
|
-
// fix: this exact input returned `null`. Pinned here as a unit test on
|
|
1884
|
-
// `jsonCountFault` directly, since the walk itself is correct per this file's
|
|
1885
|
-
// own convention — the bug was in what the coverage check was willing to
|
|
1886
|
-
// accept as evidence, not in where the block boundary falls.
|
|
1887
|
-
test("jsonCountFault still refuses a count parked in its own paragraph, split from the rest by a blank line the walk already treats as the block boundary (#1903 follow-up)", () => {
|
|
1888
|
-
const jq = "`jq empty`, not `jq -e .`: it exits 1 on a file holding `null` or `false` — both valid JSON.";
|
|
1889
|
-
const remainderAfterBlankLineSplit =
|
|
1890
|
-
"No count and no list of them, on purpose: the count this comment used to carry went stale as files were added (#1903), and ci-comment-rot-prose.test.mjs refuses one coming back. The runtime caches are NOT covered and cannot be — every one of them is gitignored, so `git ls-files` never sees them. Do not read this step as saying anything about a cache. " +
|
|
1891
|
-
jq;
|
|
1892
|
-
assert.match(jsonCountFault(remainderAfterBlankLineSplit), /no longer says which files the step parses/);
|
|
1893
|
-
});
|
|
1894
|
-
|
|
1895
|
-
// Review of PR #1942 (deferred to #1945): JSON_COUNT flagged a "<count>
|
|
1896
|
-
// files" shape ANYWHERE in the block regardless of what that sentence was
|
|
1897
|
-
// about, so an unrelated aside sharing the shape — sizing a past cleanup,
|
|
1898
|
-
// not the tracked set — matched exactly like a real count. Reworded slightly
|
|
1899
|
-
// (spelling out "files" instead of "of them"), either sentence below would
|
|
1900
|
-
// have false-positive-failed CI on a legitimate future comment edit. Fixed
|
|
1901
|
-
// by requiring a "tracked"/"json"/"git ls-files" context word alongside the
|
|
1902
|
-
// count — since #1991, attached to the count phrase (see sizesTrackedSet).
|
|
1903
|
-
test("jsonCountFault ignores a count-shaped aside whose own sentence never sizes the tracked JSON set (#1945)", () => {
|
|
1904
|
-
const jq = "`jq empty`, not `jq -e .`: it exits 1 on a file holding `null` or `false` — both valid JSON.";
|
|
1905
|
-
const lead = "Parses every file `git ls-files '*.json'` lists.";
|
|
1906
|
-
assert.equal(jsonCountFault(`${lead} The 2026-09-08 split removed two files that duplicated coverage. ${jq}`), null);
|
|
1907
|
-
assert.equal(jsonCountFault(`${lead} Two files were added to unrelated tooling that week. ${jq}`), null);
|
|
1908
|
-
});
|
|
1909
|
-
|
|
1910
|
-
// Review of PR #1942 (deferred to #1945): the window's sentence-end rule
|
|
1911
|
-
// looked only at a word's LAST character, so a period followed by a closing
|
|
1912
|
-
// paren or quote wasn't a boundary — "them.)" and `them."` both read as
|
|
1913
|
-
// ordinary words and let the window run past the real sentence end into
|
|
1914
|
-
// unrelated "Files" text. The digit branch was also unanchored against a
|
|
1915
|
-
// trailing date fragment, so "2026-09-08 files" matched as "08 files". All
|
|
1916
|
-
// three fixed directly on JSON_COUNT. The first three asserts below carry no
|
|
1917
|
-
// "tracked"/"JSON" context word of their own, so sizesTrackedSet already
|
|
1918
|
-
// refuses them regardless of JSON_COUNT's boundary behavior — they prove the
|
|
1919
|
-
// two fixes stack, not that either fires alone (PR #1984 review). The last
|
|
1920
|
-
// three put "tracked" right after the count — where sizesTrackedSet reads it
|
|
1921
|
-
// as the count's own modifier (#1991) — so the context test cannot be what
|
|
1922
|
-
// returns null: only a sentence end at `ones.)` / `ones."` (sentences() or
|
|
1923
|
-
// JSON_COUNT's own window) and the digit branch's hyphen anchor can.
|
|
1924
|
-
test("jsonCountFault treats a period-then-closer as a sentence end, and refuses a date fragment's last segment as a bare count (#1945)", () => {
|
|
1925
|
-
const jq = "`jq empty`, not `jq -e .`: it exits 1 on a file holding `null` or `false` — both valid JSON.";
|
|
1926
|
-
const lead = "Parses every file `git ls-files '*.json'` lists.";
|
|
1927
|
-
assert.equal(jsonCountFault(`${lead} Removed two of them.) Files added since need no edit. ${jq}`), null);
|
|
1928
|
-
assert.equal(jsonCountFault(`${lead} Removed two of them." Files added since need no edit. ${jq}`), null);
|
|
1929
|
-
assert.equal(jsonCountFault(`${lead} 2026-09-08 files were touched that week. ${jq}`), null);
|
|
1930
|
-
assert.equal(jsonCountFault(`${lead} Removed two tracked ones.) Files added since need no edit here. ${jq}`), null);
|
|
1931
|
-
assert.equal(jsonCountFault(`${lead} Removed two tracked ones." Files added since need no edit here. ${jq}`), null);
|
|
1932
|
-
assert.equal(jsonCountFault(`${lead} 2026-09-08 tracked files were touched that week. ${jq}`), null);
|
|
1933
|
-
});
|
|
1934
|
-
|
|
1935
|
-
// #1991 (deferred from PR #1984 review): a context word anywhere in the count's
|
|
1936
|
-
// sentence was not evidence the count sizes the tracked set, because the whole
|
|
1937
|
-
// Validate JSON block is about JSON — every sentence in the accept loop below
|
|
1938
|
-
// carries "JSON", "plugin.json" or "tracked" without sizing anything, and each
|
|
1939
|
-
// one flagged. Two of them set the count off by punctuation, the one place the
|
|
1940
|
-
// context word may sit a clause away: after a file name's ".json", and more
|
|
1941
|
-
// than two words after "tracked". The last is the block's own jq sentence
|
|
1942
|
-
// after a natural one-word rewording. The refuse half pins that the context
|
|
1943
|
-
// test now walks EVERY count in a sentence: its aside comes first, and the
|
|
1944
|
-
// real count second.
|
|
1945
|
-
test("jsonCountFault ignores a context word the count phrase does not own, and still finds a sizing count behind an aside (#1991)", () => {
|
|
1946
|
-
const jq = "`jq empty`, not `jq -e .`: it exits 1 on a file holding `null` or `false` — both valid JSON.";
|
|
1947
|
-
const lead = "Parses every file `git ls-files '*.json'` lists.";
|
|
1948
|
-
for (const aside of [
|
|
1949
|
-
"The 2026-09-08 split removed two files that duplicated JSON coverage.",
|
|
1950
|
-
"The 2026-09-08 split removed two files from plugin/.claude-plugin/plugin.json's directory.",
|
|
1951
|
-
"Beside plugin/.claude-plugin/plugin.json, two files were removed that week.",
|
|
1952
|
-
"The tracked set shrank last week: two files that duplicated coverage were deleted.",
|
|
1953
|
-
"Renovate tracked two files there last week.",
|
|
1954
|
-
"`jq empty`, not `jq -e .`: it exits 1 on a file holding `null` or `false` — both valid JSON files would otherwise fail.",
|
|
1955
|
-
]) {
|
|
1956
|
-
assert.equal(jsonCountFault(`${lead} ${aside} ${jq}`), null, aside);
|
|
1957
|
-
}
|
|
1958
|
-
assert.match(
|
|
1959
|
-
jsonCountFault(`${lead} The split removed two files that duplicated coverage, leaving nine tracked JSON files. ${jq}`),
|
|
1960
|
-
/sizes the tracked JSON set again \("nine tracked JSON files"\)/,
|
|
1961
|
-
);
|
|
1962
|
-
});
|
|
1963
|
-
|
|
1964
|
-
// #2004 (deferred from PR #2001 review): four sizing counts sizesTrackedSet
|
|
1965
|
-
// let through. A digit run right before a real count swallowed it in one
|
|
1966
|
-
// non-overlapping match ("2026 twelve tracked files"), so the real count was
|
|
1967
|
-
// never tested on its own; an article between the clause punctuation and the
|
|
1968
|
-
// count broke the clause-before anchor; a bare ".json" was not a context
|
|
1969
|
-
// word; and the clause-after rule took only a backtick before its context
|
|
1970
|
-
// word, where the modifier rule took a quote or paren too. The accept half
|
|
1971
|
-
// pins what each fix must still refuse to invent: a non-determiner word after
|
|
1972
|
-
// the punctuation opens a clause the count belongs to, and walking every
|
|
1973
|
-
// count start finds only counts, never context the sentence lacks.
|
|
1974
|
-
test("jsonCountFault refuses a count swallowed by an earlier match, set off by a determiner, or named by bare .json or a quoted glob (#2004)", () => {
|
|
1975
|
-
const jq = "`jq empty`, not `jq -e .`: it exits 1 on a file holding `null` or `false` — both valid JSON.";
|
|
1976
|
-
const lead = "Parses every file `git ls-files '*.json'` lists.";
|
|
1977
|
-
for (const [count, phrase] of [
|
|
1978
|
-
["In 2026 twelve tracked files are parsed.", "twelve tracked files"],
|
|
1979
|
-
["Parses what `git ls-files` lists, the two plugin manifests among them.", "two plugin manifests"],
|
|
1980
|
-
["Seven .json files are parsed.", "Seven .json files"],
|
|
1981
|
-
["Parses the seven files '*.json' names.", "seven files"],
|
|
1982
|
-
]) {
|
|
1983
|
-
assert.match(jsonCountFault(`${lead} ${count} ${jq}`) ?? "", new RegExp(String.raw`sizes the tracked JSON set again \("${phrase.replace(/[.*]/g, "\\$&")}"\)`), count);
|
|
1984
|
-
}
|
|
1985
|
-
for (const aside of [
|
|
1986
|
-
"Beside `git ls-files`, the author removed two files last week.",
|
|
1987
|
-
"In 2026 twelve files were removed from plugin.json's directory.",
|
|
1988
|
-
]) {
|
|
1989
|
-
assert.equal(jsonCountFault(`${lead} ${aside} ${jq}`), null, aside);
|
|
1990
|
-
}
|
|
1991
|
-
});
|
|
1992
|
-
|
|
1993
|
-
// Review of PR #2012 (correctness + tests dimensions, independently
|
|
1994
|
-
// corroborated 3 ways): four false positives in #2004's own fixes above,
|
|
1995
|
-
// each measured on the unmodified PR-head file before landing the fix — a
|
|
1996
|
-
// hyphenated spelled-out number could hand JSON_COUNT_CLAUSE_BEFORE its own
|
|
1997
|
-
// hyphen as clause punctuation once the exec-loop restart found a second,
|
|
1998
|
-
// narrower match inside it; a stem character outside \w (`}`, an accented
|
|
1999
|
-
// letter) slipped past the bare-`.json` lookbehind's deny-list; a `.json`
|
|
2000
|
-
// glued directly onto the count's own "files"/"manifests" with no separator
|
|
2001
|
-
// reached the clause-after check's now-visible-nothing lookbehind; and
|
|
2002
|
-
// sharing the modifier's full opener set pulled `(` into the clause-after
|
|
2003
|
-
// check along with the quote #2004 needed there. Each is the same shape as
|
|
2004
|
-
// an aside this file already pins as accepted, just spelled differently.
|
|
2005
|
-
// Also: #2004's own test above pins the determiner-before-the-count rule
|
|
2006
|
-
// with exactly one determiner: the "{0,2}" cap itself — two determiners
|
|
2007
|
-
// still counted, three past it not — was never itself pinned, so a mutation
|
|
2008
|
-
// narrowing the cap to one determiner passed the suite silently.
|
|
2009
|
-
test("jsonCountFault refuses a count set off by exactly two determiners but not three, and accepts four asides #2004's own fixes newly broke (#2012 review)", () => {
|
|
2010
|
-
const jq = "`jq empty`, not `jq -e .`: it exits 1 on a file holding `null` or `false` — both valid JSON.";
|
|
2011
|
-
const lead = "Parses every file `git ls-files '*.json'` lists.";
|
|
2012
|
-
assert.match(
|
|
2013
|
-
jsonCountFault(`${lead} Parses what \`git ls-files\` lists, all exactly nine files remain. ${jq}`) ?? "",
|
|
2014
|
-
/sizes the tracked JSON set again \("nine files"\)/,
|
|
2015
|
-
);
|
|
2016
|
-
assert.equal(jsonCountFault(`${lead} Parses what \`git ls-files\` lists, all exactly the nine files remain. ${jq}`), null);
|
|
2017
|
-
for (const aside of [
|
|
2018
|
-
"Renovate tracked twenty-two files there last week.",
|
|
2019
|
-
"Beside `${name}.json`, two files were removed that week.",
|
|
2020
|
-
"The split removed two files (JSON fixtures nobody read) that week.",
|
|
2021
|
-
"Seven files.json are made up.",
|
|
2022
|
-
]) {
|
|
2023
|
-
assert.equal(jsonCountFault(`${lead} ${aside} ${jq}`), null, aside);
|
|
2024
|
-
}
|
|
2025
|
-
});
|