1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
//! Macro expansion snapshot tests.
//!
//! - `tests/expand/*.rs` — all must compile (unexpanded AND expanded)
//! - `tests/expand/should-fail/` — known bugs, may fail unexpanded and/or expanded
//!
//! Snapshot diffs (macrotest) only run on x86_64 — expansion is arch-dependent.
//! Compilation tests (trybuild) run on all platforms.
//!
//! To update snapshots (on x86_64):
//! `MACROTEST=overwrite cargo test -p archmage --test macro_expand`
//!
//! Requires `cargo-expand` (`cargo install cargo-expand`).
/// Expand all passing inputs and diff against `.expanded.rs` snapshots.
/// x86_64 only — expansion output is arch-dependent (cfg-gated code differs).
#[test]
#[cfg(target_arch = "x86_64")]
fn macro_expansion_snapshots() {
macrotest::expand("tests/expand/*.rs");
}
/// Snapshot tests for known-buggy expansions.
#[test]
#[cfg(target_arch = "x86_64")]
fn macro_expansion_snapshots_known_bugs() {
macrotest::expand("tests/expand/should-fail/*.rs");
}
/// Every unexpanded input in expand/ must compile with macros applied.
/// x86_64 only — test files use x86-specific tokens and intrinsics.
#[test]
#[cfg(target_arch = "x86_64")]
fn unexpanded_input_compiles() {
let t = trybuild::TestCases::new();
t.pass("tests/expand/*.rs");
}
/// Every expanded output in expand/ must compile as standalone Rust.
/// x86_64 only — snapshots contain x86_64-specific imports and types.
#[test]
#[cfg(target_arch = "x86_64")]
fn expanded_output_compiles() {
let t = trybuild::TestCases::new();
t.pass("tests/expand/*.expanded.rs");
}
/// Known bugs: expanded output that doesn't compile standalone.
/// When fixed, move from should-fail/ back to expand/.
#[test]
#[cfg(target_arch = "x86_64")]
fn expanded_output_known_bugs() {
let t = trybuild::TestCases::new();
t.compile_fail("tests/expand/should-fail/*.expanded.rs");
}