sort: print check messages to stderr, not stdout

This commit is contained in:
Michael Debertol 2021-07-25 22:25:54 +02:00
parent 891d25cebd
commit c6e044927c
2 changed files with 5 additions and 5 deletions

View file

@ -56,7 +56,7 @@ pub fn check(path: &str, settings: &GlobalSettings) -> i32 {
) == Ordering::Greater ) == Ordering::Greater
{ {
if !settings.check_silent { if !settings.check_silent {
println!("sort: {}:{}: disorder: {}", path, line_idx, new_first.line); eprintln!("sort: {}:{}: disorder: {}", path, line_idx, new_first.line);
} }
return 1; return 1;
} }
@ -68,7 +68,7 @@ pub fn check(path: &str, settings: &GlobalSettings) -> i32 {
if compare_by(a, b, settings, chunk.line_data(), chunk.line_data()) == Ordering::Greater if compare_by(a, b, settings, chunk.line_data(), chunk.line_data()) == Ordering::Greater
{ {
if !settings.check_silent { if !settings.check_silent {
println!("sort: {}:{}: disorder: {}", path, line_idx, b.line); eprintln!("sort: {}:{}: disorder: {}", path, line_idx, b.line);
} }
return 1; return 1;
} }

View file

@ -181,7 +181,7 @@ fn test_check_zero_terminated_failure() {
.arg("-c") .arg("-c")
.arg("zero-terminated.txt") .arg("zero-terminated.txt")
.fails() .fails()
.stdout_is("sort: zero-terminated.txt:2: disorder: ../../fixtures/du\n"); .stderr_only("sort: zero-terminated.txt:2: disorder: ../../fixtures/du\n");
} }
#[test] #[test]
@ -775,13 +775,13 @@ fn test_check() {
.arg(diagnose_arg) .arg(diagnose_arg)
.arg("check_fail.txt") .arg("check_fail.txt")
.fails() .fails()
.stdout_is("sort: check_fail.txt:6: disorder: 5\n"); .stderr_only("sort: check_fail.txt:6: disorder: 5\n");
new_ucmd!() new_ucmd!()
.arg(diagnose_arg) .arg(diagnose_arg)
.arg("multiple_files.expected") .arg("multiple_files.expected")
.succeeds() .succeeds()
.stdout_is(""); .stderr_is("");
} }
} }