Skip to content

Commit 674b5ca

Browse files
authored
Add cargo_mutants_version field to outcomes.json (#562)
1 parent 3d00bf9 commit 674b5ca

File tree

5 files changed

+15
-1
lines changed

5 files changed

+15
-1
lines changed

NEWS.md

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

1111
- New: `start_time` and `end_time` fields in `outcomes.json`.
1212

13+
- New: `cargo_mutants_version` field in `outcomes.json`.
14+
1315
- Changed: Functions with attributes whose path ends with `test` are now skipped, not just those with the plain `#[test]` attribute. This means functions with `#[tokio::test]`, `#[sqlx::test]`, and similar testing framework attributes are automatically excluded from mutation testing.
1416

1517
- Changed: The bitwise assignment operators `&=` and `|=` are no longer mutated to `^=`. In code that accumulates bits into a bitmap starting from zero (e.g., `bitmap |= new_bits`), `|=` and `^=` produce the same result, making such mutations uninformative.

book/src/mutants-out.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ The output directory contains:
1818
This file is completely written before testing begins.
1919

2020
* An `outcomes.json` file describing the results of all tests,
21-
and summary counts of each outcome.
21+
summary counts of each outcome, and the cargo-mutants version.
2222

2323
* A `diff/` directory, containing a diff file for each mutation, relative to the unmutated baseline.
2424
`mutants.json` includes for each mutant the name of the diff file.

src/outcome.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -67,6 +67,7 @@ pub struct LabOutcome {
6767
pub success: usize,
6868
pub start_time: Timestamp,
6969
pub end_time: Option<Timestamp>,
70+
pub cargo_mutants_version: String,
7071
}
7172

7273
impl LabOutcome {
@@ -81,6 +82,7 @@ impl LabOutcome {
8182
success: 0,
8283
start_time,
8384
end_time: None,
85+
cargo_mutants_version: crate::VERSION.to_string(),
8486
}
8587
}
8688

tests/main.rs

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -241,6 +241,15 @@ fn small_well_tested_tree_is_clean() {
241241
let end_time: Timestamp = end_time.as_str().unwrap().parse().unwrap();
242242
assert!(end_time >= start_time);
243243
assert!(end_time <= Timestamp::now());
244+
245+
// Verify cargo_mutants_version field exists
246+
let version = outcomes["cargo_mutants_version"]
247+
.as_str()
248+
.expect("cargo_mutants_version should be present and be a string");
249+
assert!(
250+
version.contains('.'),
251+
"cargo_mutants_version should look like a version"
252+
);
244253
}
245254

246255
#[test]

tests/util/mod.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -159,5 +159,6 @@ pub fn outcome_json_counts(tmp_src_dir: &TempDir) -> serde_json::Value {
159159
outcomes_object.remove("outcomes").unwrap();
160160
outcomes_object.remove("end_time").unwrap();
161161
outcomes_object.remove("start_time").unwrap();
162+
outcomes_object.remove("cargo_mutants_version").unwrap();
162163
outcomes
163164
}

0 commit comments

Comments
 (0)