mirror of
https://github.com/RGBCube/uutils-coreutils
synced 2025-07-28 03:27:44 +00:00
join: add tests for --check-order and stdout error
This commit is contained in:
parent
41c90d79c4
commit
bf67c5d981
1 changed files with 55 additions and 5 deletions
|
@ -1,6 +1,8 @@
|
||||||
// spell-checker:ignore (words) autoformat
|
// spell-checker:ignore (words) autoformat nocheck
|
||||||
|
|
||||||
use crate::common::util::*;
|
use crate::common::util::*;
|
||||||
|
#[cfg(any(target_os = "linux", target_os = "freebsd", target_os = "netbsd"))]
|
||||||
|
use std::fs::OpenOptions;
|
||||||
#[cfg(unix)]
|
#[cfg(unix)]
|
||||||
use std::{ffi::OsStr, os::unix::ffi::OsStrExt};
|
use std::{ffi::OsStr, os::unix::ffi::OsStrExt};
|
||||||
#[cfg(windows)]
|
#[cfg(windows)]
|
||||||
|
@ -306,6 +308,16 @@ fn missing_format_fields() {
|
||||||
.stdout_only_fixture("missing_format_fields.expected");
|
.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]
|
#[test]
|
||||||
fn wrong_line_order() {
|
fn wrong_line_order() {
|
||||||
let ts = TestScenario::new(util_name!());
|
let ts = TestScenario::new(util_name!());
|
||||||
|
@ -313,11 +325,24 @@ fn wrong_line_order() {
|
||||||
.arg("fields_2.txt")
|
.arg("fields_2.txt")
|
||||||
.arg("fields_4.txt")
|
.arg("fields_4.txt")
|
||||||
.fails()
|
.fails()
|
||||||
|
.stdout_contains("7 g f 4 fg")
|
||||||
.stderr_is(&format!(
|
.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",
|
"{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.bin_path.to_string_lossy(),
|
||||||
ts.util_name
|
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]
|
#[test]
|
||||||
|
@ -327,11 +352,24 @@ fn both_files_wrong_line_order() {
|
||||||
.arg("fields_4.txt")
|
.arg("fields_4.txt")
|
||||||
.arg("fields_5.txt")
|
.arg("fields_5.txt")
|
||||||
.fails()
|
.fails()
|
||||||
|
.stdout_contains("5 e 3 ef")
|
||||||
.stderr_is(&format!(
|
.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",
|
"{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.bin_path.to_string_lossy(),
|
||||||
ts.util_name
|
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]
|
#[test]
|
||||||
|
@ -437,3 +475,15 @@ fn null_line_endings() {
|
||||||
.succeeds()
|
.succeeds()
|
||||||
.stdout_only_fixture("z.expected");
|
.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");
|
||||||
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue