maint: add sc_prohibit_or_fail syntax-check

The shell tests should use `cmd ... || fail=1` for detecting errors.
Add a syntax-check to ensure they don't use `cmd ... || fail` which
is a noop.

* cfg.mk (sc_prohibit_or_fail): Add syntax-check, borrowed from coreutils.
This commit is contained in:
Bernhard Voelker 2020-03-14 19:51:33 +01:00
parent 10635bb14a
commit 7d226e6a45

8
cfg.mk
View File

@ -171,6 +171,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: