From 63311c54a547823fe315a9f30308b86ddcae1df6 Mon Sep 17 00:00:00 2001 From: Sam Hocevar Date: Wed, 16 Dec 2009 15:54:17 +0000 Subject: [PATCH] Add a source code sanity check. --- Makefile.am | 2 +- configure.ac | 1 + src/Makefile.am | 2 ++ test/Makefile.am | 6 ++++++ test/check-build | 34 ++++++++++++++++++++++++++++++++++ tools/Makefile.am | 2 ++ 6 files changed, 46 insertions(+), 1 deletion(-) create mode 100644 test/Makefile.am create mode 100755 test/check-build diff --git a/Makefile.am b/Makefile.am index 7f45697..2c69f63 100644 --- a/Makefile.am +++ b/Makefile.am @@ -1,5 +1,5 @@ -SUBDIRS = src tools fonts doc +SUBDIRS = src tools fonts doc test DIST_SUBDIRS = $(SUBDIRS) EXTRA_DIST = bootstrap diff --git a/configure.ac b/configure.ac index f46cab6..dea4ab4 100644 --- a/configure.ac +++ b/configure.ac @@ -78,5 +78,6 @@ AC_OUTPUT([ tools/Makefile fonts/Makefile doc/Makefile + test/Makefile ]) diff --git a/src/Makefile.am b/src/Makefile.am index c920754..ed154c2 100644 --- a/src/Makefile.am +++ b/src/Makefile.am @@ -10,3 +10,5 @@ toilet_CPPFLAGS = -DFONTDIR=\"$(datadir)/figlet\" toilet_CFLAGS = @CACA_CFLAGS@ toilet_LDADD = @CACA_LIBS@ @GETOPT_LIBS@ @ZLIB_LIBS@ +echo-sources: ; echo $(SOURCES) + diff --git a/test/Makefile.am b/test/Makefile.am new file mode 100644 index 0000000..b2a1bbe --- /dev/null +++ b/test/Makefile.am @@ -0,0 +1,6 @@ +# $Id$ + +EXTRA_DIST = check-build + +TESTS = check-build + diff --git a/test/check-build b/test/check-build new file mode 100755 index 0000000..9f515e7 --- /dev/null +++ b/test/check-build @@ -0,0 +1,34 @@ +#!/bin/sh + +ret=0 + +# +# Check that we have no tabs or trailing spaces in the source code +# +failure=0 +for dir in src tools; do + pushd ../$dir >/dev/null + for x in $(make echo-sources); do + if grep '[[:space:]]$' "$x" >/dev/null 2>&1; then + echo "error: $dir/$x contains trailing spaces" + failure=1 + fi + if grep ' ' "$x" >/dev/null 2>&1; then + echo "error: $dir/$x contains tabs" + failure=1 + fi + done + popd >/dev/null +done +if test "$failure" != "0"; then + ret=1 +else + echo "0 errors in source code" +fi + +if test "$ret" != "0"; then + exit 1 +fi + +exit 0 + diff --git a/tools/Makefile.am b/tools/Makefile.am index 0c0e14f..c4b13dc 100644 --- a/tools/Makefile.am +++ b/tools/Makefile.am @@ -6,3 +6,5 @@ caca2tlf_SOURCES = caca2tlf.c caca2tlf_CFLAGS = @CACA_CFLAGS@ caca2tlf_LDADD = @CACA_LIBS@ +echo-sources: ; echo $(SOURCES) +