tac.test 1.1 KB

1234567891011121314151617181920212223242526272829
  1. #!/bin/bash
  2. [ -f testing.sh ] && . testing.sh
  3. #testing "name" "command" "result" "infile" "stdin"
  4. echo -e "one-A\none-B" > file1
  5. echo -e "two-A\ntwo-B" > file2
  6. testing "tac" "tac && echo yes" "one-B\none-A\nyes\n" "" "one-A\none-B\n"
  7. testing "-" "tac - && echo yes" "one-B\none-A\nyes\n" "" "one-A\none-B\n"
  8. testing "file1 file2" "tac file1 file2" "one-B\none-A\ntwo-B\ntwo-A\n" "" ""
  9. testing "- file" "tac - file1" "zero-B\nzero-A\none-B\none-A\n" "" "zero-A\nzero-B\n"
  10. testing "file -" "tac file1 -" "one-B\none-A\nzero-B\nzero-A\n" "" "zero-A\nzero-B\n"
  11. testing "file1 notfound file2" \
  12. "tac file1 notfound file2 2>stderr && echo ok ; tac stderr; rm stderr" \
  13. "one-B\none-A\ntwo-B\ntwo-A\ntac: notfound: No such file or directory\n" "" ""
  14. testing "no trailing newline" "tac -" "defabc\n" "" "abc\ndef"
  15. # xputs used by tac does not propagate this error condition properly.
  16. #testing "> /dev/full" \
  17. # "tac - > /dev/full 2>stderr && echo ok; cat stderr; rm stderr" \
  18. # "tac: write: No space left on device\n" "" "zero\n"
  19. #
  20. rm file1 file2