From 7fbdf2a0317d7d7042196ff9b2f31a71842d9dd8 Mon Sep 17 00:00:00 2001 From: Simon Michael Date: Tue, 12 Sep 2023 17:01:17 +0100 Subject: [PATCH] update example tests --- tests/examples/cat.test | 14 -------------- tests/examples/echo.test | 3 --- tests/examples/examples.test | 23 +++++++++++++++++++++++ tests/print/print-format1.test | 4 ---- 4 files changed, 23 insertions(+), 21 deletions(-) delete mode 100644 tests/examples/cat.test delete mode 100644 tests/examples/echo.test create mode 100644 tests/examples/examples.test diff --git a/tests/examples/cat.test b/tests/examples/cat.test deleted file mode 100644 index fa22bc6..0000000 --- a/tests/examples/cat.test +++ /dev/null @@ -1,14 +0,0 @@ -# Test that the "cat" program copies its input to stdout, -# nothing appears on stderr, and exit status is 0. -cat -<<< -foo ->>> -foo ->>>= 0 - -# Test that cat prints an error containing "unrecognized option" -# (and exits with non-zero status) if given a bad flag. -cat --no-such-flag ->>>2 /(unrecognized|illegal) option/ ->>>= !0 diff --git a/tests/examples/echo.test b/tests/examples/echo.test deleted file mode 100644 index 4d80fb0..0000000 --- a/tests/examples/echo.test +++ /dev/null @@ -1,3 +0,0 @@ -# A comment. Testing bash's builtin "echo" command (if /bin/sh is bash) -echo ->>>= 0 diff --git a/tests/examples/examples.test b/tests/examples/examples.test new file mode 100644 index 0000000..5484787 --- /dev/null +++ b/tests/examples/examples.test @@ -0,0 +1,23 @@ +# 1. Test that the "echo" command (a shell builtin, usually) +# prints its argument on stdout, prints nothing on stderr, +# and exits with a zero exit code. + +$ echo a +a + +# 2. Test that echo with no arguments prints a blank line, +# no stderr output, and exits with zero. +# Since the output ends with whitespace, this time we must write +# the exit code test (>=) explicitly, to act as a delimiter. + +$ echo + +>= + +# 3. Test that cat with a bad flag prints nothing on stdout, +# an error containing "unrecognized option" or "illegal option" on stderr, +# and exits with non-zero status. + +$ cat --no-such-flag +>2 /(unrecognized|illegal) option/ +>= !0 diff --git a/tests/print/print-format1.test b/tests/print/print-format1.test index 583ad2f..163833d 100644 --- a/tests/print/print-format1.test +++ b/tests/print/print-format1.test @@ -1,6 +1,2 @@ -$ shelltest --print=v1 tests/examples/cat.test | diff -u - tests/examples/cat.test - -$ shelltest --print=v1 tests/examples/echo.test | diff -u - tests/examples/echo.test - $ shelltest --print=v1 tests/format1/abstract-test-with-macros | diff -u - tests/format1/abstract-test-with-macros