2 # Copyright 2008 by Denys Vlasenko
3 # Licensed under GPLv2, see file LICENSE in this source tree.
7 # testing "test name" "commands" "expected result" "file input" "stdin"
9 # diff outputs date/time in the header, which should not be analysed
10 # NB: sed has tab character in s command!
11 TRIM_TAB="sed 's/ .*//'"
13 testing "diff of stdin" \
14 "diff -u - input | $TRIM_TAB" \
26 testing "diff of stdin, no newline in the file" \
27 "diff -u - input | $TRIM_TAB" \
35 \\ No newline at end of file
40 # we also test that stdin is in fact NOT read
41 testing "diff of stdin, twice" \
42 'diff - -; echo $?; wc -c' \
47 testing "diff of empty file against stdin" \
48 "diff -u - input | $TRIM_TAB" \
58 testing "diff of empty file against nonempty one" \
59 "diff -u - input | $TRIM_TAB" \
69 testing "diff -b treats EOF as whitespace" \
70 'diff -ub - input; echo $?' \
75 testing "diff -b treats all spaces as equal" \
76 'diff -ub - input; echo $?' \
81 testing "diff -B ignores changes whose lines are all blank" \
82 'diff -uB - input; echo $?' \
87 testing "diff -B does not ignore changes whose lines are not all blank" \
88 "diff -uB - input | $TRIM_TAB" \
101 testing "diff -B ignores blank single line change" \
102 'diff -qB - input; echo $?' \
107 testing "diff -B does not ignore non-blank single line change" \
108 'diff -qB - input; echo $?' \
109 "Files - and input differ\n1\n" \
113 testing "diff always takes context from old file" \
114 "diff -ub - input | $TRIM_TAB" \
126 # testing "test name" "commands" "expected result" "file input" "stdin"
131 mkdir diff1 diff2 diff2/subdir
133 echo asd >diff2/subdir/-
134 optional FEATURE_DIFF_DIR
135 testing "diff diff1 diff2/subdir" \
136 "diff -ur diff1 diff2/subdir | $TRIM_TAB" \
147 # using directory structure from prev test...
148 optional FEATURE_DIFF_DIR
149 testing "diff dir dir2/file/-" \
150 "diff -ur diff1 diff2/subdir/- | $TRIM_TAB" \
161 # using directory structure from prev test...
163 mkfifo diff2/subdir/test
164 optional FEATURE_DIFF_DIR
165 testing "diff of dir and fifo" \
166 "diff -ur diff1 diff2/subdir | $TRIM_TAB" \
173 Only in diff2/subdir: test
178 # using directory structure from prev test...
181 optional FEATURE_DIFF_DIR
182 testing "diff of file and fifo" \
183 "diff -ur diff1 diff2/subdir | $TRIM_TAB" \
190 File diff2/subdir/test is not a regular file or directory and was skipped
195 # using directory structure from prev test...
197 optional FEATURE_DIFF_DIR
198 testing "diff -rN does not read non-regular files" \
199 "diff -urN diff1 diff2/subdir | $TRIM_TAB" \
206 File diff2/subdir/test is not a regular file or directory and was skipped
207 File diff1/test2 is not a regular file or directory and was skipped
215 # NOT using directory structure from prev test...
219 optional FEATURE_DIFF_DIR
220 testing "diff diff1 diff2/" \
221 "diff -ur diff1 diff2/ | $TRIM_TAB; diff -ur .///diff1 diff2//// | $TRIM_TAB" \