@@ -5,7 +5,6 @@ use itertools::Itertools;
55use walkdir:: WalkDir ;
66
77use std:: cell:: RefCell ;
8- use std:: env;
98use std:: fs;
109use std:: io:: { self , ErrorKind } ;
1110use std:: path:: { Path , PathBuf } ;
@@ -21,28 +20,13 @@ static CARGO_INTEGRATION_TEST_DIR: &str = "cit";
2120
2221static GLOBAL_ROOT : OnceLock < Mutex < Option < PathBuf > > > = OnceLock :: new ( ) ;
2322
24- /// This is used when running cargo is pre-CARGO_TARGET_TMPDIR
25- /// TODO: Remove when `CARGO_TARGET_TMPDIR` grows old enough.
26- fn global_root_legacy ( ) -> PathBuf {
27- let mut path = t ! ( env:: current_exe( ) ) ;
28- path. pop ( ) ; // chop off exe name
29- path. pop ( ) ; // chop off "deps"
30- path. push ( "tmp" ) ;
31- path. mkdir_p ( ) ;
32- path
33- }
34-
35- fn set_global_root ( tmp_dir : Option < & ' static str > ) {
23+ fn set_global_root ( tmp_dir : & ' static str ) {
3624 let mut lock = GLOBAL_ROOT
3725 . get_or_init ( || Default :: default ( ) )
3826 . lock ( )
3927 . unwrap ( ) ;
4028 if lock. is_none ( ) {
41- let mut root = match tmp_dir {
42- Some ( tmp_dir) => PathBuf :: from ( tmp_dir) ,
43- None => global_root_legacy ( ) ,
44- } ;
45-
29+ let mut root = PathBuf :: from ( tmp_dir) ;
4630 root. push ( CARGO_INTEGRATION_TEST_DIR ) ;
4731 * lock = Some ( root) ;
4832 }
@@ -80,7 +64,7 @@ pub struct TestIdGuard {
8064}
8165
8266/// For test harnesses like [`crate::cargo_test`]
83- pub fn init_root ( tmp_dir : Option < & ' static str > ) -> TestIdGuard {
67+ pub fn init_root ( tmp_dir : & ' static str ) -> TestIdGuard {
8468 static NEXT_ID : AtomicUsize = AtomicUsize :: new ( 0 ) ;
8569
8670 let id = NEXT_ID . fetch_add ( 1 , Ordering :: SeqCst ) ;
0 commit comments