Simplify by removing intermediary script and converting it to a

function.


git-svn-id: svn+ssh://svn.gna.org/svn/gnustep/tools/make/trunk@32267 72102866-910b-0410-8b05-ffd578937521
This commit is contained in:
Richard Frith-MacDonald 2011-02-21 18:48:39 +00:00
parent 92da6167cc
commit 4d29c574a1
5 changed files with 154 additions and 240 deletions

View file

@ -1,3 +1,11 @@
2011-01-21 Richard Frith-Macdonald <rfm@gnu.org>
* TestFramework/gnustep-tests:
* TestFramework/Summary.sh:
* TestFramework/runtest.sh:
* GNUmakefile.in:
Simplify by removing intermediary script.
2011-01-21 Richard Frith-Macdonald <rfm@gnu.org>
* gnustep-config.in: Add CC to list of variables so we can build

View file

@ -228,7 +228,6 @@ install: generated-files
$(INSTALL_DATA) config.make "$(makedir)/$(GNUSTEP_TARGET_LDIR)")
$(EC)(echo "Installing Test Framework scripts"; \
$(INSTALL_PROGRAM) -m 755 TestFramework/gnustep-tests "$(tooldir)"; \
$(INSTALL_PROGRAM) -m 755 TestFramework/runtest.sh "$(testdir)"; \
$(INSTALL_PROGRAM) -m 755 TestFramework/Summary.sh "$(testdir)")
$(EC)(echo "Installing Test Framework support files"; \
for f in $(TEST_FRAMEWORK_FILES); do \
@ -278,7 +277,6 @@ uninstall:
rm -f "$(tooldir)/opentool"; \
rm -f "$(tooldir)/gnustep-config"; \
rm -f "$(tooldir)/gnustep-tests"; \
rm -f "$(testdir)/runtest.sh"; \
rm -f "$(testdir)/Summary.sh"; \
for f in $(MAKE_FILES); do \
rm -f "$(makedir)/$$f"; \

View file

@ -35,7 +35,7 @@ present()
return 1
}
present "tests.sum" "Failed set$" "Failed sets$" "Failed test$" "Failed tests$" "Failed build$" "Failed builds$" "Failed file$" "Failed files$" "Failed script$" "Failed scripts$"
present "tests.sum" "Failed set$" "Failed sets$" "Failed test$" "Failed tests$" "Failed build$" "Failed builds$" "Failed file$" "Failed files$"
if [ $? = 1 ]
then
echo "All OK!"
@ -67,15 +67,6 @@ else
exit 0
fi
if present "tests.sum" "Failed script$" "Failed script$"
then
echo
echo "Unfortunately the script to build and run the tests did not work."
echo "This means that there is a problem with the test framework itsself"
echo "probably due to some system specific problems with the shell"
echo "or a problem wiith the installation of the test framework."
fi
if present "tests.sum" "Failed build$" "Failed build$"
then
echo

View file

