Skip to content

Commit aef41d2

Browse files
committed
handle triple
1 parent c14ba95 commit aef41d2

File tree

3 files changed

+28
-9
lines changed

3 files changed

+28
-9
lines changed

tests/test_util_name.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@ fn util_name_double() {
5151
// input invalid utf8 to cause an error
5252
child.stdin.take().unwrap().write_all(&[255]).unwrap();
5353
let output = child.wait_with_output().unwrap();
54-
println!("output.stderr = {:?}", output.stderr);
54+
println!("output.stderr = {:?}", output.stderr);
5555
assert!(String::from_utf8(output.stderr).unwrap().contains("sort: "));
5656
}
5757

tests/uutests/build.rs

Lines changed: 25 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,37 @@
1-
use std::env;
21
use cargo_metadata::MetadataCommand;
2+
use std::env;
33

44
fn main() {
55
// Get the target directory from cargo
66
let metadata = MetadataCommand::new().no_deps().exec().unwrap();
77
let target_dir = metadata.target_directory;
8-
8+
99
// Determine the profile (debug or release)
1010
let profile = env::var("PROFILE").unwrap_or_else(|_| "debug".to_string());
11-
11+
12+
// Get target and host triples
13+
let target_triple = env::var("TARGET").ok();
14+
let host_triple = env::var("HOST").ok();
15+
1216
// Construct the path to the coreutils binary
13-
let binary_name = if cfg!(windows) { "coreutils.exe" } else { "coreutils" };
14-
let binary_path = target_dir.join(profile).join(binary_name);
15-
17+
let binary_name = if cfg!(windows) {
18+
"coreutils.exe"
19+
} else {
20+
"coreutils"
21+
};
22+
23+
// Build the binary path based on whether we're cross-compiling
24+
let binary_path = if target_triple != host_triple {
25+
// For cross compilation: target/<target-triple>/debug/coreutils
26+
target_dir
27+
.join(target_triple.unwrap())
28+
.join(&profile)
29+
.join(binary_name)
30+
} else {
31+
// For native compilation: target/debug/coreutils
32+
target_dir.join(&profile).join(binary_name)
33+
};
34+
1635
// Output the binary path for use in the tests
1736
println!("cargo:rustc-env=CARGO_BIN_EXE_coreutils={}", binary_path);
1837
}

tests/uutests/src/lib/util.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -38,9 +38,9 @@ use std::os::unix::process::CommandExt;
3838
use std::os::unix::process::ExitStatusExt;
3939
#[cfg(windows)]
4040
use std::os::windows::fs::{symlink_dir, symlink_file};
41-
use std::path::{Path, PathBuf};
4241
#[cfg(windows)]
4342
use std::path::MAIN_SEPARATOR_STR;
43+
use std::path::{Path, PathBuf};
4444
use std::process::{Child, Command, ExitStatus, Output, Stdio};
4545
use std::rc::Rc;
4646
use std::sync::mpsc::{self, RecvTimeoutError};
@@ -61,7 +61,7 @@ static NO_STDIN_MEANINGLESS: &str = "Setting this flag has no effect if there is
6161
static END_OF_TRANSMISSION_SEQUENCE: &[u8] = b"\n\x04";
6262

6363
pub fn get_tests_binary() -> String {
64-
//env::current_exe().unwrap().into_os_string().into_string().unwrap()
64+
//env::current_exe().unwrap().into_os_string().into_string().unwrap()
6565
env!("CARGO_BIN_EXE_coreutils").to_string()
6666
}
6767
// we can't use

0 commit comments

Comments
 (0)