Skip to content

Commit edee76e

Browse files
committed
Update include_tests macro to allow attributes on individual tests
1 parent db1c65d commit edee76e

File tree

1 file changed

+10
-14
lines changed

1 file changed

+10
-14
lines changed

tests/lib.rs

Lines changed: 10 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -35,26 +35,22 @@ fn run_file(modname: &str) -> Result<()> {
3535
return Err(Error::runtime(msg));
3636
}
3737

38+
// Helper macro to generate Rust test functions for Lua test modules.
3839
macro_rules! include_tests {
39-
($($name:ident,)*) => {
40+
($( $(#[$meta:meta])? $name:ident $(,)? )*) => {
4041
$(
41-
#[test]
42-
fn $name() -> Result<()> {
43-
run_file(stringify!($name))
44-
}
42+
$(#[$meta])*
43+
#[test]
44+
fn $name() -> Result<()> {
45+
run_file(stringify!($name))
46+
}
4547
)*
4648
};
47-
48-
($name:ident) => { include_tests! { $name, } };
4949
}
5050

5151
include_tests! {
5252
assertions,
53+
#[cfg(feature = "json")] json,
54+
#[cfg(feature = "regex")] regex,
55+
#[cfg(feature = "yaml")] yaml,
5356
}
54-
55-
#[cfg(feature = "json")]
56-
include_tests!(json);
57-
#[cfg(feature = "regex")]
58-
include_tests!(regex);
59-
#[cfg(feature = "yaml")]
60-
include_tests!(yaml);

0 commit comments

Comments
 (0)