@ -116,9 +116,18 @@ if test "$GSTESTMODE" = "failfast"
then
GSTESTFLAGS="$GSTESTFLAGS -DFAILFAST=1"
fi
export GSTESTFLAGS
GSTESTLIBS=`gnustep-config --gui-libs`
export GSTESTLIBS
if test x"$BASH_VERSION" = x
then
# In some shells the built in 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 $@
}
fi
if test ! "$MAKE_CMD"
then
@ -134,7 +143,6 @@ then
fi
fi
fi
export MAKE_CMD
if test $# = 0
then
@ -164,9 +172,6 @@ then
fi
fi
RUNCMD="$GSTESTTOP/runtest.sh"
RUNEXIT=0
# Function for platforms where grep can't search for multiple patterns.
extract()
{
@ -196,40 +201,138 @@ present()
return 1
}
run_test_file ()
# Low level function to build and run the Objective-C program $TESTFILE
# in the current directory. The TEMPLATE variable must already be set
# to the name of the make file template if gnustep-make is to do the
# building.
#
build_and_run ()
{
# Remove the extension, if there is one. If there is no extension, add
# .obj .
TESTNAME=`echo $TESTFILE | sed -e"s/^\(test^.]*\)$/\1.obj./;s/\.[^.]*//g"`
# Run the test.
if test x"$TEMPLATE" = x
then
# The very simple case, we just need to compile a single file
# putting the executable in the obj subdirectory.
rm -rf ./obj
mkdir ./obj
BUILD_CMD="$CC -o ./obj/$TESTNAME $TESTFILE $GSTESTFLAGS $GSTESTLIBS"
CLEAN_CMD=echo
RUN_CMD=./obj/$TESTNAME
else
BUILD_CMD="$MAKE_CMD $MAKEFLAGS debug=yes"
CLEAN_CMD="$MAKE_CMD clean"
RUN_CMD="$MAKE_CMD -s test"
# 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.
rm -f GNUmakefile
if test "$GSTESTMODE" = "failfast"
then
sed -e "s/@TESTNAME@/$TESTNAME/;s/@FILENAME@/$TESTFILE/;s/@FAILFAST@/-DFAILFAST=1/;s^@INCLUDEDIR@^$GSTESTTOP^" < $TEMPLATE > GNUmakefile
else
sed -e "s/@TESTNAME@/$TESTNAME/;s/@FILENAME@/$TESTFILE/;s/@FAILFAST@//;s^@INCLUDEDIR@^$GSTESTTOP^" < $TEMPLATE > GNUmakefile
fi
fi
if test "$GSTESTMODE" = "clean"
then
# Clean the test. Log everything to a temporary file.
$RUNCMD $run_args $TESTFILE > /dev/null 2>&1
return
$CLEAN_CMD >/dev/null 2>&1
rm -f GNUmakefile
rm -rf obj core
return 0
fi
# Clean up to avoid contamination by previous tests. Assume
# that this will never fail in any interesting way.
$CLEAN_CMD >/dev/null 2>&1
# Compile it. Redirect errors to stdout so it shows up in the log,
# but not in the summary.
$BUILD_CMD >$GSTESTLOG.tmp 2>&1
if test $? != 0
then
echo "Failed build: $1" >&2
if test "$GSTESTMODE" = "failfast"
then
return 1
fi
else
# We want aggressive memory checking.
# Tell glibc to check for malloc errors, and to crash if it detects
# any.
MALLOC_CHECK_=2
export MALLOC_CHECK
# Tell GNUstep-base to check for messages sent to deallocated objects
# and crash if it happens.
NSZombieEnabled=YES
CRASH_ON_ZOMBIE=YES
export NSZombieEnabled CRASH_ON_ZOMBIE
echo Running $TESTFILE...
# 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).
$RUN_CMD
if test $? != 0
then
if test -r $TESTFILE.abort
then
echo "Completed file: $TESTFILE" >&2
else
echo "Failed file: $TESTFILE aborted without running all tests!" >&2
if test "$GSTESTMODE" = "failfast"
then
return 1
fi
fi
else
echo "Completed file: $TESTFILE" >&2
fi
fi
return 0
}
# Function to build and run $TESTFILE in the current directory.
# This actually manages the logging process and calls build_and_run
# to perform the work.
#
run_test_file ()
{
RUNEXIT=0
if test "$GSTESTMODE" = "clean"
then
# Clean the test.
build_and_run > /dev/null 2>&1
return 0
else
echo >> $GSTESTLOG
echo Testing $TESTFILE... >> $GSTESTLOG
echo >> $GSTESTSUM
# Run the test. Log everything to a temporary file.
$RUNCMD $run_args $TESTFILE > $GSTESTLOG.tmp 2>&1
build_and_run > $GSTESTLOG.tmp 2>&1
RUNEXIT=$?
if test "$RUNEXIT" != "0" -a "$RUNEXIT" != "99"
then
echo "Failed script: $TESTFILE" >> $GSTESTLOG.tmp
fi
# Add the information to the detailed log.
cat $GSTESTLOG.tmp >> $GSTESTLOG
# Extract the summary information and add it to the summary file.
extract $GSTESTLOG.tmp "^Passed test:" "^Failed test:" "^Failed build:" "^Completed file:" "^Failed file:" "^Failed script:" "^Dashed hope:" "^Failed set:" "^Skipped set:" > $GSTESTSUM.tmp
extract $GSTESTLOG.tmp "^Passed test:" "^Failed test:" "^Failed build:" "^Completed file:" "^Failed file:" "^Dashed hope:" "^Failed set:" "^Skipped set:" > $GSTESTSUM.tmp
cat $GSTESTSUM.tmp >> $GSTESTSUM
# If there were failures or unresolved tests then report them...
if present $GSTESTSUM.tmp "^Failed script:" "^Failed build:" "^Failed file:" "^Failed set:" "^Failed test:"
if present $GSTESTSUM.tmp "^Failed build:" "^Failed file:" "^Failed set:" "^Failed test:"
then
echo
echo $TESTFILE:
extract $GSTESTSUM.tmp "^Failed script:" "^Failed build:" "^Failed file:" "^Failed set:" "^Failed test:"
extract $GSTESTSUM.tmp "^Failed build:" "^Failed file:" "^Failed set:" "^Failed test:"
fi
return $RUNEXIT
fi
}
@ -290,8 +393,30 @@ do
fi
fi
# Check for a custom makefile template, if it exists use it.
# Custom.mk is deprecated ... for backward compatibility only.
if test -r GNUmakefile.template
then
TEMPLATE=GNUmakefile.template
elif test -r Custom.mk
then
TEMPLATE=Custom.mk
elif test -r GNUmakefile.preamble
then
TEMPLATE=$GSTESTTOP/GNUmakefile.in
elif test -r GNUmakefile.postamble
then
TEMPLATE=$GSTESTTOP/GNUmakefile.in
elif test -r ../GNUmakefile.super
then
TEMPLATE=$GSTESTTOP/GNUmakefile.in
else
TEMPLATE=
fi
# Now we process each test file in turn.
# When cleaning, we only need to do one clean per directory.
RUNEXOT=0
for TESTFILE in $TESTS
do
run_test_file
@ -350,7 +475,7 @@ else
# common (hopefully passes) output first.
# NB. we omit the 'Completed file' tests as uninteresting ... users
# generally only want to see the total pass count and any problems.
extract tests.sum "^Passed test:" "^Failed test:" "^Failed script:" "^Failed build:" "^Failed file:" "^Dashed hope:" "^Failed set:" "^Skipped set:" | 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
extract tests.sum "^Passed test:" "^Failed test:" "^Failed build:" "^Failed file:" "^Dashed hope:" "^Failed set:" "^Skipped set:" | 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
else
echo "No tests found." > tests.tmp
fi

