File tree 4 files changed +14
-30
lines changed
4 files changed +14
-30
lines changed Original file line number Diff line number Diff line change 1
1
//! `bless` updates the reference files in the repo with changed output files
2
2
//! from the last test run.
3
3
4
- use std:: env;
5
4
use std:: ffi:: OsStr ;
6
5
use std:: fs;
7
6
use std:: lazy:: SyncLazy ;
@@ -10,17 +9,9 @@ use walkdir::WalkDir;
10
9
11
10
use crate :: clippy_project_root;
12
11
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
-
19
12
static 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" ) ;
24
15
fs:: metadata ( path) . ok ( ) ?. modified ( ) . ok ( )
25
16
} ) ;
26
17
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
7
7
None => env:: current_dir ( ) . unwrap ( ) . join ( "target" ) ,
8
8
} ) ;
9
9
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
-
23
10
#[ must_use]
24
11
pub fn is_rustc_test_suite ( ) -> bool {
25
12
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 {
50
50
option_env ! ( "HOST_LIBS" ) . map_or ( cargo:: CARGO_TARGET_DIR . join ( env ! ( "PROFILE" ) ) , PathBuf :: from)
51
51
}
52
52
53
- fn clippy_driver_path ( ) -> PathBuf {
54
- option_env ! ( "CLIPPY_DRIVER_PATH" ) . map_or ( cargo:: TARGET_LIB . join ( "clippy-driver" ) , PathBuf :: from)
55
- }
56
-
57
53
/// Produces a string with an `--extern` flag for all UI test crate
58
54
/// dependencies.
59
55
///
@@ -122,6 +118,7 @@ fn default_config() -> compiletest::Config {
122
118
}
123
119
let current_exe_path = std:: env:: current_exe ( ) . unwrap ( ) ;
124
120
let deps_path = current_exe_path. parent ( ) . unwrap ( ) ;
121
+ let profile_path = deps_path. parent ( ) . unwrap ( ) ;
125
122
126
123
// Using `-L dependency={}` enforces that external dependencies are added with `--extern`.
127
124
// This is valuable because a) it allows us to monitor what external dependencies are used
@@ -137,7 +134,11 @@ fn default_config() -> compiletest::Config {
137
134
) ) ;
138
135
139
136
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
+ } ) ;
141
142
config
142
143
}
143
144
Original file line number Diff line number Diff line change @@ -15,7 +15,12 @@ use std::process::Command;
15
15
16
16
mod cargo;
17
17
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
+ } ) ;
19
24
20
25
#[ test]
21
26
fn dogfood_clippy ( ) {
You can’t perform that action at this time.
0 commit comments