diff --git a/src/uu/nice/src/nice.rs b/src/uu/nice/src/nice.rs index 90aab84c3d..fd4d84cd5d 100644 --- a/src/uu/nice/src/nice.rs +++ b/src/uu/nice/src/nice.rs @@ -137,7 +137,7 @@ pub fn uumain(args: impl uucore::Args) -> UResult<()> { if let Err(e) = rustix::process::setpriority_process(None, new_niceness) { let warning_msg = translate!("nice-warning-setpriority", "util_name" => "nice", "error" => strip_errno(&e.into()) ); - if write!(std::io::stderr(), "{warning_msg}").is_err() { + if writeln!(std::io::stderr(), "{warning_msg}").is_err() { set_exit_code(125); return Ok(()); } diff --git a/tests/by-util/test_nice.rs b/tests/by-util/test_nice.rs index a3e6f44045..d08558f6aa 100644 --- a/tests/by-util/test_nice.rs +++ b/tests/by-util/test_nice.rs @@ -15,17 +15,16 @@ fn test_get_current_niceness() { #[test] #[cfg(not(target_os = "android"))] -fn test_negative_adj_is_adjustment() { +fn test_nice_adj_negative() { // This assumes the test suite is run as a normal (non-root) user, and as // such attempting to set a negative niceness value will be rejected by // the OS. If it gets denied, then we know a negative value was parsed // correctly. - let res = new_ucmd!().args(&["--adj", "-1", "true"]).succeeds(); - assert!( - res.stderr_str() - .starts_with("nice: warning: setpriority: Permission denied") - ); // spell-checker:disable-line + new_ucmd!() + .args(&["--adj", "-20", "true"]) + .succeeds() + .stderr_is("nice: warning: setpriority: Permission denied\n"); } #[test]