findutils-patches
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[PATCH 1/6] maint: add sc_prohibit_or_fail syntax-check


From: Bernhard Voelker
Subject: [PATCH 1/6] maint: add sc_prohibit_or_fail syntax-check
Date: Wed, 18 Mar 2020 08:10:03 +0100

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.
---
 cfg.mk | 8 ++++++++
 1 file changed, 8 insertions(+)

diff --git a/cfg.mk b/cfg.mk
index 30a7296a..cd7acced 100644
--- a/cfg.mk
+++ b/cfg.mk
@@ -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:
-- 
2.25.1




reply via email to

[Prev in Thread] Current Thread [Next in Thread]