2011-02-07 20:41:58 +00:00
|
|
|
#!/bin/sh
|
|
|
|
#
|
|
|
|
# Runs tests for the GNUstep Testsuite
|
|
|
|
#
|
|
|
|
# Copyright (C) 2005-2011 Free Software Foundation, Inc.
|
|
|
|
#
|
|
|
|
# Written by: Alexander Malmberg <alexander@malmberg.org>
|
|
|
|
# Updates by: Richard Frith-Macdonald <rfm@gnu.org>
|
|
|
|
#
|
|
|
|
# This package is free software; you can redistribute it and/or
|
|
|
|
# modify it under the terms of the GNU General Public
|
|
|
|
# License as published by the Free Software Foundation; either
|
|
|
|
# version 3 of the License, or (at your option) any later version.
|
|
|
|
#
|
|
|
|
# This library is distributed in the hope that it will be useful,
|
|
|
|
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
|
|
|
# General Public License for more details.
|
|
|
|
#
|
|
|
|
#
|
|
|
|
# Usage: gnustep-tests [directory | test1.m [test2.m ...]]
|
|
|
|
#
|
|
|
|
# Runs the tests in the specified directory (or those in the individual files)
|
|
|
|
# or all the tests in subdirectories of the current directory if no arguments
|
|
|
|
# are given.
|
|
|
|
# A summary is written to tests.sum, a log to tests.log, and a brief
|
|
|
|
# summary to stdout.
|
|
|
|
# The log and summary from the previous testrun are renamed to
|
|
|
|
# oldtests.log and oldtests.sum, available for comparison.
|
|
|
|
|
|
|
|
if test -z "$GNUSTEP_MAKEFILES"; then
|
|
|
|
GNUSTEP_MAKEFILES=`gnustep-config --variable=GNUSTEP_MAKEFILES 2>/dev/null`
|
|
|
|
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
|
2011-02-12 11:31:26 +00:00
|
|
|
echo "You forgot to set your GNUSTEP_MAKEFILES environment variable."
|
|
|
|
echo "Setting it to $GNUSTEP_MAKEFILES during this test run."
|
2011-02-07 20:41:58 +00:00
|
|
|
export GNUSTEP_MAKEFILES
|
|
|
|
. $GNUSTEP_MAKEFILES/GNUstep.sh
|
|
|
|
fi
|
|
|
|
fi
|
|
|
|
|
2011-02-16 05:44:45 +00:00
|
|
|
GSTESTMODE=normal
|
2011-02-13 08:05:06 +00:00
|
|
|
|
2011-02-07 20:41:58 +00:00
|
|
|
# Argument checking
|
|
|
|
while test $# != 0
|
|
|
|
do
|
|
|
|
gs_option=
|
|
|
|
case $1 in
|
2011-02-13 08:05:06 +00:00
|
|
|
--clean)
|
2011-02-16 05:44:45 +00:00
|
|
|
GSTESTMODE=clean
|
2011-02-13 08:05:06 +00:00
|
|
|
;;
|
2011-02-12 11:31:26 +00:00
|
|
|
--documentation)
|
|
|
|
echo
|
|
|
|
echo "$0: Script to run the GNUstep testsuite"
|
|
|
|
echo "Usage: gnustep-tests [directory | test1.m [test2.m ...]]"
|
|
|
|
echo "Runs the specified tests, or any in subdirectories of the"
|
|
|
|
echo "current directory if no arguments are given."
|
|
|
|
echo "Use 'gnustep-tests --help' for basic help."
|
|
|
|
echo
|
|
|
|
cat $GNUSTEP_MAKEFILES/TestFramework/README
|
|
|
|
exit 0
|
|
|
|
;;
|
2011-02-16 05:44:45 +00:00
|
|
|
--failfast)
|
|
|
|
GSTESTMODE=failfast
|
|
|
|
;;
|
2011-02-07 20:41:58 +00:00
|
|
|
--help | -h)
|
|
|
|
echo
|
|
|
|
echo "$0: Script to run the GNUstep testsuite"
|
|
|
|
echo "Usage: gnustep-tests [directory | test1.m [test2.m ...]]"
|
2011-02-08 11:23:26 +00:00
|
|
|
echo "Runs the specified tests, or any in subdirectories of the"
|
2011-02-07 20:41:58 +00:00
|
|
|
echo "current directory if no arguments are given."
|
2011-02-12 11:31:26 +00:00
|
|
|
echo "Use 'gnustep-tests --documentation' for full details."
|
2011-02-16 05:44:45 +00:00
|
|
|
echo "Use 'gnustep-tests --failfast' to stop at the first failure."
|
2011-02-13 08:08:53 +00:00
|
|
|
echo "Use 'gnustep-tests --clean' to remove old logs and leftover files."
|
2011-02-07 20:41:58 +00:00
|
|
|
echo
|
|
|
|
echo "Interpreting the output"
|
|
|
|
echo "-----------------------"
|
|
|
|
echo "The summary output lists all test failures ... there should not"
|
|
|
|
echo "be any. If a test fails then either there is a problem in the"
|
2011-02-08 11:23:26 +00:00
|
|
|
echo "software being tested, or a problem in the test itself. Either"
|
2011-02-07 20:41:58 +00:00
|
|
|
echo "way, you should try to fix the problem and provide a patch, or"
|
|
|
|
echo "at least report it at: https://savannah.gnu.org/bugs/?group=gnustep"
|
|
|
|
echo
|
|
|
|
exit 0
|
|
|
|
;;
|
|
|
|
--debug | -d) # ignore for backward compatibility.
|
|
|
|
;;
|
|
|
|
*)
|
|
|
|
break
|
|
|
|
;;
|
|
|
|
esac
|
|
|
|
shift
|
|
|
|
done
|
|
|
|
|
2011-02-16 09:46:28 +00:00
|
|
|
export GSTESTMODE
|
|
|
|
|
2011-02-07 20:41:58 +00:00
|
|
|
if [ ! "$MAKE_CMD" ]
|
|
|
|
then
|
2011-02-18 16:27:22 +00:00
|
|
|
MAKE_CMD=`gnustep-config --variable=GNUMAKE`
|
|
|
|
$MAKE_CMD --version > /dev/null 2>&1
|
|
|
|
if [ $? != 0 ]
|
2011-02-07 20:41:58 +00:00
|
|
|
then
|
|
|
|
MAKE_CMD=gmake
|
2011-02-18 16:27:22 +00:00
|
|
|
$MAKE_CMD --version > /dev/null 2>&1
|
|
|
|
if [ $? != 0 ]
|
|
|
|
then
|
|
|
|
MAKE_CMD=make
|
|
|
|
fi
|
2011-02-07 20:41:58 +00:00
|
|
|
fi
|
|
|
|
fi
|
|
|
|
export MAKE_CMD
|
2011-02-13 08:05:06 +00:00
|
|
|
|
|
|
|
if test $# = 0
|
|
|
|
then
|
|
|
|
echo "Checking for presence of test subdirectories ..."
|
|
|
|
fi
|
|
|
|
|
2011-02-07 20:41:58 +00:00
|
|
|
TEMP=`echo *`
|
|
|
|
TESTDIRS=
|
|
|
|
for file in $TEMP
|
|
|
|
do
|
|
|
|
if [ -d $file -a $file != CVS -a $file != obj ]
|
|
|
|
then
|
|
|
|
TESTDIRS="$TESTDIRS $file"
|
|
|
|
fi
|
|
|
|
done
|
|
|
|
|
|
|
|
if [ x$1 != x ]
|
|
|
|
then
|
|
|
|
if [ -d $1 ]
|
|
|
|
then
|
|
|
|
# Only find in the directories specified.
|
|
|
|
TESTDIRS=$*
|
|
|
|
else
|
|
|
|
TESTDIRS=
|
|
|
|
TESTS=$*
|
|
|
|
fi
|
|
|
|
fi
|
|
|
|
|
|
|
|
CWD=`pwd`
|
2011-02-16 05:44:45 +00:00
|
|
|
OWD=
|
|
|
|
RUNCMD=$GNUSTEP_MAKEFILES/TestFramework/runtest.sh
|
|
|
|
RUNEXIT=0
|
2011-02-07 20:41:58 +00:00
|
|
|
|
|
|
|
run_test_file ()
|
|
|
|
{
|
2011-02-16 05:44:45 +00:00
|
|
|
sub=`dirname $TESTFILE`
|
|
|
|
if [ "x$OWD" != "x$sub" ]
|
|
|
|
then
|
|
|
|
OWD=$sub
|
|
|
|
if [ "$GSTESTMODE" = "clean" ]
|
|
|
|
then
|
|
|
|
echo "--- Cleaning tests in $sub ---"
|
|
|
|
rm -rf $sub/GNUmakefile.tmp $sub/obj $sub/core
|
|
|
|
rm -rf $sub/tests.tmp $sub/tests.sum.tmp
|
|
|
|
rm -rf $sub/tests.log $sub/tests.sum
|
|
|
|
rm -rf $sub/oldtests.log $sub/oldtests.sum
|
|
|
|
else
|
|
|
|
echo "--- Running tests in $sub ---"
|
|
|
|
echo "--- Running tests in $sub ---" >> $CWD/tests.log
|
|
|
|
if [ -r $dir/URGENT ]
|
|
|
|
then
|
|
|
|
cat $dir/URGENT
|
|
|
|
cat $dir/URGENT >> $CWD/tests.log
|
|
|
|
fi
|
|
|
|
if [ -r $dir/README ]
|
|
|
|
then
|
|
|
|
cat $dir/README >> $CWD/tests.log
|
|
|
|
fi
|
|
|
|
fi
|
|
|
|
fi
|
|
|
|
|
|
|
|
if [ "$GSTESTMODE" != "clean" ]
|
|
|
|
then
|
|
|
|
echo >> $CWD/tests.log
|
|
|
|
echo Testing $TESTFILE... >> $CWD/tests.log
|
|
|
|
echo >> $CWD/tests.sum
|
2011-02-07 20:41:58 +00:00
|
|
|
|
2011-02-16 05:44:45 +00:00
|
|
|
# Run the test. Log everything to a temporary file.
|
|
|
|
export GSTESTMODE
|
|
|
|
$RUNCMD $run_args $TESTFILE > $CWD/tests.tmp 2>&1
|
|
|
|
RUNEXIT=$?
|
2011-02-18 17:19:24 +00:00
|
|
|
if [ "$RUNEXIT" = "1" ]
|
2011-02-18 17:14:55 +00:00
|
|
|
then
|
2011-02-18 17:19:24 +00:00
|
|
|
echo "Failed file: $TESTFILE" >> $CWD/tests.tmp
|
2011-02-18 17:14:55 +00:00
|
|
|
fi
|
2011-02-07 20:41:58 +00:00
|
|
|
|
2011-02-16 05:44:45 +00:00
|
|
|
# Add the information to the detailed log.
|
|
|
|
cat $CWD/tests.tmp >> $CWD/tests.log
|
2011-02-07 20:41:58 +00:00
|
|
|
|
2011-02-16 05:44:45 +00:00
|
|
|
# Extract the summary information and add it to the summary file.
|
|
|
|
grep "^\(Passed test\|Failed test\|Failed build\|Completed file\|Failed file\|Dashed hope\|Failed set\|Skipped set\):" $CWD/tests.tmp > $CWD/tests.sum.tmp
|
|
|
|
cat $CWD/tests.sum.tmp >> $CWD/tests.sum
|
2011-02-07 20:41:58 +00:00
|
|
|
|
2011-02-16 05:44:45 +00:00
|
|
|
# If there were failures or unresolved tests then report them...
|
2011-02-18 16:10:47 +00:00
|
|
|
grep "^\(Failed build\|Failed file\|Failed set\|Failed test\):" $CWD/tests.sum.tmp 2>/dev/null >/dev/null
|
2011-02-18 17:19:24 +00:00
|
|
|
if [ $? = "1" ]
|
2011-02-18 16:10:47 +00:00
|
|
|
then
|
2011-02-16 05:44:45 +00:00
|
|
|
echo
|
|
|
|
echo $TESTFILE:
|
|
|
|
grep "^\(Failed build\|Failed file\|Failed set\|Failed test\):" $CWD/tests.sum.tmp
|
|
|
|
fi
|
2011-02-07 20:41:58 +00:00
|
|
|
fi
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2011-02-13 08:05:06 +00:00
|
|
|
# Replace the old files.
|
2011-02-07 20:41:58 +00:00
|
|
|
if [ -f tests.log ]
|
|
|
|
then
|
|
|
|
mv tests.log oldtests.log
|
|
|
|
fi
|
|
|
|
if [ -f tests.sum ]
|
|
|
|
then
|
|
|
|
mv tests.sum oldtests.sum
|
|
|
|
fi
|
|
|
|
|
2011-02-16 09:46:28 +00:00
|
|
|
SUMD=.
|
2011-02-07 20:41:58 +00:00
|
|
|
if [ x"$TESTDIRS" = x ]
|
|
|
|
then
|
2011-02-16 05:44:45 +00:00
|
|
|
# Run specific individual test files.
|
|
|
|
for TESTFILE in $TESTS
|
|
|
|
do
|
|
|
|
run_test_file
|
|
|
|
if [ "$RUNEXIT" != "0" ]
|
|
|
|
then
|
|
|
|
break
|
|
|
|
fi
|
|
|
|
done
|
2011-02-07 20:41:58 +00:00
|
|
|
else
|
|
|
|
for dir in $TESTDIRS
|
|
|
|
do
|
2011-02-16 09:46:28 +00:00
|
|
|
SUMD=$dir
|
2011-02-16 05:44:45 +00:00
|
|
|
TESTS=`find $dir -name \*.m | sort | sed -e 's/\(^\| \)X[^ ]*//g'`
|
|
|
|
|
|
|
|
# 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" ]
|
2011-02-07 20:41:58 +00:00
|
|
|
then
|
2011-02-16 05:44:45 +00:00
|
|
|
if [ "$GSTESTMODE" = "clean" ]
|
2011-02-13 08:05:06 +00:00
|
|
|
then
|
2011-02-16 05:44:45 +00:00
|
|
|
echo "--- Cleaning tests in $dir ---"
|
|
|
|
else
|
|
|
|
echo "--- Running tests in $dir ---"
|
|
|
|
echo "--- Running tests in $dir ---" >> $CWD/tests.log
|
|
|
|
if [ -r $dir/URGENT ]
|
|
|
|
then
|
|
|
|
cat $dir/URGENT
|
|
|
|
cat $dir/URGENT >> $CWD/tests.log
|
|
|
|
fi
|
|
|
|
if [ -r $dir/README ]
|
2011-02-13 08:05:06 +00:00
|
|
|
then
|
2011-02-16 05:44:45 +00:00
|
|
|
cat $dir/README >> $CWD/tests.log
|
2011-02-13 08:05:06 +00:00
|
|
|
fi
|
|
|
|
fi
|
2011-02-16 05:44:45 +00:00
|
|
|
fi
|
|
|
|
|
|
|
|
# If there is a GNUmakefile.tests in the directory, run it first.
|
|
|
|
cd $dir
|
|
|
|
if [ -f GNUmakefile.tests ]
|
|
|
|
then
|
|
|
|
$MAKE_CMD -f GNUmakefile.tests $MAKEFLAGS debug=yes 2>&1
|
|
|
|
fi
|
|
|
|
|
|
|
|
# Now we process each test file in turn.
|
|
|
|
cd $CWD
|
|
|
|
for TESTFILE in $TESTS
|
|
|
|
do
|
|
|
|
run_test_file
|
|
|
|
if [ "$RUNEXIT" != "0" ]
|
2011-02-07 20:41:58 +00:00
|
|
|
then
|
2011-02-16 05:44:45 +00:00
|
|
|
break
|
2011-02-07 20:41:58 +00:00
|
|
|
fi
|
2011-02-16 05:44:45 +00:00
|
|
|
done
|
2011-02-07 20:41:58 +00:00
|
|
|
done
|
|
|
|
fi
|
|
|
|
|
2011-02-16 05:44:45 +00:00
|
|
|
if [ "$GSTESTMODE" = "clean" ]
|
2011-02-07 20:41:58 +00:00
|
|
|
then
|
2011-02-16 09:46:28 +00:00
|
|
|
rm -f GNUmakefile.tmp tests.tmp tests.sum.tmp
|
2011-02-16 05:44:45 +00:00
|
|
|
rm -f tests.log tests.sum
|
|
|
|
rm -f oldtests.log oldtests.sum
|
2011-02-07 20:41:58 +00:00
|
|
|
else
|
2011-02-13 08:05:06 +00:00
|
|
|
# Make some stats.
|
|
|
|
if [ -r tests.sum ]
|
|
|
|
then
|
2011-02-13 12:40:12 +00:00
|
|
|
# Nasty pipeline of commands ...
|
|
|
|
# Look for each type of test result, sort and count the results,
|
|
|
|
# append 's' to each summary, then remove the trailing 's' from
|
|
|
|
# any summary with only a single result so the output is pretty.
|
2011-02-13 13:02:20 +00:00
|
|
|
# Sort the resulting lines by number of each status with the most
|
|
|
|
# common (hopefully passes) output first.
|
2011-02-16 05:44:45 +00:00
|
|
|
# NB. we omit the 'Completed file' tests as uninteresting ... users
|
|
|
|
# generally only want to see the total pass count and any problems.
|
|
|
|
grep "^\(Passed test\|Failed test\|Failed build\|Failed file\|Dashed hope\|Failed set\|Skipped set\):" tests.sum | cut -d: -f1 | sort | uniq -c | sed -e 's/.*/&s/' | sed -e 's/^\([^0-9]*1[^0-9].*\)s$/\1/' | sort -n -b -r > tests.tmp
|
2011-02-13 08:05:06 +00:00
|
|
|
else
|
|
|
|
echo "No tests found." > tests.tmp
|
|
|
|
fi
|
2011-02-07 20:41:58 +00:00
|
|
|
|
2011-02-13 08:05:06 +00:00
|
|
|
echo >> tests.sum
|
|
|
|
cat tests.tmp >> tests.sum
|
2011-02-07 20:41:58 +00:00
|
|
|
|
2011-02-13 08:05:06 +00:00
|
|
|
echo
|
|
|
|
cat tests.tmp
|
2011-02-16 05:44:45 +00:00
|
|
|
echo
|
|
|
|
|
2011-02-16 09:46:28 +00:00
|
|
|
fi
|
2011-02-16 05:44:45 +00:00
|
|
|
|
2011-02-16 09:46:28 +00:00
|
|
|
# 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 ]
|
|
|
|
then
|
|
|
|
RUNCMD=$SUMD/Summary.sh
|
|
|
|
else
|
|
|
|
RUNCMD=$GNUSTEP_MAKEFILES/TestFramework/Summary.sh
|
2011-02-13 08:05:06 +00:00
|
|
|
fi
|
2011-02-16 09:46:28 +00:00
|
|
|
$RUNCMD
|
2011-02-07 20:41:58 +00:00
|
|
|
|
|
|
|
# Delete the temporary file.
|
|
|
|
rm -f tests.tmp tests.sum.tmp
|
|
|
|
|