Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 16 additions & 1 deletion scripts/check-type-check-coverage.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -3794,6 +3794,12 @@ function observed() {
};
}

// Returned by `selfTest()` only after its verdict is printed. The dispatch
// refuses anything else: a `return` that leaves the function above that line
// prints nothing and still exits 0 — a self-test that never finished, reported
// as one that passed (#13798).
const SELF_TEST_VERDICT = 'check-type-check-coverage self-test reached its verdict';

/**
* The ledger semantics are the one part of this gate that can be wrong while
* every package is right -- an evaluate() that under-reports waves the next
Expand Down Expand Up @@ -5657,10 +5663,19 @@ function selfTest() {
`${planCases.length + rewriteCases.length + roundTripCases.length} auto-lowering case(s) + ` +
`${REFUSING.length * 2 + 1 + exitCodeCases.length + textCases.length} exit-code case(s) hold.`,
);

return SELF_TEST_VERDICT;
}

if (process.argv.includes('--self-test')) {
selfTest();
if (selfTest() !== SELF_TEST_VERDICT) {
console.error(
'\n✗ check:type-check-coverage self-test: selfTest() returned without reaching its verdict,\n'
+ 'so no success line was printed. Exiting 0 here would report a self-test\n'
+ 'that never finished as a self-test that passed.\n',
);
process.exit(1);
}
process.exit(0);
}

Expand Down
20 changes: 18 additions & 2 deletions scripts/pm/bare-root-worklist.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -1352,6 +1352,12 @@ function report({ wide = false } = {}) {
}
}

// Returned by `selfTest()` only after its verdict is printed. The dispatch
// refuses anything else: a `return` that leaves the function above that line
// prints nothing and still exits 0 — a self-test that never finished, reported
// as one that passed (#13798).
const SELF_TEST_VERDICT = 'bare-root-worklist self-test reached its verdict';

function selfTest() {
const failures = [];
const t = (label, ok) => { if (!ok) failures.push(label); };
Expand Down Expand Up @@ -1654,9 +1660,19 @@ function selfTest() {
+ '(#14695) are well-formed, disjoint from TRIAGE, contribute no hint of their own, and share '
+ 'one base commit.',
);

return SELF_TEST_VERDICT;
}

if (isEntrypoint(import.meta.url)) {
if (process.argv.includes('--self-test')) selfTest();
else report({ wide: process.argv.includes('--wide') });
if (process.argv.includes('--self-test')) {
if (selfTest() !== SELF_TEST_VERDICT) {
console.error(
'\n✗ bare-root-worklist self-test: selfTest() returned without reaching its verdict,\n'
+ 'so no success line was printed. Exiting 0 here would report a self-test\n'
+ 'that never finished as a self-test that passed.\n',
);
process.exit(1);
}
} else report({ wide: process.argv.includes('--wide') });
}
Loading