Skip to content

Commit 2d45cdb

Browse files
committed
Test RUSTC_FORCE_RUSTC_VERSION
1 parent e936289 commit 2d45cdb

File tree

2 files changed

+15
-0
lines changed

2 files changed

+15
-0
lines changed

src/tools/compiletest/src/header.rs

+1
Original file line numberDiff line numberDiff line change
@@ -321,6 +321,7 @@ impl TestProps {
321321
pub fn from_file(testfile: &Path, revision: Option<&str>, config: &Config) -> Self {
322322
let mut props = TestProps::new();
323323
props.load_from(testfile, revision, config);
324+
props.exec_env.push(("RUSTC".to_string(), config.rustc_path.display().to_string()));
324325

325326
match (props.pass_mode, props.fail_mode) {
326327
(None, None) if config.mode == Mode::Ui => props.fail_mode = Some(FailMode::Check),
+14
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
//@ run-pass
2+
use std::process::Command;
3+
4+
fn main() {
5+
let signalled_version = "Ceci n'est pas une rustc";
6+
let version = Command::new(std::env::var_os("RUSTC").unwrap())
7+
.env("RUSTC_FORCE_RUSTC_VERSION", signalled_version)
8+
.arg("--version")
9+
.output()
10+
.unwrap()
11+
.stdout;
12+
let version = std::str::from_utf8(&version).unwrap().strip_prefix("rustc ").unwrap().trim_end();
13+
assert_ne!(version, signalled_version);
14+
}

0 commit comments

Comments
 (0)