Skip to content

Commit 95bf714

Browse files
committed
Merge remote-tracking branch 'origin/main' into claude/issue-15537-15569-lint-yml-stale-comments
2 parents 0882e02 + 5b0c779 commit 95bf714

4 files changed

Lines changed: 90 additions & 8 deletions

File tree

scripts/check-closing-keyword-parity.mjs

Lines changed: 23 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -413,6 +413,15 @@ const MUTATIONS = [
413413
},
414414
];
415415

416+
// Set by `selfTest()` only after a verdict is printed -- either verdict -- and
417+
// read at the dispatch below: a `return` that leaves the function above those
418+
// lines prints nothing and still exits 0, so a self-test that never finished
419+
// reports as one that passed. The self-test's own exit code stays load-bearing,
420+
// so the handshake is a flag rather than a returned sentinel. The failure path
421+
// sets it too: the refusal below must fire only when NEITHER verdict was
422+
// printed, never on a genuine red that already said what failed.
423+
let selfTestReachedVerdict = false;
424+
416425
function selfTest() {
417426
const root = repoRoot();
418427
const failures = [];
@@ -465,16 +474,28 @@ function selfTest() {
465474

466475
if (failures.length === 0) {
467476
console.log(`✓ check-closing-keyword-parity --self-test: ${checked} assertions, ${MUTATIONS.length} mutations of the shipped parsers each driven to red.`);
477+
selfTestReachedVerdict = true;
468478
return 0;
469479
}
470480
console.error(`✗ check-closing-keyword-parity --self-test -- ${failures.length} failure(s)\n`);
471481
for (const f of failures) console.error(` • ${f}`);
482+
selfTestReachedVerdict = true;
472483
return 1;
473484
}
474485

475486
if (isEntrypoint(import.meta.url)) {
476487
const arg = process.argv[2];
477488
if (arg === '--list') list();
478-
else if (arg === '--self-test') process.exit(selfTest());
479-
else process.exit(run());
489+
else if (arg === '--self-test') {
490+
const code = selfTest();
491+
if (!selfTestReachedVerdict) {
492+
console.error(
493+
'\n✗ check-closing-keyword-parity self-test: selfTest() returned without reaching its verdict,\n'
494+
+ 'so no success line was printed. Exiting 0 here would report a self-test\n'
495+
+ 'that never finished as a self-test that passed.\n',
496+
);
497+
process.exit(1);
498+
}
499+
process.exit(code);
500+
} else process.exit(run());
480501
}

scripts/check-pnpm-filter-targets.mjs

Lines changed: 23 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -375,6 +375,15 @@ function list() {
375375
return 0;
376376
}
377377

378+
// Set by `selfTest()` only after a verdict is printed -- either verdict -- and
379+
// read at the dispatch below: a `return` that leaves the function above those
380+
// lines prints nothing and still exits 0, so a self-test that never finished
381+
// reports as one that passed. The self-test's own exit code stays load-bearing,
382+
// so the handshake is a flag rather than a returned sentinel. The failure path
383+
// sets it too: the refusal below must fire only when NEITHER verdict was
384+
// printed, never on a genuine red that already said what failed.
385+
let selfTestReachedVerdict = false;
386+
378387
export function selfTest() {
379388
const failures = [];
380389
let checked = 0;
@@ -526,16 +535,28 @@ export function selfTest() {
526535
+ 'four carriers (workflow, package.json, shell, JS) and the same fixtures observed SILENT with a '
527536
+ `real name; ${live.occurrences.length} live occurrence(s) swept.`,
528537
);
538+
selfTestReachedVerdict = true;
529539
return 0;
530540
}
531541
console.error(`✗ check-pnpm-filter-targets --self-test — ${failures.length} failure(s)\n`);
532542
for (const failure of failures) console.error(` • ${failure}`);
543+
selfTestReachedVerdict = true;
533544
return 1;
534545
}
535546

536547
if (isEntrypoint(import.meta.url)) {
537548
const flag = process.argv[2];
538-
if (flag === '--self-test') process.exit(selfTest());
539-
else if (flag === '--list') process.exit(list());
549+
if (flag === '--self-test') {
550+
const code = selfTest();
551+
if (!selfTestReachedVerdict) {
552+
console.error(
553+
'\n✗ check-pnpm-filter-targets self-test: selfTest() returned without reaching its verdict,\n'
554+
+ 'so no success line was printed. Exiting 0 here would report a self-test\n'
555+
+ 'that never finished as a self-test that passed.\n',
556+
);
557+
process.exit(1);
558+
}
559+
process.exit(code);
560+
} else if (flag === '--list') process.exit(list());
540561
else process.exit(run());
541562
}

scripts/check-settings-bind-window.mjs

Lines changed: 21 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -727,6 +727,15 @@ function list() {
727727

728728
// ── Self-test ────────────────────────────────────────────────────────────────
729729

730+
// Set by `selfTest()` only after a verdict is printed -- either verdict -- and
731+
// read at the dispatch below: a `return` that leaves the function above those
732+
// lines prints nothing and still exits 0, so a self-test that never finished
733+
// reports as one that passed. The self-test's own exit code stays load-bearing,
734+
// so the handshake is a flag rather than a returned sentinel. The failure path
735+
// sets it too: the refusal below must fire only when NEITHER verdict was
736+
// printed, never on a genuine red that already said what failed.
737+
let selfTestReachedVerdict = false;
738+
730739
function selfTest() {
731740
const assert = (cond, msg) => { if (!cond) { console.error('✗ self-test: ' + msg); process.exit(1); } };
732741

@@ -1039,11 +1048,21 @@ function selfTest() {
10391048
}
10401049

10411050
console.log(`✓ settings bind-window guard self-test: all cases pass.`);
1051+
selfTestReachedVerdict = true;
10421052
}
10431053

10441054
// ── Entry ────────────────────────────────────────────────────────────────────
10451055

10461056
const arg = process.argv[2];
1047-
if (arg === '--self-test') selfTest();
1048-
else if (arg === '--list') list();
1057+
if (arg === '--self-test') {
1058+
selfTest();
1059+
if (!selfTestReachedVerdict) {
1060+
console.error(
1061+
'\n✗ check-settings-bind-window self-test: selfTest() returned without reaching its verdict,\n'
1062+
+ 'so no success line was printed. Exiting 0 here would report a self-test\n'
1063+
+ 'that never finished as a self-test that passed.\n',
1064+
);
1065+
process.exit(1);
1066+
}
1067+
} else if (arg === '--list') list();
10491068
else audit();

scripts/pnpm-filter-targets.mjs

Lines changed: 23 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -531,6 +531,15 @@ function cliPreflight(command) {
531531
return 0;
532532
}
533533

534+
// Set by `selfTest()` only after a verdict is printed -- either verdict -- and
535+
// read at the dispatch below: a `return` that leaves the function above those
536+
// lines prints nothing and still exits 0, so a self-test that never finished
537+
// reports as one that passed. The self-test's own exit code stays load-bearing,
538+
// so the handshake is a flag rather than a returned sentinel. The failure path
539+
// sets it too: the refusal below must fire only when NEITHER verdict was
540+
// printed, never on a genuine red that already said what failed.
541+
let selfTestReachedVerdict = false;
542+
534543
export async function selfTest() {
535544
const failures = [];
536545
let checked = 0;
@@ -683,17 +692,29 @@ export async function selfTest() {
683692
`✓ pnpm-filter-targets --self-test: ${checked} assertions over ${names.length} real workspace packages `
684693
+ '(match rule pinned against measured pnpm behaviour; preflight observed both REFUSING and SILENT).',
685694
);
695+
selfTestReachedVerdict = true;
686696
return 0;
687697
}
688698
console.error(`✗ pnpm-filter-targets --self-test -- ${failures.length} failure(s)\n`);
689699
for (const failure of failures) console.error(` • ${failure}`);
700+
selfTestReachedVerdict = true;
690701
return 1;
691702
}
692703

693704
if (isEntrypoint(import.meta.url)) {
694705
const [flag, argument] = process.argv.slice(2);
695-
if (flag === '--self-test') process.exit(await selfTest());
696-
else if (flag === '--list') process.exit(cliList());
706+
if (flag === '--self-test') {
707+
const code = await selfTest();
708+
if (!selfTestReachedVerdict) {
709+
console.error(
710+
'\n✗ pnpm-filter-targets self-test: selfTest() returned without reaching its verdict,\n'
711+
+ 'so no success line was printed. Exiting 0 here would report a self-test\n'
712+
+ 'that never finished as a self-test that passed.\n',
713+
);
714+
process.exit(1);
715+
}
716+
process.exit(code);
717+
} else if (flag === '--list') process.exit(cliList());
697718
else if (flag === '--preflight') process.exit(cliPreflight(argument ?? ''));
698719
else {
699720
console.error('usage: pnpm-filter-targets.mjs [--list | --preflight <command> | --self-test]');

0 commit comments

Comments
 (0)