mirror of
https://github.com/RGBCube/uutils-coreutils
synced 2025-07-28 11:37:44 +00:00
tests: Adjust some tests to use improved UChild. test_tac: Ignore pipe tests on windows.
Summary: * Disable test_retry6 on android because of intermittent failures * Use wait() instead of wait_with_output in test_cat, test_cp, test_sort * tests/sort: Simplify usage of test_sigpipe_panic * Fix tests in test_tee. tests/tac: There was a change in the `tests/common/util.rs` test api concerning piped input which may have revealed a bug in the implementation of tac. Please see also https://github.com/uutils/coreutils/pull/4136
This commit is contained in:
parent
4f54eedb74
commit
4a2ced5940
7 changed files with 40 additions and 17 deletions
|
@ -484,9 +484,7 @@ fn test_domain_socket() {
|
||||||
|
|
||||||
let child = new_ucmd!().args(&[socket_path]).run_no_wait();
|
let child = new_ucmd!().args(&[socket_path]).run_no_wait();
|
||||||
barrier.wait();
|
barrier.wait();
|
||||||
let stdout = &child.wait_with_output().unwrap().stdout;
|
child.wait().unwrap().stdout_is("a\tb");
|
||||||
let output = String::from_utf8_lossy(stdout);
|
|
||||||
assert_eq!("a\tb", output);
|
|
||||||
|
|
||||||
thread.join().unwrap();
|
thread.join().unwrap();
|
||||||
}
|
}
|
||||||
|
|
|
@ -2330,10 +2330,7 @@ fn test_copy_contents_fifo() {
|
||||||
// At this point the child process should have terminated
|
// At this point the child process should have terminated
|
||||||
// successfully with no output. The `outfile` should have the
|
// successfully with no output. The `outfile` should have the
|
||||||
// contents of `fifo` copied into it.
|
// contents of `fifo` copied into it.
|
||||||
let output = child.wait_with_output().unwrap();
|
child.wait().unwrap().no_stdout().no_stderr().success();
|
||||||
assert!(output.status.success());
|
|
||||||
assert!(output.stdout.is_empty());
|
|
||||||
assert!(output.stderr.is_empty());
|
|
||||||
assert_eq!(at.read("outfile"), "foo");
|
assert_eq!(at.read("outfile"), "foo");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -977,10 +977,7 @@ fn test_sigpipe_panic() {
|
||||||
// Dropping the stdout should not lead to an error.
|
// Dropping the stdout should not lead to an error.
|
||||||
// The "Broken pipe" error should be silently ignored.
|
// The "Broken pipe" error should be silently ignored.
|
||||||
child.close_stdout();
|
child.close_stdout();
|
||||||
assert_eq!(
|
child.wait().unwrap().no_stderr();
|
||||||
String::from_utf8(child.wait_with_output().unwrap().stderr),
|
|
||||||
Ok(String::new())
|
|
||||||
);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
|
|
|
@ -7,6 +7,8 @@ fn test_invalid_arg() {
|
||||||
}
|
}
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
|
// FIXME: See https://github.com/uutils/coreutils/issues/4204
|
||||||
|
#[cfg(not(windows))]
|
||||||
fn test_stdin_default() {
|
fn test_stdin_default() {
|
||||||
new_ucmd!()
|
new_ucmd!()
|
||||||
.pipe_in("100\n200\n300\n400\n500")
|
.pipe_in("100\n200\n300\n400\n500")
|
||||||
|
@ -15,6 +17,8 @@ fn test_stdin_default() {
|
||||||
}
|
}
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
|
// FIXME: See https://github.com/uutils/coreutils/issues/4204
|
||||||
|
#[cfg(not(windows))]
|
||||||
fn test_stdin_non_newline_separator() {
|
fn test_stdin_non_newline_separator() {
|
||||||
new_ucmd!()
|
new_ucmd!()
|
||||||
.args(&["-s", ":"])
|
.args(&["-s", ":"])
|
||||||
|
@ -24,6 +28,8 @@ fn test_stdin_non_newline_separator() {
|
||||||
}
|
}
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
|
// FIXME: See https://github.com/uutils/coreutils/issues/4204
|
||||||
|
#[cfg(not(windows))]
|
||||||
fn test_stdin_non_newline_separator_before() {
|
fn test_stdin_non_newline_separator_before() {
|
||||||
new_ucmd!()
|
new_ucmd!()
|
||||||
.args(&["-b", "-s", ":"])
|
.args(&["-b", "-s", ":"])
|
||||||
|
@ -76,11 +82,14 @@ fn test_invalid_input() {
|
||||||
}
|
}
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
|
#[cfg(not(windows))] // FIXME: https://github.com/uutils/coreutils/issues/4204
|
||||||
fn test_no_line_separators() {
|
fn test_no_line_separators() {
|
||||||
new_ucmd!().pipe_in("a").succeeds().stdout_is("a");
|
new_ucmd!().pipe_in("a").succeeds().stdout_is("a");
|
||||||
}
|
}
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
|
// FIXME: See https://github.com/uutils/coreutils/issues/4204
|
||||||
|
#[cfg(not(windows))]
|
||||||
fn test_before_trailing_separator_no_leading_separator() {
|
fn test_before_trailing_separator_no_leading_separator() {
|
||||||
new_ucmd!()
|
new_ucmd!()
|
||||||
.arg("-b")
|
.arg("-b")
|
||||||
|
@ -90,6 +99,8 @@ fn test_before_trailing_separator_no_leading_separator() {
|
||||||
}
|
}
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
|
// FIXME: See https://github.com/uutils/coreutils/issues/4204
|
||||||
|
#[cfg(not(windows))]
|
||||||
fn test_before_trailing_separator_and_leading_separator() {
|
fn test_before_trailing_separator_and_leading_separator() {
|
||||||
new_ucmd!()
|
new_ucmd!()
|
||||||
.arg("-b")
|
.arg("-b")
|
||||||
|
@ -99,6 +110,8 @@ fn test_before_trailing_separator_and_leading_separator() {
|
||||||
}
|
}
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
|
// FIXME: See https://github.com/uutils/coreutils/issues/4204
|
||||||
|
#[cfg(not(windows))]
|
||||||
fn test_before_leading_separator_no_trailing_separator() {
|
fn test_before_leading_separator_no_trailing_separator() {
|
||||||
new_ucmd!()
|
new_ucmd!()
|
||||||
.arg("-b")
|
.arg("-b")
|
||||||
|
@ -108,6 +121,8 @@ fn test_before_leading_separator_no_trailing_separator() {
|
||||||
}
|
}
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
|
// FIXME: See https://github.com/uutils/coreutils/issues/4204
|
||||||
|
#[cfg(not(windows))]
|
||||||
fn test_before_no_separator() {
|
fn test_before_no_separator() {
|
||||||
new_ucmd!()
|
new_ucmd!()
|
||||||
.arg("-b")
|
.arg("-b")
|
||||||
|
@ -117,11 +132,15 @@ fn test_before_no_separator() {
|
||||||
}
|
}
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
|
// FIXME: See https://github.com/uutils/coreutils/issues/4204
|
||||||
|
#[cfg(not(windows))]
|
||||||
fn test_before_empty_file() {
|
fn test_before_empty_file() {
|
||||||
new_ucmd!().arg("-b").pipe_in("").succeeds().stdout_is("");
|
new_ucmd!().arg("-b").pipe_in("").succeeds().stdout_is("");
|
||||||
}
|
}
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
|
// FIXME: See https://github.com/uutils/coreutils/issues/4204
|
||||||
|
#[cfg(not(windows))]
|
||||||
fn test_multi_char_separator() {
|
fn test_multi_char_separator() {
|
||||||
new_ucmd!()
|
new_ucmd!()
|
||||||
.args(&["-s", "xx"])
|
.args(&["-s", "xx"])
|
||||||
|
@ -131,6 +150,8 @@ fn test_multi_char_separator() {
|
||||||
}
|
}
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
|
// FIXME: See https://github.com/uutils/coreutils/issues/4204
|
||||||
|
#[cfg(not(windows))]
|
||||||
fn test_multi_char_separator_overlap() {
|
fn test_multi_char_separator_overlap() {
|
||||||
// The right-most pair of "x" characters in the input is treated as
|
// The right-most pair of "x" characters in the input is treated as
|
||||||
// the only line separator. That is, "axxx" is interpreted as having
|
// the only line separator. That is, "axxx" is interpreted as having
|
||||||
|
@ -161,6 +182,8 @@ fn test_multi_char_separator_overlap() {
|
||||||
}
|
}
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
|
// FIXME: See https://github.com/uutils/coreutils/issues/4204
|
||||||
|
#[cfg(not(windows))]
|
||||||
fn test_multi_char_separator_overlap_before() {
|
fn test_multi_char_separator_overlap_before() {
|
||||||
// With the "-b" option, the line separator is assumed to be at the
|
// With the "-b" option, the line separator is assumed to be at the
|
||||||
// beginning of the line. In this case, That is, "axxx" is
|
// beginning of the line. In this case, That is, "axxx" is
|
||||||
|
@ -203,6 +226,8 @@ fn test_multi_char_separator_overlap_before() {
|
||||||
}
|
}
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
|
// FIXME: See https://github.com/uutils/coreutils/issues/4204
|
||||||
|
#[cfg(not(windows))]
|
||||||
fn test_null_separator() {
|
fn test_null_separator() {
|
||||||
new_ucmd!()
|
new_ucmd!()
|
||||||
.args(&["-s", ""])
|
.args(&["-s", ""])
|
||||||
|
@ -212,6 +237,8 @@ fn test_null_separator() {
|
||||||
}
|
}
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
|
// FIXME: See https://github.com/uutils/coreutils/issues/4204
|
||||||
|
#[cfg(not(windows))]
|
||||||
fn test_regex() {
|
fn test_regex() {
|
||||||
new_ucmd!()
|
new_ucmd!()
|
||||||
.args(&["-r", "-s", "[xyz]+"])
|
.args(&["-r", "-s", "[xyz]+"])
|
||||||
|
@ -240,6 +267,8 @@ fn test_regex() {
|
||||||
}
|
}
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
|
// FIXME: See https://github.com/uutils/coreutils/issues/4204
|
||||||
|
#[cfg(not(windows))]
|
||||||
fn test_regex_before() {
|
fn test_regex_before() {
|
||||||
new_ucmd!()
|
new_ucmd!()
|
||||||
.args(&["-b", "-r", "-s", "[xyz]+"])
|
.args(&["-b", "-r", "-s", "[xyz]+"])
|
||||||
|
|
|
@ -1404,8 +1404,12 @@ fn test_retry5() {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// intermittent failures on android with diff
|
||||||
|
// Diff < left / right > :
|
||||||
|
// ==> existing <==
|
||||||
|
// >X
|
||||||
#[test]
|
#[test]
|
||||||
#[cfg(not(target_os = "windows"))] // FIXME: for currently not working platforms
|
#[cfg(all(not(target_os = "windows"), not(target_os = "android")))] // FIXME: for currently not working platforms
|
||||||
fn test_retry6() {
|
fn test_retry6() {
|
||||||
// inspired by: gnu/tests/tail-2/retry.sh
|
// inspired by: gnu/tests/tail-2/retry.sh
|
||||||
// Ensure that --follow=descriptor (without --retry) does *not* try
|
// Ensure that --follow=descriptor (without --retry) does *not* try
|
||||||
|
@ -3002,8 +3006,7 @@ fn test_pipe_when_lines_option_given_input_size_is_one_byte_greater_than_buffer_
|
||||||
// FIXME: windows: this test failed with timeout in the CI. Running this test in
|
// FIXME: windows: this test failed with timeout in the CI. Running this test in
|
||||||
// a Windows VirtualBox image produces no errors.
|
// a Windows VirtualBox image produces no errors.
|
||||||
#[test]
|
#[test]
|
||||||
// TODO: switch back on
|
#[cfg(not(target_os = "windows"))]
|
||||||
// #[cfg(not(target_os = "windows"))]
|
|
||||||
fn test_pipe_when_lines_option_given_input_size_has_multiple_size_of_buffer_size() {
|
fn test_pipe_when_lines_option_given_input_size_has_multiple_size_of_buffer_size() {
|
||||||
let total_lines = 100;
|
let total_lines = 100;
|
||||||
let random_string = RandomString::generate_with_delimiter(
|
let random_string = RandomString::generate_with_delimiter(
|
||||||
|
@ -3310,8 +3313,7 @@ fn test_pipe_when_bytes_option_given_input_size_is_one_byte_greater_than_buffer_
|
||||||
// FIXME: windows: this test failed with timeout in the CI. Running this test in
|
// FIXME: windows: this test failed with timeout in the CI. Running this test in
|
||||||
// a Windows VirtualBox image produces no errors.
|
// a Windows VirtualBox image produces no errors.
|
||||||
#[test]
|
#[test]
|
||||||
// TODO: switch back on
|
#[cfg(not(target_os = "windows"))]
|
||||||
// #[cfg(not(target_os = "windows"))]
|
|
||||||
fn test_pipe_when_bytes_option_given_input_size_has_multiple_size_of_buffer_size() {
|
fn test_pipe_when_bytes_option_given_input_size_has_multiple_size_of_buffer_size() {
|
||||||
let random_string = RandomString::generate(AlphanumericNewline, CHUNK_BUFFER_SIZE * 3);
|
let random_string = RandomString::generate(AlphanumericNewline, CHUNK_BUFFER_SIZE * 3);
|
||||||
let random_string = random_string.as_str();
|
let random_string = random_string.as_str();
|
||||||
|
|
|
@ -134,6 +134,7 @@ mod linux_only {
|
||||||
|
|
||||||
#[allow(deprecated)]
|
#[allow(deprecated)]
|
||||||
let output = proc
|
let output = proc
|
||||||
|
.ignore_stdin_write_error()
|
||||||
.run_no_wait()
|
.run_no_wait()
|
||||||
.pipe_in_and_wait_with_output(content.as_bytes());
|
.pipe_in_and_wait_with_output(content.as_bytes());
|
||||||
|
|
||||||
|
|
|
@ -362,7 +362,6 @@ impl CmdResult {
|
||||||
self.no_stderr().stdout_is_bytes(msg)
|
self.no_stderr().stdout_is_bytes(msg)
|
||||||
}
|
}
|
||||||
|
|
||||||
// TODO: implement same functionality asserting as String instead
|
|
||||||
/// like stdout_only(...), but expects the contents of the file at the provided relative path
|
/// like stdout_only(...), but expects the contents of the file at the provided relative path
|
||||||
pub fn stdout_only_fixture<T: AsRef<OsStr>>(&self, file_rel_path: T) -> &Self {
|
pub fn stdout_only_fixture<T: AsRef<OsStr>>(&self, file_rel_path: T) -> &Self {
|
||||||
let contents = read_scenario_fixture(&self.tmpd, file_rel_path);
|
let contents = read_scenario_fixture(&self.tmpd, file_rel_path);
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue