From e96f7d5658950ddee68e54fba4b6321b9a6a2ed8 Mon Sep 17 00:00:00 2001 From: Austin English Date: Fri, 19 Oct 2018 14:59:23 -0500 Subject: [PATCH] src/tests/runtests.sh: add a FATAL_CHECKS variable to make whitespace/etc. fatal --- src/test/runtests.sh | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/src/test/runtests.sh b/src/test/runtests.sh index 1736dd55..81edac2b 100755 --- a/src/test/runtests.sh +++ b/src/test/runtests.sh @@ -20,6 +20,16 @@ checkit() { ret=0 +fail_on_out() { + # If FATAL_CHECKS is set, then fail when $out has output: + if [ -n "${FATAL_CHECKS}" ]; then + if [ -n "${out}" ]; then + eerror "Last command failed and FATAL_CHECKS is set; failing" + exit 1 + fi + fi +} + ebegin "Checking exported symbols in libeinfo.so (data)" checkit einfo.data $( readelf -Ws ${libeinfo_builddir}/libeinfo.so \ @@ -74,6 +84,7 @@ out=$(cd ${top_srcdir}; find */ \ -exec grep -n -E '[[:space:]]+$' {} +) [ -z "${out}" ] eend $? "Trailing whitespace needs to be deleted:"$'\n'"${out}" +fail_on_out ebegin "Checking trailing newlines in code" out=$(cd ${top_srcdir}; @@ -82,6 +93,7 @@ out=$(cd ${top_srcdir}; done) [ -z "${out}" ] eend $? "Trailing newlines need to be deleted:"$'\n'"${out}" +fail_on_out ebegin "Checking for obsolete functions" out=$(cd ${top_srcdir}; find src -name '*.[ch]' \ @@ -89,6 +101,7 @@ out=$(cd ${top_srcdir}; find src -name '*.[ch]' \ -exec grep -n -E '\<(malloc|memory|sys/(errno|fcntl|signal|stropts|termios|unistd))\.h\>' {} +) [ -z "${out}" ] eend $? "Avoid these obsolete functions:"$'\n'"${out}" +fail_on_out ebegin "Checking for x* func usage" out=$(cd ${top_srcdir}; find src -name '*.[ch]' \ @@ -99,6 +112,7 @@ out=$(cd ${top_srcdir}; find src -name '*.[ch]' \ -e src/libeinfo/libeinfo.c) [ -z "${out}" ] eend $? "These need to be using the x* variant:"$'\n'"${out}" +fail_on_out ebegin "Checking spacing style" out=$(cd ${top_srcdir}; find src -name '*.[ch]' \ @@ -113,6 +127,7 @@ out=$(cd ${top_srcdir}; find src -name '*.[ch]' \ {} +) [ -z "${out}" ] eend $? "These lines violate style rules:"$'\n'"${out}" +fail_on_out einfo "Running unit tests" eindent