summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJim Meyering <meyering@redhat.com>2011-11-29 17:11:59 +0100
committerJim Meyering <meyering@redhat.com>2011-11-29 17:17:10 +0100
commit31b43733d40d0a919e0af013f48e271f5824200e (patch)
tree7b64f5ec95a771bae76e5d2dad5cbae947e21813
parent5e2baecb26cede9f42456da9593bd0f15af823bb (diff)
downloaddiffutils-31b43733d40d0a919e0af013f48e271f5824200e.tar.gz
tests: use "compare exp out", not "compare out exp"
Likewise, when an empty file is expected, use "compare /dev/null out", not "compare out /dev/null". I.e., specify the expected/desired contents via the first file name. Prompted by a suggestion from Bruno Haible in http://thread.gmane.org/gmane.comp.gnu.grep.bugs/4020/focus=29154 Run these commands: git grep -l -E 'compare [^ ]+ exp' \ |xargs perl -pi -e 's/\b(compare) (\S+) (exp\S*)/$1 $3 $2/' git grep -l -E 'compare [^ ]+ /dev/null' \ |xargs perl -pi -e 's,\b(compare) (\S+) (/dev/null),$1 $3 $2,' But manually convert this one: -compare out exp-$(echo $opt|tr ' ' _) +compare exp-$(echo $opt|tr ' ' _) out and avoid an inappropriate change to cfg.mk.
-rwxr-xr-xtests/basic2
-rwxr-xr-xtests/binary2
-rwxr-xr-xtests/excess-slash4
-rwxr-xr-xtests/function-line-vs-leading-space4
-rwxr-xr-xtests/label-vs-func4
-rwxr-xr-xtests/no-newline-at-eof8
-rwxr-xr-xtests/stdin2
7 files changed, 13 insertions, 13 deletions
diff --git a/tests/basic b/tests/basic
index c1475b3..45b9c9c 100755
--- a/tests/basic
+++ b/tests/basic
@@ -36,7 +36,7 @@ for opt in '' -u -c; do
diff $opt a b > out 2> err; test $? = 1 || fail=1
# Remove date and time.
sed -e 's/^\([-+*][-+*][-+*] [^ ]*\) .*/\1/' out > k; mv k out
- compare out exp-$(echo $opt|tr ' ' _) || fail=1
+ compare exp-$(echo $opt|tr ' ' _) out || fail=1
done
Exit $fail
diff --git a/tests/binary b/tests/binary
index e163f01..02c71a3 100755
--- a/tests/binary
+++ b/tests/binary
@@ -12,6 +12,6 @@ printf '\0'|diff - /dev/null > out 2> err
# diff must exit with status 2, stdout as above, and no stderr.
test $? = 2 || fail=1
compare out out-exp || fail=1
-compare err /dev/null || fail=1
+compare /dev/null err || fail=1
Exit $fail
diff --git a/tests/excess-slash b/tests/excess-slash
index 32ffc89..22c2060 100755
--- a/tests/excess-slash
+++ b/tests/excess-slash
@@ -11,8 +11,8 @@ fail=0
diff -r a b/ > out 2> err && fail=1
# expect no stderr
-compare err /dev/null || fail=1
+compare /dev/null err || fail=1
-compare out expected-out || fail=1
+compare expected-out out || fail=1
Exit $fail
diff --git a/tests/function-line-vs-leading-space b/tests/function-line-vs-leading-space
index 1541365..572427c 100755
--- a/tests/function-line-vs-leading-space
+++ b/tests/function-line-vs-leading-space
@@ -57,9 +57,9 @@ test $? = 1 || fail=1
sed -n '3,$p' out > k && mv k out || fail=1
-compare out exp || fail=1
+compare exp out || fail=1
# expect empty stderr
-compare err /dev/null || fail=1
+compare /dev/null err || fail=1
Exit $fail
diff --git a/tests/label-vs-func b/tests/label-vs-func
index bb2873e..2de61f7 100755
--- a/tests/label-vs-func
+++ b/tests/label-vs-func
@@ -23,9 +23,9 @@ diff -p -u0 a b > out 2> err; test $? = 1 || fail=1
tail -3 out > k && mv k out || fail=1
-compare out exp || fail=1
+compare exp out || fail=1
# expect empty stderr
-compare err /dev/null || fail=1
+compare /dev/null err || fail=1
Exit $fail
diff --git a/tests/no-newline-at-eof b/tests/no-newline-at-eof
index 6052206..14d5f49 100755
--- a/tests/no-newline-at-eof
+++ b/tests/no-newline-at-eof
@@ -35,9 +35,9 @@ diff $opt -U1 a b > out 2> err
test $? = 1 || fail=1
sed -n '/^@@/,$p' out > k && mv k out || fail=1
-compare out exp || fail=1
+compare exp out || fail=1
# expect empty stderr
-compare err /dev/null || fail=1
+compare /dev/null err || fail=1
# Repeat, but with a newline at the end of "a".
echo >> a
@@ -46,8 +46,8 @@ diff $opt -U1 a b > out 2> err
test $? = 1 || fail=1
sed -n '/^@@/,$p' out > k && mv k out || fail=1
-compare out exp2 || fail=1
+compare exp2 out || fail=1
# expect empty stderr
-compare err /dev/null || fail=1
+compare /dev/null err || fail=1
Exit $fail
diff --git a/tests/stdin b/tests/stdin
index 1f006a1..295e98d 100755
--- a/tests/stdin
+++ b/tests/stdin
@@ -19,6 +19,6 @@ echo b > b
diff -u - b < a > out 2> err; test $? = 1 || fail=1
# Remove date and time.
sed -e 's/^\([-+*][-+*][-+*] [^ ]*\) .*/\1/' out > k; mv k out
-compare out exp || fail=1
+compare exp out || fail=1
Exit $fail