From a2c811db420717d61bf948afdd879454d9187d38 Mon Sep 17 00:00:00 2001 From: Jim Meyering Date: Tue, 22 Nov 2011 10:08:04 +0100 Subject: 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/' * tests/chgrp/no-x: As above. * tests/chmod/no-x: Likewise. * tests/chmod/silent: Likewise. * tests/chmod/thru-dangling: Likewise. * tests/chown/basic: Likewise. * tests/chown/deref: Likewise. * tests/chown/preserve-root: Likewise. * tests/cp/abuse: Likewise. * tests/cp/backup-is-src: Likewise. * tests/cp/cp-a-selinux: Likewise. * tests/cp/cp-mv-enotsup-xattr: Likewise. * tests/cp/fail-perm: Likewise. * tests/cp/into-self: Likewise. * tests/cp/proc-zero-len: Likewise. * tests/cp/src-base-dot: Likewise. * tests/cp/thru-dangling: Likewise. * tests/dd/reblock: Likewise. * tests/dd/unblock-sync: Likewise. * tests/du/2g: Likewise. * tests/du/8gb: Likewise. * tests/du/basic: Likewise. * tests/du/bigtime: Likewise. * tests/du/deref-args: Likewise. * tests/du/exclude: Likewise. * tests/du/files0-from-dir: Likewise. * tests/du/hard-link: Likewise. * tests/du/inacc-dest: Likewise. * tests/du/inacc-dir: Likewise. * tests/du/long-sloop: Likewise. * tests/du/max-depth: Likewise. * tests/du/move-dir-while-traversing: Likewise. * tests/du/no-deref: Likewise. * tests/du/no-x: Likewise. * tests/du/one-file-system: Likewise. * tests/du/slash: Likewise. * tests/du/trailing-slash: Likewise. * tests/install/strip-program: Likewise. * tests/ln/hard-backup: Likewise. * tests/ls/block-size: Likewise. * tests/ls/color-clear-to-eol: Likewise. * tests/ls/color-dtype-dir: Likewise. * tests/ls/color-norm: Likewise. * tests/ls/dangle: Likewise. * tests/ls/dired: Likewise. * tests/ls/file-type: Likewise. * tests/ls/follow-slink: Likewise. * tests/ls/infloop: Likewise. * tests/ls/m-option: Likewise. * tests/ls/no-arg: Likewise. * tests/ls/recursive: Likewise. * tests/ls/rt-1: Likewise. * tests/ls/stat-dtype: Likewise. * tests/ls/stat-failed: Likewise. * tests/ls/stat-free-symlinks: Likewise. * tests/ls/x-option: Likewise. * tests/misc/arch: Likewise. * tests/misc/cat-buf: Likewise. * tests/misc/cat-proc: Likewise. * tests/misc/chcon: Likewise. * tests/misc/csplit: Likewise. * tests/misc/df-P: Likewise. * tests/misc/fmt-long-line: Likewise. * tests/misc/groups-dash: Likewise. * tests/misc/groups-version: Likewise. * tests/misc/head-pos: Likewise. * tests/misc/nl: Likewise. * tests/misc/od-N: Likewise. * tests/misc/od-multiple-t: Likewise. * tests/misc/od-x8: Likewise. * tests/misc/printf: Likewise. * tests/misc/printf-hex: Likewise. * tests/misc/pwd-option: Likewise. * tests/misc/readlink-fp-loop: Likewise. * tests/misc/runcon-no-reorder: Likewise. * tests/misc/seq-long-double: Likewise. * tests/misc/sort-NaN-infloop: Likewise. * tests/misc/sort-benchmark-random: Likewise. * tests/misc/sort-debug-keys: Likewise. * tests/misc/sort-float: Likewise. * tests/misc/sort-merge-fdlimit: Likewise. * tests/misc/sort-unique-segv: Likewise. * tests/misc/stat-hyphen: Likewise. * tests/misc/stat-slash: Likewise. * tests/misc/stdbuf: Likewise. * tests/misc/sum-sysv: Likewise. * tests/misc/tac-2-nonseekable: Likewise. * tests/misc/tac-continue: Likewise. * tests/misc/tr-case-class: Likewise. * tests/misc/truncate-fail-diag: Likewise. * tests/misc/wc-files0: Likewise. * tests/mkdir/selinux: Likewise. * tests/mv/backup-dir: Likewise. * tests/mv/backup-is-src: Likewise. * tests/mv/diag: Likewise. * tests/mv/dir2dir: Likewise. * tests/mv/dup-source: Likewise. * tests/mv/force: Likewise. * tests/mv/hard-verbose: Likewise. * tests/mv/i-link-no: Likewise. * tests/mv/into-self: Likewise. * tests/mv/into-self-2: Likewise. * tests/mv/into-self-3: Likewise. * tests/mv/mv-special-1: Likewise. * tests/mv/part-fail: Likewise. * tests/mv/perm-1: Likewise. * tests/mv/sticky-to-xpart: Likewise. * tests/mv/trailing-slash: Likewise. * tests/rm/rm1: Likewise. * tests/rm/rm2: Likewise. * tests/rm/cycle: Likewise. * tests/rm/dir-no-w: Likewise. * tests/rm/dir-nonrecur: Likewise. * tests/rm/fail-2eperm: Likewise. * tests/rm/fail-eacces: Likewise. * tests/rm/i-never: Likewise. * tests/rm/inaccessible: Likewise. * tests/rm/interactive-always: Likewise. * tests/rm/interactive-once: Likewise. * tests/rm/isatty: Likewise. * tests/rm/one-file-system: Likewise. * tests/rm/rm3: Likewise. * tests/rm/rm5: Likewise. * tests/rm/unread2: Likewise. * tests/rm/v-slash: Likewise. * tests/sample-test: Likewise. * tests/split/b-chunk: Likewise. * tests/split/fail: Likewise. * tests/split/l-chunk: Likewise. * tests/split/lines: Likewise. * tests/split/r-chunk: Likewise. * tests/split/suffix-length: Likewise. * tests/tail-2/big-4gb: Likewise. * tests/tail-2/follow-name: Likewise. * tests/tail-2/follow-stdin: Likewise. * tests/tail-2/pipe-f: Likewise. * tests/tail-2/pipe-f2: Likewise. * tests/tail-2/start-middle: Likewise. * tests/touch/60-seconds: Likewise. * tests/touch/fail-diag: Likewise. * tests/touch/not-owner: Likewise. * tests/touch/relative: Likewise. --- tests/cp/abuse | 2 +- tests/cp/backup-is-src | 2 +- tests/cp/cp-a-selinux | 4 ++-- tests/cp/cp-mv-enotsup-xattr | 2 +- tests/cp/fail-perm | 4 ++-- tests/cp/into-self | 2 +- tests/cp/proc-zero-len | 2 +- tests/cp/src-base-dot | 2 +- tests/cp/thru-dangling | 4 ++-- 9 files changed, 12 insertions(+), 12 deletions(-) (limited to 'tests/cp') diff --git a/tests/cp/abuse b/tests/cp/abuse index 43b7df0d9..1573ed5b0 100755 --- a/tests/cp/abuse +++ b/tests/cp/abuse @@ -34,7 +34,7 @@ for i in dangling-dest existing-dest; do cp -dR a/1 b/1 c 2> out && fail=1 - compare out exp || fail=1 + compare exp out || fail=1 # When the destination is a dangling symlink, # ensure that cp does not create it. diff --git a/tests/cp/backup-is-src b/tests/cp/backup-is-src index bb6478940..9547c4e7e 100755 --- a/tests/cp/backup-is-src +++ b/tests/cp/backup-is-src @@ -31,6 +31,6 @@ cat > exp <<\EOF XXX: backing up `a' would destroy source; `a~' not copied EOF -compare out2 exp || fail=1 +compare exp out2 || fail=1 Exit $fail diff --git a/tests/cp/cp-a-selinux b/tests/cp/cp-a-selinux index 0f9c14938..7ef24d801 100755 --- a/tests/cp/cp-a-selinux +++ b/tests/cp/cp-a-selinux @@ -100,7 +100,7 @@ cp --preserve=context f g 2> out && fail=1 test -s g && fail=1 sed "s/ .g' to .*//" out > k mv k out -compare out exp || fail=1 +compare exp out || fail=1 rm -f g echo > g @@ -110,6 +110,6 @@ cp -a --preserve=context f g 2> out2 && fail=1 test -s g && fail=1 sed "s/ .g' to .*//" out2 > k mv k out2 -compare out2 exp || fail=1 +compare exp out2 || fail=1 Exit $fail diff --git a/tests/cp/cp-mv-enotsup-xattr b/tests/cp/cp-mv-enotsup-xattr index 32798d2fc..f30358136 100755 --- a/tests/cp/cp-mv-enotsup-xattr +++ b/tests/cp/cp-mv-enotsup-xattr @@ -98,7 +98,7 @@ cp: cannot preserve extended attributes, cp is built without xattr support EOF fi -compare err exp || fail=1 +compare exp err || fail=1 rm -f err noxattr/a diff --git a/tests/cp/fail-perm b/tests/cp/fail-perm index 404c83e39..d05189785 100755 --- a/tests/cp/fail-perm +++ b/tests/cp/fail-perm @@ -47,11 +47,11 @@ cp F symlink 2> out && fail=1 # ...: The file access permissions do not allow the specified action. # to the expected one: sed 's/: The file access permissions.*/: Permission denied/'o1;mv o1 out -compare out exp || fail=1 +compare exp out || fail=1 cp --target-directory=symlink F 2> out && fail=1 sed 's/: The file access permissions.*/: Permission denied/'o1;mv o1 out -compare out exp || fail=1 +compare exp out || fail=1 chmod 700 D diff --git a/tests/cp/into-self b/tests/cp/into-self index deb5a5325..91c3a5a85 100755 --- a/tests/cp/into-self +++ b/tests/cp/into-self @@ -52,6 +52,6 @@ cp: cannot copy a directory, `dir', into itself, `dir/dir' EOF #' -compare out exp || fail=1 +compare exp out || fail=1 Exit $fail diff --git a/tests/cp/proc-zero-len b/tests/cp/proc-zero-len index 53abc43f9..cc6fd0fbc 100755 --- a/tests/cp/proc-zero-len +++ b/tests/cp/proc-zero-len @@ -35,6 +35,6 @@ cp $f exp || fail=1 test -s out && { rm -f out; echo nonempty > out; } test -s exp && { rm -f exp; echo nonempty > exp; } -compare out exp || fail=1 +compare exp out || fail=1 Exit $fail diff --git a/tests/cp/src-base-dot b/tests/cp/src-base-dot index 069c1935c..4ec39a873 100755 --- a/tests/cp/src-base-dot +++ b/tests/cp/src-base-dot @@ -27,6 +27,6 @@ cp --verbose -ab ../x/. . > out 2>&1 || fail=1 cat <<\EOF > exp || fail=1 EOF -compare out exp || fail=1 +compare exp out || fail=1 Exit $fail diff --git a/tests/cp/thru-dangling b/tests/cp/thru-dangling index 62f111587..1c5c12d4c 100755 --- a/tests/cp/thru-dangling +++ b/tests/cp/thru-dangling @@ -29,13 +29,13 @@ echo "cp: not writing through dangling symlink \`dangle'" \ # Starting with 6.9.90, this usage fails, by default: cp f dangle > err 2>&1 && fail=1 -compare err exp-err || fail=1 +compare exp-err err || fail=1 test -f no-such && fail=1 # But you can set POSIXLY_CORRECT to get the historical behavior. env POSIXLY_CORRECT=1 cp f dangle > out 2>&1 || fail=1 cat no-such >> out || fail=1 -compare out exp || fail=1 +compare exp out || fail=1 Exit $fail -- cgit v1.2.3-54-g00ecf