diff --git a/Makefile.am b/Makefile.am index 9cb329a..567e15d 100644 --- a/Makefile.am +++ b/Makefile.am @@ -18,4 +18,6 @@ update-changelog: FORCE && git log --stat | grep -v '^ \(git-svn-id\|$$\)' \ | sed '/^Author:/s/ <.*@.*>//' > ChangeLog +echo-dirs: ; echo src test + FORCE: diff --git a/test/Makefile.am b/test/Makefile.am index 7c2e106..80e6b23 100644 --- a/test/Makefile.am +++ b/test/Makefile.am @@ -8,7 +8,7 @@ TESTS = check-zzuf-A-autoinc \ check-zzuf-m-md5 \ check-zzuf-M-max-memory \ check-zzuf-r-ratio \ - check-build check-overflow check-div0 check-utils + check-source check-win32 check-overflow check-div0 check-utils echo-sources: ; echo $(SOURCES) diff --git a/test/check-build b/test/check-build deleted file mode 100755 index 6eb43ea..0000000 --- a/test/check-build +++ /dev/null @@ -1,65 +0,0 @@ -#!/bin/sh -# -# check-build - check build system and source code for inconsistencies -# Copyright (c) 2009-2010 Sam Hocevar -# All Rights Reserved -# -# This program is free software. It comes without any warranty, to -# the extent permitted by applicable law. You can redistribute it -# and/or modify it under the terms of the Do What The Fuck You Want -# To Public License, Version 2, as published by Sam Hocevar. See -# http://sam.zoy.org/wtfpl/COPYING for more details. -# - -ret=0 - -# -# Check that the Win32 config.h is in sync with config.h.in -# - -config_h_in=$(dirname "$0")/../config.h.in -msvc_config_h=$(dirname "$0")/../msvc/config.h - -failure=0 -for key in $(sed -ne 's/.*#undef *\([A-Za-z0-9_]*\).*/\1/p' "$config_h_in"); -do - if ! grep "[ef] $key[ (]" "$msvc_config_h" >/dev/null 2>&1; then - echo "error: $key missing from msvc/config.h" - failure=1 - fi -done -if test "$failure" != "0"; then - ret=1 -else - echo "0 errors in Win32 config.h" -fi - -# -# Check that we have no tabs or trailing spaces in the source code -# -failure=0 -for dir in src test; do - (cd $(dirname "$0")/../$dir - for x in $(make -s 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) -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-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 + diff --git a/test/check-win32 b/test/check-win32 new file mode 100755 index 0000000..5f33b1e --- /dev/null +++ b/test/check-win32 @@ -0,0 +1,30 @@ +#!/bin/sh + +ret=0 + +# +# Check that the Win32 config.h is in sync with config.h.in +# + +config_h_in=$(dirname "$0")/../config.h.in +win32_config_h=$(dirname "$0")/../msvc/config.h + +nfails=0 +ntokens=0 +for key in $(sed -ne 's/.*#undef *\([A-Za-z0-9_]*\).*/\1/p' "$config_h_in"); +do + ntokens=$(($ntokens + 1)) + if ! grep '[ef] \<'"$key"'\>' "$win32_config_h" >/dev/null 2>&1; then + echo "error: $key missing from msvc/config.h" + nfails=$(($nfails + 1)) + fi +done + +echo "$ntokens tokens, $nfails errors in Win32 config.h" + +if test "$nfails" != "0"; then + exit 1 +fi + +exit 0 +