Hi there,
I'm trying to generate required top level macro invocations like those:
#![cfg_attr(test, no_main)]
#![feature(custom_test_frameworks)]
#![reexport_test_harness_main = "test_main"]
#![test_runner(test_runner)]
But this simple proc macro does not seem to make the trick:
#[proc_macro_attribute]
pub fn ruspiro_test_framework(_attr: TokenStream, _item: TokenStream) -> TokenStream {
quote!(
#![cfg_attr(test, no_main)]
#![feature(custom_test_frameworks)]
#![reexport_test_harness_main = "test_main"]
#![test_runner(test_runner)]
)
.into()
}
This leads to the issue:
error: an inner attribute is not permitted in this context
--> src\lib.rs:13:19
|
13 | #![cfg_attr(test, ruspiro_test_macros::ruspiro_test_framework)]
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
= note: inner attributes, like `#![no_std]`, annotate the item enclosing them, and are usually found at the beginning of source files. Outer attributes, like `#[test]`, annotate the item following them.
= note: this error originates in an attribute macro (in Nightly builds, run with -Z macro-backtrace for more info)
Is this not possible, or do I need a special implementation within my proc_macro to make this possible?
Thanks in advance for any hints.