Elie De Brauwer | e9e10b5 | 2012-12-15 19:51:43 +0100 | [diff] [blame] | 1 | #!/bin/bash |
| 2 | |
| 3 | [ -f testing.sh ] && . testing.sh |
| 4 | |
| 5 | #testing "name" "command" "result" "infile" "stdin" |
| 6 | |
| 7 | |
| 8 | echo -e "one-A\none-B" > file1 |
| 9 | echo -e "two-A\ntwo-B" > file2 |
| 10 | testing "tac" "tac && echo yes" "one-B\none-A\nyes\n" "" "one-A\none-B\n" |
| 11 | testing "tac -" "tac - && echo yes" "one-B\none-A\nyes\n" "" "one-A\none-B\n" |
| 12 | testing "tac file1 file2" "tac file1 file2" "one-B\none-A\ntwo-B\ntwo-A\n" "" "" |
| 13 | testing "tac - file" "tac - file1" "zero-B\nzero-A\none-B\none-A\n" "" "zero-A\nzero-B\n" |
| 14 | testing "tac file -" "tac file1 -" "one-B\none-A\nzero-B\nzero-A\n" "" "zero-A\nzero-B\n" |
| 15 | |
| 16 | testing "tac file1 notfound file2" \ |
| 17 | "tac file1 notfound file2 2>stderr && echo ok ; tac stderr; rm stderr" \ |
| 18 | "one-B\none-A\ntwo-B\ntwo-A\ntac: notfound: No such file or directory\n" "" "" |
| 19 | |
Elie De Brauwer | de08aef | 2012-12-22 11:50:11 +0100 | [diff] [blame^] | 20 | testing "tac no trailing newline" "tac -" "defabc\n" "" "abc\ndef" |
Elie De Brauwer | e9e10b5 | 2012-12-15 19:51:43 +0100 | [diff] [blame] | 21 | |
| 22 | # xputs used by tac does not propagate this error condition properly. |
| 23 | #testing "tac > /dev/full" \ |
| 24 | # "tac - > /dev/full 2>stderr && echo ok; cat stderr; rm stderr" \ |
| 25 | # "tac: write: No space left on device\n" "" "zero\n" |
| 26 | |
| 27 | # |
| 28 | |
| 29 | rm file1 file2 |