Batch 9 of 17 in the ad hoc timeout literal migration (epic #4445). Replaces every bare numeric timeout/timeoutMs object-literal property in 14 files with a named constant, per eslint-rules/no-adhoc-timeout-literal.cjs. Removes the 14 files from the rule's allowlist. The issue's own guess ("all run a scripts/*.cjs generator or lint script once, BUILD_TIMEOUT_MS class") needed two corrections found by reading every site directly. First, BUILD_TIMEOUT_MS's own doc comment scopes it specifically to scripts/build-hooks.js, which none of this batch's generator/lint-script sites run — a new shared constant, GENERATOR_SCRIPT_TIMEOUT_MS, covers the class instead. Second, no-pending-3212-markers.test.cjs's single site spawns `git ls-files` directly, not a scripts/*.cjs script at all — routed to a second new shared constant, REAL_REPO_GIT_TIMEOUT_MS, promoted once emitted-attribution.test.cjs's own git-plumbing sites were found sharing the same class and value. Isolated Standards-axis review caught a further misclassification: one of REAL_REPO_GIT_TIMEOUT_MS's three emitted-attribution.test.cjs sites actually builds a fresh throwaway temp repo (createTempDir + git init), contradicting that constant's own real-repo-tree-only scope. Fixed with a new file-local FRESH_FIXTURE_GIT_TIMEOUT_MS holding the exact pre-existing value under an honest name, rather than reusing the shared GIT_FIXTURE_TIMEOUT_MS (which would have doubled the bound). emitted-attribution.test.cjs also gets two more file-local constants: HEAVY_REAL_TREE_TEST_TIMEOUT_MS (node:test's own per-test timeout option, not a spawn bound) and BUILD_HOOKS_UNDER_LOAD_TIMEOUT_MS (the same build-hooks.js script as the shared norm, at 4x its bound inside the suite's heaviest test). emitted-ack-trailer.test.cjs gets IMPOSSIBLY_SHORT_GIT_TIMEOUT_MS — the one value in this migration that is deliberately tiny (20ms), used to force a timeout in a negative test, not generous headroom. No src/bin file touched, no numeric value changed anywhere. Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
81 lines
3.0 KiB
JavaScript
81 lines
3.0 KiB
JavaScript
// allow-test-rule: structural-regression-guard see #3415
|
|
// Row 15 of .gsd/phase/chore-3415-prohibition-with-teeth/50-test-matrix.md
|
|
// (design doc §4, docs/adr/3212-lexical-seam-consolidation.md:149/167): Phase 4
|
|
// burns down and deletes the grandfather allowlists that Phases 1-3 used to
|
|
// grandfather pre-existing #2128-class regex sites, so no file in the tracked
|
|
// tree may still carry a `pending #3212` marker after this phase ships. This
|
|
// is a structural source-text property (the marker's mere presence, not its
|
|
// runtime behavior), so a tracked-tree scan is the only faithful check.
|
|
'use strict';
|
|
|
|
const { test } = require('node:test');
|
|
const assert = require('node:assert/strict');
|
|
const path = require('node:path');
|
|
const { execFileSync } = require('node:child_process');
|
|
const { REAL_REPO_GIT_TIMEOUT_MS } = require('./helpers/timeouts.cjs');
|
|
|
|
const ROOT = path.resolve(__dirname, '..');
|
|
const MARKER = 'pending #3212';
|
|
|
|
// Files that legitimately contain the literal marker string in prose/self-
|
|
// reference rather than as an actual (now-forbidden) suppression marker:
|
|
// - this file itself (the string appears in this comment/the assertion
|
|
// message, describing what it guards against)
|
|
// - docs/adr/3212-lexical-seam-consolidation.md — the ADR prose that
|
|
// DEFINES the "pending #3212" marker convention and Phase 4's mandate to
|
|
// burn it down (lines 149, 167); verified via `git grep -n "pending
|
|
// #3212"` to be the only doc referencing the phrase.
|
|
const EXCLUDED_RELATIVE_PATHS = new Set([
|
|
'tests/no-pending-3212-markers.test.cjs',
|
|
'docs/adr/3212-lexical-seam-consolidation.md',
|
|
]);
|
|
|
|
/**
|
|
* Returns the repo's tracked files (repo-relative, forward-slash-normalized),
|
|
* so untracked/gitignored files (e.g. .gsd/) are naturally excluded.
|
|
* @returns {string[]}
|
|
*/
|
|
function listTrackedFiles() {
|
|
const stdout = execFileSync('git', ['-c', 'safe.directory=*', 'ls-files'], {
|
|
cwd: ROOT,
|
|
encoding: 'utf8',
|
|
timeout: REAL_REPO_GIT_TIMEOUT_MS,
|
|
});
|
|
return stdout
|
|
.split(/\r?\n/)
|
|
.map((line) => line.replace(/\\/g, '/'))
|
|
.filter((line) => line.length > 0);
|
|
}
|
|
|
|
test('#3212 epic: no tracked file contains a "pending #3212" marker (design doc §4)', () => {
|
|
const fs = require('node:fs');
|
|
const violations = [];
|
|
|
|
for (const relPath of listTrackedFiles()) {
|
|
if (EXCLUDED_RELATIVE_PATHS.has(relPath)) continue;
|
|
|
|
const fullPath = path.join(ROOT, relPath);
|
|
let content;
|
|
try {
|
|
content = fs.readFileSync(fullPath, 'utf8');
|
|
} catch (_) {
|
|
// Not a regular readable text file (e.g. a submodule gitlink, a binary
|
|
// asset, or a symlink target that moved) — skip; this guard is about
|
|
// source-text markers, not filesystem integrity.
|
|
continue;
|
|
}
|
|
|
|
if (content.includes(MARKER)) {
|
|
violations.push(relPath);
|
|
}
|
|
}
|
|
|
|
assert.equal(
|
|
violations.length,
|
|
0,
|
|
`Found ${violations.length} tracked file(s) still carrying a "pending #3212" ` +
|
|
`grandfather marker (ADR-3212 Phase 4 requires them all burned down and ` +
|
|
`deleted): ${violations.join(', ')}`,
|
|
);
|
|
});
|