]> git.lizzy.rs Git - rust.git/blobdiff - clippy_dev/src/bless.rs
Move `return_self_not_must_use` to `pedantic`
[rust.git] / clippy_dev / src / bless.rs
index 2a869e9d4491b6805a332495fd753b886a1c821e..daf0fcc993bad320ff894014596fa13328ba0307 100644 (file)
@@ -1,7 +1,6 @@
 //! `bless` updates the reference files in the repo with changed output files
 //! from the last test run.
 
-use std::env;
 use std::ffi::OsStr;
 use std::fs;
 use std::lazy::SyncLazy;
@@ -10,17 +9,9 @@
 
 use crate::clippy_project_root;
 
-// NOTE: this is duplicated with tests/cargo/mod.rs What to do?
-pub static CARGO_TARGET_DIR: SyncLazy<PathBuf> = SyncLazy::new(|| match env::var_os("CARGO_TARGET_DIR") {
-    Some(v) => v.into(),
-    None => env::current_dir().unwrap().join("target"),
-});
-
 static CLIPPY_BUILD_TIME: SyncLazy<Option<std::time::SystemTime>> = SyncLazy::new(|| {
-    let profile = env::var("PROFILE").unwrap_or_else(|_| "debug".to_string());
-    let mut path = PathBuf::from(&**CARGO_TARGET_DIR);
-    path.push(profile);
-    path.push("cargo-clippy");
+    let mut path = std::env::current_exe().unwrap();
+    path.set_file_name("cargo-clippy");
     fs::metadata(path).ok()?.modified().ok()
 });
 
@@ -42,9 +33,10 @@ pub fn bless(ignore_timestamp: bool) {
             .for_each(|f| {
                 let test_name = f.path().strip_prefix(test_suite_dir).unwrap();
                 for &ext in &["stdout", "stderr", "fixed"] {
+                    let test_name_ext = format!("stage-id.{}", ext);
                     update_reference_file(
                         f.path().with_extension(ext),
-                        test_name.with_extension(ext),
+                        test_name.with_extension(test_name_ext),
                         ignore_timestamp,
                     );
                 }
@@ -93,10 +85,7 @@ fn updated_since_clippy_build(path: &Path) -> Option<bool> {
 }
 
 fn build_dir() -> PathBuf {
-    let profile = env::var("PROFILE").unwrap_or_else(|_| "debug".to_string());
-    let mut path = PathBuf::new();
-    path.push(CARGO_TARGET_DIR.clone());
-    path.push(profile);
-    path.push("test_build_base");
+    let mut path = std::env::current_exe().unwrap();
+    path.set_file_name("test");
     path
 }