From 2462bd17a029e8333796bb7190bce4bdfc4da91b Mon Sep 17 00:00:00 2001 From: Eric Huss Date: Mon, 8 Aug 2022 22:51:16 -0700 Subject: [PATCH] compiletest: Add warning and comment about running tests without RUSTC --- src/tools/compiletest/src/header/tests.rs | 17 ++++++++++++++++- 1 file changed, 16 insertions(+), 1 deletion(-) diff --git a/src/tools/compiletest/src/header/tests.rs b/src/tools/compiletest/src/header/tests.rs index 6c0e8f2e46f7..bcd222b5a932 100644 --- a/src/tools/compiletest/src/header/tests.rs +++ b/src/tools/compiletest/src/header/tests.rs @@ -58,7 +58,22 @@ fn config() -> Config { ]; let mut args: Vec = 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) }