ā test(sarathi): cli.ts and config.ts have no surviving mutant (#489)
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:
| Where | Change | Why it is the same |
|---|---|---|
compileMatcher | drops matcher === '' | The empty regular expression, unanchored, matches every target, just as () => true does. The suite asserts compileMatcher('')('Anything') is true. |
parseEntry, timeout | drops typeof timeout !== 'number' | Number.isFinite is false for anything but a finite number, so a string or a boolean is still refused. |
parseEntry, matcher | compiles the matcher unconditionally | A non-string matcher is refused a few lines earlier; an absent one compiles to "match all" and is not kept. |
loadConfig | String(readFileSync(path)) for readFileSync(path, 'utf8') | Buffer#toString() decodes UTF-8. |
loadConfig | String(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. |
settingsMatcher | drops matcher === '' and matcher === '*' | PLAIN (/^[\w|-]+$/) refuses both, so they still return undefined. |
forbiddenSet | passes the value straight to isOn | isOn 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 beforecompileMatcher. - Reads files with
String()instead of'utf8', and drops?? 'error'on a failed read's errno code. - Lets
forbiddenSetpass values straight toisOn, which already returns false forundefined.