Skip to content

Commit 395da6a

Browse files
authored
nice: add newline to warning message (#12929)
* nice: add newline to warning message * writeln instead of \n * nice: test_nice_adj_negative * Update test_nice.rs * Update test_nice.rs * message is different for android * merge two adjust negative tests * move test_nice_adj_negative where the old test was
1 parent de30f0a commit 395da6a

2 files changed

Lines changed: 6 additions & 7 deletions

File tree

src/uu/nice/src/nice.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -137,7 +137,7 @@ pub fn uumain(args: impl uucore::Args) -> UResult<()> {
137137
if let Err(e) = rustix::process::setpriority_process(None, new_niceness) {
138138
let warning_msg = translate!("nice-warning-setpriority", "util_name" => "nice", "error" => strip_errno(&e.into()) );
139139

140-
if write!(std::io::stderr(), "{warning_msg}").is_err() {
140+
if writeln!(std::io::stderr(), "{warning_msg}").is_err() {
141141
set_exit_code(125);
142142
return Ok(());
143143
}

tests/by-util/test_nice.rs

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -15,17 +15,16 @@ fn test_get_current_niceness() {
1515

1616
#[test]
1717
#[cfg(not(target_os = "android"))]
18-
fn test_negative_adj_is_adjustment() {
18+
fn test_nice_adj_negative() {
1919
// This assumes the test suite is run as a normal (non-root) user, and as
2020
// such attempting to set a negative niceness value will be rejected by
2121
// the OS. If it gets denied, then we know a negative value was parsed
2222
// correctly.
2323

24-
let res = new_ucmd!().args(&["--adj", "-1", "true"]).succeeds();
25-
assert!(
26-
res.stderr_str()
27-
.starts_with("nice: warning: setpriority: Permission denied")
28-
); // spell-checker:disable-line
24+
new_ucmd!()
25+
.args(&["--adj", "-20", "true"])
26+
.succeeds()
27+
.stderr_is("nice: warning: setpriority: Permission denied\n");
2928
}
3029

3130
#[test]

0 commit comments

Comments
 (0)