āœ… test(sarathi): cli.ts and config.ts have no surviving mutant (#489)

Merged
AT
4d ago
+86-10

Slice: #489

pnpm exec agnipariksha --lane sarathi --files packages/sarathi/src/cli.ts,packages/sarathi/src/config.ts --no-reuse now ends with 658 killed of 658 in 2 files: no Survived and no NoCoverage mutant.

Before. config.ts is unchanged since 9b535c2, where the inventory left 24 (22 survived, 2 with no coverage). cli.ts changed on main since then (#432), and that change already judged it whole: none of its 78 is left, and this pull request does not touch it. The run above had other slices' uncommitted sarathi drafts in the tree. The pre-push gate then judged this branch's config.ts alone, on a clean tree: 302 killed of 302.

Tests. config.test.ts gains a suite, "the hook list, rule by rule". It asserts literal values and builds each fixture inside its own it.

Rewrites. Each one keeps today's behaviour:

WhereChangeWhy it is the same
compileMatcherdrops matcher === ''The empty regular expression, unanchored, matches every target, just as () => true does. The suite asserts compileMatcher('')('Anything') is true.
parseEntry, timeoutdrops typeof timeout !== 'number'Number.isFinite is false for anything but a finite number, so a string or a boolean is still refused.
parseEntry, matchercompiles the matcher unconditionallyA non-string matcher is refused a few lines earlier; an absent one compiles to "match all" and is not kept.
loadConfigString(readFileSync(path)) for readFileSync(path, 'utf8')Buffer#toString() decodes UTF-8.
loadConfigString(code) for code ?? 'error'A failed readFileSync always carries an errno code. The only difference is an error with no code, which would now read (undefined) instead of (error), and readFileSync does not throw one.
settingsMatcherdrops matcher === '' and matcher === '*'PLAIN (/^[\w|-]+$/) refuses both, so they still return undefined.
forbiddenSetpasses the value straight to isOnisOn is false for undefined, and the env's values are strings by type (process.env holds nothing else). A non-string own value, reachable only past the types, would now throw instead of being skipped.

Equivalent mutants. None listed: every mutant is killed.

Released nothing and bumped no version.

šŸ¤– Generated with Claude Code


Summary by cubic

Refactors config.ts so mutation testing reports no surviving mutants — the pre-push gate now kills 302 of 302 — and adds a test suite to config.test.ts that walks the hook list rule by rule. Behavior is unchanged; cli.ts already had no surviving mutants on main.

Rewrites

  • Drops conditions no input can distinguish from surrounding code: matcher === '', typeof timeout !== 'number', and the guard before compileMatcher.
  • Reads files with String() instead of 'utf8', and drops ?? 'error' on a failed read's errno code.
  • Lets forbiddenSet pass values straight to isOn, which already returns false for undefined.