Skip to main content

fallow_api/mutation/
verdicts.rs

1//! Joins a mutation report with a separate verdict document.
2//!
3//! A verdict marks one mutant as equivalent to the original code. This
4//! replaces an inline suppression comment: the report stays the evidence, and the verdict is a separate,
5//! reviewable judgment. The join key is the `review_key` of the verdict, which
6//! is the `mutant_id` of the report. The id hashes the enclosing function
7//! text, so a verdict stays valid until that function changes.
8
9use std::collections::BTreeSet;
10
11use fallow_output::{
12    MutantEquivalenceHint, MutantStatus, MutationFunctionResult, MutationReport,
13    MutationStatusCounts, MutationSummary, MutationVerdictInput, MutationVerdictJoin,
14};
15use rustc_hash::FxHashSet;
16use std::fmt::Write as _;
17
18use sha2::{Digest, Sha256};
19
20use crate::ProgrammaticError;
21
22/// The largest verdict document that the join reads.
23pub const MAX_VERDICT_INPUT_BYTES: usize = 16 * 1024 * 1024;
24
25fn verdict_error(message: impl Into<String>) -> ProgrammaticError {
26    ProgrammaticError::new(message, 2)
27        .with_code("FALLOW_MUTATION_VERDICTS_INVALID")
28        .with_context("mutation.verdicts")
29}
30
31fn sha256_hex(bytes: &[u8]) -> String {
32    Sha256::digest(bytes)
33        .iter()
34        .fold(String::with_capacity(64), |mut hex, byte| {
35            let _ = write!(hex, "{byte:02x}");
36            hex
37        })
38}
39
40/// The effect of one verdict on a mutant with `status`.
41enum Effect {
42    Applied,
43    Contradicted,
44    Deferred,
45}
46
47const fn effect(status: MutantStatus) -> Effect {
48    match status {
49        MutantStatus::Survived
50        | MutantStatus::NoCoverage
51        | MutantStatus::Flaky
52        | MutantStatus::Equivalent => Effect::Applied,
53        MutantStatus::Killed | MutantStatus::Timeout | MutantStatus::CompileError => {
54            Effect::Contradicted
55        }
56        MutantStatus::Pending
57        | MutantStatus::RuntimeError
58        | MutantStatus::Pruned
59        | MutantStatus::NotKilledByTarget => Effect::Deferred,
60    }
61}
62
63/// Moves one mutant from `from` to `equivalent` in the function group that
64/// holds it.
65///
66/// Two callbacks on one line can give two groups with the same file, name
67/// and first line. A survivor is in the `survived` list of exactly one
68/// group, so that list decides. Other statuses have no such list, so a group
69/// that also spans the line of the mutant comes first. The report has no
70/// column span, so two callbacks that start and end on one line still share
71/// the key. A group that holds the count without the span still takes the
72/// move, because a `--recheck` merge counts carried mutants under the first
73/// group of the key and the counts must stay in step with the mutants.
74fn move_in_function(report: &mut MutationReport, index: usize, from: MutantStatus) {
75    let location = &report.mutants[index].location;
76    let key = (
77        location.file.as_str(),
78        location.function.as_deref(),
79        location.function_line,
80    );
81    let holds = |group: &MutationFunctionResult| {
82        if from == MutantStatus::Survived {
83            return group.survived.contains(&location.mutant_id);
84        }
85        (group.file.as_str(), group.name.as_deref(), group.line) == key
86            && count_of(&group.counts, from) > 0
87    };
88    let spans =
89        |group: &MutationFunctionResult| group.end_line.is_none_or(|end| location.line <= end);
90    let position = report
91        .functions
92        .iter()
93        .position(|group| holds(group) && spans(group))
94        .or_else(|| report.functions.iter().position(holds));
95    let Some(group) = position.map(|position| &mut report.functions[position]) else {
96        return;
97    };
98    group.counts.remove(from);
99    group.counts.add(MutantStatus::Equivalent);
100    group.survived.retain(|id| *id != location.mutant_id);
101    group.score = group.counts.score();
102}
103
104const fn count_of(counts: &MutationStatusCounts, status: MutantStatus) -> usize {
105    match status {
106        MutantStatus::Killed => counts.killed,
107        MutantStatus::Timeout => counts.timeout,
108        MutantStatus::Survived => counts.survived,
109        MutantStatus::NoCoverage => counts.no_coverage,
110        MutantStatus::RuntimeError => counts.runtime_error,
111        MutantStatus::Flaky => counts.flaky,
112        MutantStatus::Pruned => counts.pruned,
113        MutantStatus::Pending => counts.pending,
114        MutantStatus::Equivalent => counts.equivalent,
115        MutantStatus::CompileError => counts.compile_error,
116        MutantStatus::NotKilledByTarget => counts.not_killed_by_target,
117    }
118}
119
120/// Parses a verdict document and checks its keys.
121fn parse_verdicts(verdict_json: &[u8]) -> Result<MutationVerdictInput, ProgrammaticError> {
122    if verdict_json.len() > MAX_VERDICT_INPUT_BYTES {
123        return Err(verdict_error(
124            "the mutation verdict document is larger than 16 MiB",
125        ));
126    }
127    let input: MutationVerdictInput = serde_json::from_slice(verdict_json)
128        .map_err(|error| verdict_error(format!("invalid mutation verdict document: {error}")))?;
129    let mut keys = FxHashSet::default();
130    for verdict in &input.verdicts {
131        if verdict.review_key.trim().is_empty() {
132            return Err(verdict_error("a mutation verdict has an empty review_key"));
133        }
134        if !keys.insert(verdict.review_key.as_str()) {
135            return Err(verdict_error(format!(
136                "the review_key `{}` occurs more than one time",
137                verdict.review_key
138            )));
139        }
140    }
141    Ok(input)
142}
143
144/// Checks a verdict document without a report.
145///
146/// A caller runs this check before a mutation run, so an invalid document
147/// stops the command before any test runs.
148///
149/// # Errors
150///
151/// Returns the same errors as [`apply_mutation_verdicts`].
152pub fn validate_mutation_verdicts(verdict_json: &[u8]) -> Result<(), ProgrammaticError> {
153    parse_verdicts(verdict_json).map(|_| ())
154}
155
156/// Applies a verdict document to `report`.
157///
158/// Each verdict for a `survived`, `no_coverage` or `flaky` mutant sets the
159/// status `equivalent`, which does not count in the score. The mutant loses
160/// its `equivalence_hint`, and `typecheck.hinted` counts the hints that stay
161/// in the report. A verdict for a
162/// killed or timed-out mutant is contradicted by a test, so the status stays.
163/// A verdict for a mutant with no tested result (`pending`, `runtime_error`,
164/// `pruned`) is deferred. A verdict that matches no mutant is unmatched; it
165/// is not an error, because one verdict document serves many scoped runs.
166/// The summary and the function results are recomputed.
167///
168/// # Errors
169///
170/// Returns a fail-closed error for a document over 16 MiB, a malformed
171/// document, an empty `review_key`, or a `review_key` that occurs twice.
172pub fn apply_mutation_verdicts(
173    report: &mut MutationReport,
174    verdict_json: &[u8],
175) -> Result<(), ProgrammaticError> {
176    let input = parse_verdicts(verdict_json)?;
177    let keys: FxHashSet<&str> = input
178        .verdicts
179        .iter()
180        .map(|verdict| verdict.review_key.as_str())
181        .collect();
182
183    let mut applied = BTreeSet::new();
184    let mut contradicted = BTreeSet::new();
185    let mut deferred = BTreeSet::new();
186    let mut matched = FxHashSet::default();
187    for index in 0..report.mutants.len() {
188        let id = report.mutants[index].location.mutant_id.clone();
189        if !keys.contains(id.as_str()) {
190            continue;
191        }
192        matched.insert(id.clone());
193        let status = report.mutants[index].status;
194        match effect(status) {
195            Effect::Applied => {
196                if status != MutantStatus::Equivalent {
197                    report.mutants[index].status = MutantStatus::Equivalent;
198                    report.mutants[index].equivalence_hint = None;
199                    move_in_function(report, index, status);
200                }
201                applied.insert(id);
202            }
203            Effect::Contradicted => {
204                contradicted.insert(id);
205            }
206            Effect::Deferred => {
207                deferred.insert(id);
208            }
209        }
210    }
211    let unmatched: BTreeSet<String> = input
212        .verdicts
213        .iter()
214        .filter(|verdict| !matched.contains(&verdict.review_key))
215        .map(|verdict| verdict.review_key.clone())
216        .collect();
217
218    report.summary = MutationSummary::from_results(&report.mutants);
219    report.withhold_target_first_scores();
220    if let Some(typecheck) = report.typecheck.as_mut() {
221        typecheck.hinted = report
222            .mutants
223            .iter()
224            .filter(|mutant| mutant.equivalence_hint == Some(MutantEquivalenceHint::TypeNonNullish))
225            .count();
226    }
227    report.verdicts = Some(MutationVerdictJoin {
228        verdicts_sha256: sha256_hex(verdict_json),
229        applied: applied.into_iter().collect(),
230        contradicted: contradicted.into_iter().collect(),
231        deferred: deferred.into_iter().collect(),
232        unmatched: unmatched.into_iter().collect(),
233    });
234    Ok(())
235}
236
237#[cfg(test)]
238#[expect(clippy::unwrap_used, reason = "tests unwrap to keep assertions short")]
239mod tests {
240    use fallow_output::{
241        MutantEquivalenceHint, MutantLocation, MutantResult, MutationCompletion,
242        MutationFunctionResult, MutationSchemaVersion, MutationScopeKind, MutationScopeOutput,
243        MutationSummary, MutationTimings, MutationTypecheckOutput, MutationWorktreeCheck,
244    };
245    use fallow_types::envelope::{ElapsedMs, ToolVersion};
246
247    use super::*;
248
249    fn mutant(id: &str, status: MutantStatus) -> MutantResult {
250        MutantResult {
251            location: MutantLocation {
252                mutant_id: id.to_owned(),
253                file: "src/a.ts".to_owned(),
254                line: 2,
255                column: 3,
256                span: (10, 15),
257                operator: "arithmetic-operator".to_owned(),
258                function: Some("add".to_owned()),
259                function_line: Some(1),
260                rank: Some(1),
261                change: None,
262            },
263            status,
264            prune_reason: None,
265            pending_reason: None,
266            killing_tests: Vec::new(),
267            kill_matrix_complete: false,
268            killed_by: None,
269            covering_tests: match status {
270                MutantStatus::NoCoverage | MutantStatus::Pending | MutantStatus::Pruned => {
271                    Vec::new()
272                }
273                _ => vec!["test/a.test.ts::t1".to_owned()],
274            },
275            static_mutant: false,
276            duration_ms: None,
277            test_reach: None,
278            retried: false,
279            attempts: Vec::new(),
280            cached: false,
281            resumed: false,
282            carried: false,
283            type_error_codes: Vec::new(),
284            equivalence_hint: None,
285            witness: None,
286        }
287    }
288
289    fn report(mutants: Vec<MutantResult>) -> MutationReport {
290        let mut counts = MutationStatusCounts::default();
291        let mut survived = Vec::new();
292        for result in &mutants {
293            counts.add(result.status);
294            if result.status == MutantStatus::Survived {
295                survived.push(result.location.mutant_id.clone());
296            }
297        }
298        MutationReport {
299            schema_version: MutationSchemaVersion::V2,
300            version: ToolVersion("0.0.0".to_owned()),
301            elapsed_ms: ElapsedMs(0),
302            completion: MutationCompletion::from_reasons(Vec::new()),
303            kill_matrix: fallow_output::MutationKillMatrix::default(),
304            scope: MutationScopeOutput {
305                kind: MutationScopeKind::All,
306                base_ref: None,
307            },
308            runner: None,
309            cache: None,
310            resume: None,
311            summary: MutationSummary::from_results(&mutants),
312            functions: vec![MutationFunctionResult {
313                file: "src/a.ts".to_owned(),
314                name: Some("add".to_owned()),
315                line: Some(1),
316                end_line: Some(4),
317                in_diff: true,
318                cyclomatic: Some(1),
319                counts,
320                score: counts.score(),
321                survived,
322            }],
323            mutants,
324            no_test_files: false,
325            baseline_failures: Vec::new(),
326            skipped_files: Vec::new(),
327            unmatched_paths: Vec::new(),
328            unmatched_path_reasons: Vec::new(),
329            unloaded_paths: Vec::new(),
330            worktree: MutationWorktreeCheck {
331                checked: true,
332                allow_dirty: false,
333                dirty_at_start: Vec::new(),
334                changed_paths: Vec::new(),
335            },
336            errors: Vec::new(),
337            timings: MutationTimings::default(),
338            files: Vec::new(),
339            verdicts: None,
340            typecheck: None,
341            recheck: None,
342            compare: None,
343            gate_outcomes: None,
344            recording: None,
345            journal_run_id: None,
346        }
347    }
348
349    #[test]
350    fn normal_report_explains_unavailable_kill_matrix() {
351        let value = serde_json::to_value(report(Vec::new())).expect("report");
352        assert_eq!(value["kill_matrix"]["status"], "unavailable");
353        assert_eq!(
354            value["kill_matrix"]["reasons"],
355            serde_json::json!(["kill-matrix-disabled"])
356        );
357    }
358
359    fn document(keys: &[&str]) -> Vec<u8> {
360        let verdicts: Vec<serde_json::Value> = keys
361            .iter()
362            .map(|key| serde_json::json!({ "review_key": key, "verdict": "equivalent" }))
363            .collect();
364        serde_json::to_vec(&serde_json::json!({ "schema_version": "1", "verdicts": verdicts }))
365            .unwrap()
366    }
367
368    /// A verdict for a hinted survivor makes the hint redundant. The final
369    /// report keeps the hint only on a mutant that is still `survived`, and
370    /// `typecheck.hinted` counts the hints of the final report.
371    #[test]
372    fn a_verdict_clears_the_hint_and_the_hinted_count() {
373        let mut judged = mutant("m2", MutantStatus::Survived);
374        judged.equivalence_hint = Some(MutantEquivalenceHint::TypeNonNullish);
375        let mut open = mutant("m3", MutantStatus::Survived);
376        open.equivalence_hint = Some(MutantEquivalenceHint::TypeNonNullish);
377        let mut report = report(vec![mutant("m1", MutantStatus::Killed), judged, open]);
378        report.typecheck = Some(MutationTypecheckOutput {
379            completed: true,
380            survivors: 2,
381            checked: 2,
382            compile_errors: 0,
383            hinted: 2,
384            skipped: Vec::new(),
385        });
386
387        apply_mutation_verdicts(&mut report, &document(&["m2"])).unwrap();
388
389        assert_eq!(report.mutants[1].status, MutantStatus::Equivalent);
390        assert_eq!(report.mutants[1].equivalence_hint, None);
391        assert_eq!(report.mutants[2].status, MutantStatus::Survived);
392        assert_eq!(
393            report.mutants[2].equivalence_hint,
394            Some(MutantEquivalenceHint::TypeNonNullish)
395        );
396        let typecheck = report.typecheck.as_ref().unwrap();
397        assert_eq!(typecheck.hinted, 1);
398        assert_eq!(typecheck.checked, 2);
399        let value = serde_json::to_value(&report.mutants[1]).unwrap();
400        assert!(value.get("equivalence_hint").is_none(), "{value}");
401    }
402
403    /// `typecheck.hinted` counts the type hints only. A `constant-parameter`
404    /// hint does not come from the type check.
405    #[test]
406    fn the_hinted_count_leaves_out_the_constant_parameter_hint() {
407        let mut typed = mutant("m1", MutantStatus::Survived);
408        typed.equivalence_hint = Some(MutantEquivalenceHint::TypeNonNullish);
409        let mut constant = mutant("m2", MutantStatus::Survived);
410        constant.equivalence_hint = Some(MutantEquivalenceHint::ConstantParameter);
411        let mut report = report(vec![typed, constant]);
412        report.typecheck = Some(MutationTypecheckOutput {
413            completed: true,
414            survivors: 2,
415            checked: 2,
416            compile_errors: 0,
417            hinted: 1,
418            skipped: Vec::new(),
419        });
420
421        apply_mutation_verdicts(&mut report, &document(&["unmatched"])).unwrap();
422
423        assert_eq!(report.typecheck.as_ref().unwrap().hinted, 1);
424        assert_eq!(
425            report.mutants[1].equivalence_hint,
426            Some(MutantEquivalenceHint::ConstantParameter)
427        );
428    }
429
430    #[test]
431    fn a_verdict_gives_a_target_first_report_no_score() {
432        let mut report = report(vec![
433            mutant("m1", MutantStatus::Killed),
434            mutant("m2", MutantStatus::NotKilledByTarget),
435            mutant("m3", MutantStatus::NoCoverage),
436        ]);
437        report.kill_matrix.target_mode =
438            Some(fallow_output::MutationKillMatrixTargetMode::TargetFirst);
439        report.withhold_target_first_scores();
440
441        apply_mutation_verdicts(&mut report, &document(&["m3"])).unwrap();
442
443        assert_eq!(report.summary.counts.equivalent, 1);
444        assert_eq!(report.summary.score, None);
445        assert!(
446            report
447                .functions
448                .iter()
449                .all(|function| function.score.is_none())
450        );
451    }
452
453    #[test]
454    fn equivalent_verdicts_leave_the_score_and_the_survivor_list() {
455        let mut report = report(vec![
456            mutant("m1", MutantStatus::Killed),
457            mutant("m2", MutantStatus::Survived),
458            mutant("m3", MutantStatus::Survived),
459            mutant("m4", MutantStatus::NoCoverage),
460        ]);
461        assert_eq!(report.summary.score, Some(1.0 / 3.0));
462        assert_eq!(report.summary.coverage, Some(0.75));
463
464        apply_mutation_verdicts(&mut report, &document(&["m2", "m4"])).unwrap();
465
466        let statuses: Vec<MutantStatus> = report.mutants.iter().map(|m| m.status).collect();
467        assert_eq!(
468            statuses,
469            vec![
470                MutantStatus::Killed,
471                MutantStatus::Equivalent,
472                MutantStatus::Survived,
473                MutantStatus::Equivalent
474            ]
475        );
476        assert_eq!(report.summary.counts.equivalent, 2);
477        assert_eq!(report.summary.counts.survived, 1);
478        assert_eq!(report.summary.counts.no_coverage, 0);
479        assert_eq!(report.summary.counts.total, 4);
480        assert_eq!(report.summary.score, Some(0.5));
481        assert_eq!(report.summary.coverage, Some(1.0));
482        let function = &report.functions[0];
483        assert_eq!(function.counts.equivalent, 2);
484        assert_eq!(function.counts.no_coverage, 0);
485        assert_eq!(function.survived, vec!["m3".to_owned()]);
486        assert_eq!(function.score, Some(0.5));
487        let join = report.verdicts.unwrap();
488        assert_eq!(join.applied, vec!["m2".to_owned(), "m4".to_owned()]);
489        assert!(join.unmatched.is_empty());
490        assert_eq!(join.verdicts_sha256.len(), 64);
491    }
492
493    /// Two anonymous callbacks on one line: one function group each, with the
494    /// same file, name and first line.
495    fn two_callbacks_on_one_line(
496        first: MutantResult,
497        second: MutantResult,
498        second_end_line: u32,
499    ) -> MutationReport {
500        let mut first = first;
501        let mut second = second;
502        for result in [&mut first, &mut second] {
503            result.location.function = None;
504            result.location.function_line = Some(1);
505        }
506        first.location.line = 1;
507        second.location.line = second_end_line;
508        let group = |result: &MutantResult, end_line: u32| {
509            let mut counts = MutationStatusCounts::default();
510            counts.add(result.status);
511            MutationFunctionResult {
512                file: "src/a.ts".to_owned(),
513                name: None,
514                line: Some(1),
515                end_line: Some(end_line),
516                in_diff: true,
517                cyclomatic: Some(1),
518                counts,
519                score: counts.score(),
520                survived: (result.status == MutantStatus::Survived)
521                    .then(|| result.location.mutant_id.clone())
522                    .into_iter()
523                    .collect(),
524            }
525        };
526        let functions = vec![group(&first, 1), group(&second, second_end_line)];
527        let mut report = report(vec![first, second]);
528        report.functions = functions;
529        report
530    }
531
532    #[test]
533    fn a_verdict_moves_the_survivor_in_its_own_callback_group() {
534        let mut report = two_callbacks_on_one_line(
535            mutant("m1", MutantStatus::Survived),
536            mutant("m2", MutantStatus::Survived),
537            1,
538        );
539
540        apply_mutation_verdicts(&mut report, &document(&["m2"])).unwrap();
541
542        let [first, second] = report.functions.as_slice() else {
543            panic!("two groups");
544        };
545        assert_eq!(first.survived, ["m1"]);
546        assert_eq!(first.counts.survived, 1);
547        assert_eq!(first.counts.equivalent, 0);
548        assert!(second.survived.is_empty());
549        assert_eq!(second.counts.survived, 0);
550        assert_eq!(second.counts.equivalent, 1);
551    }
552
553    #[test]
554    fn a_verdict_moves_an_uncovered_mutant_in_the_group_that_spans_its_line() {
555        let mut report = two_callbacks_on_one_line(
556            mutant("m1", MutantStatus::NoCoverage),
557            mutant("m2", MutantStatus::NoCoverage),
558            3,
559        );
560
561        apply_mutation_verdicts(&mut report, &document(&["m2"])).unwrap();
562
563        let [first, second] = report.functions.as_slice() else {
564            panic!("two groups");
565        };
566        assert_eq!(first.counts.no_coverage, 1);
567        assert_eq!(first.counts.equivalent, 0);
568        assert_eq!(second.counts.no_coverage, 0);
569        assert_eq!(second.counts.equivalent, 1);
570    }
571
572    /// A `--recheck` merge counts a carried mutant under the first group of
573    /// its key, also when the mutant sits past the end of that group.
574    #[test]
575    fn a_verdict_moves_a_mutant_that_only_the_first_group_of_its_key_counts() {
576        let mut report = two_callbacks_on_one_line(
577            mutant("m1", MutantStatus::NoCoverage),
578            mutant("m2", MutantStatus::NoCoverage),
579            3,
580        );
581        report.functions[0].counts.add(MutantStatus::NoCoverage);
582        report.functions[1].counts.remove(MutantStatus::NoCoverage);
583
584        apply_mutation_verdicts(&mut report, &document(&["m2"])).unwrap();
585
586        let [first, second] = report.functions.as_slice() else {
587            panic!("two groups");
588        };
589        assert_eq!(first.counts.no_coverage, 1);
590        assert_eq!(first.counts.equivalent, 1);
591        assert_eq!(second.counts.no_coverage, 0);
592        assert_eq!(second.counts.equivalent, 0);
593    }
594
595    #[test]
596    fn a_kill_contradicts_a_verdict_and_unknown_keys_stay_unmatched() {
597        let mut report = report(vec![
598            mutant("m1", MutantStatus::Killed),
599            mutant("m2", MutantStatus::Pending),
600            mutant("m3", MutantStatus::Survived),
601        ]);
602
603        apply_mutation_verdicts(&mut report, &document(&["gone", "m1", "m2"])).unwrap();
604
605        assert_eq!(report.mutants[0].status, MutantStatus::Killed);
606        assert_eq!(report.mutants[1].status, MutantStatus::Pending);
607        assert_eq!(report.mutants[2].status, MutantStatus::Survived);
608        assert_eq!(report.summary.score, Some(0.5));
609        let join = report.verdicts.unwrap();
610        assert!(join.applied.is_empty());
611        assert_eq!(join.contradicted, vec!["m1".to_owned()]);
612        assert_eq!(join.deferred, vec!["m2".to_owned()]);
613        assert_eq!(join.unmatched, vec!["gone".to_owned()]);
614    }
615
616    #[test]
617    fn malformed_and_duplicate_verdicts_fail_closed() {
618        let cases: [(&[u8], &str); 4] = [
619            (b"{", "invalid mutation verdict document"),
620            (
621                br#"{"schema_version":"1","verdicts":[{"review_key":"m1","verdict":"survived"}]}"#,
622                "invalid mutation verdict document",
623            ),
624            (
625                br#"{"schema_version":"1","verdicts":[{"review_key":" ","verdict":"equivalent"}]}"#,
626                "empty review_key",
627            ),
628            (&document(&["m1", "m1"]), "more than one time"),
629        ];
630        for (json, needle) in cases {
631            let checked = validate_mutation_verdicts(json).unwrap_err();
632            assert_eq!(checked.exit_code, 2);
633            assert!(checked.message.contains(needle), "{}", checked.message);
634            let mut report = report(vec![mutant("m1", MutantStatus::Survived)]);
635            let error = apply_mutation_verdicts(&mut report, json).unwrap_err();
636            assert_eq!(
637                error.code.as_deref(),
638                Some("FALLOW_MUTATION_VERDICTS_INVALID")
639            );
640            assert_eq!(error.exit_code, 2);
641            assert!(error.message.contains(needle), "{}", error.message);
642            assert_eq!(report.mutants[0].status, MutantStatus::Survived);
643            assert!(report.verdicts.is_none());
644        }
645        assert!(validate_mutation_verdicts(&document(&["m1", "m2"])).is_ok());
646    }
647}