Skip to content

Commit c14ba95

Browse files
committed
try a diff approach
1 parent fa75a76 commit c14ba95

File tree

6 files changed

+93
-9
lines changed

6 files changed

+93
-9
lines changed

Cargo.lock

Lines changed: 59 additions & 5 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Cargo.toml

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -263,6 +263,10 @@ feat_os_windows_legacy = [
263263
# * bypass/override ~ translate 'test' feature name to avoid dependency collision with rust core 'test' crate (o/w surfaces as compiler errors during testing)
264264
test = ["uu_test"]
265265

266+
[workspace]
267+
members = ["tests/uutests"]
268+
default-members = ["."]
269+
266270
[workspace.package]
267271
readme = "README.package.md"
268272

@@ -492,6 +496,7 @@ yes = { optional = true, version = "0.0.29", package = "uu_yes", path = "src/uu/
492496
#pin_cc = { version="1.0.61, < 1.0.62", package="cc" } ## cc v1.0.62 has compiler errors for MinRustV v1.32.0, requires 1.34 (for `std::str::split_ascii_whitespace()`)
493497

494498
[dev-dependencies]
499+
uutests = { workspace = true }
495500
chrono = { workspace = true }
496501
filetime = { workspace = true }
497502
glob = { workspace = true }
@@ -504,7 +509,7 @@ sha1 = { workspace = true, features = ["std"] }
504509
tempfile = { workspace = true }
505510
time = { workspace = true, features = ["local-offset"] }
506511
unindent = "0.2.3"
507-
uutests = { workspace = true }
512+
#uutests = { workspace = true }
508513
uucore = { workspace = true, features = [
509514
"mode",
510515
"entries",

tests/test_util_name.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -51,6 +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);
5455
assert!(String::from_utf8(output.stderr).unwrap().contains("sort: "));
5556
}
5657

tests/uutests/Cargo.toml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -59,3 +59,6 @@ xattr = { workspace = true }
5959
serde = { version = "1.0.202", features = ["derive"] }
6060
bincode = { version = "1.3.3" }
6161
serde-big-array = "0.5.1"
62+
63+
[build-dependencies]
64+
cargo_metadata = "0.19.1"

tests/uutests/build.rs

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
use std::env;
2+
use cargo_metadata::MetadataCommand;
3+
4+
fn main() {
5+
// Get the target directory from cargo
6+
let metadata = MetadataCommand::new().no_deps().exec().unwrap();
7+
let target_dir = metadata.target_directory;
8+
9+
// Determine the profile (debug or release)
10+
let profile = env::var("PROFILE").unwrap_or_else(|_| "debug".to_string());
11+
12+
// 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+
16+
// Output the binary path for use in the tests
17+
println!("cargo:rustc-env=CARGO_BIN_EXE_coreutils={}", binary_path);
18+
}

tests/uutests/src/lib/util.rs

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,6 @@ 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::MAIN_SEPARATOR;
4241
use std::path::{Path, PathBuf};
4342
#[cfg(windows)]
4443
use std::path::MAIN_SEPARATOR_STR;
@@ -61,10 +60,14 @@ static MULTIPLE_STDIN_MEANINGLESS: &str = "Ucommand is designed around a typical
6160
static NO_STDIN_MEANINGLESS: &str = "Setting this flag has no effect if there is no stdin";
6261
static END_OF_TRANSMISSION_SEQUENCE: &[u8] = b"\n\x04";
6362

63+
pub fn get_tests_binary() -> String {
64+
//env::current_exe().unwrap().into_os_string().into_string().unwrap()
65+
env!("CARGO_BIN_EXE_coreutils").to_string()
66+
}
6467
// we can't use
6568
// pub const TESTS_BINARY: &str = env!("CARGO_BIN_EXE_coreutils");
6669
// as we are in a library, not a binary
67-
pub fn get_tests_binary() -> String {
70+
/*pub fn get_tests_binary() -> String {
6871
std::env::var("CARGO_BIN_EXE_coreutils").unwrap_or_else(|_| {
6972
let manifest_dir = Path::new(env!("CARGO_MANIFEST_DIR"));
7073
let mut target_dir = manifest_dir.to_path_buf();
@@ -129,7 +132,7 @@ pub fn get_tests_binary() -> String {
129132
log_info("3= tmp", &tmp);
130133
tmp
131134
})
132-
}
135+
}*/
133136

134137
pub const PATH: &str = env!("PATH");
135138

0 commit comments

Comments
 (0)