# HG changeset patch # User Elie De Brauwer # Date 1355597503 -3600 # Node ID d020ee45c2278b2d440daa59f8d85b3deb443577 # Parent f7eaff0c8d0cf3b32b8f29f7411862aea705a3a8 Adding tests for tac based on cat tests diff -r f7eaff0c8d0c -r d020ee45c227 scripts/test/tac.test --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/scripts/test/tac.test Sat Dec 15 19:51:43 2012 +0100 @@ -0,0 +1,30 @@ +#!/bin/bash + +[ -f testing.sh ] && . testing.sh + +#testing "name" "command" "result" "infile" "stdin" + + +echo -e "one-A\none-B" > file1 +echo -e "two-A\ntwo-B" > file2 +testing "tac" "tac && echo yes" "one-B\none-A\nyes\n" "" "one-A\none-B\n" +testing "tac -" "tac - && echo yes" "one-B\none-A\nyes\n" "" "one-A\none-B\n" +testing "tac file1 file2" "tac file1 file2" "one-B\none-A\ntwo-B\ntwo-A\n" "" "" +testing "tac - file" "tac - file1" "zero-B\nzero-A\none-B\none-A\n" "" "zero-A\nzero-B\n" +testing "tac file -" "tac file1 -" "one-B\none-A\nzero-B\nzero-A\n" "" "zero-A\nzero-B\n" + +testing "tac file1 notfound file2" \ + "tac file1 notfound file2 2>stderr && echo ok ; tac stderr; rm stderr" \ + "one-B\none-A\ntwo-B\ntwo-A\ntac: notfound: No such file or directory\n" "" "" + +# echo -ne "abc\ndef" | tac actually gives "defabc\n" +testing "tac no trailing newline" "tac -" "def\nabc\n" "" "abc\ndef" + +# xputs used by tac does not propagate this error condition properly. +#testing "tac > /dev/full" \ +# "tac - > /dev/full 2>stderr && echo ok; cat stderr; rm stderr" \ +# "tac: write: No space left on device\n" "" "zero\n" + +# + +rm file1 file2 \ No newline at end of file