Portability fixes

git-svn-id: svn+ssh://svn.gna.org/svn/gnustep/tools/make/trunk@32214 72102866-910b-0410-8b05-ffd578937521
This commit is contained in:
Richard Frith-MacDonald 2011-02-19 05:21:40 +00:00
parent abdddb1b70
commit 40209c3392
3 changed files with 69 additions and 50 deletions

View file

@ -1,3 +1,11 @@
2011-01-19 Richard Frith-Macdonald <rfm@gnu.org>
* TestFramework/gnustep-tests:
* TestFramework/runtest.sh:
* TestFramework/Summary.sh:
Portability fixes for systems where grep has limited functionality
and/or where the shell's builtin 'test' command is limited/faulty.
2011-01-18 Richard Frith-Macdonald <rfm@gnu.org>
* gnustep-config.in:

View file

@ -96,15 +96,15 @@ done
export GSTESTMODE
if [ ! "$MAKE_CMD" ]
if test ! "$MAKE_CMD"
then
MAKE_CMD=`gnustep-config --variable=GNUMAKE`
$MAKE_CMD --version > /dev/null 2>&1
if [ $? != 0 ]
if test $? != 0
then
MAKE_CMD=gmake
$MAKE_CMD --version > /dev/null 2>&1
if [ $? != 0 ]
if test $? != 0
then
MAKE_CMD=make
fi
@ -121,15 +121,15 @@ TEMP=`echo *`
TESTDIRS=
for file in $TEMP
do
if [ -d $file -a $file != CVS -a $file != obj ]
if test -d $file -a $file != CVS -a $file != obj
then
TESTDIRS="$TESTDIRS $file"
fi
done
if [ x$1 != x ]
if test x$1 != x
then
if [ -d $1 ]
if test -d $1
then
# Only find in the directories specified.
TESTDIRS=$*
@ -164,7 +164,7 @@ present()
while test $# != 0
do
grep "$1" "$f" >/dev/null
if [ $? = "0" ]
if test $? = "0"
then
return 0
fi
@ -176,10 +176,10 @@ present()
run_test_file ()
{
sub=`dirname $TESTFILE`
if [ "x$OWD" != "x$sub" ]
if test "x$OWD" != "x$sub"
then
OWD=$sub
if [ "$GSTESTMODE" = "clean" ]
if test "$GSTESTMODE" = "clean"
then
echo "--- Cleaning tests in $sub ---"
rm -rf $sub/GNUmakefile.tmp $sub/obj $sub/core
@ -189,19 +189,19 @@ run_test_file ()
else
echo "--- Running tests in $sub ---"
echo "--- Running tests in $sub ---" >> $CWD/tests.log
if [ -r $dir/URGENT ]
if test -r $dir/URGENT
then
cat $dir/URGENT
cat $dir/URGENT >> $CWD/tests.log
fi
if [ -r $dir/README ]
if test -r $dir/README
then
cat $dir/README >> $CWD/tests.log
fi
fi
fi
if [ "$GSTESTMODE" != "clean" ]
if test "$GSTESTMODE" != "clean"
then
echo >> $CWD/tests.log
echo Testing $TESTFILE... >> $CWD/tests.log
@ -211,7 +211,7 @@ run_test_file ()
export GSTESTMODE
$RUNCMD $run_args $TESTFILE > $CWD/tests.tmp 2>&1
RUNEXIT=$?
if [ "$RUNEXIT" != "0" -a "$RUNEXIT" != "999" ]
if test "$RUNEXIT" != "0" -a "$RUNEXIT" != "999"
then
echo "Failed script: $TESTFILE" >> $CWD/tests.tmp
fi
@ -235,23 +235,23 @@ run_test_file ()
# Replace the old files.
if [ -f tests.log ]
if test -f tests.log
then
mv tests.log oldtests.log
fi
if [ -f tests.sum ]
if test -f tests.sum
then
mv tests.sum oldtests.sum
fi
SUMD=.
if [ x"$TESTDIRS" = x ]
if test x"$TESTDIRS" = x
then
# Run specific individual test files.
for TESTFILE in $TESTS
do
run_test_file
if [ "$RUNEXIT" != "0" ]
if test "$RUNEXIT" != "0"
then
break
fi
@ -264,20 +264,20 @@ else
# If there are no test files found, we need to print out a message
# at this level to let people know we processed the directory.
if [ "x$TESTS" = "x" ]
if test "x$TESTS" = "x"
then
if [ "$GSTESTMODE" = "clean" ]
if test "$GSTESTMODE" = "clean"
then
echo "--- Cleaning tests in $dir ---"
else
echo "--- Running tests in $dir ---"
echo "--- Running tests in $dir ---" >> $CWD/tests.log
if [ -r $dir/URGENT ]
if test -r $dir/URGENT
then
cat $dir/URGENT
cat $dir/URGENT >> $CWD/tests.log
fi
if [ -r $dir/README ]
if test -r $dir/README
then
cat $dir/README >> $CWD/tests.log
fi
@ -286,7 +286,7 @@ else
# If there is a GNUmakefile.tests in the directory, run it first.
cd $dir
if [ -f GNUmakefile.tests ]
if test -f GNUmakefile.tests
then
$MAKE_CMD -f GNUmakefile.tests $MAKEFLAGS debug=yes 2>&1
fi
@ -296,7 +296,7 @@ else
for TESTFILE in $TESTS
do
run_test_file
if [ "$RUNEXIT" != "0" ]
if test "$RUNEXIT" != "0"
then
break
fi
@ -304,14 +304,14 @@ else
done
fi
if [ "$GSTESTMODE" = "clean" ]
if test "$GSTESTMODE" = "clean"
then
rm -f GNUmakefile.tmp tests.tmp tests.sum.tmp
rm -f tests.log tests.sum
rm -f oldtests.log oldtests.sum
else
# Make some stats.
if [ -r tests.sum ]
if test -r tests.sum
then
# Nasty pipeline of commands ...
# Look for each type of test result, sort and count the results,
@ -337,7 +337,7 @@ fi
# In the case where we ran a single testsuite, we allow the Summary.sh
# script in that testsuite to generate our summary.
if [ x"$TESTDIRS" = x"$SUMD" -a -r $SUMD/Summary.sh -a -x $SUMD/Summary.sh ]
if test x"$TESTDIRS" = x"$SUMD" -a -r $SUMD/Summary.sh -a -x $SUMD/Summary.sh
then
RUNCMD=$SUMD/Summary.sh
else

View file

@ -46,28 +46,36 @@ do
shift
done
if [ x$1 = x ]
# In some shells the builtin test command actually only implements a subset
# of the normally expected functionality (or is partially broken), so we
# define a function to call a real program to do the job.
test()
{
/bin/test $@
}
if test x$1 = x
then
echo "ERROR: $0: No test given"
exit 1
fi
if [ $# != 1 ]
if test $# != 1
then
echo "ERROR: $0: Too many arguments (single test file name expected)"
exit 1
fi
if [ -e $1 ]
if test -e $1
then
if [ ! -f $1 ]
if test ! -f $1
then
echo "ERROR: $0: Argument ($1) is not the name of a regular file"
exit 1
fi
if [ ! -r $1 ]
if test ! -r $1
then
echo "ERROR: $0: Test file ($1) is not readable by you"
exit 1
@ -78,9 +86,11 @@ else
exit 1
fi
if test -z "$GNUSTEP_MAKEFILES"; then
if test -z "$GNUSTEP_MAKEFILES"
then
GNUSTEP_MAKEFILES=`gnustep-config --variable=GNUSTEP_MAKEFILES 2>/dev/null`
if test -z "$GNUSTEP_MAKEFILES"; then
if test -z "$GNUSTEP_MAKEFILES"
then
echo "You need to have GNUstep-make installed and set up."
echo "Did you remember to source GNUstep.sh?"
else
@ -92,22 +102,23 @@ TOP=$GNUSTEP_MAKEFILES/TestFramework
# Move to the test's directory.
DIR=`dirname $1`
if [ ! -d $DIR ]; then
if test ! -d $DIR
then
echo "Unable to proceed ... $DIR is not a directory"
exit 1
fi
cd $DIR
DIR=`pwd`
if [ ! "$MAKE_CMD" ]
if test ! "$MAKE_CMD"
then
MAKE_CMD=`gnustep-config --variable=GNUMAKE`
$MAKE_CMD --version > /dev/null 2>&1
if [ $? != 0 ]
if test $? != 0
then
MAKE_CMD=gmake
$MAKE_CMD --version > /dev/null 2>&1
if [ $? != 0 ]
if test $? != 0
then
MAKE_CMD=make
fi
@ -116,7 +127,7 @@ fi
NAME=`basename $1`
if [ ! -f IGNORE ]
if test ! -f IGNORE ]
then
# remove any leftover makefile from a previous test
@ -124,10 +135,10 @@ then
# Remove the extension, if there is one. If there is no extension, add
# .obj .
TESTNAME=`echo $NAME | sed -e"s/^\([^.]*\)$/\1.obj./;s/\.[^.]*//g"`
TESTNAME=`echo $NAME | sed -e"s/^\(test^.]*\)$/\1.obj./;s/\.[^.]*//g"`
# Check for a custom makefile template, if it exists use it.
if [ -r Custom.mk ]
if test -r Custom.mk
then
TEMPLATE=Custom.mk
else
@ -137,7 +148,7 @@ then
# Create the GNUmakefile by filling in the name of the test,
# the name of the file, the include directory, and the failfast
# option if needed.
if [ "$GSTESTMODE" = "failfast" ]
if test "$GSTESTMODE" = "failfast"
then
sed -e "s/@TESTNAME@/$TESTNAME/;s/@FILENAME@/$NAME/;s/@FAILFAST@/-DFAILFAST=1/;s^@INCLUDEDIR@^$TOP^" < $TEMPLATE > GNUmakefile.tmp
else
@ -145,7 +156,7 @@ then
fi
rm -f GNUmakefile.bck
if [ -e GNUmakefile ]
if test -e GNUmakefile
then
mv GNUmakefile GNUmakefile.bck
fi
@ -158,13 +169,13 @@ then
# Compile it. Redirect errors to stdout so it shows up in the log, but not
# in the summary.
$MAKE_CMD $MAKEFLAGS debug=yes 2>&1
if [ $? != 0 ]
if test $? != 0
then
echo "Failed build: $1" >&2
if [ "$GSTESTMODE" = "failfast" ]
if test "$GSTESTMODE" = "failfast"
then
mv GNUmakefile GNUmakefile.tmp
if [ -e GNUmakefile.bck ]
if test -e GNUmakefile.bck
then
mv GNUmakefile.bck GNUmakefile
fi
@ -188,17 +199,17 @@ then
# Run it. If it terminates abnormally, mark it as a crash (unless we have
# a special file to mark it as being expected to abort).
$MAKE_CMD -s test
if [ $? != 0 ]
if test $? != 0
then
if [ -r $NAME.abort ]
if test -r $NAME.abort
then
echo "Completed file: $1" >&2
else
echo "Failed file: $1 aborted without running all tests!" >&2
if [ "$GSTESTMODE" = "failfast" ]
if test "$GSTESTMODE" = "failfast"
then
mv GNUmakefile GNUmakefile.tmp
if [ -e GNUmakefile.bck ]
if test -e GNUmakefile.bck
then
mv GNUmakefile.bck GNUmakefile
fi
@ -212,7 +223,7 @@ then
# Restore any old makefile
mv GNUmakefile GNUmakefile.tmp
if [ -e GNUmakefile.bck ]
if test -e GNUmakefile.bck
then
mv GNUmakefile.bck GNUmakefile
fi