From e91d0bd14fbf5426cd1fe438cd29cf987c0cc1d9 Mon Sep 17 00:00:00 2001 From: Ben Wiederhake Date: Sun, 25 Feb 2024 17:56:04 +0100 Subject: [PATCH 1/3] uniq: fix flaky test gnu_tests The testcase tries to write to the stdin pipe while the process under test is simultaneously exiting with an error code. Naturally, this is a race, and we should ignore any stdin write errors. However, adding this feature to the list makes it even more unreadable, and adds no real value, so let's skip the input data entirely. --- tests/by-util/test_uniq.rs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/tests/by-util/test_uniq.rs b/tests/by-util/test_uniq.rs index 7ebc5c482e9..8b791e6c0c8 100644 --- a/tests/by-util/test_uniq.rs +++ b/tests/by-util/test_uniq.rs @@ -755,7 +755,7 @@ fn gnu_tests() { TestCase { name: "112", args: &["-D", "-c"], - input: "a a\na b\n", + input: "", // Note: Different from GNU test, but should not matter stdout: Some(""), stderr: Some("uniq: printing all duplicated lines and repeat counts is meaningless\nTry 'uniq --help' for more information.\n"), exit: Some(1), @@ -811,7 +811,7 @@ fn gnu_tests() { TestCase { name: "119", args: &["--all-repeated=badoption"], - input: "a a\na b\n", + input: "", // Note: Different from GNU test, but should not matter stdout: Some(""), stderr: Some("uniq: invalid argument 'badoption' for '--all-repeated'\nValid arguments are:\n - 'none'\n - 'prepend'\n - 'separate'\nTry 'uniq --help' for more information.\n"), exit: Some(1), From c2e7eed27fbcab7391336f5fee0b146a0e5aaeb0 Mon Sep 17 00:00:00 2001 From: "renovate[bot]" <29139614+renovate[bot]@users.noreply.github.com> Date: Mon, 26 Feb 2024 04:34:43 +0000 Subject: [PATCH 2/3] chore(deps): update rust crate half to 2.4 --- Cargo.lock | 4 ++-- Cargo.toml | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 3f656b7d19b..cb31be62163 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -1010,9 +1010,9 @@ checksum = "d2fabcfbdc87f4758337ca535fb41a6d701b65693ce38287d856d1674551ec9b" [[package]] name = "half" -version = "2.3.1" +version = "2.4.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "bc52e53916c08643f1b56ec082790d1e86a32e58dc5268f897f313fbae7b4872" +checksum = "b5eceaaeec696539ddaf7b333340f1af35a5aa87ae3e4f3ead0532f72affab2e" dependencies = [ "cfg-if", "crunchy", diff --git a/Cargo.toml b/Cargo.toml index 0bc33644f5f..487da295489 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -284,7 +284,7 @@ fts-sys = "0.2" fundu = "2.0.0" gcd = "2.3" glob = "0.3.1" -half = "2.3" +half = "2.4" hostname = "0.3" indicatif = "0.17" itertools = "0.12.1" From 095eced4be525d939216b879a789baf02add7547 Mon Sep 17 00:00:00 2001 From: Matei Mantu <66641453+mtimaN@users.noreply.github.com> Date: Mon, 26 Feb 2024 12:01:50 +0200 Subject: [PATCH 3/3] chmod: Fix chmod -c --reference reporting when no change is made (#6016) * Make fperm hold 6 digit octal permission. Set it to 4 digits when displaying * Add test * Make every permission 4 octal digits * Change test name to be more suggestive * chmod: merge two args in test --------- Co-authored-by: Daniel Hofstetter --- src/uu/chmod/src/chmod.rs | 2 +- tests/by-util/test_chmod.rs | 14 ++++++++++++++ 2 files changed, 15 insertions(+), 1 deletion(-) diff --git a/src/uu/chmod/src/chmod.rs b/src/uu/chmod/src/chmod.rs index 31663b1af9c..3c387b5f8ee 100644 --- a/src/uu/chmod/src/chmod.rs +++ b/src/uu/chmod/src/chmod.rs @@ -101,7 +101,7 @@ pub fn uumain(args: impl uucore::Args) -> UResult<()> { let recursive = matches.get_flag(options::RECURSIVE); let fmode = match matches.get_one::(options::REFERENCE) { Some(fref) => match fs::metadata(fref) { - Ok(meta) => Some(meta.mode()), + Ok(meta) => Some(meta.mode() & 0o7777), Err(err) => { return Err(USimpleError::new( 1, diff --git a/tests/by-util/test_chmod.rs b/tests/by-util/test_chmod.rs index be730a8c0ad..35197f85ee4 100644 --- a/tests/by-util/test_chmod.rs +++ b/tests/by-util/test_chmod.rs @@ -645,6 +645,20 @@ fn test_quiet_n_verbose_used_multiple_times() { .succeeds(); } +#[test] +fn test_changes_from_identical_reference() { + let scene = TestScenario::new(util_name!()); + let at = &scene.fixtures; + at.touch("file"); + scene + .ucmd() + .arg("-c") + .arg("--reference=file") + .arg("file") + .succeeds() + .no_stdout(); +} + #[test] fn test_gnu_invalid_mode() { let scene = TestScenario::new(util_name!());