File tree Expand file tree Collapse file tree 4 files changed +14
-30
lines changed Expand file tree Collapse file tree 4 files changed +14
-30
lines changed Original file line number Diff line number Diff line change 11//! `bless` updates the reference files in the repo with changed output files
22//! from the last test run.
33
4- use std:: env;
54use std:: ffi:: OsStr ;
65use std:: fs;
76use std:: lazy:: SyncLazy ;
@@ -10,17 +9,9 @@ use walkdir::WalkDir;
109
1110use crate :: clippy_project_root;
1211
13- // NOTE: this is duplicated with tests/cargo/mod.rs What to do?
14- pub static CARGO_TARGET_DIR : SyncLazy < PathBuf > = SyncLazy :: new ( || match env:: var_os ( "CARGO_TARGET_DIR" ) {
15- Some ( v) => v. into ( ) ,
16- None => env:: current_dir ( ) . unwrap ( ) . join ( "target" ) ,
17- } ) ;
18-
1912static CLIPPY_BUILD_TIME : SyncLazy < Option < std:: time:: SystemTime > > = SyncLazy :: new ( || {
20- let profile = env:: var ( "PROFILE" ) . unwrap_or_else ( |_| "debug" . to_string ( ) ) ;
21- let mut path = PathBuf :: from ( & * * CARGO_TARGET_DIR ) ;
22- path. push ( profile) ;
23- path. push ( "cargo-clippy" ) ;
13+ let mut path = std:: env:: current_exe ( ) . unwrap ( ) ;
14+ path. set_file_name ( "cargo-clippy" ) ;
2415 fs:: metadata ( path) . ok ( ) ?. modified ( ) . ok ( )
2516} ) ;
2617
Original file line number Diff line number Diff line change @@ -7,19 +7,6 @@ pub static CARGO_TARGET_DIR: SyncLazy<PathBuf> = SyncLazy::new(|| match env::var
77 None => env:: current_dir ( ) . unwrap ( ) . join ( "target" ) ,
88} ) ;
99
10- pub static TARGET_LIB : SyncLazy < PathBuf > = SyncLazy :: new ( || {
11- if let Some ( path) = option_env ! ( "TARGET_LIBS" ) {
12- path. into ( )
13- } else {
14- let mut dir = CARGO_TARGET_DIR . clone ( ) ;
15- if let Some ( target) = env:: var_os ( "CARGO_BUILD_TARGET" ) {
16- dir. push ( target) ;
17- }
18- dir. push ( env ! ( "PROFILE" ) ) ;
19- dir
20- }
21- } ) ;
22-
2310#[ must_use]
2411pub fn is_rustc_test_suite ( ) -> bool {
2512 option_env ! ( "RUSTC_TEST_SUITE" ) . is_some ( )
Original file line number Diff line number Diff line change @@ -50,10 +50,6 @@ fn host_lib() -> PathBuf {
5050 option_env ! ( "HOST_LIBS" ) . map_or ( cargo:: CARGO_TARGET_DIR . join ( env ! ( "PROFILE" ) ) , PathBuf :: from)
5151}
5252
53- fn clippy_driver_path ( ) -> PathBuf {
54- option_env ! ( "CLIPPY_DRIVER_PATH" ) . map_or ( cargo:: TARGET_LIB . join ( "clippy-driver" ) , PathBuf :: from)
55- }
56-
5753/// Produces a string with an `--extern` flag for all UI test crate
5854/// dependencies.
5955///
@@ -122,6 +118,7 @@ fn default_config() -> compiletest::Config {
122118 }
123119 let current_exe_path = std:: env:: current_exe ( ) . unwrap ( ) ;
124120 let deps_path = current_exe_path. parent ( ) . unwrap ( ) ;
121+ let profile_path = deps_path. parent ( ) . unwrap ( ) ;
125122
126123 // Using `-L dependency={}` enforces that external dependencies are added with `--extern`.
127124 // This is valuable because a) it allows us to monitor what external dependencies are used
@@ -137,7 +134,11 @@ fn default_config() -> compiletest::Config {
137134 ) ) ;
138135
139136 config. build_base = host_lib ( ) . join ( "test_build_base" ) ;
140- config. rustc_path = clippy_driver_path ( ) ;
137+ config. rustc_path = profile_path. join ( if cfg ! ( windows) {
138+ "clippy-driver.exe"
139+ } else {
140+ "clippy-driver"
141+ } ) ;
141142 config
142143}
143144
Original file line number Diff line number Diff line change @@ -15,7 +15,12 @@ use std::process::Command;
1515
1616mod cargo;
1717
18- static CLIPPY_PATH : SyncLazy < PathBuf > = SyncLazy :: new ( || cargo:: TARGET_LIB . join ( "cargo-clippy" ) ) ;
18+ static CLIPPY_PATH : SyncLazy < PathBuf > = SyncLazy :: new ( || {
19+ let mut path = std:: env:: current_exe ( ) . unwrap ( ) ;
20+ assert ! ( path. pop( ) ) ; // deps
21+ path. set_file_name ( "cargo-clippy" ) ;
22+ path
23+ } ) ;
1924
2025#[ test]
2126fn dogfood_clippy ( ) {
You can’t perform that action at this time.
0 commit comments