Skip to content

Commit 890aded

Browse files
Copilotsourcefrog
andcommitted
Add test to verify non-test attributes are not skipped
Co-authored-by: sourcefrog <346355+sourcefrog@users.noreply.github.com>
1 parent c91ca01 commit 890aded

File tree

1 file changed

+30
-0
lines changed

1 file changed

+30
-0
lines changed

src/visit.rs

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1143,6 +1143,36 @@ mod test {
11431143
assert_eq!(mutants, []);
11441144
}
11451145

1146+
#[test]
1147+
fn do_not_skip_functions_with_non_test_attributes() {
1148+
let mutants = mutate_source_str(
1149+
indoc! {"
1150+
#[derive(Debug)]
1151+
pub fn testing_something() -> i32 {
1152+
42
1153+
}
1154+
1155+
#[some_crate::test]
1156+
fn some_test() {
1157+
println!(\"test\");
1158+
}
1159+
1160+
#[some_attr]
1161+
pub fn regular_function() -> i32 {
1162+
100
1163+
}
1164+
"},
1165+
&Options::default(),
1166+
)
1167+
.unwrap();
1168+
// Should have mutants for testing_something and regular_function, but not for some_test
1169+
let mutant_names = mutants.iter().map(|m| m.name(false)).collect_vec();
1170+
assert_eq!(mutant_names.len(), 6); // 3 mutants each for the two non-test functions
1171+
assert!(mutant_names.iter().any(|n| n.contains("testing_something")));
1172+
assert!(mutant_names.iter().any(|n| n.contains("regular_function")));
1173+
assert!(!mutant_names.iter().any(|n| n.contains("some_test")));
1174+
}
1175+
11461176
/// Skip mutating arguments to a particular named function.
11471177
#[test]
11481178
fn skip_named_fn() {

0 commit comments

Comments
 (0)