Macro compile

Source
macro_rules! compile {
    ($($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.
macro_rules! assert_snapshot {
    ($expr:expr) => {};
}

let output = postcompile::compile! {
    const TEST: u32 = 1;
};

assert_eq!(output.status, postcompile::ExitStatus::Success);
assert!(output.stderr.is_empty());
assert_snapshot!(output.stdout); // We dont have an assert_snapshot! macro in this crate, but you get the idea.