11use plib:: testing:: { run_test, run_test_with_checker, TestPlan } ;
2+ use std:: path:: Path ;
23use std:: process:: Output ;
34use std:: sync:: atomic:: { AtomicBool , Ordering } ;
45
@@ -10,21 +11,18 @@ fn set_env_vars() {
1011 . compare_exchange ( false , true , Ordering :: SeqCst , Ordering :: SeqCst )
1112 . is_ok ( )
1213 {
13- let mut current_dir = std:: env:: current_dir ( ) . unwrap ( ) ;
14- let read_dir;
15- let write_dir;
16- if current_dir. ends_with ( "sh" ) {
17- read_dir = current_dir. join ( "tests/read_dir" ) ;
18- current_dir. pop ( ) ;
19- write_dir = current_dir. join ( "target/tmp/sh_test_write_dir" ) ;
14+ let current_dir = std:: env:: current_dir ( ) . unwrap ( ) ;
15+ let read_dir = if current_dir. ends_with ( "sh" ) {
16+ current_dir. join ( "tests/read_dir" )
2017 } else {
21- read_dir = current_dir. join ( "sh/tests/read_dir" ) ;
22- write_dir = current_dir. join ( "target/tmp/sh_test_write_dir" )
18+ current_dir. join ( "sh/tests/read_dir" )
2319 } ;
20+ std:: env:: set_var ( "TEST_READ_DIR" , read_dir) ;
21+
22+ let write_dir = Path :: new ( concat ! ( env!( "CARGO_TARGET_TMPDIR" ) , "/sh_test_write_dir" ) ) ;
2423 if !write_dir. exists ( ) {
2524 std:: fs:: create_dir ( & write_dir) . expect ( "failed to create write_dir" ) ;
2625 }
27- std:: env:: set_var ( "TEST_READ_DIR" , read_dir) ;
2826 std:: env:: set_var ( "TEST_WRITE_DIR" , write_dir) ;
2927 TEST_VARS_ARE_SET . store ( true , Ordering :: SeqCst ) ;
3028 }
0 commit comments