Skip to content

Commit bb9458e

Browse files
committed
test(test2): Add test checking the test-name itself
1 parent d947398 commit bb9458e

2 files changed

Lines changed: 35 additions & 0 deletions

File tree

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
fn test_cmd() -> snapbox::cmd::Command {
2+
static BIN: once_cell_polyfill::sync::OnceLock<(std::path::PathBuf, std::path::PathBuf)> =
3+
once_cell_polyfill::sync::OnceLock::new();
4+
5+
let (bin, current_dir) = BIN.get_or_init(|| {
6+
let package_root = crate::util::new_test(
7+
r#"
8+
#[libtest2::main]
9+
fn main() {}
10+
11+
#[libtest2::test]
12+
fn checks_the_name_of_itself(context: &libtest2::TestContext) {
13+
assert_eq!(context.test_name(), "checks_the_name_of_itself");
14+
}
15+
16+
mod some_module {
17+
#[libtest2::test]
18+
fn checks_the_name_of_itself(context: &libtest2::TestContext) {
19+
assert_eq!(context.test_name(), "some_module::checks_the_name_of_itself");
20+
}
21+
}
22+
"#,
23+
false,
24+
);
25+
let bin = crate::util::compile_test(&package_root);
26+
(bin, package_root)
27+
});
28+
snapbox::cmd::Command::new(bin).current_dir(current_dir)
29+
}
30+
31+
#[test]
32+
fn all_pass() {
33+
test_cmd().assert().code(0);
34+
}

crates/libtest2/tests/testsuite/main.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
mod all_passing;
22
mod argfile;
3+
mod macros;
34
mod mixed_bag;
45
mod panic;
56
mod should_panic;

0 commit comments

Comments
 (0)