Skip to content

Commit 10c2547

Browse files
committed
Test RUSTC_OVERRIDE_VERSION_STRING
1 parent a5ee5cb commit 10c2547

File tree

2 files changed

+19
-0
lines changed

2 files changed

+19
-0
lines changed

src/tools/compiletest/src/header.rs

+1
Original file line numberDiff line numberDiff line change
@@ -330,6 +330,7 @@ impl TestProps {
330330
pub fn from_file(testfile: &Path, revision: Option<&str>, config: &Config) -> Self {
331331
let mut props = TestProps::new();
332332
props.load_from(testfile, revision, config);
333+
props.exec_env.push(("RUSTC".to_string(), config.rustc_path.display().to_string()));
333334

334335
match (props.pass_mode, props.fail_mode) {
335336
(None, None) if config.mode == Mode::Ui => props.fail_mode = Some(FailMode::Check),
+18
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
//@ run-pass
2+
//@ ignore-wasm
3+
//@ ignore-emscripten
4+
//@ ignore-sgx
5+
// FIXME: this should be more like //@ needs-subprocesses
6+
use std::process::Command;
7+
8+
fn main() {
9+
let signalled_version = "Ceci n'est pas une rustc";
10+
let version = Command::new(std::env::var_os("RUSTC").unwrap())
11+
.env("RUSTC_OVERRIDE_VERSION_STRING", signalled_version)
12+
.arg("--version")
13+
.output()
14+
.unwrap()
15+
.stdout;
16+
let version = std::str::from_utf8(&version).unwrap().strip_prefix("rustc ").unwrap().trim_end();
17+
assert_ne!(version, signalled_version);
18+
}

0 commit comments

Comments
 (0)