diff --git a/tests/by-util/test_comm.rs b/tests/by-util/test_comm.rs index b62febf5047..c0818ba8703 100644 --- a/tests/by-util/test_comm.rs +++ b/tests/by-util/test_comm.rs @@ -2,7 +2,7 @@ // // For the full copyright and license information, please view the LICENSE // file that was distributed with this source code. -// spell-checker:ignore (words) defaultcheck nocheck +// spell-checker:ignore (words) defaultcheck nocheck helpb helpz nwordb nwordwordz wordtotal use crate::common::util::TestScenario; @@ -13,111 +13,169 @@ fn test_invalid_arg() { #[test] fn ab_no_args() { - new_ucmd!() - .args(&["a", "b"]) - .succeeds() - .stdout_only_fixture("ab.expected"); -} + let scene = TestScenario::new(util_name!()); + let at = &scene.fixtures; + at.write("a", "a\nz\n"); + at.write("b", "b\nz\n"); -#[test] -fn ab_dash_one() { - new_ucmd!() - .args(&["a", "b", "-1"]) + scene + .ucmd() + .args(&["a", "b"]) .succeeds() - .stdout_only_fixture("ab1.expected"); + .stdout_is("a\n\tb\n\t\tz\n"); } #[test] fn ab_dash_two() { - new_ucmd!() + let scene = TestScenario::new(util_name!()); + let at = &scene.fixtures; + at.write("a", "a\nz\n"); + at.write("b", "b\nz\n"); + + scene + .ucmd() .args(&["a", "b", "-2"]) .succeeds() - .stdout_only_fixture("ab2.expected"); + .stdout_is("a\n\tz\n"); } #[test] fn ab_dash_three() { - new_ucmd!() + let scene = TestScenario::new(util_name!()); + let at = &scene.fixtures; + at.write("a", "a\nz\n"); + at.write("b", "b\nz\n"); + + scene + .ucmd() .args(&["a", "b", "-3"]) .succeeds() - .stdout_only_fixture("ab3.expected"); + .stdout_is("a\n\tb\n"); } - #[test] fn a_empty() { - new_ucmd!() + let scene = TestScenario::new(util_name!()); + let at = &scene.fixtures; + at.write("a", "a\nz\n"); + at.touch("empty"); + scene + .ucmd() .args(&["a", "empty"]) .succeeds() - .stdout_only_fixture("aempty.expected"); // spell-checker:disable-line + .stdout_is("a\nz\n"); } #[test] fn empty_empty() { - new_ucmd!() + let scene = TestScenario::new(util_name!()); + let at = &scene.fixtures; + at.touch("empty"); + scene + .ucmd() .args(&["empty", "empty"]) .succeeds() - .stdout_only_fixture("emptyempty.expected"); // spell-checker:disable-line + .no_output(); } #[test] fn total() { - new_ucmd!() + let scene = TestScenario::new(util_name!()); + let at = &scene.fixtures; + at.write("a", "a\nz\n"); + at.write("b", "b\nz\n"); + scene + .ucmd() .args(&["--total", "a", "b"]) .succeeds() - .stdout_is_fixture("ab_total.expected"); + .stdout_is("a\n\tb\n\t\tz\n1\t1\t1\ttotal\n"); } #[test] fn total_with_suppressed_regular_output() { - new_ucmd!() + let scene = TestScenario::new(util_name!()); + let at = &scene.fixtures; + at.write("a", "a\nz\n"); + at.write("b", "b\nz\n"); + scene + .ucmd() .args(&["--total", "-123", "a", "b"]) .succeeds() - .stdout_is_fixture("ab_total_suppressed_regular_output.expected"); + .stdout_is("1\t1\t1\ttotal\n"); } #[test] fn repeated_flags() { - new_ucmd!() + let scene = TestScenario::new(util_name!()); + let at = &scene.fixtures; + at.write("a", "a\nz\n"); + at.write("b", "b\nz\n"); + scene + .ucmd() .args(&["--total", "-123123", "--total", "a", "b"]) .succeeds() - .stdout_is_fixture("ab_total_suppressed_regular_output.expected"); + .stdout_is("1\t1\t1\ttotal\n"); } #[test] fn total_with_output_delimiter() { - new_ucmd!() + let scene = TestScenario::new(util_name!()); + let at = &scene.fixtures; + at.write("a", "a\nz\n"); + at.write("b", "b\nz\n"); + scene + .ucmd() .args(&["--total", "--output-delimiter=word", "a", "b"]) .succeeds() - .stdout_is_fixture("ab_total_delimiter_word.expected"); + .stdout_is("a\nwordb\nwordwordz\n1word1word1wordtotal\n"); } #[test] fn output_delimiter() { - new_ucmd!() + let scene = TestScenario::new(util_name!()); + let at = &scene.fixtures; + at.write("a", "a\nz\n"); + at.write("b", "b\nz\n"); + scene + .ucmd() .args(&["--output-delimiter=word", "a", "b"]) .succeeds() - .stdout_only_fixture("ab_delimiter_word.expected"); + .stdout_is("a\nwordb\nwordwordz\n"); } #[test] fn output_delimiter_hyphen_one() { - new_ucmd!() + let scene = TestScenario::new(util_name!()); + let at = &scene.fixtures; + at.write("a", "a\nz\n"); + at.write("b", "b\nz\n"); + scene + .ucmd() .args(&["--output-delimiter", "-1", "a", "b"]) .succeeds() - .stdout_only_fixture("ab_delimiter_hyphen_one.expected"); + .stdout_is("a\n-1b\n-1-1z\n"); } #[test] fn output_delimiter_hyphen_help() { - new_ucmd!() + let scene = TestScenario::new(util_name!()); + let at = &scene.fixtures; + at.write("a", "a\nz\n"); + at.write("b", "b\nz\n"); + scene + .ucmd() .args(&["--output-delimiter", "--help", "a", "b"]) .succeeds() - .stdout_only_fixture("ab_delimiter_hyphen_help.expected"); + .stdout_is("a\n--helpb\n--help--helpz\n"); } #[test] fn output_delimiter_multiple_identical() { - new_ucmd!() + let scene = TestScenario::new(util_name!()); + let at = &scene.fixtures; + at.write("a", "a\nz\n"); + at.write("b", "b\nz\n"); + scene + .ucmd() .args(&[ "--output-delimiter=word", "--output-delimiter=word", @@ -125,12 +183,17 @@ fn output_delimiter_multiple_identical() { "b", ]) .succeeds() - .stdout_only_fixture("ab_delimiter_word.expected"); + .stdout_is("a\nwordb\nwordwordz\n"); } #[test] fn output_delimiter_multiple_different() { - new_ucmd!() + let scene = TestScenario::new(util_name!()); + let at = &scene.fixtures; + at.write("a", "a\nz\n"); + at.write("b", "b\nz\n"); + scene + .ucmd() .args(&[ "--output-delimiter=word", "--output-delimiter=other", @@ -147,7 +210,12 @@ fn output_delimiter_multiple_different() { #[test] #[ignore = "This is too weird; deviate intentionally."] fn output_delimiter_multiple_different_prevents_help() { - new_ucmd!() + let scene = TestScenario::new(util_name!()); + let at = &scene.fixtures; + at.write("a", "a\nz\n"); + at.write("b", "b\nz\n"); + scene + .ucmd() .args(&[ "--output-delimiter=word", "--output-delimiter=other", @@ -164,59 +232,92 @@ fn output_delimiter_multiple_different_prevents_help() { #[test] fn output_delimiter_nul() { - new_ucmd!() + let scene = TestScenario::new(util_name!()); + let at = &scene.fixtures; + at.write("a", "a\nz\n"); + at.write("b", "b\nz\n"); + scene + .ucmd() .args(&["--output-delimiter=", "a", "b"]) .succeeds() - .stdout_only_fixture("ab_delimiter_nul.expected"); + .stdout_is("a\n\0b\n\0\0z\n"); } #[test] fn zero_terminated() { + let scene = TestScenario::new(util_name!()); + let at = &scene.fixtures; + + at.write("a_nul", "a\0z\0"); + at.write("b_nul", "b\0z\0"); for param in ["-z", "--zero-terminated"] { - new_ucmd!() + scene + .ucmd() .args(&[param, "a_nul", "b_nul"]) .succeeds() - .stdout_only_fixture("ab_nul.expected"); + .stdout_is("a\0\tb\0\t\tz\0"); } } #[test] fn zero_terminated_provided_multiple_times() { + let scene = TestScenario::new(util_name!()); + let at = &scene.fixtures; + + at.write("a_nul", "a\0z\0"); + at.write("b_nul", "b\0z\0"); for param in ["-z", "--zero-terminated"] { - new_ucmd!() + scene + .ucmd() .args(&[param, param, param, "a_nul", "b_nul"]) .succeeds() - .stdout_only_fixture("ab_nul.expected"); + .stdout_is("a\0\tb\0\t\tz\0"); } } #[test] fn zero_terminated_with_total() { + let scene = TestScenario::new(util_name!()); + let at = &scene.fixtures; + + at.write("a_nul", "a\0z\0"); + at.write("b_nul", "b\0z\0"); + for param in ["-z", "--zero-terminated"] { - new_ucmd!() + scene + .ucmd() .args(&[param, "--total", "a_nul", "b_nul"]) .succeeds() - .stdout_only_fixture("ab_nul_total.expected"); + .stdout_is("a\0\tb\0\t\tz\x001\t1\t1\ttotal\0"); } } #[cfg_attr(not(feature = "test_unimplemented"), ignore)] #[test] fn check_order() { - new_ucmd!() + let scene = TestScenario::new(util_name!()); + let at = &scene.fixtures; + at.write("bad_order_1", "e\nd\nb\na\n"); + at.write("bad_order_2", "e\nc\nb\na\n"); + scene + .ucmd() .args(&["--check-order", "bad_order_1", "bad_order_2"]) .fails() - .stdout_is_fixture("bad_order12.check_order.expected") + .stdout_is("\t\te") .stderr_is("error to be defined"); } #[cfg_attr(not(feature = "test_unimplemented"), ignore)] #[test] fn nocheck_order() { + let scene = TestScenario::new(util_name!()); + let at = &scene.fixtures; + at.write("bad_order_1", "e\nd\nb\na\n"); + at.write("bad_order_2", "e\nc\nb\na\n"); new_ucmd!() .args(&["--nocheck-order", "bad_order_1", "bad_order_2"]) .succeeds() - .stdout_only_fixture("bad_order12.nocheck_order.expected"); + .stdout_is("\t\te\n\tc\n\tb\n\ta\nd\nb\na\n"); } // when neither --check-order nor --no-check-order is provided, @@ -225,6 +326,9 @@ fn nocheck_order() { #[cfg_attr(not(feature = "test_unimplemented"), ignore)] #[test] fn defaultcheck_order() { + let scene = TestScenario::new(util_name!()); + let at = &scene.fixtures; + at.write("bad_order_1", "e\nd\nb\na\n"); new_ucmd!() .args(&["a", "bad_order_1"]) .fails() @@ -240,19 +344,28 @@ fn defaultcheck_order() { #[test] fn defaultcheck_order_identical_bad_order_files() { - new_ucmd!() + let scene = TestScenario::new(util_name!()); + let at = &scene.fixtures; + at.write("bad_order_1", "e\nd\nb\na\n"); + scene + .ucmd() .args(&["bad_order_1", "bad_order_1"]) .succeeds() - .stdout_only_fixture("bad_order11.defaultcheck_order.expected"); + .stdout_is("\t\te\n\t\td\n\t\tb\n\t\ta\n"); } #[cfg_attr(not(feature = "test_unimplemented"), ignore)] #[test] fn defaultcheck_order_two_different_bad_order_files() { - new_ucmd!() + let scene = TestScenario::new(util_name!()); + let at = &scene.fixtures; + at.write("bad_order_1", "e\nd\nb\na\n"); + at.write("bad_order_2", "e\nc\nb\na\n"); + scene + .ucmd() .args(&["bad_order_1", "bad_order_2"]) .fails() - .stdout_is_fixture("bad_order12.nocheck_order.expected") + .stdout_is("\t\te\n\tc\n\tb\n\ta\nd\nb\na\n") .stderr_is("error to be defined"); } @@ -269,10 +382,15 @@ fn defaultcheck_order_two_different_bad_order_files() { #[cfg_attr(not(feature = "test_unimplemented"), ignore)] #[test] fn unintuitive_default_behavior_1() { - new_ucmd!() + let scene = TestScenario::new(util_name!()); + let at = &scene.fixtures; + at.write("defaultcheck_unintuitive_1", "m\nh\nn\no\nc\np\n"); + at.write("defaultcheck_unintuitive_2", "m\nh\nn\no\np\n"); + scene + .ucmd() .args(&["defaultcheck_unintuitive_1", "defaultcheck_unintuitive_2"]) .succeeds() - .stdout_only_fixture("defaultcheck_unintuitive.expected"); + .stdout_is("\t\tm\n\t\th\n\t\tn\n\t\to\nc\n\t\tp\n"); } #[test] diff --git a/tests/fixtures/comm/a b/tests/fixtures/comm/a deleted file mode 100644 index 58f424cdb4f..00000000000 --- a/tests/fixtures/comm/a +++ /dev/null @@ -1,2 +0,0 @@ -a -z diff --git a/tests/fixtures/comm/a_nul b/tests/fixtures/comm/a_nul deleted file mode 100644 index 3142c801ccd..00000000000 Binary files a/tests/fixtures/comm/a_nul and /dev/null differ diff --git a/tests/fixtures/comm/ab.expected b/tests/fixtures/comm/ab.expected deleted file mode 100644 index 0efac0666b0..00000000000 --- a/tests/fixtures/comm/ab.expected +++ /dev/null @@ -1,3 +0,0 @@ -a - b - z diff --git a/tests/fixtures/comm/ab1.expected b/tests/fixtures/comm/ab1.expected deleted file mode 100644 index 7c81c8ba7cb..00000000000 --- a/tests/fixtures/comm/ab1.expected +++ /dev/null @@ -1,2 +0,0 @@ -b - z diff --git a/tests/fixtures/comm/ab2.expected b/tests/fixtures/comm/ab2.expected deleted file mode 100644 index c98cd0da66d..00000000000 --- a/tests/fixtures/comm/ab2.expected +++ /dev/null @@ -1,2 +0,0 @@ -a - z diff --git a/tests/fixtures/comm/ab3.expected b/tests/fixtures/comm/ab3.expected deleted file mode 100644 index 1898bc804f2..00000000000 --- a/tests/fixtures/comm/ab3.expected +++ /dev/null @@ -1,2 +0,0 @@ -a - b diff --git a/tests/fixtures/comm/ab_delimiter_hyphen_help.expected b/tests/fixtures/comm/ab_delimiter_hyphen_help.expected deleted file mode 100644 index c245aa27f13..00000000000 --- a/tests/fixtures/comm/ab_delimiter_hyphen_help.expected +++ /dev/null @@ -1,3 +0,0 @@ -a ---helpb ---help--helpz diff --git a/tests/fixtures/comm/ab_delimiter_hyphen_one.expected b/tests/fixtures/comm/ab_delimiter_hyphen_one.expected deleted file mode 100644 index 458f98dd42f..00000000000 --- a/tests/fixtures/comm/ab_delimiter_hyphen_one.expected +++ /dev/null @@ -1,3 +0,0 @@ -a --1b --1-1z diff --git a/tests/fixtures/comm/ab_delimiter_nul.expected b/tests/fixtures/comm/ab_delimiter_nul.expected deleted file mode 100644 index e56ec5cd789..00000000000 Binary files a/tests/fixtures/comm/ab_delimiter_nul.expected and /dev/null differ diff --git a/tests/fixtures/comm/ab_delimiter_word.expected b/tests/fixtures/comm/ab_delimiter_word.expected deleted file mode 100644 index a0c510e2071..00000000000 --- a/tests/fixtures/comm/ab_delimiter_word.expected +++ /dev/null @@ -1,3 +0,0 @@ -a -wordb -wordwordz diff --git a/tests/fixtures/comm/ab_nul.expected b/tests/fixtures/comm/ab_nul.expected deleted file mode 100644 index f826106bb19..00000000000 Binary files a/tests/fixtures/comm/ab_nul.expected and /dev/null differ diff --git a/tests/fixtures/comm/ab_nul_total.expected b/tests/fixtures/comm/ab_nul_total.expected deleted file mode 100644 index 9f46f9558b1..00000000000 Binary files a/tests/fixtures/comm/ab_nul_total.expected and /dev/null differ diff --git a/tests/fixtures/comm/ab_total.expected b/tests/fixtures/comm/ab_total.expected deleted file mode 100644 index 430354a6620..00000000000 --- a/tests/fixtures/comm/ab_total.expected +++ /dev/null @@ -1,4 +0,0 @@ -a - b - z -1 1 1 total diff --git a/tests/fixtures/comm/ab_total_delimiter_word.expected b/tests/fixtures/comm/ab_total_delimiter_word.expected deleted file mode 100644 index f7215ea28a3..00000000000 --- a/tests/fixtures/comm/ab_total_delimiter_word.expected +++ /dev/null @@ -1,4 +0,0 @@ -a -wordb -wordwordz -1word1word1wordtotal diff --git a/tests/fixtures/comm/ab_total_suppressed_regular_output.expected b/tests/fixtures/comm/ab_total_suppressed_regular_output.expected deleted file mode 100644 index 733c1d344e5..00000000000 --- a/tests/fixtures/comm/ab_total_suppressed_regular_output.expected +++ /dev/null @@ -1 +0,0 @@ -1 1 1 total diff --git a/tests/fixtures/comm/aempty.expected b/tests/fixtures/comm/aempty.expected deleted file mode 100644 index 58f424cdb4f..00000000000 --- a/tests/fixtures/comm/aempty.expected +++ /dev/null @@ -1,2 +0,0 @@ -a -z diff --git a/tests/fixtures/comm/b b/tests/fixtures/comm/b deleted file mode 100644 index 63d7d705891..00000000000 --- a/tests/fixtures/comm/b +++ /dev/null @@ -1,2 +0,0 @@ -b -z diff --git a/tests/fixtures/comm/b_nul b/tests/fixtures/comm/b_nul deleted file mode 100644 index ca4569669d4..00000000000 Binary files a/tests/fixtures/comm/b_nul and /dev/null differ diff --git a/tests/fixtures/comm/bad_order11.defaultcheck_order.expected b/tests/fixtures/comm/bad_order11.defaultcheck_order.expected deleted file mode 100644 index 81aa48629c9..00000000000 --- a/tests/fixtures/comm/bad_order11.defaultcheck_order.expected +++ /dev/null @@ -1,4 +0,0 @@ - e - d - b - a diff --git a/tests/fixtures/comm/bad_order12.check_order.expected b/tests/fixtures/comm/bad_order12.check_order.expected deleted file mode 100644 index 3930ff03699..00000000000 --- a/tests/fixtures/comm/bad_order12.check_order.expected +++ /dev/null @@ -1 +0,0 @@ - e diff --git a/tests/fixtures/comm/bad_order12.nocheck_order.expected b/tests/fixtures/comm/bad_order12.nocheck_order.expected deleted file mode 100644 index b5711801391..00000000000 --- a/tests/fixtures/comm/bad_order12.nocheck_order.expected +++ /dev/null @@ -1,7 +0,0 @@ - e - c - b - a -d -b -a diff --git a/tests/fixtures/comm/bad_order_1 b/tests/fixtures/comm/bad_order_1 deleted file mode 100644 index 2ebde65a6a1..00000000000 --- a/tests/fixtures/comm/bad_order_1 +++ /dev/null @@ -1,4 +0,0 @@ -e -d -b -a diff --git a/tests/fixtures/comm/bad_order_2 b/tests/fixtures/comm/bad_order_2 deleted file mode 100644 index 76603aeded1..00000000000 --- a/tests/fixtures/comm/bad_order_2 +++ /dev/null @@ -1,4 +0,0 @@ -e -c -b -a diff --git a/tests/fixtures/comm/defaultcheck_unintuitive.expected b/tests/fixtures/comm/defaultcheck_unintuitive.expected deleted file mode 100644 index 132eab5b250..00000000000 --- a/tests/fixtures/comm/defaultcheck_unintuitive.expected +++ /dev/null @@ -1,6 +0,0 @@ - m - h - n - o -c - p diff --git a/tests/fixtures/comm/defaultcheck_unintuitive_1 b/tests/fixtures/comm/defaultcheck_unintuitive_1 deleted file mode 100644 index f32fc1fd758..00000000000 --- a/tests/fixtures/comm/defaultcheck_unintuitive_1 +++ /dev/null @@ -1,6 +0,0 @@ -m -h -n -o -c -p diff --git a/tests/fixtures/comm/defaultcheck_unintuitive_2 b/tests/fixtures/comm/defaultcheck_unintuitive_2 deleted file mode 100644 index 212de88c4d0..00000000000 --- a/tests/fixtures/comm/defaultcheck_unintuitive_2 +++ /dev/null @@ -1,5 +0,0 @@ -m -h -n -o -p diff --git a/tests/fixtures/comm/empty b/tests/fixtures/comm/empty deleted file mode 100644 index e69de29bb2d..00000000000 diff --git a/tests/fixtures/comm/emptyempty.expected b/tests/fixtures/comm/emptyempty.expected deleted file mode 100644 index e69de29bb2d..00000000000 diff --git a/tests/fixtures/comm/lowercase_uppercase b/tests/fixtures/comm/lowercase_uppercase deleted file mode 100644 index 768ebc2b947..00000000000 --- a/tests/fixtures/comm/lowercase_uppercase +++ /dev/null @@ -1,2 +0,0 @@ -a -A \ No newline at end of file diff --git a/tests/fixtures/comm/lowercase_uppercase.c.expected b/tests/fixtures/comm/lowercase_uppercase.c.expected deleted file mode 100644 index 8458d7960bc..00000000000 --- a/tests/fixtures/comm/lowercase_uppercase.c.expected +++ /dev/null @@ -1 +0,0 @@ - a diff --git a/tests/fixtures/comm/lowercase_uppercase.en_us.expected b/tests/fixtures/comm/lowercase_uppercase.en_us.expected deleted file mode 100644 index 3992b34d039..00000000000 --- a/tests/fixtures/comm/lowercase_uppercase.en_us.expected +++ /dev/null @@ -1,2 +0,0 @@ - a - A