diff options
| author | Oli Scherer <git-spam-no-reply9815368754983@oli-obk.de> | 2024-04-25 08:55:39 +0000 |
|---|---|---|
| committer | Oli Scherer <git-spam-no-reply9815368754983@oli-obk.de> | 2024-07-30 14:08:02 +0000 |
| commit | cbab16feafcd828c813a1c4926eade67f464cff9 (patch) | |
| tree | 00352bdd56f87d339c62df1157e35b30ec0699bd | |
| parent | a5ee5cbad1dde83dde61959e9436716094e3408c (diff) | |
| download | rust-cbab16feafcd828c813a1c4926eade67f464cff9.tar.gz rust-cbab16feafcd828c813a1c4926eade67f464cff9.zip | |
Test RUSTC_OVERRIDE_VERSION_STRING
| -rw-r--r-- | src/tools/compiletest/src/header.rs | 1 | ||||
| -rw-r--r-- | tests/ui/feature-gates/version_check.rs | 17 |
2 files changed, 18 insertions, 0 deletions
diff --git a/src/tools/compiletest/src/header.rs b/src/tools/compiletest/src/header.rs index 0208ed34ac1..cde3e3295c6 100644 --- a/src/tools/compiletest/src/header.rs +++ b/src/tools/compiletest/src/header.rs @@ -330,6 +330,7 @@ impl TestProps { pub fn from_file(testfile: &Path, revision: Option<&str>, config: &Config) -> Self { let mut props = TestProps::new(); props.load_from(testfile, revision, config); + props.exec_env.push(("RUSTC".to_string(), config.rustc_path.display().to_string())); match (props.pass_mode, props.fail_mode) { (None, None) if config.mode == Mode::Ui => props.fail_mode = Some(FailMode::Check), diff --git a/tests/ui/feature-gates/version_check.rs b/tests/ui/feature-gates/version_check.rs new file mode 100644 index 00000000000..093fda3fbe5 --- /dev/null +++ b/tests/ui/feature-gates/version_check.rs @@ -0,0 +1,17 @@ +//@ run-pass +//@ only-linux +//@ only-x86 +// FIXME: this should be more like //@ needs-subprocesses +use std::process::Command; + +fn main() { + let signalled_version = "Ceci n'est pas une rustc"; + let version = Command::new(std::env::var_os("RUSTC").unwrap()) + .env("RUSTC_OVERRIDE_VERSION_STRING", signalled_version) + .arg("--version") + .output() + .unwrap() + .stdout; + let version = std::str::from_utf8(&version).unwrap().strip_prefix("rustc ").unwrap().trim_end(); + assert_ne!(version, signalled_version); +} |
