Skip to content

Commit ddb83f5

Browse files
committed
also manage triples
1 parent f771e42 commit ddb83f5

File tree

1 file changed

+33
-4
lines changed

1 file changed

+33
-4
lines changed

tests/uutests/src/lib/util.rs

Lines changed: 33 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,6 @@ 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-
6766
pub fn get_tests_binary() -> String {
6867
std::env::var("CARGO_BIN_EXE_coreutils").unwrap_or_else(|_| {
6968
let manifest_dir = Path::new(env!("CARGO_MANIFEST_DIR"));
@@ -78,6 +77,22 @@ pub fn get_tests_binary() -> String {
7877
} else {
7978
"release"
8079
};
80+
81+
// 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+
90+
// Check if triple-specific path exists
91+
if Path::new(&triple_path).exists() {
92+
return triple_path;
93+
}
94+
95+
// Fallback to regular path
8196
return format!("{}/{}/coreutils", target_dir.display(), debug_or_release);
8297
}
8398
target_dir.pop();
@@ -90,11 +105,25 @@ pub fn get_tests_binary() -> String {
90105
} else {
91106
"release"
92107
};
93-
format!(
94-
"{}/target/{}/coreutils",
108+
109+
// Try triple-specific path first in fallback case
110+
let triple = std::env::var("TARGET");
111+
let triple_path = format!(
112+
"{}/target/{:?}/{}/coreutils",
95113
manifest_dir.display(),
114+
triple,
96115
debug_or_release
97-
)
116+
);
117+
118+
if Path::new(&triple_path).exists() {
119+
triple_path
120+
} else {
121+
format!(
122+
"{}/target/{}/coreutils",
123+
manifest_dir.display(),
124+
debug_or_release
125+
)
126+
}
98127
})
99128
}
100129

0 commit comments

Comments
 (0)