Open mersinvald opened 4 years ago
@mersinvald pls correct me if I wrong.
An example of how the expansion of this procedural macro will probably look like:
Suppose we have 3 test cases in tests/expand/
directory: a.rs
, b.rs
, and c.rs
.
In our tests/expand.rs
we have the following code:
#[macrotest:tests("tests/expand/*.rs");
mod expansion_tests;
This should probably expand to something like this:
mod macro_tests {
#[test]
pub fn test_expand_a() {
macrotest::expand("tests/expand/a.rs");
}
#[test]
pub fn test_expand_b() {
macrotest::expand("tests/expand/b.rs");
}
#[test]
pub fn test_expand_c() {
macrotest::expand("tests/expand/c.rs");
}
}
NB: the #[macrotest:tests("glob-pattern")]
must ignore the *.expanded.rs
files in the directory specified. Otherwise, the macro will generate test cases for expanded code.
@eupn sorry I missed your response. Yes, that’s exactly the expansion I have had in mind.
It would be awesome to have a macro for generating separate test cases for each generated sample in the
expanded/
directory.Motivation for that is having more granular test results, which would show a test failure for a specific macro or specific macro invocation.
The ideal API, IMHO, would be something like