From d96aa3e0980928d66c3df65b65bd91d325695a14 Mon Sep 17 00:00:00 2001 From: Piotr Kwiecinski Date: Thu, 23 Mar 2023 14:07:12 +0100 Subject: [PATCH 01/13] more: move help strings to markdown file --- src/uu/more/more.md | 7 +++++++ src/uu/more/src/more.rs | 6 +++++- 2 files changed, 12 insertions(+), 1 deletion(-) create mode 100644 src/uu/more/more.md diff --git a/src/uu/more/more.md b/src/uu/more/more.md new file mode 100644 index 000000000..588ed1ab4 --- /dev/null +++ b/src/uu/more/more.md @@ -0,0 +1,7 @@ +# more + +``` +more [OPTIONS] ... +``` + +A file perusal filter for CRT viewing. diff --git a/src/uu/more/src/more.rs b/src/uu/more/src/more.rs index 31b1640a2..4dc8a3db6 100644 --- a/src/uu/more/src/more.rs +++ b/src/uu/more/src/more.rs @@ -28,8 +28,11 @@ use unicode_segmentation::UnicodeSegmentation; use unicode_width::UnicodeWidthStr; use uucore::display::Quotable; use uucore::error::{UResult, USimpleError, UUsageError}; +use uucore::{format_usage, help_about, help_usage}; +const ABOUT: &str = help_about!("more.md"); const BELL: &str = "\x07"; +const USAGE: &str = help_usage!("more.md"); pub mod options { pub const SILENT: &str = "silent"; @@ -97,7 +100,8 @@ pub fn uumain(args: impl uucore::Args) -> UResult<()> { pub fn uu_app() -> Command { Command::new(uucore::util_name()) - .about("A file perusal filter for CRT viewing.") + .about(ABOUT) + .override_usage(format_usage(USAGE)) .version(crate_version!()) .infer_long_args(true) .arg( From 0768c63361f1c0ea3edaa569cd1f1d7619891453 Mon Sep 17 00:00:00 2001 From: Piotr Kwiecinski Date: Thu, 23 Mar 2023 14:30:17 +0100 Subject: [PATCH 02/13] mv: move help strings to markdown file --- src/uu/mv/mv.md | 10 ++++++++++ src/uu/mv/src/mv.rs | 9 +++------ 2 files changed, 13 insertions(+), 6 deletions(-) create mode 100644 src/uu/mv/mv.md diff --git a/src/uu/mv/mv.md b/src/uu/mv/mv.md new file mode 100644 index 000000000..a6cc904f4 --- /dev/null +++ b/src/uu/mv/mv.md @@ -0,0 +1,10 @@ +# mv + +``` + +mv [OPTION]... [-T] SOURCE DEST +mv [OPTION]... SOURCE... DIRECTORY +mv [OPTION]... -t DIRECTORY SOURCE... +``` + +Move `SOURCE` to `DEST`, or multiple `SOURCE`(s) to `DIRECTORY`. diff --git a/src/uu/mv/src/mv.rs b/src/uu/mv/src/mv.rs index 0a1394594..ff2601d84 100644 --- a/src/uu/mv/src/mv.rs +++ b/src/uu/mv/src/mv.rs @@ -25,7 +25,7 @@ use std::path::{Path, PathBuf}; use uucore::backup_control::{self, BackupMode}; use uucore::display::Quotable; use uucore::error::{FromIo, UError, UResult, USimpleError, UUsageError}; -use uucore::{format_usage, prompt_yes, show}; +use uucore::{format_usage, help_about, help_usage, prompt_yes, show}; use fs_extra::dir::{ get_size as dir_get_size, move_dir, move_dir_with_progress, CopyOptions as DirCopyOptions, @@ -53,12 +53,9 @@ pub enum OverwriteMode { Force, } -static ABOUT: &str = "Move SOURCE to DEST, or multiple SOURCE(s) to DIRECTORY."; +static ABOUT: &str = help_about!("mv.md"); static LONG_HELP: &str = ""; -const USAGE: &str = "\ - {} [OPTION]... [-T] SOURCE DEST - {} [OPTION]... SOURCE... DIRECTORY - {} [OPTION]... -t DIRECTORY SOURCE..."; +const USAGE: &str = help_usage!("mv.md"); static OPT_FORCE: &str = "force"; static OPT_INTERACTIVE: &str = "interactive"; From 896314a64e20ebb742ee79193b6b5793a15cf115 Mon Sep 17 00:00:00 2001 From: Piotr Kwiecinski Date: Thu, 23 Mar 2023 14:52:33 +0100 Subject: [PATCH 03/13] nice: move help strings to markdown file --- src/uu/nice/nice.md | 10 ++++++++++ src/uu/nice/src/nice.rs | 10 +++------- 2 files changed, 13 insertions(+), 7 deletions(-) create mode 100644 src/uu/nice/nice.md diff --git a/src/uu/nice/nice.md b/src/uu/nice/nice.md new file mode 100644 index 000000000..872c239ca --- /dev/null +++ b/src/uu/nice/nice.md @@ -0,0 +1,10 @@ +# nice + +``` +nice [OPTIONS] [COMMAND [ARGS]] +``` + +Run `COMMAND` with an adjusted niceness, which affects process scheduling. +With no `COMMAND`, print the current niceness. Niceness values range from at +least -20 (most favorable to the process) to 19 (least favorable to the +process). diff --git a/src/uu/nice/src/nice.rs b/src/uu/nice/src/nice.rs index a059e13b7..b23608ff6 100644 --- a/src/uu/nice/src/nice.rs +++ b/src/uu/nice/src/nice.rs @@ -15,7 +15,7 @@ use std::ptr; use clap::{crate_version, Arg, ArgAction, Command}; use uucore::{ error::{set_exit_code, UClapError, UResult, USimpleError, UUsageError}, - format_usage, show_error, + format_usage, help_about, help_usage, show_error, }; pub mod options { @@ -23,12 +23,8 @@ pub mod options { pub static COMMAND: &str = "COMMAND"; } -const ABOUT: &str = "\ - Run COMMAND with an adjusted niceness, which affects process scheduling. \ - With no COMMAND, print the current niceness. Niceness values range from at \ - least -20 (most favorable to the process) to 19 (least favorable to the \ - process)."; -const USAGE: &str = "{} [OPTIONS] [COMMAND [ARGS]]"; +const ABOUT: &str = help_about!("nice.md"); +const USAGE: &str = help_usage!("nice.md"); fn is_prefix_of(maybe_prefix: &str, target: &str, min_match: usize) -> bool { if maybe_prefix.len() < min_match || maybe_prefix.len() > target.len() { From 04c0b5118d37bf583c82a0d918e9c627d81521c8 Mon Sep 17 00:00:00 2001 From: Piotr Kwiecinski Date: Thu, 23 Mar 2023 16:06:10 +0100 Subject: [PATCH 04/13] mv: remove long help, change static to const, remove whitespace --- src/uu/mv/mv.md | 1 - src/uu/mv/src/mv.rs | 10 ++-------- 2 files changed, 2 insertions(+), 9 deletions(-) diff --git a/src/uu/mv/mv.md b/src/uu/mv/mv.md index a6cc904f4..772e4bfaf 100644 --- a/src/uu/mv/mv.md +++ b/src/uu/mv/mv.md @@ -1,7 +1,6 @@ # mv ``` - mv [OPTION]... [-T] SOURCE DEST mv [OPTION]... SOURCE... DIRECTORY mv [OPTION]... -t DIRECTORY SOURCE... diff --git a/src/uu/mv/src/mv.rs b/src/uu/mv/src/mv.rs index ff2601d84..4560bf2c3 100644 --- a/src/uu/mv/src/mv.rs +++ b/src/uu/mv/src/mv.rs @@ -53,8 +53,7 @@ pub enum OverwriteMode { Force, } -static ABOUT: &str = help_about!("mv.md"); -static LONG_HELP: &str = ""; +const ABOUT: &str = help_about!("mv.md"); const USAGE: &str = help_usage!("mv.md"); static OPT_FORCE: &str = "force"; @@ -70,12 +69,7 @@ static ARG_FILES: &str = "files"; #[uucore::main] pub fn uumain(args: impl uucore::Args) -> UResult<()> { - let help = format!( - "{}\n{}", - LONG_HELP, - backup_control::BACKUP_CONTROL_LONG_HELP - ); - let mut app = uu_app().after_help(help); + let mut app = uu_app(); let matches = app.try_get_matches_from_mut(args)?; if !matches.contains_id(OPT_TARGET_DIRECTORY) From 6c9664433ff3341ada8e09df99a08415739c0b39 Mon Sep 17 00:00:00 2001 From: Piotr Kwiecinski Date: Thu, 23 Mar 2023 16:09:04 +0100 Subject: [PATCH 05/13] more: group about and usage --- src/uu/more/src/more.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/uu/more/src/more.rs b/src/uu/more/src/more.rs index 4dc8a3db6..6cf9df1ab 100644 --- a/src/uu/more/src/more.rs +++ b/src/uu/more/src/more.rs @@ -31,8 +31,8 @@ use uucore::error::{UResult, USimpleError, UUsageError}; use uucore::{format_usage, help_about, help_usage}; const ABOUT: &str = help_about!("more.md"); -const BELL: &str = "\x07"; const USAGE: &str = help_usage!("more.md"); +const BELL: &str = "\x07"; pub mod options { pub const SILENT: &str = "silent"; From ac01925583a932765d49650bcb642ab3776864c4 Mon Sep 17 00:00:00 2001 From: Piotr Kwiecinski Date: Thu, 23 Mar 2023 16:12:55 +0100 Subject: [PATCH 06/13] mv: restore backup control long help --- src/uu/mv/src/mv.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/uu/mv/src/mv.rs b/src/uu/mv/src/mv.rs index 4560bf2c3..d3a6d2ed0 100644 --- a/src/uu/mv/src/mv.rs +++ b/src/uu/mv/src/mv.rs @@ -69,7 +69,7 @@ static ARG_FILES: &str = "files"; #[uucore::main] pub fn uumain(args: impl uucore::Args) -> UResult<()> { - let mut app = uu_app(); + let mut app = uu_app().after_help(backup_control::BACKUP_CONTROL_LONG_HELP); let matches = app.try_get_matches_from_mut(args)?; if !matches.contains_id(OPT_TARGET_DIRECTORY) From d4758ff3c86ed687466663785b62e3bb765ba65d Mon Sep 17 00:00:00 2001 From: Piotr Kwiecinski Date: Thu, 23 Mar 2023 18:44:03 +0100 Subject: [PATCH 07/13] more: modernize about section --- src/uu/more/more.md | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/uu/more/more.md b/src/uu/more/more.md index 588ed1ab4..cb626060e 100644 --- a/src/uu/more/more.md +++ b/src/uu/more/more.md @@ -4,4 +4,5 @@ more [OPTIONS] ... ``` -A file perusal filter for CRT viewing. +Display the contents of a text file + From 81a4e8fb7d349dfb4b29e21d50f6b2424a019163 Mon Sep 17 00:00:00 2001 From: Miles Liu Date: Fri, 24 Mar 2023 10:52:02 +0800 Subject: [PATCH 08/13] Remove `keep_env` from the test framework --- tests/by-util/test_chown.rs | 14 +++++------ tests/by-util/test_cp.rs | 10 +++++--- tests/by-util/test_env.rs | 4 +-- tests/by-util/test_mktemp.rs | 2 -- tests/by-util/test_nproc.rs | 17 ------------- tests/by-util/test_printenv.rs | 16 +++--------- tests/by-util/test_sort.rs | 7 ------ tests/by-util/test_uptime.rs | 1 - tests/by-util/test_users.rs | 1 - tests/common/util.rs | 45 +++++++++++++--------------------- 10 files changed, 36 insertions(+), 81 deletions(-) diff --git a/tests/by-util/test_chown.rs b/tests/by-util/test_chown.rs index bf2fbe89a..9bd6382a6 100644 --- a/tests/by-util/test_chown.rs +++ b/tests/by-util/test_chown.rs @@ -396,7 +396,7 @@ fn test_chown_only_user_id() { let scene = TestScenario::new(util_name!()); let at = &scene.fixtures; - let result = scene.cmd("id").keep_env().arg("-u").run(); + let result = scene.cmd("id").arg("-u").run(); if skipping_test_is_okay(&result, "id: cannot find name for group ID") { return; } @@ -430,7 +430,7 @@ fn test_chown_fail_id() { let scene = TestScenario::new(util_name!()); let at = &scene.fixtures; - let result = scene.cmd("id").keep_env().arg("-u").run(); + let result = scene.cmd("id").arg("-u").run(); if skipping_test_is_okay(&result, "id: cannot find name for group ID") { return; } @@ -487,7 +487,7 @@ fn test_chown_only_group_id() { let scene = TestScenario::new(util_name!()); let at = &scene.fixtures; - let result = scene.cmd("id").keep_env().arg("-g").run(); + let result = scene.cmd("id").arg("-g").run(); if skipping_test_is_okay(&result, "id: cannot find name for group ID") { return; } @@ -551,14 +551,14 @@ fn test_chown_owner_group_id() { let scene = TestScenario::new(util_name!()); let at = &scene.fixtures; - let result = scene.cmd("id").keep_env().arg("-u").run(); + let result = scene.cmd("id").arg("-u").run(); if skipping_test_is_okay(&result, "id: cannot find name for group ID") { return; } let user_id = String::from(result.stdout_str().trim()); assert!(!user_id.is_empty()); - let result = scene.cmd("id").keep_env().arg("-g").run(); + let result = scene.cmd("id").arg("-g").run(); if skipping_test_is_okay(&result, "id: cannot find name for group ID") { return; } @@ -612,14 +612,14 @@ fn test_chown_owner_group_mix() { let scene = TestScenario::new(util_name!()); let at = &scene.fixtures; - let result = scene.cmd("id").keep_env().arg("-u").run(); + let result = scene.cmd("id").arg("-u").run(); if skipping_test_is_okay(&result, "id: cannot find name for group ID") { return; } let user_id = String::from(result.stdout_str().trim()); assert!(!user_id.is_empty()); - let result = scene.cmd("id").keep_env().arg("-gn").run(); + let result = scene.cmd("id").arg("-gn").run(); if skipping_test_is_okay(&result, "id: cannot find name for group ID") { return; } diff --git a/tests/by-util/test_cp.rs b/tests/by-util/test_cp.rs index 4fa2e9fd1..ca913adb5 100644 --- a/tests/by-util/test_cp.rs +++ b/tests/by-util/test_cp.rs @@ -29,6 +29,10 @@ use std::fs as std_fs; use std::thread::sleep; use std::time::Duration; +#[cfg(any(target_os = "linux", target_os = "android"))] +#[cfg(feature = "truncate")] +use crate::common::util::PATH; + static TEST_EXISTING_FILE: &str = "existing_file.txt"; static TEST_HELLO_WORLD_SOURCE: &str = "hello_world.txt"; static TEST_HELLO_WORLD_SOURCE_SYMLINK: &str = "hello_world.txt.link"; @@ -1687,7 +1691,7 @@ fn test_cp_reflink_always_override() { if !scene .cmd("env") - .keep_env() + .env("PATH", PATH) .args(&["mkfs.btrfs", "--rootdir", ROOTDIR, DISK]) .run() .succeeded() @@ -1700,7 +1704,7 @@ fn test_cp_reflink_always_override() { let mount = scene .cmd("sudo") - .keep_env() + .env("PATH", PATH) .args(&["-E", "--non-interactive", "mount", DISK, MOUNTPOINT]) .run(); @@ -1727,7 +1731,7 @@ fn test_cp_reflink_always_override() { scene .cmd("sudo") - .keep_env() + .env("PATH", PATH) .args(&["-E", "--non-interactive", "umount", MOUNTPOINT]) .succeeds(); } diff --git a/tests/by-util/test_env.rs b/tests/by-util/test_env.rs index fcca47cad..bd206c8e5 100644 --- a/tests/by-util/test_env.rs +++ b/tests/by-util/test_env.rs @@ -153,11 +153,9 @@ fn test_null_delimiter() { #[test] fn test_unset_variable() { - // This test depends on the HOME variable being pre-defined by the - // default shell let out = TestScenario::new(util_name!()) .ucmd() - .keep_env() + .env("HOME", "FOO") .arg("-u") .arg("HOME") .succeeds() diff --git a/tests/by-util/test_mktemp.rs b/tests/by-util/test_mktemp.rs index 8fc5669cd..e80f61a28 100644 --- a/tests/by-util/test_mktemp.rs +++ b/tests/by-util/test_mktemp.rs @@ -426,7 +426,6 @@ fn test_mktemp_tmpdir_one_arg() { let result = scene .ucmd() - .keep_env() .arg("--tmpdir") .arg("apt-key-gpghome.XXXXXXXXXX") .succeeds(); @@ -440,7 +439,6 @@ fn test_mktemp_directory_tmpdir() { let result = scene .ucmd() - .keep_env() .arg("--directory") .arg("--tmpdir") .arg("apt-key-gpghome.XXXXXXXXXX") diff --git a/tests/by-util/test_nproc.rs b/tests/by-util/test_nproc.rs index b79715157..2e3c5c603 100644 --- a/tests/by-util/test_nproc.rs +++ b/tests/by-util/test_nproc.rs @@ -21,7 +21,6 @@ fn test_nproc_all_omp() { let result = TestScenario::new(util_name!()) .ucmd() - .keep_env() .env("OMP_NUM_THREADS", "60") .succeeds(); @@ -30,7 +29,6 @@ fn test_nproc_all_omp() { let result = TestScenario::new(util_name!()) .ucmd() - .keep_env() .env("OMP_NUM_THREADS", "1") // Has no effect .arg("--all") .succeeds(); @@ -40,7 +38,6 @@ fn test_nproc_all_omp() { // If the parsing fails, returns the number of CPU let result = TestScenario::new(util_name!()) .ucmd() - .keep_env() .env("OMP_NUM_THREADS", "incorrectnumber") // returns the number CPU .succeeds(); let nproc_omp: u8 = result.stdout_str().trim().parse().unwrap(); @@ -55,7 +52,6 @@ fn test_nproc_ignore() { // Ignore all CPU but one let result = TestScenario::new(util_name!()) .ucmd() - .keep_env() .arg("--ignore") .arg((nproc_total - 1).to_string()) .succeeds(); @@ -64,7 +60,6 @@ fn test_nproc_ignore() { // Ignore all CPU but one with a string let result = TestScenario::new(util_name!()) .ucmd() - .keep_env() .arg("--ignore= 1") .succeeds(); let nproc: u8 = result.stdout_str().trim().parse().unwrap(); @@ -76,7 +71,6 @@ fn test_nproc_ignore() { fn test_nproc_ignore_all_omp() { let result = TestScenario::new(util_name!()) .ucmd() - .keep_env() .env("OMP_NUM_THREADS", "42") .arg("--ignore=40") .succeeds(); @@ -88,7 +82,6 @@ fn test_nproc_ignore_all_omp() { fn test_nproc_omp_limit() { let result = TestScenario::new(util_name!()) .ucmd() - .keep_env() .env("OMP_NUM_THREADS", "42") .env("OMP_THREAD_LIMIT", "0") .succeeds(); @@ -97,7 +90,6 @@ fn test_nproc_omp_limit() { let result = TestScenario::new(util_name!()) .ucmd() - .keep_env() .env("OMP_NUM_THREADS", "42") .env("OMP_THREAD_LIMIT", "2") .succeeds(); @@ -106,7 +98,6 @@ fn test_nproc_omp_limit() { let result = TestScenario::new(util_name!()) .ucmd() - .keep_env() .env("OMP_NUM_THREADS", "42") .env("OMP_THREAD_LIMIT", "2bad") .succeeds(); @@ -119,7 +110,6 @@ fn test_nproc_omp_limit() { let result = TestScenario::new(util_name!()) .ucmd() - .keep_env() .env("OMP_THREAD_LIMIT", "1") .succeeds(); let nproc: u8 = result.stdout_str().trim().parse().unwrap(); @@ -127,7 +117,6 @@ fn test_nproc_omp_limit() { let result = TestScenario::new(util_name!()) .ucmd() - .keep_env() .env("OMP_NUM_THREADS", "0") .env("OMP_THREAD_LIMIT", "") .succeeds(); @@ -136,7 +125,6 @@ fn test_nproc_omp_limit() { let result = TestScenario::new(util_name!()) .ucmd() - .keep_env() .env("OMP_NUM_THREADS", "") .env("OMP_THREAD_LIMIT", "") .succeeds(); @@ -145,7 +133,6 @@ fn test_nproc_omp_limit() { let result = TestScenario::new(util_name!()) .ucmd() - .keep_env() .env("OMP_NUM_THREADS", "2,2,1") .env("OMP_THREAD_LIMIT", "") .succeeds(); @@ -154,7 +141,6 @@ fn test_nproc_omp_limit() { let result = TestScenario::new(util_name!()) .ucmd() - .keep_env() .env("OMP_NUM_THREADS", "2,ignored") .env("OMP_THREAD_LIMIT", "") .succeeds(); @@ -163,7 +149,6 @@ fn test_nproc_omp_limit() { let result = TestScenario::new(util_name!()) .ucmd() - .keep_env() .env("OMP_NUM_THREADS", "2,2,1") .env("OMP_THREAD_LIMIT", "0") .succeeds(); @@ -172,7 +157,6 @@ fn test_nproc_omp_limit() { let result = TestScenario::new(util_name!()) .ucmd() - .keep_env() .env("OMP_NUM_THREADS", "2,2,1") .env("OMP_THREAD_LIMIT", "1bad") .succeeds(); @@ -181,7 +165,6 @@ fn test_nproc_omp_limit() { let result = TestScenario::new(util_name!()) .ucmd() - .keep_env() .env("OMP_NUM_THREADS", "29,2,1") .env("OMP_THREAD_LIMIT", "1bad") .succeeds(); diff --git a/tests/by-util/test_printenv.rs b/tests/by-util/test_printenv.rs index 8365b130a..fa7d420e1 100644 --- a/tests/by-util/test_printenv.rs +++ b/tests/by-util/test_printenv.rs @@ -1,29 +1,21 @@ use crate::common::util::TestScenario; -use std::env; #[test] fn test_get_all() { - let key = "KEY"; - env::set_var(key, "VALUE"); - assert_eq!(env::var(key), Ok("VALUE".to_string())); - TestScenario::new(util_name!()) .ucmd() - .keep_env() + .env("HOME", "FOO") + .env("KEY", "VALUE") .succeeds() - .stdout_contains("HOME=") + .stdout_contains("HOME=FOO") .stdout_contains("KEY=VALUE"); } #[test] fn test_get_var() { - let key = "KEY"; - env::set_var(key, "VALUE"); - assert_eq!(env::var(key), Ok("VALUE".to_string())); - let result = TestScenario::new(util_name!()) .ucmd() - .keep_env() + .env("KEY", "VALUE") .arg("KEY") .succeeds(); diff --git a/tests/by-util/test_sort.rs b/tests/by-util/test_sort.rs index eef31e7dd..a61db56b0 100644 --- a/tests/by-util/test_sort.rs +++ b/tests/by-util/test_sort.rs @@ -32,7 +32,6 @@ fn test_buffer_sizes() { for buffer_size in &buffer_sizes { TestScenario::new(util_name!()) .ucmd() - .keep_env() .arg("-n") .arg("-S") .arg(buffer_size) @@ -46,7 +45,6 @@ fn test_buffer_sizes() { for buffer_size in &buffer_sizes { TestScenario::new(util_name!()) .ucmd() - .keep_env() .arg("-n") .arg("-S") .arg(buffer_size) @@ -921,7 +919,6 @@ fn test_compress_fail() { #[cfg(not(windows))] TestScenario::new(util_name!()) .ucmd() - .keep_env() .args(&[ "ext_sort.txt", "-n", @@ -938,7 +935,6 @@ fn test_compress_fail() { #[cfg(windows)] TestScenario::new(util_name!()) .ucmd() - .keep_env() .args(&[ "ext_sort.txt", "-n", @@ -954,7 +950,6 @@ fn test_compress_fail() { fn test_merge_batches() { TestScenario::new(util_name!()) .ucmd() - .keep_env() .timeout(Duration::from_secs(120)) .args(&["ext_sort.txt", "-n", "-S", "150b"]) .succeeds() @@ -965,7 +960,6 @@ fn test_merge_batches() { fn test_merge_batch_size() { TestScenario::new(util_name!()) .ucmd() - .keep_env() .arg("--batch-size=2") .arg("-m") .arg("--unique") @@ -1074,7 +1068,6 @@ fn test_output_is_input() { at.append("file", input); scene .ucmd() - .keep_env() .args(&["-m", "-u", "-o", "file", "file", "file", "file"]) .succeeds(); assert_eq!(at.read("file"), input); diff --git a/tests/by-util/test_uptime.rs b/tests/by-util/test_uptime.rs index 5453c6104..46613ef56 100644 --- a/tests/by-util/test_uptime.rs +++ b/tests/by-util/test_uptime.rs @@ -11,7 +11,6 @@ fn test_invalid_arg() { fn test_uptime() { TestScenario::new(util_name!()) .ucmd() - .keep_env() .succeeds() .stdout_contains("load average:") .stdout_contains(" up "); diff --git a/tests/by-util/test_users.rs b/tests/by-util/test_users.rs index c8a7bd643..6a54aa8d2 100644 --- a/tests/by-util/test_users.rs +++ b/tests/by-util/test_users.rs @@ -23,7 +23,6 @@ fn test_users_check_name() { #[allow(clippy::needless_borrow)] let expected = TestScenario::new(&util_name) .cmd(util_name) - .keep_env() .env("LC_ALL", "C") .succeeds() .stdout_move_str(); diff --git a/tests/common/util.rs b/tests/common/util.rs index 4005c87d9..3f37c7f10 100644 --- a/tests/common/util.rs +++ b/tests/common/util.rs @@ -47,6 +47,7 @@ static MULTIPLE_STDIN_MEANINGLESS: &str = "Ucommand is designed around a typical static NO_STDIN_MEANINGLESS: &str = "Setting this flag has no effect if there is no stdin"; pub const TESTS_BINARY: &str = env!("CARGO_BIN_EXE_coreutils"); +pub const PATH: &str = env!("PATH"); /// Test if the program is running under CI pub fn is_ci() -> bool { @@ -1170,14 +1171,12 @@ impl TestScenario { /// * [`UCommand::from_test_scenario`]: Run `coreutils UTIL_NAME` instead of the shell in the /// temporary directory of the [`TestScenario`] /// * [`UCommand::current_dir`]: Sets the working directory -/// * [`UCommand::keep_env`]: Keep environment variables instead of clearing them /// * ... #[derive(Debug, Default)] pub struct UCommand { args: VecDeque, env_vars: Vec<(OsString, OsString)>, current_dir: Option, - env_clear: bool, bin_path: Option, util_name: Option, has_run: bool, @@ -1203,7 +1202,6 @@ impl UCommand { /// temporary directory for safety purposes. pub fn new() -> Self { Self { - env_clear: true, ..Default::default() } } @@ -1253,12 +1251,6 @@ impl UCommand { self } - /// Keep the environment variables instead of clearing them before running the command. - pub fn keep_env(&mut self) -> &mut Self { - self.env_clear = false; - self - } - /// Set the working directory for this [`UCommand`] /// /// Per default the working directory is set to the [`UCommands`] temporary directory. @@ -1376,7 +1368,6 @@ impl UCommand { /// which this command will be run and `current_dir` will be set to this `temp_dir`. /// * `current_dir`: The temporary directory given by `temp_dir`. /// * `timeout`: `30 seconds` - /// * `env_clear`: `true`. (Almost) all environment variables will be cleared. /// * `stdin`: `Stdio::null()` /// * `ignore_stdin_write_error`: `false` /// * `stdout`, `stderr`: If not specified the output will be captured with [`CapturedOutput`] @@ -1435,22 +1426,20 @@ impl UCommand { self.tmpd = Some(Rc::new(temp_dir)); } - if self.env_clear { - command.env_clear(); - if cfg!(windows) { - // spell-checker:ignore (dll) rsaenh - // %SYSTEMROOT% is required on Windows to initialize crypto provider - // ... and crypto provider is required for std::rand - // From `procmon`: RegQueryValue HKLM\SOFTWARE\Microsoft\Cryptography\Defaults\Provider\Microsoft Strong Cryptographic Provider\Image Path - // SUCCESS Type: REG_SZ, Length: 66, Data: %SystemRoot%\system32\rsaenh.dll" - if let Some(systemroot) = env::var_os("SYSTEMROOT") { - command.env("SYSTEMROOT", systemroot); - } - } else { - // if someone is setting LD_PRELOAD, there's probably a good reason for it - if let Some(ld_preload) = env::var_os("LD_PRELOAD") { - command.env("LD_PRELOAD", ld_preload); - } + command.env_clear(); + if cfg!(windows) { + // spell-checker:ignore (dll) rsaenh + // %SYSTEMROOT% is required on Windows to initialize crypto provider + // ... and crypto provider is required for std::rand + // From `procmon`: RegQueryValue HKLM\SOFTWARE\Microsoft\Cryptography\Defaults\Provider\Microsoft Strong Cryptographic Provider\Image Path + // SUCCESS Type: REG_SZ, Length: 66, Data: %SystemRoot%\system32\rsaenh.dll" + if let Some(systemroot) = env::var_os("SYSTEMROOT") { + command.env("SYSTEMROOT", systemroot); + } + } else { + // if someone is setting LD_PRELOAD, there's probably a good reason for it + if let Some(ld_preload) = env::var_os("LD_PRELOAD") { + command.env("LD_PRELOAD", ld_preload); } } @@ -2455,7 +2444,7 @@ pub fn expected_result(ts: &TestScenario, args: &[&str]) -> std::result::Result< let result = ts .cmd(util_name.as_ref()) - .keep_env() + .env("PATH", PATH) .env("LC_ALL", "C") .args(args) .run(); @@ -2530,7 +2519,7 @@ pub fn run_ucmd_as_root( // run ucmd as root: Ok(ts .cmd("sudo") - .keep_env() + .env("PATH", PATH) .env("LC_ALL", "C") .arg("-E") .arg("--non-interactive") From 2ed432ebdc6ca892eb350584896c7c7dd4223036 Mon Sep 17 00:00:00 2001 From: "renovate[bot]" <29139614+renovate[bot]@users.noreply.github.com> Date: Fri, 24 Mar 2023 09:32:18 +0000 Subject: [PATCH 09/13] chore(deps): update rust crate blake3 to 1.3.3 --- Cargo.lock | 4 ++-- Cargo.toml | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index c86edc12a..24f9da3eb 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -128,9 +128,9 @@ dependencies = [ [[package]] name = "blake3" -version = "1.3.2" +version = "1.3.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "895adc16c8b3273fbbc32685a7d55227705eda08c01e77704020f3491924b44b" +checksum = "42ae2468a89544a466886840aa467a25b766499f4f04bf7d9fcd10ecee9fccef" dependencies = [ "arrayref", "arrayvec", diff --git a/Cargo.toml b/Cargo.toml index 1331839b2..8386558d3 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -339,7 +339,7 @@ sha1 = "0.10.1" sha2 = "0.10.2" sha3 = "0.10.6" blake2b_simd = "1.0.1" -blake3 = "1.3.2" +blake3 = "1.3.3" sm3 = "0.4.1" digest = "0.10.6" From e86c94233a37f710fb2529eac8015653d4bbdce5 Mon Sep 17 00:00:00 2001 From: "renovate[bot]" <29139614+renovate[bot]@users.noreply.github.com> Date: Fri, 24 Mar 2023 09:34:01 +0000 Subject: [PATCH 10/13] chore(deps): update rust crate chrono to ^0.4.24 --- Cargo.lock | 4 ++-- Cargo.toml | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index c86edc12a..2c853c1fb 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -202,9 +202,9 @@ checksum = "baf1de4339761588bc0619e3cbc0120ee582ebb74b53b4efbf79117bd2da40fd" [[package]] name = "chrono" -version = "0.4.23" +version = "0.4.24" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "16b0a3d9ed01224b22057780a37bb8c5dbfe1be8ba48678e7bf57ec4b385411f" +checksum = "4e3c5919066adf22df73762e50cffcde3a758f2a848b113b586d1f86728b673b" dependencies = [ "iana-time-zone", "num-integer", diff --git a/Cargo.toml b/Cargo.toml index 1331839b2..9d562484c 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -268,7 +268,7 @@ binary-heap-plus = "0.5.0" bstr = "1.0" bytecount = "0.6.3" byteorder = "1.3.2" -chrono = { version="^0.4.23", default-features=false, features=["std", "alloc", "clock"]} +chrono = { version="^0.4.24", default-features=false, features=["std", "alloc", "clock"]} clap = { version = "4.1", features = ["wrap_help", "cargo"] } clap_complete = "4.0" clap_mangen = "0.2" From 8774a09eb4fb664ccae91fd518a7b565cd0203d5 Mon Sep 17 00:00:00 2001 From: Sylvestre Ledru Date: Fri, 24 Mar 2023 10:38:02 +0100 Subject: [PATCH 11/13] remove dependabot configuration. we are using renovatebot --- .github/dependabot.yml | 12 ------------ 1 file changed, 12 deletions(-) delete mode 100644 .github/dependabot.yml diff --git a/.github/dependabot.yml b/.github/dependabot.yml deleted file mode 100644 index c29a77873..000000000 --- a/.github/dependabot.yml +++ /dev/null @@ -1,12 +0,0 @@ -version: 2 -updates: - - package-ecosystem: "cargo" - directory: "/" - schedule: - interval: weekly - open-pull-requests-limit: 10 - - package-ecosystem: "github-actions" - directory: "/" - schedule: - interval: weekly - open-pull-requests-limit: 5 From e155994dc58a5ed3114824beab1ef7a6a01da71c Mon Sep 17 00:00:00 2001 From: Daniel Hofstetter Date: Fri, 24 Mar 2023 14:25:40 +0100 Subject: [PATCH 12/13] GNU/coreutils: update reference to 9.2 --- .github/workflows/GnuTests.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/GnuTests.yml b/.github/workflows/GnuTests.yml index 7c8c307ec..2e8297ba8 100644 --- a/.github/workflows/GnuTests.yml +++ b/.github/workflows/GnuTests.yml @@ -42,7 +42,7 @@ jobs: outputs path_GNU path_GNU_tests path_reference path_UUTILS # repo_default_branch="${{ github.event.repository.default_branch }}" - repo_GNU_ref="v9.1" + repo_GNU_ref="v9.2" repo_reference_branch="${{ github.event.repository.default_branch }}" outputs repo_default_branch repo_GNU_ref repo_reference_branch # @@ -305,7 +305,7 @@ jobs: with: repository: 'coreutils/coreutils' path: 'gnu' - ref: 'v9.1' + ref: 'v9.2' submodules: recursive - name: Install `rust` toolchain run: | From 603ba39128e934bec07bec76d5883666bf8e8613 Mon Sep 17 00:00:00 2001 From: "renovate[bot]" <29139614+renovate[bot]@users.noreply.github.com> Date: Fri, 24 Mar 2023 15:07:45 +0000 Subject: [PATCH 13/13] chore(deps): update rust crate hex-literal to 0.3.4 --- Cargo.toml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Cargo.toml b/Cargo.toml index 1331839b2..95828ad2c 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -489,7 +489,7 @@ unindent = "0.1" uucore = { workspace=true, features=["entries", "process", "signals"] } walkdir = { workspace=true } is-terminal = { workspace=true } -hex-literal = "0.3.1" +hex-literal = "0.3.4" rstest = "0.16.0" [target.'cfg(any(target_os = "linux", target_os = "android"))'.dev-dependencies]