* refactor(#1191): inject clock/reset testability seams + handle valid-null settings - worktree-safety reapOrphanWorktrees: injectable deps.nowMs clock for deterministic stale-lock boundary tests (mirrors snapshotWorktreeInventory's options.nowMs). - active-workstream-store: _resetControllingTtyCacheForTests() seam clears the memoized controlling-TTY probe cache; test replaces require.cache busting. - gen-capability-registry: export stripGeneratedComment (additive); test imports the real helper + equivalence assertion, keeping the deliberate drift oracle. - install.js readSettings: a successfully-parsed JSON null is treated as empty settings ({}) instead of being mis-reported as malformed; genuine parse failures still warn. readSettings/stripJsonComments exported (GSD_TEST_MODE-guarded require) for real behavioral tests. Closes #1191 Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com> * chore(#1191): add changeset for valid-null settings fix (#1233) Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com> * fix(#1191): replace Stryker-incompatible structural reset test with behavioral isTTY-spy The seam-2 reset test read the BUILT active-workstream-store.cjs and grepped for 'didProbeControllingTtyToken = false' — Stryker instruments that file so the literal is absent, failing the mutation DRY RUN. Replaced with a behavioral test that spies on process.stdin.isTTY access count to prove a post-reset probe re-runs (kills the didProbe-reset mutant) without reading source text. Local stryker: dry run passes, score 85.21% >= 80. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com> --------- Co-authored-by: Claude Opus 4.8 <noreply@anthropic.com>
This commit is contained in:
@@ -31,6 +31,7 @@ const {
|
||||
computeRequiresClosure,
|
||||
topoSortSteps,
|
||||
normalizeLineEndings,
|
||||
stripGeneratedComment,
|
||||
validateConfigSliceEntry,
|
||||
VALID_CONFIG_SLICE_TYPES,
|
||||
SCHEMA_VERSION,
|
||||
@@ -589,6 +590,11 @@ const REGISTRY_PATH = path.join(ROOT, 'gsd-core', 'bin', 'lib', 'capability-regi
|
||||
* Kept here intentionally: the test validates BEHAVIOR, and the implementation is
|
||||
* stable (a single-line filter). If the source changes the sentinel string, this
|
||||
* test will correctly start failing — that is the desired red signal.
|
||||
*
|
||||
* NOTE (#1191): The equivalence test below pins the exported stripGeneratedComment
|
||||
* to this mirror. If the export's sentinel ever drifts from the mirror's sentinel,
|
||||
* the equivalence test goes RED — making the implicit "sentinel drift = red signal"
|
||||
* comment above into an explicit automated check.
|
||||
*/
|
||||
function applyStripGeneratedComment(content) {
|
||||
return content
|
||||
@@ -602,6 +608,31 @@ function checkPipeline(content) {
|
||||
return normalizeLineEndings(applyStripGeneratedComment(content));
|
||||
}
|
||||
|
||||
// ─── Seam-3 equivalence test (#1191) ─────────────────────────────────────────
|
||||
//
|
||||
// Verifies that the now-exported stripGeneratedComment from gen-capability-registry.cjs
|
||||
// matches the local oracle (applyStripGeneratedComment) on a representative sample.
|
||||
// This turns the oracle's implicit "fails if sentinel drifts" into an explicit guard.
|
||||
|
||||
describe('exported stripGeneratedComment matches the test oracle (no sentinel drift)', () => {
|
||||
test('exported stripGeneratedComment matches the test oracle (no sentinel drift)', () => {
|
||||
const sample = [
|
||||
'// generated by scripts/gen-capability-registry.cjs — DO NOT EDIT',
|
||||
"'use strict';",
|
||||
'// normal comment (not a generated-by line)',
|
||||
"module.exports = { version: '1' };",
|
||||
'// generated by scripts/gen-capability-registry.cjs (second occurrence)',
|
||||
].join('\n');
|
||||
|
||||
assert.strictEqual(
|
||||
stripGeneratedComment(sample),
|
||||
applyStripGeneratedComment(sample),
|
||||
'exported stripGeneratedComment must produce identical output to the test oracle — ' +
|
||||
'a sentinel mismatch means the export and the oracle have drifted'
|
||||
);
|
||||
});
|
||||
});
|
||||
|
||||
describe('--check drift detection', () => {
|
||||
test('stale VERSION survives stripGeneratedComment+normalizeLineEndings and IS detected as drift', () => {
|
||||
// Build a fresh registry from the real UI cap — this is the "live" content
|
||||
|
||||
Reference in New Issue
Block a user