Skip to content

Commit 2462bd1

Browse files
committed
compiletest: Add warning and comment about running tests without RUSTC
1 parent c86e523 commit 2462bd1

File tree

1 file changed

+16
-1
lines changed
  • src/tools/compiletest/src/header

1 file changed

+16
-1
lines changed

src/tools/compiletest/src/header/tests.rs

+16-1
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,22 @@ fn config() -> Config {
5858
];
5959
let mut args: Vec<String> = args.iter().map(ToString::to_string).collect();
6060
args.push("--rustc-path".to_string());
61-
args.push(std::env::var("RUSTC").unwrap_or_else(|_| "rustc".to_string()));
61+
// This is a subtle/fragile thing. On rust-lang CI, there is no global
62+
// `rustc`, and Cargo doesn't offer a convenient way to get the path to
63+
// `rustc`. Fortunately bootstrap sets `RUSTC` for us, which is pointing
64+
// to the stage0 compiler.
65+
//
66+
// Otherwise, if you are running compiletests's tests manually, you
67+
// probably don't have `RUSTC` set, in which case this falls back to the
68+
// global rustc. If your global rustc is too far out of sync with stage0,
69+
// then this may cause confusing errors. Or if for some reason you don't
70+
// have rustc in PATH, that would also fail.
71+
args.push(std::env::var("RUSTC").unwrap_or_else(|_| {
72+
eprintln!(
73+
"warning: RUSTC not set, using global rustc (are you not running via bootstrap?)"
74+
);
75+
"rustc".to_string()
76+
}));
6277
crate::parse_config(args)
6378
}
6479

0 commit comments

Comments
 (0)