* [gentoo-commits] gentoo-projects commit in pax-utils/tests/source: Makefile dotest space.py
@ 2008-12-30 12:34 Mike Frysinger (vapier)
0 siblings, 0 replies; only message in thread
From: Mike Frysinger (vapier) @ 2008-12-30 12:34 UTC (permalink / raw
To: gentoo-commits
vapier 08/12/30 12:34:20
Added: Makefile dotest space.py
Log:
add test framework
Revision Changes Path
1.1 pax-utils/tests/source/Makefile
file : http://sources.gentoo.org/viewcvs.py/gentoo-projects/pax-utils/tests/source/Makefile?rev=1.1&view=markup
plain: http://sources.gentoo.org/viewcvs.py/gentoo-projects/pax-utils/tests/source/Makefile?rev=1.1&content-type=text/plain
Index: Makefile
===================================================================
all: check
test check:
./dotest
clean:
.PHONY: all check clean test
1.1 pax-utils/tests/source/dotest
file : http://sources.gentoo.org/viewcvs.py/gentoo-projects/pax-utils/tests/source/dotest?rev=1.1&view=markup
plain: http://sources.gentoo.org/viewcvs.py/gentoo-projects/pax-utils/tests/source/dotest?rev=1.1&content-type=text/plain
Index: dotest
===================================================================
#!/bin/bash
[ -e /etc/init.d/functions.sh ] && source /etc/init.d/functions.sh
ret=0
testit() {
if [ -s $1 ] ; then
echo ${BAD}FAIL${NORMAL}: $1
cat $1
rm -f $1
ret=1
return
fi
rm -f $1
echo ${GOOD}PASS${NORMAL}: $1
}
#
# check for misc common typos
#
find ../.. \
'(' -type d -a '(' -name CVS -o -name tests ')' -prune ')' \
-o '(' -type f -a -print0 ')' | xargs -0 \
grep -n -I \
-e '\<compatability\>' \
-e '\<compatable\>' \
-e '\<fordeground\>' \
-e '\<depency\>' \
-e '\<defalt\>' \
-e '\<remaing\>' \
-e '\<queuing\>' \
-e '\<detatch\>' \
-e '\<sempahore\>' \
-e '\<reprenstative\>' \
-e '\<overriden\>' \
-e '\<readed\>' \
-e '\<formated\>' \
-e '\<algorithic\>' \
-e '\<deamon\>' \
-e '\<derefernce\>' \
| sed -e "s:^\.\./\.\./::g" > src.typos
testit src.typos
#
# don't allow obsolete functions
#
find ../.. '(' -name '*.c' -o -name '*.h' ')' -print0 | xargs -0 \
grep -n -E -e '\<(bcmp|bcopy|bzero|getwd|index|mktemp|rindex|utimes)\>[[:space:]]*\(' \
| sed -e "s:^\.\./\.\./::g" > src.obsolete.funcs
testit src.obsolete.funcs
#
# make sure people use our constants
#
find ../.. '(' -name '*.c' -o -name '*.h' ')' -print0 | xargs -0 \
grep -n -E -e '\<PATH_MAX\>' | grep -v __PAX_UTILS_PATH_MAX \
| sed -e "s:^\.\./\.\./::g" > src.bad.constants
testit src.bad.constants
#
# don't allow obsolete headers
#
find ../.. '(' -name '*.c' -o -name '*.h' ')' -print0 | xargs -0 \
grep -n -E -e '\<(malloc|memory|sys/(errno|fcntl|signal|stropts|termios|unistd))\.h\>' \
| sed -e "s:^\.\./\.\./::g" > src.obsolete.headers
testit src.obsolete.headers
#
# make sure people use the x* helper funcs
#
xfuncs=$(printf '%s|' $(sed -n 's:.*x\([^(]*\)(.*:\1:p' ../../xfuncs.h))
xfuncs=${xfuncs:0:${#xfuncs}-1}
find ../.. '(' -name '*.c' -o -name '*.h' ')' -print0 | xargs -0 \
grep -n -E -e "\<(${xfuncs})[[:space:]]*\(" \
| grep -v xfuncs.c \
| sed -e "s:^\.\./\.\./::g" > src.use.xfuncs
testit src.use.xfuncs
#
# check for style
#
find ../.. '(' -name '*.c' -o -name '*.h' ')' -print0 | xargs -0 \
grep -n -E \
-e '\<(for|if|switch|while)\(' \
-e '\<(for|if|switch|while) \( ' \
-e ' ;' \
-e '[[:space:]]$' \
-e '\){' \
-e '(^|[^:])//' \
| sed -e "s:^\.\./\.\./::g" > src.style
testit src.style
# Stupid BSD makes us check for this..
if [ $(type -P md5sum) != "" ]; then
for x in $(find ../.. '(' -name '*.c' -o -name '*.h' ')' ); do
python space.py $x > $x~
if [[ $(md5sum $x | awk '{print $1}') != $(md5sum $x~ | awk '{print $1}') ]]; then
diff -u $x $x~
#cp $x~ $x
fi
rm $x~
done > src.space
testit src.space
fi
exit ${ret}
1.1 pax-utils/tests/source/space.py
file : http://sources.gentoo.org/viewcvs.py/gentoo-projects/pax-utils/tests/source/space.py?rev=1.1&view=markup
plain: http://sources.gentoo.org/viewcvs.py/gentoo-projects/pax-utils/tests/source/space.py?rev=1.1&content-type=text/plain
Index: space.py
===================================================================
#!/usr/bin/python
# Very simple src checker.
# Trim trailing whitespace and consecutive newlines.
# -solar 2007
import os
import sys
def crapspace(fname):
chars = True
fp = open(fname, "r")
line = fp.readline()
while line:
line = line.rstrip()
if line:
chars = True
print line
else:
if chars:
print ""
chars = False
line = fp.readline()
if __name__ == "__main__":
if len(sys.argv) < 2:
sys.stderr.write( "Usage: rstrip <file>\n")
sys.exit(1)
crapspace(sys.argv[1])
^ permalink raw reply [flat|nested] only message in thread
only message in thread, other threads:[~2008-12-30 12:34 UTC | newest]
Thread overview: (only message) (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2008-12-30 12:34 [gentoo-commits] gentoo-projects commit in pax-utils/tests/source: Makefile dotest space.py Mike Frysinger (vapier)
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox