comparison scripts/test/cat.test @ 741:cecd0fd45c49

Adding tests for cat
author Elie De Brauwer <eliedebrauwer@gmail.com>
date Sat, 08 Dec 2012 13:28:40 +0100
parents 786841fdb1e0
children
comparison
equal deleted inserted replaced
740:f5ef67700a26 741:cecd0fd45c49
2 2
3 [ -f testing.sh ] && . testing.sh 3 [ -f testing.sh ] && . testing.sh
4 4
5 #testing "name" "command" "result" "infile" "stdin" 5 #testing "name" "command" "result" "infile" "stdin"
6 6
7 echo "one" > file1
8 echo "two" > file2
7 testing "cat" "cat && echo yes" "oneyes\n" "" "one" 9 testing "cat" "cat && echo yes" "oneyes\n" "" "one"
10 testing "cat -" "cat - && echo yes" "oneyes\n" "" "one"
11 testing "cat file1 file2" "cat file1 file2" "one\ntwo\n" "" ""
12 testing "cat - file" "cat - file1" "zero\none\n" "" "zero\n"
13 testing "cat file -" "cat file1 -" "one\nzero\n" "" "zero\n"
14
15 testing "cat file1 notfound file2" \
16 "cat file1 notfound file2 2>stderr && echo ok ; cat stderr; rm stderr" \
17 "one\ntwo\ncat: notfound: No such file or directory\n" "" ""
18
8 testing "cat file1" \ 19 testing "cat file1" \
9 "cat /proc/self/exe > file1 && diff -u /proc/self/exe file1 && echo yes" \ 20 "cat /proc/self/exe > file1 && cmp /proc/self/exe file1 && echo yes" \
10 "yes\n" "" "" 21 "yes\n" "" ""
11 #testing "cat file1 file2" "cat /bin/cat file1 > file2 && diff -u -
12 22
13 testing "cat - file1" \ 23 testing "cat - file1" \
14 "cat - file1 | diff -a -U 0 - file1 | tail -n 1" \ 24 "cat - file1 | diff -a -U 0 - file1 | tail -n 1" \
15 "-hello\n" "" "hello\n" 25 "-hello\n" "" "hello\n"
16 26
17 rm file1 27 testing "cat > /dev/full" \
18 #testing "cat file1 file2" "cat $0" 28 "cat - > /dev/full 2>stderr && echo ok; cat stderr; rm stderr" \
19 #testing "cat - file" 29 "cat: xwrite: No space left on device\n" "" "zero\n"
20 #testing "cat > /dev/full" 30
21 #testing "cat file1 notfound file2" 31 rm file1 file2