View file

@ -1,208 +0,0 @@
#!/bin/sh
#
# run tests script for the GNUstep Testsuite
#
# Copyright (C) 2005-2011 Free Software Foundation, Inc.
#
# Written by: Alexander Malmberg <alexander@malmberg.org>
# Updated 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: ./runtest.sh test_name.m
#
# Compiles and runs the test test_name. Detailed logging should go to stdout;
# only summary information should go to stderr.
if test x"GSTESTMODE" = x
then
echo "Do not execute this script directly... use gnustep-tests instead"
exit 1
fi
USEDEBUG=YES
# Argument checking
while test $# != 0
do
gs_option=
case $1 in
--help | -h)
echo "$0: Script to run a test a GNUstep testsuite program"
echo "Usage: ./runtest.sh test_name.m"
echo "Options:"
echo " --help - Print help"
echo
exit 0
;;
--debug | -d) # ignore for backward compatibility
;;
*)
break
;;
esac
shift
done
if test x"$BASH_VERSION" = x
then
# In some shells the built in 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 $@
}
fi
if test x$1 = x
then
echo "ERROR: $0: No test given"
exit 1
fi
if test $# != 1
then
echo "ERROR: $0: Too many arguments (single test file name expected)"
exit 1
fi
if test -e $1
then
if test ! -f $1
then
echo "ERROR: $0: Argument ($1) is not the name of a regular file"
exit 1
fi
if test ! -r $1
then
echo "ERROR: $0: Test file ($1) is not readable by you"
exit 1
fi
else
echo "ERROR: $0: Test file ($1) does not exist"
exit 1
fi
NAME=`basename $1`
if test ! -f IGNORE
then
# Remove the extension, if there is one. If there is no extension, add
# .obj .
TESTNAME=`echo $NAME | sed -e"s/^\(test^.]*\)$/\1.obj./;s/\.[^.]*//g"`
# Check for a custom makefile template, if it exists use it.
# Custom.mk is deprecated ... for backward compatibility only.
if test -r GNUmakefile.template
then
TEMPLATE=GNUmakefile.template
elif test -r Custom.mk
then
TEMPLATE=Custom.mk
elif test -r GNUmakefile.preamble
then
TEMPLATE=$GSTESTTOP/GNUmakefile.in
elif test -r GNUmakefile.postamble
then
TEMPLATE=$GSTESTTOP/GNUmakefile.in
elif test -r ../GNUmakefile.super
then
TEMPLATE=$GSTESTTOP/GNUmakefile.in
else
TEMPLATE=
fi
if test x"$TEMPLATE" = x
then
# The very simple case, we just need to compile a single file
# putting the executable in the obj subdirectory.
rm -rf ./obj
mkdir ./obj
BUILD_CMD="$CC -o ./obj/$TESTNAME $NAME $GSTESTFLAGS $GSTESTLIBS"
CLEAN_CMD=echo
RUN_CMD=./obj/$TESTNAME
else
BUILD_CMD="$MAKE_CMD $MAKEFLAGS debug=yes"
CLEAN_CMD="$MAKE_CMD clean"
RUN_CMD="$MAKE_CMD -s test"
# 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.
rm -f GNUmakefile
if test "$GSTESTMODE" = "failfast"
then
sed -e "s/@TESTNAME@/$TESTNAME/;s/@FILENAME@/$NAME/;s/@FAILFAST@/-DFAILFAST=1/;s^@INCLUDEDIR@^$GSTESTTOP^" < $TEMPLATE > GNUmakefile
else
sed -e "s/@TESTNAME@/$TESTNAME/;s/@FILENAME@/$NAME/;s/@FAILFAST@//;s^@INCLUDEDIR@^$GSTESTTOP^" < $TEMPLATE > GNUmakefile
fi
fi
if test "$GSTESTMODE" = "clean"
then
$CLEAN_CMD >/dev/null 2>&1
rm -f GNUmakefile
rm -rf obj core
else
# Clean up to avoid contamination by previous tests. Assume
# that this will never fail in any interesting way.
$CLEAN_CMD >/dev/null 2>&1
# Compile it. Redirect errors to stdout so it shows up in the log,
# but not in the summary.
$BUILD_CMD 2>&1
if test $? != 0
then
echo "Failed build: $1" >&2
if test "$GSTESTMODE" = "failfast"
then
exit 99
fi
else
# We want aggressive memory checking.
# Tell glibc to check for malloc errors, and to crash if it detects
# any.
MALLOC_CHECK_=2
export MALLOC_CHECK
# Tell GNUstep-base to check for messages sent to deallocated objects
# and crash if it happens.
NSZombieEnabled=YES
CRASH_ON_ZOMBIE=YES
export NSZombieEnabled CRASH_ON_ZOMBIE
echo Running $1...
# 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).
$RUN_CMD
if test $? != 0
then
if test -r $NAME.abort
then
echo "Completed file: $1" >&2
else
echo "Failed file: $1 aborted without running all tests!" >&2
if test "$GSTESTMODE" = "failfast"
then
exit 99
fi
fi
else
echo "Completed file: $1" >&2
fi
fi
fi
# Clean up any core dump.
rm -f core
fi