From 3c75940ef70e20d11088028370ec9e35386f4e80 Mon Sep 17 00:00:00 2001 From: Oli Scherer Date: Thu, 25 Apr 2024 08:55:39 +0000 Subject: [PATCH] Test RUSTC_FORCE_RUSTC_VERSION --- tests/ui/feature-gates/version_check.rs | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) create mode 100644 tests/ui/feature-gates/version_check.rs diff --git a/tests/ui/feature-gates/version_check.rs b/tests/ui/feature-gates/version_check.rs new file mode 100644 index 0000000000000..baa57221c4c21 --- /dev/null +++ b/tests/ui/feature-gates/version_check.rs @@ -0,0 +1,23 @@ +//@ run-pass +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_FORCE_RUSTC_VERSION", signalled_version) + .arg("--version") + .output() + .unwrap() + .stdout; + let version = String::from_utf8(version).unwrap(); + assert_ne!(version, signalled_version); + let version = Command::new(std::env::var_os("RUSTC").unwrap()) + .env("RUSTC_FORCE_RUSTC_VERSION", signalled_version) + .arg("--version") + .arg("--verbose") + .output() + .unwrap() + .stdout; + let version = String::from_utf8(version).unwrap(); + assert_ne!(version, signalled_version); +}