diff options
author | Jim Meyering <meyering@redhat.com> | 2011-11-29 17:06:11 +0100 |
---|---|---|
committer | Jim Meyering <meyering@redhat.com> | 2011-11-29 17:06:50 +0100 |
commit | 5f2a03af5258eabb1263e58229fd4d1f395ca14a (patch) | |
tree | cf89f94c7a33bfbcccadbedb893a9b6f9a861a0d /tests | |
parent | 8798244b1f23c7df8db079747308c1417254a0ca (diff) | |
download | grep-5f2a03af5258eabb1263e58229fd4d1f395ca14a.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/(compare) (\S+) (exp\S*)/$1 $3 $2/'
git grep -l -E 'compare [^ ]+ /dev/null' \
|xargs perl -pi -e 's/(compare) (\S+) (\/dev\/null)/$1 $3 $2/'
Diffstat (limited to 'tests')
-rwxr-xr-x | tests/backref-word | 2 | ||||
-rwxr-xr-x | tests/case-fold-backref | 2 | ||||
-rwxr-xr-x | tests/case-fold-char-class | 4 | ||||
-rwxr-xr-x | tests/case-fold-char-range | 4 | ||||
-rwxr-xr-x | tests/case-fold-char-type | 4 | ||||
-rwxr-xr-x | tests/char-class-multibyte | 4 | ||||
-rwxr-xr-x | tests/dfaexec-multibyte | 6 | ||||
-rwxr-xr-x | tests/fgrep-infloop | 2 | ||||
-rwxr-xr-x | tests/ignore-mmap | 2 | ||||
-rwxr-xr-x | tests/include-exclude | 14 | ||||
-rw-r--r-- | tests/init.cfg | 2 | ||||
-rwxr-xr-x | tests/max-count-vs-context | 4 | ||||
-rwxr-xr-x | tests/pcre-abort | 2 | ||||
-rwxr-xr-x | tests/pcre-z | 8 | ||||
-rwxr-xr-x | tests/prefix-of-multibyte | 2 | ||||
-rwxr-xr-x | tests/reversed-range-endpoints | 2 | ||||
-rwxr-xr-x | tests/sjis-mb | 4 | ||||
-rwxr-xr-x | tests/warn-char-classes | 2 | ||||
-rwxr-xr-x | tests/word-delim-multibyte | 2 | ||||
-rwxr-xr-x | tests/word-multi-file | 4 |
20 files changed, 38 insertions, 38 deletions
diff --git a/tests/backref-word b/tests/backref-word index adf6a100..557c6d87 100755 --- a/tests/backref-word +++ b/tests/backref-word @@ -8,7 +8,7 @@ fail=0 for LOC in en_US.UTF-8 zh_CN $LOCALE_FR_UTF8; do out=out1-$LOC LC_ALL=$LOC grep -w '\(foo\) \1' exp1 > $out || fail=1 - compare $out exp1 || fail=1 + compare exp1 $out || fail=1 done Exit $fail diff --git a/tests/case-fold-backref b/tests/case-fold-backref index ef9e9bca..dfa41618 100755 --- a/tests/case-fold-backref +++ b/tests/case-fold-backref @@ -8,7 +8,7 @@ fail=0 for LOC in en_US.UTF-8 en_US zh_CN $LOCALE_FR_UTF8 C; do out=out1-$LOC LC_ALL=$LOC grep -Ei '(foo) \1' exp1 > $out || fail=1 - compare $out exp1 || fail=1 + compare exp1 $out || fail=1 done Exit $fail diff --git a/tests/case-fold-char-class b/tests/case-fold-char-class index 018d2d24..ac8f3ee2 100755 --- a/tests/case-fold-char-class +++ b/tests/case-fold-char-class @@ -8,7 +8,7 @@ fail=0 for LOC in en_US.UTF-8 zh_CN $LOCALE_FR_UTF8; do out=out1-$LOC printf 'X\nY\nZ\n' | LC_ALL=$LOC grep -i '[y]' > $out || fail=1 - compare $out exp1 || fail=1 + compare exp1 $out || fail=1 done printf 'y\n' > exp2 || framework_failure_ @@ -16,7 +16,7 @@ printf 'y\n' > exp2 || framework_failure_ for LOC in en_US.UTF-8 zh_CN $LOCALE_FR_UTF8; do out=out2-$LOC printf 'x\ny\nz\n' | LC_ALL=$LOC grep -i '[Y]' > $out || fail=1 - compare $out exp2 || fail=1 + compare exp2 $out || fail=1 done Exit $fail diff --git a/tests/case-fold-char-range b/tests/case-fold-char-range index d0364924..42030243 100755 --- a/tests/case-fold-char-range +++ b/tests/case-fold-char-range @@ -8,7 +8,7 @@ fail=0 for LOC in en_US.UTF-8 zh_CN $LOCALE_FR_UTF8; do out=out1-$LOC printf 'A\n1\nZ\n.\n' | LC_ALL=$LOC grep -i '[a-z]' > $out || fail=1 - compare $out exp1 || fail=1 + compare exp1 $out || fail=1 done # This actually passes also for grep-2.5.3 @@ -17,7 +17,7 @@ printf 'a\nz\n' > exp2 || framework_failure_ for LOC in en_US.UTF-8 zh_CN $LOCALE_FR_UTF8; do out=out2-$LOC printf 'a\n1\nz\n.\n' | LC_ALL=$LOC grep -i '[A-Z]' > $out || fail=1 - compare $out exp2 || fail=1 + compare exp2 $out || fail=1 done Exit $fail diff --git a/tests/case-fold-char-type b/tests/case-fold-char-type index 7ae7d4b5..d5fd67ca 100755 --- a/tests/case-fold-char-type +++ b/tests/case-fold-char-type @@ -8,7 +8,7 @@ fail=0 for LOC in en_US.UTF-8 zh_CN $LOCALE_FR_UTF8; do out=out1-$LOC printf '1\nY\n.\n' | LC_ALL=$LOC grep -i '[[:lower:]]' > $out || fail=1 - compare $out exp1 || fail=1 + compare exp1 $out || fail=1 done printf 'y\n' > exp2 || framework_failure_ @@ -16,7 +16,7 @@ printf 'y\n' > exp2 || framework_failure_ for LOC in en_US.UTF-8 zh_CN $LOCALE_FR_UTF8; do out=out2-$LOC printf '1\ny\n.\n' | LC_ALL=$LOC grep -i '[[:upper:]]' > $out || fail=1 - compare $out exp2 || fail=1 + compare exp2 $out || fail=1 done Exit $fail diff --git a/tests/char-class-multibyte b/tests/char-class-multibyte index 88b8fa07..fae75116 100755 --- a/tests/char-class-multibyte +++ b/tests/char-class-multibyte @@ -11,7 +11,7 @@ fail=0 for LOC in en_US.UTF-8 $LOCALE_FR_UTF8; do out=out1-$LOC printf 'á\nç\né\n' | LC_ALL=$LOC grep '[é]' > $out || fail=1 - compare $out exp1 || fail=1 + compare exp1 $out || fail=1 done printf 'É\n' > exp2 || framework_failure_ @@ -19,7 +19,7 @@ printf 'É\n' > exp2 || framework_failure_ for LOC in en_US.UTF-8 $LOCALE_FR_UTF8; do out=out2-$LOC printf 'Á\nÇ\nÉ\n' | LC_ALL=$LOC grep '[É]' > $out || fail=1 - compare $out exp2 || fail=1 + compare exp2 $out || fail=1 done for LOC in en_US.UTF-8 $LOCALE_FR_UTF8; do diff --git a/tests/dfaexec-multibyte b/tests/dfaexec-multibyte index eea63154..baac9bad 100755 --- a/tests/dfaexec-multibyte +++ b/tests/dfaexec-multibyte @@ -10,15 +10,15 @@ fail=0 for LOC in en_US.UTF-8 zh_CN $LOCALE_FR_UTF8; do out=out1-ab-$LOC LC_ALL=$LOC grep -E '([a]|[b]){2}' < exp1 > $out || fail=1 - compare $out exp1 || fail=1 + compare exp1 $out || fail=1 out=out1-ba-$LOC LC_ALL=$LOC grep -E '([b]|[a]){2}' < exp1 > $out || fail=1 - compare $out exp1 || fail=1 + compare exp1 $out || fail=1 out=out2-$LOC LC_ALL=$LOC grep -E '^([[:digit:]]+[[:space:]]+){2}' < exp2 > $out || fail=1 - compare $out exp2 || fail=1 + compare exp2 $out || fail=1 done diff --git a/tests/fgrep-infloop b/tests/fgrep-infloop index 7ef82971..07a0ce04 100755 --- a/tests/fgrep-infloop +++ b/tests/fgrep-infloop @@ -15,7 +15,7 @@ for LOC in en_US.UTF-8 $LOCALE_FR_UTF8; do encode ABC \ | LC_ALL=$LOC timeout 10s grep -F "$(encode BC)" > $out 2>&1 test $? = 1 || fail=1 - compare $out /dev/null || fail=1 + compare /dev/null $out || fail=1 done Exit $fail diff --git a/tests/ignore-mmap b/tests/ignore-mmap index a7572169..a6d30caf 100755 --- a/tests/ignore-mmap +++ b/tests/ignore-mmap @@ -11,6 +11,6 @@ compare out in || fail=1 grep --mmap b in > out 2>&1 # Expect no match and no output. test $? = 1 || fail=1 -compare out /dev/null || fail=1 +compare /dev/null out || fail=1 Exit $fail diff --git a/tests/include-exclude b/tests/include-exclude index 4be5c785..4249c56a 100755 --- a/tests/include-exclude +++ b/tests/include-exclude @@ -15,32 +15,32 @@ printf '%s\n' x/a:aaa > exp-a || framework_failure_ grep -r --exclude='a*' . x > out || fail=1 sort out > k && mv k out -compare out exp-not-a || fail=1 +compare exp-not-a out || fail=1 grep -r --exclude='[ab]' . x > out || fail=1 sort out > k && mv k out -compare out exp-not-ab || fail=1 +compare exp-not-ab out || fail=1 grep -r --exclude='*d' . x > out || fail=1 sort out > k && mv k out -compare out exp-not-d || fail=1 +compare exp-not-d out || fail=1 grep -r --exclude-dir=dir . x > out || fail=1 sort out > k && mv k out -compare out exp-not-dir || fail=1 +compare exp-not-dir out || fail=1 # Test with a non-glob. grep -r --include=a . x > out || fail=1 # no need to sort -compare out exp-a || fail=1 +compare exp-a out || fail=1 # Also test --include with a "glob". grep -r --include='a*' . x > out || fail=1 # no need to sort -compare out exp-a || fail=1 +compare exp-a out || fail=1 # --include (without --recursive) uses different code grep --include=a '^aaa$' x/* > out || fail=1 -compare out exp-a || fail=1 +compare exp-a out || fail=1 Exit $fail diff --git a/tests/init.cfg b/tests/init.cfg index e04d90f2..772e1192 100644 --- a/tests/init.cfg +++ b/tests/init.cfg @@ -48,7 +48,7 @@ require_timeout_() require_pcre_() { echo . | grep -P . 2>err || skip_ no PCRE support - compare err /dev/null || fail_ PCRE available, but stderr not empty. + compare /dev/null err || fail_ PCRE available, but stderr not empty. } # Some tests would fail without this particular locale. diff --git a/tests/max-count-vs-context b/tests/max-count-vs-context index ec20728a..5633dd6a 100755 --- a/tests/max-count-vs-context +++ b/tests/max-count-vs-context @@ -17,7 +17,7 @@ sed 4q in > exp || framework_failure_ fail=0 grep -m1 -A5 needle in > out 2>err || fail=1 -compare out exp || fail=1 -compare err /dev/null || fail=1 +compare exp out || fail=1 +compare /dev/null err || fail=1 Exit $fail diff --git a/tests/pcre-abort b/tests/pcre-abort index 131fa477..0b605aac 100755 --- a/tests/pcre-abort +++ b/tests/pcre-abort @@ -16,6 +16,6 @@ fail=0 echo aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaab > in || framework_failure_ grep -P '((a+)*)+$' in > out test $? = 2 || fail=1 -compare out /dev/null || fail=1 +compare /dev/null out || fail=1 Exit $fail diff --git a/tests/pcre-z b/tests/pcre-z index 169c44e8..99ebc43c 100755 --- a/tests/pcre-z +++ b/tests/pcre-z @@ -8,16 +8,16 @@ REGEX=a printf "%s\n0" abc def ghi aaa gah | tr 0 \\0 > in grep -z "$REGEX" in > exp 2>err || fail_ 'Cannot do BRE (grep -z) match.' -compare err /dev/null || fail_ 'stderr not empty on grep -z.' +compare /dev/null err || fail_ 'stderr not empty on grep -z.' # Sanity check the output test "$(grep -cz $REGEX in 2>err)" = 3 \ || fail_ 'Incorrect BRE (grep -cz) match.' -compare err /dev/null || fail_ 'stderr not empty on grep -cz.' +compare /dev/null err || fail_ 'stderr not empty on grep -cz.' fail=0 grep -Pz "$REGEX" in > out 2>err || fail=1 -compare out exp || fail=1 -compare err /dev/null || fail=1 +compare exp out || fail=1 +compare /dev/null err || fail=1 Exit $fail diff --git a/tests/prefix-of-multibyte b/tests/prefix-of-multibyte index 851e1f68..b15fa9b3 100755 --- a/tests/prefix-of-multibyte +++ b/tests/prefix-of-multibyte @@ -14,7 +14,7 @@ for LOC in en_US.UTF-8 $LOCALE_FR_UTF8; do out=out-$opt-$LOC encode ABC | LC_ALL=$LOC grep $opt "$(encode A)" > $out 2>&1 test $? = 1 || fail=1 - compare $out /dev/null || fail=1 + compare /dev/null $out || fail=1 done done diff --git a/tests/reversed-range-endpoints b/tests/reversed-range-endpoints index eb845940..92567245 100755 --- a/tests/reversed-range-endpoints +++ b/tests/reversed-range-endpoints @@ -13,7 +13,7 @@ for prog in grep egrep 'grep -E'; do # Remove "program_name: " prefix from actual output. sed 's/^[a-z]*: //' out > k && mv k out - compare out exp || fail=1 + compare exp out || fail=1 done Exit $fail diff --git a/tests/sjis-mb b/tests/sjis-mb index b1ec853d..990c7700 100755 --- a/tests/sjis-mb +++ b/tests/sjis-mb @@ -29,7 +29,7 @@ test_grep_reject() { encode "$2" | \ LC_ALL=$locale \ timeout 10s grep $1 $(encode "$3") > out$k 2>&1 - test $? = 1 && compare out$k /dev/null + test $? = 1 && compare /dev/null out$k } test_grep() { @@ -37,7 +37,7 @@ test_grep() { encode "$2" > exp$k LC_ALL=$locale \ timeout 10s grep $1 $(encode "$3") exp$k > out$k 2>&1 - test $? = 0 && compare out$k exp$k + test $? = 0 && compare exp$k out$k } test "$(get-mb-cur-max $locale)" = 2 || skip_ 'SJIS locale not found' diff --git a/tests/warn-char-classes b/tests/warn-char-classes index 8cc65635..1b49b870 100755 --- a/tests/warn-char-classes +++ b/tests/warn-char-classes @@ -12,7 +12,7 @@ printf 'grep: character class syntax is [[:space:]], not [:space:]\n' \ grep '[:space:]' x 2> err test $? = 2 || fail=1 -compare err exp-err || fail=1 +compare exp-err err || fail=1 grep '[[:space:]]' x 2> err test $? = 1 || fail=1 diff --git a/tests/word-delim-multibyte b/tests/word-delim-multibyte index e0fa2661..b7f1576d 100755 --- a/tests/word-delim-multibyte +++ b/tests/word-delim-multibyte @@ -14,6 +14,6 @@ fail=0 grep "\<$e_acute" in > out 2>err || fail=1 compare out in || fail=1 -compare err /dev/null || fail=1 +compare /dev/null err || fail=1 Exit $fail diff --git a/tests/word-multi-file b/tests/word-multi-file index 6614ab66..1816d606 100755 --- a/tests/word-multi-file +++ b/tests/word-multi-file @@ -21,9 +21,9 @@ sed s/..// exp1 > exp2 || framework_failure_ fail=0 grep -rw bb a > out || fail=1 sort < out > k; mv k out -compare out exp1 || fail=1 +compare exp1 out || fail=1 (cd a && grep -w bb [1-4]) > out || fail=1 -compare out exp2 || fail=1 +compare exp2 out || fail=1 Exit $fail |