File tree Expand file tree Collapse file tree 1 file changed +25
-2
lines changed
Expand file tree Collapse file tree 1 file changed +25
-2
lines changed Original file line number Diff line number Diff line change @@ -63,15 +63,38 @@ static END_OF_TRANSMISSION_SEQUENCE: &[u8] = b"\n\x04";
6363// we can't use
6464// pub const TESTS_BINARY: &str = env!("CARGO_BIN_EXE_coreutils");
6565// as we are in a library, not a binary
66+
6667pub fn get_tests_binary ( ) -> String {
6768 std:: env:: var ( "CARGO_BIN_EXE_coreutils" ) . unwrap_or_else ( |_| {
68- let manifest_dir = env ! ( "CARGO_MANIFEST_DIR" ) ;
69+ let manifest_dir = Path :: new ( env ! ( "CARGO_MANIFEST_DIR" ) ) ;
70+ let mut target_dir = manifest_dir. to_path_buf ( ) ;
71+
72+ // Check for target directory at different levels
73+ for _ in 0 ..3 {
74+ target_dir. push ( "target" ) ;
75+ if target_dir. exists ( ) {
76+ let debug_or_release = if cfg ! ( debug_assertions) {
77+ "debug"
78+ } else {
79+ "release"
80+ } ;
81+ return format ! ( "{}/{}/coreutils" , target_dir. display( ) , debug_or_release) ;
82+ }
83+ target_dir. pop ( ) ;
84+ target_dir. pop ( ) ;
85+ }
86+
87+ // If target directory not found, fallback to the manifest directory
6988 let debug_or_release = if cfg ! ( debug_assertions) {
7089 "debug"
7190 } else {
7291 "release"
7392 } ;
74- format ! ( "{manifest_dir}/../../target/{debug_or_release}/coreutils" )
93+ format ! (
94+ "{}/target/{}/coreutils" ,
95+ manifest_dir. display( ) ,
96+ debug_or_release
97+ )
7598 } )
7699}
77100
You can’t perform that action at this time.
0 commit comments