aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorPádraig Brady <P@draigBrady.com>2020-02-29 20:48:58 +0000
committerPádraig Brady <P@draigBrady.com>2020-02-29 22:45:00 +0000
commitea1c1b75153740355fd54c4455237be1f8cbd427 (patch)
tree6144b57ce379287b8e33a476f6db7eb2a90990b8
parenttests: avoid false failures on darwin 19.2.0 (diff)
downloadcoreutils-ea1c1b75153740355fd54c4455237be1f8cbd427.tar.gz
coreutils-ea1c1b75153740355fd54c4455237be1f8cbd427.zip
tests: fix incorrect `|| fail` pattern in tests
* tests/ls/stat-free-symlinks.sh: s/|| fail/|| fail=1/. * tests/misc/tee.sh: Likewise. * tests/touch/relative.sh: Likewise. * cfg.mk (sc_prohibit_or_fail): A new syntax-check to avoid this.
-rw-r--r--cfg.mk8
-rwxr-xr-xtests/ls/stat-free-symlinks.sh2
-rwxr-xr-xtests/misc/tee.sh2
-rwxr-xr-xtests/touch/relative.sh2
4 files changed, 11 insertions, 3 deletions
diff --git a/cfg.mk b/cfg.mk
index c9b8c7af5..bb0960a26 100644
--- a/cfg.mk
+++ b/cfg.mk
@@ -519,6 +519,14 @@ sc_prohibit_and_fail_1:
in_vc_files='^tests/' \
$(_sc_search_regexp)
+# Ensure that tests don't use `cmd ... || fail` as that's a noop.
+sc_prohibit_or_fail:
+ @prohibit='\|\| fail$$' \
+ exclude=':#' \
+ halt='|| fail detected. Please use: || fail=1' \
+ in_vc_files='^tests/' \
+ $(_sc_search_regexp)
+
# Ensure that env vars are not passed through returns_ as
# that was seen to fail on FreeBSD /bin/sh at least
sc_prohibit_env_returns:
diff --git a/tests/ls/stat-free-symlinks.sh b/tests/ls/stat-free-symlinks.sh
index c538a1c51..a786145db 100755
--- a/tests/ls/stat-free-symlinks.sh
+++ b/tests/ls/stat-free-symlinks.sh
@@ -32,7 +32,7 @@ ln -s x link-to-x || framework_failure_
# symlink and an executable file properly.
LS_COLORS='or=0:mi=0:ex=01;32:ln=01;35' \
- strace -qe stat ls -F --color=always x link-to-x > out.tmp 2> err || fail
+ strace -qe stat ls -F --color=always x link-to-x > out.tmp 2> err || fail=1
# Elide info messages strace can send to stdout of the form:
# [ Process PID=1234 runs in 32 bit mode. ]
sed '/Process PID=/d' out.tmp > out
diff --git a/tests/misc/tee.sh b/tests/misc/tee.sh
index f8774787a..d5b3e555b 100755
--- a/tests/misc/tee.sh
+++ b/tests/misc/tee.sh
@@ -37,7 +37,7 @@ done
tee - <sample >out 2>err || fail=1
compare sample ./- || fail=1
compare sample out || fail=1
-compare /dev/null err || fail
+compare /dev/null err || fail=1
# Ensure tee exits early if no more writable outputs
if test -w /dev/full && test -c /dev/full; then
diff --git a/tests/touch/relative.sh b/tests/touch/relative.sh
index 215807f0e..74924e2d1 100755
--- a/tests/touch/relative.sh
+++ b/tests/touch/relative.sh
@@ -26,7 +26,7 @@ TZ=UTC0 touch --date='2004-01-16 12:00 +0000' f || framework_failure_
# Set times back by 5 days.
touch --ref f --date='-5 days' f || fail=1
-TZ=UTC0 ls -og --time-style=+%Y-%m-%d f > out.1 || fail
+TZ=UTC0 ls -og --time-style=+%Y-%m-%d f > out.1 || fail=1
sed 's/ f$//;s/.* //' out.1 > out
cat <<\EOF > exp || framework_failure_