Skip to content

Commit 7e67b44

Browse files
committed
Warn if no mutants are viable
1 parent 58b75b4 commit 7e67b44

File tree

3 files changed

+20
-9
lines changed

3 files changed

+20
-9
lines changed

NEWS.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,8 @@
1717

1818
- Changed: Renamed fields in `outcomes.json` from `cargo_result` to `process_status` and from `command` to `argv`.
1919

20+
- Warn if no mutants were generated or if all mutants were unviable.
21+
2022
## 1.2.1
2123

2224
Released 2023-01-05

src/lab.rs

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ use std::thread;
88
use std::time::{Duration, Instant};
99

1010
use anyhow::{anyhow, Context, Result};
11+
use tracing::warn;
1112
#[allow(unused)]
1213
use tracing::{debug, debug_span, error, info, trace};
1314

@@ -144,7 +145,15 @@ pub fn test_unmutated_then_all_mutants(
144145
.into_inner()
145146
.expect("final unlock mutants queue");
146147
console.lab_finished(&output_dir.lab_outcome, start_time, &options);
147-
Ok(output_dir.take_lab_outcome())
148+
let lab_outcome = output_dir.take_lab_outcome();
149+
if lab_outcome.total_mutants == 0 {
150+
// This should be unreachable as we also bail out before copying
151+
// the tree if no mutants are generated.
152+
warn!("No mutants were generated");
153+
} else if lab_outcome.unviable == lab_outcome.total_mutants {
154+
warn!("No mutants were viable; perhaps there is a problem with building in a scratch directory");
155+
}
156+
Ok(lab_outcome)
148157
}
149158

150159
/// Test various phases of one scenario in a build dir.

src/outcome.rs

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -56,14 +56,14 @@ impl fmt::Display for Phase {
5656
#[derive(Debug, Default, Serialize)]
5757
pub struct LabOutcome {
5858
/// All the scenario outcomes, including baseline builds.
59-
outcomes: Vec<ScenarioOutcome>,
60-
total_mutants: usize,
61-
missed: usize,
62-
caught: usize,
63-
timeout: usize,
64-
unviable: usize,
65-
success: usize,
66-
failure: usize,
59+
pub outcomes: Vec<ScenarioOutcome>,
60+
pub total_mutants: usize,
61+
pub missed: usize,
62+
pub caught: usize,
63+
pub timeout: usize,
64+
pub unviable: usize,
65+
pub success: usize,
66+
pub failure: usize,
6767
}
6868

6969
impl LabOutcome {

0 commit comments

Comments
 (0)