Comparing expected against actual gives more consistent diff listings
when reporting test failures. Enforce this idiom on test files
that use init.sh, and allow projects to recognize an alternate
pattern for recognizing tests scripts that use a compare function.
* top/maint.mk (sc_prohibit_reversed_compare_failure): New rule,
moved here from coreutils.
Signed-off-by: Eric Blake <eblake@redhat.com>
2011-11-29 Eric Blake <eblake@redhat.com>
+ maint.mk: add syntax check for use of compare from init.sh
+ * top/maint.mk (sc_prohibit_reversed_compare_failure): New rule,
+ moved here from coreutils.
+
manywarnings: drop -Wunsuffixed-float-constants
* m4/manywarnings.m4 (gl_MANYWARN_ALL_GCC): C99 does not allow
'1.0D', which is the only way to silence this warning for 'double'.
1>&2; exit 1; } || :; \
fi
+# BRE regex of file contents to identify a test script.
+_test_script_regex ?= \<init\.sh\>
+
+# In tests, use "compare expected actual", not the reverse.
+sc_prohibit_reversed_compare_failure:
+ @prohibit='\<compare [^ ]+ ([^ ]*exp|/dev/null)' \
+ containing='$(_test_script_regex)' \
+ halt='reversed compare arguments' \
+ $(_sc_search_regexp)
+
# #if HAVE_... will evaluate to false for any non numeric string.
# That would be flagged by using -Wundef, however gnulib currently
# tests many undefined macros, and so we can't enable that option.