Skip to content

Commit

Permalink
compiletest: Add warning and comment about running tests without RUSTC
Browse files Browse the repository at this point in the history
  • Loading branch information
ehuss committed Aug 9, 2022
1 parent c86e523 commit 2462bd1
Showing 1 changed file with 16 additions and 1 deletion.
17 changes: 16 additions & 1 deletion src/tools/compiletest/src/header/tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,22 @@ fn config() -> Config {
];
let mut args: Vec<String> = args.iter().map(ToString::to_string).collect();
args.push("--rustc-path".to_string());
args.push(std::env::var("RUSTC").unwrap_or_else(|_| "rustc".to_string()));
// This is a subtle/fragile thing. On rust-lang CI, there is no global
// `rustc`, and Cargo doesn't offer a convenient way to get the path to
// `rustc`. Fortunately bootstrap sets `RUSTC` for us, which is pointing
// to the stage0 compiler.
//
// Otherwise, if you are running compiletests's tests manually, you
// probably don't have `RUSTC` set, in which case this falls back to the
// global rustc. If your global rustc is too far out of sync with stage0,
// then this may cause confusing errors. Or if for some reason you don't
// have rustc in PATH, that would also fail.
args.push(std::env::var("RUSTC").unwrap_or_else(|_| {
eprintln!(
"warning: RUSTC not set, using global rustc (are you not running via bootstrap?)"
);
"rustc".to_string()
}));
crate::parse_config(args)
}

Expand Down

0 comments on commit 2462bd1

Please sign in to comment.