Skip to content

Commit c989901

Browse files
authored
fix: Add tests for accepting #[cfg(..)] (#143)
This adds some tests verifying that we accept `#[cfg(..)]` together with the `#[test]` macro. Fixes #141
2 parents ebfd9aa + e1bd15a commit c989901

File tree

2 files changed

+11
-0
lines changed

2 files changed

+11
-0
lines changed

crates/libtest2-mimic/tests/testsuite/mixed_bag.rs

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,11 +39,16 @@ fn main() {
3939
state.ignore()?;
4040
Err(RunError::fail("got lost blindly following the flock"))
4141
}),
42+
#[cfg(all())]
4243
Trial::test("horse", |state| {
4344
state.ignore_for("slow")?;
4445
Ok(())
4546
}),
4647
Trial::test("custom_error", |_| Err(RunError::from(std::io::Error::new(std::io::ErrorKind::Other, "I failed")))),
48+
#[cfg(any())]
49+
Trial::test("unicorn", |state| {
50+
panic!("I don't exist");
51+
}),
4752
])
4853
.main();
4954
}

crates/libtest2/tests/testsuite/mixed_bag.rs

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -60,6 +60,7 @@ fn sheep(context: &libtest2::TestContext) -> libtest2::RunResult {
6060
}
6161
6262
#[libtest2::test]
63+
#[cfg(all())]
6364
#[ignore = "slow"]
6465
fn horse(context: &libtest2::TestContext) {
6566
}
@@ -69,6 +70,11 @@ fn custom_error(context: &libtest2::TestContext) -> std::io::Result<()> {
6970
Err(std::io::Error::new(std::io::ErrorKind::Other, "I failed"))
7071
}
7172
73+
#[libtest2::test]
74+
#[cfg(any())]
75+
fn unicorn(context: &libtest2::TestContext) {
76+
panic!("I don't exist");
77+
}
7278
"#,
7379
false,
7480
);

0 commit comments

Comments
 (0)