macro_rules! compile {
(
$config:expr,
{ $($tokens:tt)* }$(,)?
) => { ... };
(
{ $($tokens:tt)* }$(,)?
) => { ... };
}
Expand description
Compiles the given tokens and returns the output.
This macro will panic if we fail to invoke the compiler.
// Dummy macro to assert the snapshot.
let output = postcompile::compile!({
const TEST: u32 = 1;
});
assert_eq!(output.status, postcompile::ExitStatus::Success);
// We dont have an assert_snapshot! macro in this crate, but you get the idea.
assert_snapshot!(output);
You can provide a custom config using the config!
macro. If not provided the default config is used.
In this example we enable the test
flag which will run the tests inside the provided source code.
// Dummy macro to assert the snapshot.
let output = postcompile::compile!(
postcompile::config! {
test: true
},
{
const TEST: u32 = 1;
#[test]
fn test() {
assert_eq!(TEST, 1);
}
}
);
assert_eq!(output.status, postcompile::ExitStatus::Success);
// We dont have an assert_snapshot! macro in this crate, but you get the idea.
assert_snapshot!(output);