diff --git a/tests/by-util/test_join.rs b/tests/by-util/test_join.rs index 51e3d98cc..dbc0bf411 100644 --- a/tests/by-util/test_join.rs +++ b/tests/by-util/test_join.rs @@ -1,6 +1,8 @@ -// spell-checker:ignore (words) autoformat +// spell-checker:ignore (words) autoformat nocheck use crate::common::util::*; +#[cfg(any(target_os = "linux", target_os = "freebsd", target_os = "netbsd"))] +use std::fs::OpenOptions; #[cfg(unix)] use std::{ffi::OsStr, os::unix::ffi::OsStrExt}; #[cfg(windows)] @@ -306,6 +308,16 @@ fn missing_format_fields() { .stdout_only_fixture("missing_format_fields.expected"); } +#[test] +fn nocheck_order() { + new_ucmd!() + .arg("fields_1.txt") + .arg("fields_2.txt") + .arg("--nocheck-order") + .succeeds() + .stdout_only_fixture("default.expected"); +} + #[test] fn wrong_line_order() { let ts = TestScenario::new(util_name!()); @@ -313,11 +325,24 @@ fn wrong_line_order() { .arg("fields_2.txt") .arg("fields_4.txt") .fails() + .stdout_contains("7 g f 4 fg") .stderr_is(&format!( - "{0} {1}: fields_4.txt:5: is not sorted: 11 g 5 gh\n{0} {1}: input is not in sorted order", - ts.bin_path.to_string_lossy(), - ts.util_name - )); + "{0} {1}: fields_4.txt:5: is not sorted: 11 g 5 gh\n{0} {1}: input is not in sorted order", + ts.bin_path.to_string_lossy(), + ts.util_name + )); + + new_ucmd!() + .arg("--check-order") + .arg("fields_2.txt") + .arg("fields_4.txt") + .fails() + .stdout_does_not_contain("7 g f 4 fg") + .stderr_is(&format!( + "{0} {1}: fields_4.txt:5: is not sorted: 11 g 5 gh", + ts.bin_path.to_string_lossy(), + ts.util_name + )); } #[test] @@ -327,11 +352,24 @@ fn both_files_wrong_line_order() { .arg("fields_4.txt") .arg("fields_5.txt") .fails() + .stdout_contains("5 e 3 ef") .stderr_is(&format!( "{0} {1}: fields_5.txt:4: is not sorted: 3\n{0} {1}: fields_4.txt:5: is not sorted: 11 g 5 gh\n{0} {1}: input is not in sorted order", ts.bin_path.to_string_lossy(), ts.util_name )); + + new_ucmd!() + .arg("--check-order") + .arg("fields_4.txt") + .arg("fields_5.txt") + .fails() + .stdout_does_not_contain("5 e 3 ef") + .stderr_is(&format!( + "{0} {1}: fields_5.txt:4: is not sorted: 3", + ts.bin_path.to_string_lossy(), + ts.util_name + )); } #[test] @@ -437,3 +475,15 @@ fn null_line_endings() { .succeeds() .stdout_only_fixture("z.expected"); } + +#[test] +#[cfg(any(target_os = "linux", target_os = "freebsd", target_os = "netbsd"))] +fn test_full() { + let dev_full = OpenOptions::new().write(true).open("/dev/full").unwrap(); + new_ucmd!() + .arg("fields_1.txt") + .arg("fields_2.txt") + .set_stdout(dev_full) + .fails() + .stderr_contains("No space left on device"); +}