blob: 96f25310395e279acf68c826ec61d4594c4cbb6c [file] [log] [blame]
Elie De Brauwere9e10b52012-12-15 19:51:43 +01001#!/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 -" "tac - && echo yes" "one-B\none-A\nyes\n" "" "one-A\none-B\n"
12testing "tac file1 file2" "tac file1 file2" "one-B\none-A\ntwo-B\ntwo-A\n" "" ""
13testing "tac - file" "tac - file1" "zero-B\nzero-A\none-B\none-A\n" "" "zero-A\nzero-B\n"
14testing "tac file -" "tac file1 -" "one-B\none-A\nzero-B\nzero-A\n" "" "zero-A\nzero-B\n"
15
16testing "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 Brauwerde08aef2012-12-22 11:50:11 +010020testing "tac no trailing newline" "tac -" "defabc\n" "" "abc\ndef"
Elie De Brauwere9e10b52012-12-15 19:51:43 +010021
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
29rm file1 file2