Skip to content

Commit dcd52ec

Browse files
Add PROC_MACRO_TEST_TOOLCHAIN environment variable
This allows overriding the toolchain used to run `proc-macro-srv` tests.
1 parent 7dc36ee commit dcd52ec

File tree

1 file changed

+16
-1
lines changed

1 file changed

+16
-1
lines changed

crates/proc-macro-test/build.rs

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,10 @@
22
//! `OUT_DIR`.
33
//!
44
//! `proc-macro-test` itself contains only a path to that artifact.
5+
//!
6+
//! The `PROC_MACRO_TEST_TOOLCHAIN` environment variable can be exported to use
7+
//! a specific rustup toolchain: this allows testing against older ABIs (e.g.
8+
//! 1.58) and future ABIs (stage1, nightly)
59
610
use std::{
711
env, fs,
@@ -13,6 +17,7 @@ use cargo_metadata::Message;
1317

1418
fn main() {
1519
println!("cargo:rerun-if-changed=imp");
20+
println!("cargo:rerun-if-env-changed=PROC_MACRO_TEST_TOOLCHAIN");
1621

1722
let out_dir = env::var_os("OUT_DIR").unwrap();
1823
let out_dir = Path::new(&out_dir);
@@ -47,7 +52,17 @@ fn main() {
4752
}
4853

4954
let target_dir = out_dir.join("target");
50-
let output = Command::new(toolchain::cargo())
55+
56+
let mut cmd = if let Ok(toolchain) = std::env::var("PROC_MACRO_TEST_TOOLCHAIN") {
57+
// leverage rustup to find user-specific toolchain
58+
let mut cmd = Command::new("cargo");
59+
cmd.arg(format!("+{toolchain}"));
60+
cmd
61+
} else {
62+
Command::new(toolchain::cargo())
63+
};
64+
65+
let output = cmd
5166
.current_dir(&staging_dir)
5267
.args(&["build", "-p", "proc-macro-test-impl", "--message-format", "json"])
5368
// Explicit override the target directory to avoid using the same one which the parent

0 commit comments

Comments
 (0)