Hello,
When working on SourceLayout I got a few false errors from
build-test.sh when it could not find some string in the make output. The
attached patch fixes that by relying on make exit code rather than some
magic string some make targets may print in the middle of the make
process. The build is still considered failed if error strings are found
in the log.
I was also annoyed on how the test would quit on the first error,
wasting a lot of test time if the first error gets unnoticed. The
attached patch adds a --keep-going option, similar to "make -k". The
option is off by default so I am not changing the default behavior here.
Finally, I made test spec names processing a little bit more flexible.
It is now possible to explicitly specify multiple tests, similar to
"make all check distcheck".
More detailed comments are below. Please review.
Thank you,
Alex.
bb:approve
------- change log -----------
Support multiple test spec arguments. If at least one test fails, the script
exits with a non-zero code (but possibly not immediately, see --keep-going).
Each test spec is a test config file name or a well-known config name
(no path
or extension!). If no specs are given, all known test specs are used (as
before). The same happens if the only test spec given is 'all'. The
following are now equivalent:
./test-builds.sh
./test-builds.sh all
./test-builds.sh btlayer-00-default btlayer-01-minimal
btlayer-02-maximus
./test-builds.sh test-suite/buildtests/layer-*
You can mix file names and spec names, but not the 'all' macro: There is
currently no support for using 'all' together with other test cases.
Tolerate individual test errors if --keep-going is specified. This helps
when
one wants to find more errors than just the first one, especially when tests
are long and are running without a human watching.
When detecting test failures, rely on test-suite/buildtest.sh exit
status code
rather than on the presence of error-like strings in the log file.
Added and polished comments.
-----------------------------------
# Bazaar merge directive format 2 (Bazaar 0.90)
# revision_id: [email protected]\
# 6lkaoiv1jznsmql6
# target_branch: http://www.squid-cache.org/bzr/squid3/trunk
# testament_sha1: 66c28c9b4c5a70895ab7db67ca0763657272c2b7
# timestamp: 2009-03-09 10:38:20 -0600
# base_revision_id: [email protected]\
# 4hkp9exkjcdwqvfi
#
# Begin patch
=== modified file 'test-builds.sh'
--- test-builds.sh 2009-03-08 10:57:37 +0000
+++ test-builds.sh 2009-03-09 16:20:57 +0000
@@ -1,11 +1,14 @@
#!/bin/sh
#
-# Run specific build tests for a given OS environment.
+# Run all or some build tests for a given OS environment.
#
top=`dirname $0`
+globalResult=0
+
cleanup="no"
verbose="no"
+keepGoing="no"
while [ $# -ge 1 ]; do
case "$1" in
--cleanup)
@@ -16,15 +19,16 @@
verbose="yes"
shift
;;
+ --keep-going)
+ keepGoing="yes"
+ shift
+ ;;
*)
break
;;
esac
done
-# Things to catch
-errors="^ERROR|\ error:|\ Error\ |No\ such|assertion\ failed|FAIL:"
-
logtee() {
if [ $verbose = yes ]; then
tee $1
@@ -41,52 +45,93 @@
echo "TESTING: ${layer}"
rm -f -r ${btlayer} && mkdir ${btlayer}
{
+ result=255
cd ${btlayer}
if test -e $top/test-suite/buildtest.sh ; then
$top/test-suite/buildtest.sh $opts
+ result=$?
elif test -e ../$top/test-suite/buildtest.sh ; then
../$top/test-suite/buildtest.sh ../$opts
+ result=$?
+ else
+ echo "Error: cannot find $top/test-suite/buildtest.sh script"
+ result=1
fi
+ # log the result for the outer script to notice
+ echo "buildtest.sh result is $result";
} 2>&1 | logtee $log
+
+ result=1 # failure by default
+ if grep -q '^buildtest.sh result is 0$' $log; then
+ result=0
+ fi
+
grep -E "BUILD" ${log}
- grep -E "${errors}" $log && exit 1
+
+ # logged strings to treat as errors
+ errors="^ERROR|\ error:|\ Error\ |No\ such|assertion\ failed|FAIL:"
+ if grep -E "${errors}" $log; then
+ # Possible errors detected.
+ # Let's be conservative and assume those were real errors.
+ if test $result -eq 0; then
+ echo "Internal error: failed test with a successful result code"
+ result=1
+ # else we already know that there was an error
+ fi
+ fi
+
if test "${cleanup}" = "yes" ; then
echo "REMOVE DATA: ${btlayer}"
rm -f -r ${btlayer}
fi
- result=`tail -2 $log | head -1`
- if test "${result}" = "Build Successful." ; then
- echo "${result}"
+
+ if test $result -eq 0; then
+ # successful execution
+ if test "$verbose" = yes; then
+ echo 'Build OK.'
+ fi
else
- echo "Build Failed:"
+ echo "Build Failed ($result):"
tail -5 $log
- exit 1
+ globalResult=1
fi
+
if test "${cleanup}" = "yes" ; then
echo "REMOVE LOG: ${log}"
rm -f -r $log
fi
}
-# Run a single test build by name or opts file
-if [ -e "$1" ]; then
-
- buildtest $1
- exit 0
-fi
-tmp=`basename "${1}" .opts`
-if test -e $top/test-suite/buildtests/${tmp}.opts ; then
- buildtest $top/test-suite/buildtests/${tmp}.opts
- exit 0
-fi
-
-#
-# Run specific tests for each combination of configure-time
-# Options.
-#
-# These layers are constructed from detailed knowledge of
-# component dependencies.
-#
-for f in `ls -1 $top/test-suite/buildtests/layer*.opts` ; do
- buildtest $f
+# decide what tests to run, $* contains test spec names or filenames
+# use all knows specs if $* is empty
+if test -n "$*" -a "$*" != all; then
+ tests="$*"
+else
+ tests=`ls -1 $top/test-suite/buildtests/layer*.opts`
+fi
+
+for t in $tests; do
+ if test -e "$t"; then
+ # A configuration file
+ cfg="$t"
+ elif test -e "$top/test-suite/buildtests/${t}.opts"; then
+ # A well-known configuration name
+ cfg="$top/test-suite/buildtests/${t}.opts"
+ else
+ echo "Error: Unknown test specs '$t'"
+ cfg=''
+ globalResult=1
+ fi
+
+ # run the test, if any
+ if test -n "$cfg"; then
+ buildtest $cfg
+ fi
+
+ # quit on errors unless we should $keepGoing
+ if test $globalResult -ne 0 -a $keepGoing != yes; then
+ exit $globalResult
+ fi
done
+
+exit $globalResult
# Begin bundle
IyBCYXphYXIgcmV2aXNpb24gYnVuZGxlIHY0CiMKQlpoOTFBWSZTWXjpNacAA49fgEQwfff///Ot
3qX////+YAk9X27tgtHHKt0dcddBo7btqJbZRThKIQmmIZGhpkJtTIT9RNpPTUHqeoPUaaeo0DQB
ojQJhNAmptTUwQA9RoAaGjQaAaaAONGTIwjEAwmgwCaDQMmTRkyGEBhKZIIRpNI9U9qeomymj1P1
TxR6GmmhNMgNAeoDQONGTIwjEAwmgwCaDQMmTRkyGEBhIiIATQmTU9NEyGUn6UYYU00NA0AAHlKA
d0REFYgKogQkj2ba4/iK72Km19qwujlnueFpjYZ2OtdxS2ppXnGw3FSlvMaXaJYnYSNbjmMb9Lch
O7FeEvd+fbkLZf8s9llOOr+3t8BgZaPg4ooKLpNbpYVEG9iUMNHp+GGNOrhlgySjhUpNnC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