Skip to content

Commit c3edeff

Browse files
committed
test: -Zbuild-std proc_macro test case without --target requirement
Add a new test case for building a crate with -Zbuild-std, without the requirement for the --target flag.
1 parent 52d03c7 commit c3edeff

File tree

1 file changed

+59
-0
lines changed

1 file changed

+59
-0
lines changed

tests/build-std/main.rs

+59
Original file line numberDiff line numberDiff line change
@@ -131,6 +131,65 @@ fn basic() {
131131
assert_eq!(p.glob(deps_dir.join("*.dylib")).count(), 0);
132132
}
133133

134+
#[cargo_test(build_std_real)]
135+
fn target_proc_macro() {
136+
let p = project()
137+
.file(
138+
"Cargo.toml",
139+
r#"
140+
[package]
141+
name = "foo"
142+
version = "0.1.0"
143+
edition = "2021"
144+
145+
[dependencies]
146+
macro_test = { path = "macro_test" }
147+
"#,
148+
)
149+
.file(
150+
"src/main.rs",
151+
r#"
152+
extern crate macro_test;
153+
use macro_test::make_answer;
154+
155+
make_answer!();
156+
157+
fn main() {
158+
println!("Hello, World: {}", answer());
159+
}
160+
"#,
161+
)
162+
.file(
163+
"macro_test/Cargo.toml",
164+
r#"
165+
[package]
166+
name = "macro_test"
167+
version = "0.1.0"
168+
edition = "2021"
169+
170+
[lib]
171+
proc-macro = true
172+
"#,
173+
)
174+
.file(
175+
"macro_test/src/lib.rs",
176+
r#"
177+
extern crate proc_macro;
178+
use proc_macro::TokenStream;
179+
180+
#[proc_macro]
181+
pub fn make_answer(_item: TokenStream) -> TokenStream {
182+
"fn answer() -> u32 { 42 }".parse().unwrap()
183+
}
184+
"#,
185+
)
186+
.build();
187+
188+
p.cargo("build -v")
189+
.build_std_arg("core")
190+
.run();
191+
}
192+
134193
#[cargo_test(build_std_real)]
135194
fn cross_custom() {
136195
let p = project()

0 commit comments

Comments
 (0)