Skip to content

Commit cbab16f

Browse files
committed
Test RUSTC_OVERRIDE_VERSION_STRING
1 parent a5ee5cb commit cbab16f

File tree

2 files changed

+18
-0
lines changed

2 files changed

+18
-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),
+17
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
//@ run-pass
2+
//@ only-linux
3+
//@ only-x86
4+
// FIXME: this should be more like //@ needs-subprocesses
5+
use std::process::Command;
6+
7+
fn main() {
8+
let signalled_version = "Ceci n'est pas une rustc";
9+
let version = Command::new(std::env::var_os("RUSTC").unwrap())
10+
.env("RUSTC_OVERRIDE_VERSION_STRING", signalled_version)
11+
.arg("--version")
12+
.output()
13+
.unwrap()
14+
.stdout;
15+
let version = std::str::from_utf8(&version).unwrap().strip_prefix("rustc ").unwrap().trim_end();
16+
assert_ne!(version, signalled_version);
17+
}

0 commit comments

Comments
 (0)