From f03f5e8823a5063b240dcf77384bac7bd4a56ed1 Mon Sep 17 00:00:00 2001 From: Sam Hocevar Date: Tue, 9 Feb 2010 00:50:15 +0000 Subject: [PATCH] Improve testsuite. --- test/Makefile.am | 4 ++-- test/check-build | 38 -------------------------------------- test/check-fonts | 39 ++++++++++++++++++--------------------- test/check-source | 37 +++++++++++++++++++++++++++++++++++++ 4 files changed, 57 insertions(+), 61 deletions(-) delete mode 100755 test/check-build create mode 100755 test/check-source diff --git a/test/Makefile.am b/test/Makefile.am index db0d98a..c3b0cf6 100644 --- a/test/Makefile.am +++ b/test/Makefile.am @@ -1,5 +1,5 @@ -EXTRA_DIST = check-build check-fonts +EXTRA_DIST = check-source check-fonts -TESTS = check-build check-fonts +TESTS = check-source check-fonts diff --git a/test/check-build b/test/check-build deleted file mode 100755 index d0c6db1..0000000 --- a/test/check-build +++ /dev/null @@ -1,38 +0,0 @@ -#!/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 -s echo-sources); do - case "$x" in - *.c|*.cpp|*.h|*.m) ;; - *) continue ;; - esac - 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/test/check-fonts b/test/check-fonts index d642ee2..47652b2 100755 --- a/test/check-fonts +++ b/test/check-fonts @@ -5,28 +5,25 @@ ret=0 # # Check that we have no tabs or trailing spaces in the source code # -failure=0 -(cd ../fonts - for x in $(make -s echo-fonts); do - case "$x" in - *.tlf|*.flf) ;; - *) continue ;; - esac - echo "Checking font $x..." - if ../src/toilet -d ../fonts -f "$x" Hello World >/dev/null; then - : - else - echo "Error loading font $x" - failure=1 - fi - done) -if test "$failure" != "0"; then - ret=1 -else - echo "0 errors in fonts" -fi +nfails=0 +nfonts=0 +for x in $(make -s echo-fonts -C ../fonts); do + case "$x" in + *.tlf|*.flf) ;; + *) continue ;; + esac + nfonts=$(($nfonts + 1)) + if ../src/toilet -d ../fonts -f "$x" Hello World >/dev/null; then + : + else + echo "Error loading font $x" + nfails=$(($nfails + 1)) + fi +done -if test "$ret" != "0"; then +echo "$nfonts fonts, $nfails load errors" + +if test "$nfails" != "0"; then exit 1 fi diff --git a/test/check-source b/test/check-source new file mode 100755 index 0000000..f5dc9fc --- /dev/null +++ b/test/check-source @@ -0,0 +1,37 @@ +#!/bin/sh + +# +# Check that we have no tabs or trailing spaces in the source code +# +nfails=0 +nfiles=0 +nlines=0 +for dir in $(make -s echo-dirs -C ..); do + if [ ! -d "../$dir" ]; then continue; fi + for x in $(make -s echo-sources -C ../$dir); do + case "$x" in + *.c|*.cpp|*.h|*.m|*.php|*.cs|*.java|.py|.pl) + nfiles=$(($nfiles + 1)); + nlines=$(($nlines + `grep -c . "../$dir/$x"`)) ;; + *) + continue ;; + esac + if grep '[[:space:]]$' "../$dir/$x" >/dev/null 2>&1; then + echo "error: $dir/$x contains trailing spaces" + nfails=$(($nfails + 1)) + fi + if grep ' ' "../$dir/$x" >/dev/null 2>&1; then + echo "error: $dir/$x contains tabs" + nfails=$(($nfails + 1)) + fi + done +done + +echo "$nfiles files, $nlines lines, $nfails errors in source code" + +if test "$nfails" != "0"; then + exit 1 +fi + +exit 0 +