]> git.lizzy.rs Git - rust.git/blobdiff - tests/versioncheck.rs
tests: ignore check_that_clippy_has_the_same_major_version_as_rustc() inside the...
[rust.git] / tests / versioncheck.rs
index 589b19f68f7a05bb485b1a700e3a0c2ddc0c50dd..bc5ed0816cc812b139a5f7f299fbfdbb174b45fb 100644 (file)
@@ -23,15 +23,22 @@ fn check_that_clippy_lints_has_the_same_version_as_clippy() {
 
 #[test]
 fn check_that_clippy_has_the_same_major_version_as_rustc() {
+    // do not run this test inside the upstream rustc repo:
+    // https://github.com/rust-lang/rust-clippy/issues/6683
+    if option_env!("RUSTC_TEST_SUITE").is_some() {
+        return;
+    }
+
     let clippy_version = rustc_tools_util::get_version_info!();
     let clippy_major = clippy_version.major;
     let clippy_minor = clippy_version.minor;
     let clippy_patch = clippy_version.patch;
 
-    // get the rustc version
-    // this way the rust-toolchain file version is honored
+    // get the rustc version either from the rustc installed with the toolchain file or from
+    // `RUSTC_REAL` if Clippy is build in the Rust repo with `./x.py`.
+    let rustc = std::env::var("RUSTC_REAL").unwrap_or_else(|_| "rustc".to_string());
     let rustc_version = String::from_utf8(
-        std::process::Command::new("rustc")
+        std::process::Command::new(&rustc)
             .arg("--version")
             .output()
             .expect("failed to run `rustc --version`")