• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1#!/bin/bash
2
3[ -f testing.sh ] && . testing.sh
4
5#testing "name" "command" "result" "infile" "stdin"
6
7
8echo -e "one-A\none-B" > file1
9echo -e "two-A\ntwo-B" > file2
10testing "tac" "tac && echo yes" "one-B\none-A\nyes\n" "" "one-A\none-B\n"
11testing "-" "tac - && echo yes" "one-B\none-A\nyes\n" "" "one-A\none-B\n"
12testing "file1 file2" "tac file1 file2" "one-B\none-A\ntwo-B\ntwo-A\n"  "" ""
13testing "- file"      "tac - file1"     "zero-B\nzero-A\none-B\none-A\n" "" "zero-A\nzero-B\n"
14testing "file -"      "tac file1 -"     "one-B\none-A\nzero-B\nzero-A\n" "" "zero-A\nzero-B\n"
15
16testing "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
20testing "no trailing newline" "tac -" "defabc\n" "" "abc\ndef"
21
22# xputs used by tac does not propagate this error condition properly.
23#testing "> /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
29rm file1 file2