mutant-cafe 0.1.0 → 0.1.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +17 -8
- package/dist/bin.js +338 -89
- package/dist/bin.js.map +4 -4
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -1,16 +1,18 @@
|
|
|
1
1
|
# mutant.cafe
|
|
2
2
|
|
|
3
|
+

|
|
4
|
+
|
|
3
5
|
Mutation testing for [Effect](https://effect.website) TypeScript. mutant.cafe reads your types, breaks your functions in ways that still type-check, runs the tests related to each break, and lists the breaks your tests miss.
|
|
4
6
|
|
|
5
7
|
It is inspired by [cargo-mutants](https://mutants.rs) by Martin Pool ([source](https://github.com/sourcefrog/cargo-mutants), MIT). The core idea, replacing a function body with a plausible value of its return type and reporting what the tests don't notice, comes from cargo-mutants, and so does the operator experience: a baseline run first, a scratch copy of your tree, per-mutant timeouts, `--in-diff`, and a `mutants.out` directory of results. mutant.cafe ports those ideas to Effect; it shares no code with cargo-mutants.
|
|
6
8
|
|
|
7
9
|
## What it adds for Effect
|
|
8
10
|
|
|
9
|
-
An `Effect<A, E, R>` declares its failures in `E`. For each tagged error in `E`, mutant.cafe makes a mutant that swallows that error and succeeds instead. If
|
|
11
|
+
An `Effect<A, E, R>` declares its failures in `E`. For each tagged error in `E`, mutant.cafe makes a mutant that swallows that error and succeeds instead. If no value of `A` can be synthesized, a separate `TagToDefect` mutant turns that tag into a defect. That is not a successful recovery: it checks whether tests distinguish typed failures from defects, rather than only asserting `Exit.isFailure`.
|
|
10
12
|
|
|
11
13
|
Other mutants, all chosen from the checker's view of the return type:
|
|
12
14
|
|
|
13
|
-
- `Effect.succeed(value)` for plausible values of `A`, `Effect.fail` of each tag, `Effect.die`, and `Effect.never` behind a
|
|
15
|
+
- `Effect.succeed(value)` for plausible values of `A`, `Effect.fail` of each tag, `Effect.die`, and `Effect.never` behind a measured timeout
|
|
14
16
|
- `Option.none()` and `Option.some(value)`
|
|
15
17
|
- `Stream.empty`, a one-element stream, and a failing stream
|
|
16
18
|
- a `Layer` that fails at build
|
|
@@ -30,7 +32,7 @@ Run it from the package whose tests you want to check. In a monorepo that resolv
|
|
|
30
32
|
|
|
31
33
|
| Flag | Meaning |
|
|
32
34
|
| --- | --- |
|
|
33
|
-
| `--list` | print the mutants and exit |
|
|
35
|
+
| `--list` | print the mutants, per-file counts and a total, then exit |
|
|
34
36
|
| `--in-diff <file>` | only mutants on lines a unified diff adds or changes |
|
|
35
37
|
| `--file <glob>`, `--exclude <glob>` | choose source files (repeatable) |
|
|
36
38
|
| `--jobs <n>` | scratch copies tested in parallel |
|
|
@@ -39,18 +41,25 @@ Run it from the package whose tests you want to check. In a monorepo that resolv
|
|
|
39
41
|
| `--output <dir>` | results directory, default `mutants.out` |
|
|
40
42
|
| `--tsconfig <path>` | default `tsconfig.json` |
|
|
41
43
|
|
|
42
|
-
Results land in `mutants.out/`: `missed.txt`, `caught.txt`, `timeout.txt`, `unviable.txt`, a diff and a log per mutant, and `outcomes.json`. Add `mutants.out*` to `.gitignore`. Your source tree is never edited: each mutant runs in a scratch copy.
|
|
44
|
+
Results land in `mutants.out/`: `missed.txt`, `caught.txt`, `timeout.txt`, `unviable.txt`, `untested.txt`, a context diff and a log per mutant, and `outcomes.json`. Every result line includes the mutant id used by `diff/<id>.diff` and `logs/<id>.log`. Lines show the declared return type when available, or an abbreviated inferred type; JSON keeps full types. Add `mutants.out*` to `.gitignore`. Your source tree is never edited: each mutant runs in a scratch copy.
|
|
45
|
+
|
|
46
|
+
An include glob that matches no source file is a usage error, including a path outside the package root. Diff paths resolve from the Git toplevel, with support for `git diff --relative`; outside Git they resolve from the working directory.
|
|
43
47
|
|
|
44
|
-
Exit codes: 0
|
|
48
|
+
Exit codes: 0 no missed, untested or timed-out mutants, 1 usage error, 2 some mutants were missed or untested, 3 some timed out with none missed or untested, 4 the baseline tests fail, 5 the `--in-diff` diff doesn't match the tree, 6 the diff can't be parsed, 70 internal error. **Missed or untested takes precedence over timeout:** a run with both exits 2.
|
|
45
49
|
|
|
46
50
|
## Outcomes
|
|
47
51
|
|
|
48
52
|
| Outcome | Meaning |
|
|
49
53
|
| --- | --- |
|
|
50
|
-
| caught | a
|
|
51
|
-
| missed |
|
|
54
|
+
| caught | a test failed, or a collected test run hung on `Effect.never` past its measured budget |
|
|
55
|
+
| missed | the selected tests passed |
|
|
52
56
|
| unviable | the mutant does not type-check |
|
|
53
|
-
| timeout | the tests ran past the per-mutant
|
|
57
|
+
| timeout | the tests ran past the per-mutant budget without a reported failure or evidence of a caught `Effect.never` |
|
|
58
|
+
| untested | neither related selection nor the package's full suite found any test files |
|
|
59
|
+
|
|
60
|
+
Vitest first runs tests related to the mutated file. When that selects no test files, mutant.cafe reruns the package's full suite within the remaining budget. Selection and partial failures come from Vitest's reporter hooks, not its human-readable messages. A reported failure still counts as caught if another test file hangs.
|
|
61
|
+
|
|
62
|
+
Ordinary mutants use the configured timeout. For `Effect.never`, mutant.cafe measures the unmutated related run once per file, including any full-suite fallback. Its budget is that duration × the timeout multiplier, with a 1 s floor. Slow tests that never call the function can finish normally; a process killed before test collection is not credited as caught. Each mutant run also sets Vitest's per-test timeout to half its budget, overriding a package's `testTimeout: 0`, and stops after the first reported failure.
|
|
54
63
|
|
|
55
64
|
## Prior art
|
|
56
65
|
|