Skip to content

Commit 1b81eb6

Browse files
committed
different approach
1 parent 66cbee4 commit 1b81eb6

File tree

1 file changed

+30
-32
lines changed

1 file changed

+30
-32
lines changed

tests/uutests/src/lib/util.rs

Lines changed: 30 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,6 @@ pub fn get_tests_binary() -> String {
6767
std::env::var("CARGO_BIN_EXE_coreutils").unwrap_or_else(|_| {
6868
let manifest_dir = Path::new(env!("CARGO_MANIFEST_DIR"));
6969
let mut target_dir = manifest_dir.to_path_buf();
70-
7170
// Check for target directory at different levels
7271
for _ in 0..3 {
7372
target_dir.push("target");
@@ -77,21 +76,22 @@ pub fn get_tests_binary() -> String {
7776
} else {
7877
"release"
7978
};
80-
8179
// First try the triple-specific path
82-
let triple = std::env::var("TARGET");
83-
let triple_path = format!(
84-
"{}/{:?}/{}/coreutils",
85-
target_dir.display(),
86-
triple,
87-
debug_or_release
88-
);
89-
log_info("0= Checking for binary at: {}", &triple_path);
90-
// Check if triple-specific path exists
91-
if Path::new(&triple_path).exists() {
92-
return triple_path;
80+
let triple =
81+
std::env::var("CARGO_BUILD_TARGET").unwrap_or_else(|_| String::from(""));
82+
if !triple.is_empty() {
83+
let triple_path = format!(
84+
"{}/{}/{}/coreutils",
85+
target_dir.display(),
86+
triple,
87+
debug_or_release
88+
);
89+
log_info("0= Checking for binary at: {}", &triple_path);
90+
// Check if triple-specific path exists
91+
if Path::new(&triple_path).exists() {
92+
return triple_path;
93+
}
9394
}
94-
9595
// Fallback to regular path
9696
let tmp = format!("{}/{}/coreutils", target_dir.display(), debug_or_release);
9797
log_info("1= tmp0", &tmp);
@@ -100,35 +100,33 @@ pub fn get_tests_binary() -> String {
100100
target_dir.pop();
101101
target_dir.pop();
102102
}
103-
104103
// If target directory not found, fallback to the manifest directory
105104
let debug_or_release = if cfg!(debug_assertions) {
106105
"debug"
107106
} else {
108107
"release"
109108
};
110-
111109
// Try triple-specific path first in fallback case
112-
let triple = std::env::var("TARGET");
113-
let triple_path = format!(
114-
"{}/target/{:?}/{}/coreutils",
115-
manifest_dir.display(),
116-
triple,
117-
debug_or_release
118-
);
119-
120-
if Path::new(&triple_path).exists() {
121-
log_info("2= triple_path", &triple_path);
122-
triple_path
123-
} else {
124-
let tmp = format!(
125-
"{}/target/{}/coreutils",
110+
let triple = std::env::var("CARGO_BUILD_TARGET").unwrap_or_else(|_| String::from(""));
111+
if !triple.is_empty() {
112+
let triple_path = format!(
113+
"{}/target/{}/{}/coreutils",
126114
manifest_dir.display(),
115+
triple,
127116
debug_or_release
128117
);
129-
log_info("3= tmp", &tmp);
130-
tmp
118+
if Path::new(&triple_path).exists() {
119+
log_info("2= triple_path", &triple_path);
120+
return triple_path;
121+
}
131122
}
123+
let tmp = format!(
124+
"{}/target/{}/coreutils",
125+
manifest_dir.display(),
126+
debug_or_release
127+
);
128+
log_info("3= tmp", &tmp);
129+
tmp
132130
})
133131
}
134132

0 commit comments

Comments
 (0)