[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[bug-diffutils] [PATCH] tests: use "compare exp out", not "compare out e
From: |
Jim Meyering |
Subject: |
[bug-diffutils] [PATCH] tests: use "compare exp out", not "compare out exp" |
Date: |
Tue, 29 Nov 2011 17:38:07 +0100 |
Test normalization:
>From 31b43733d40d0a919e0af013f48e271f5824200e Mon Sep 17 00:00:00 2001
From: Jim Meyering <address@hidden>
Date: Tue, 29 Nov 2011 17:11:59 +0100
Subject: [PATCH] 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.
---
tests/basic | 2 +-
tests/binary | 2 +-
tests/excess-slash | 4 ++--
tests/function-line-vs-leading-space | 4 ++--
tests/label-vs-func | 4 ++--
tests/no-newline-at-eof | 8 ++++----
tests/stdin | 2 +-
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
--
1.7.8.rc4
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [bug-diffutils] [PATCH] tests: use "compare exp out", not "compare out exp",
Jim Meyering <=