When doing 'make clean', we remove the cached image. So doing
'make -C TEST-NN-foo clean setup run clean-again' in a loop is very slow.
Let's filter out the 'clean' target (if specified), and do the cleaning
in the beginning, and then run other targets in a loop as before.
BUILD_DIR="$($(dirname "$0")/../tools/find-build-dir.sh)"
if [ $# -gt 0 ]; then
args="$@"
- do_clean=0
else
args="setup run clean-again"
- do_clean=1
fi
+args_no_clean=$(sed -r 's/(^| )clean($| )/ /g' <<<$args)
+do_clean=$( [ "$args" = "$args_no_clean" ]; echo $? )
ninja -C "$BUILD_DIR"
cd "$(dirname "$0")"
+# Let's always do the cleaning operation first, because it destroys the image
+# cache.
if [ $do_clean = 1 ]; then
for TEST in TEST-??-* ; do
( set -x ; make -C "$TEST" "BUILD_DIR=$BUILD_DIR" clean )
echo -e "\n--x-- Running $TEST --x--"
set +e
- ( set -x ; make -C "$TEST" "BUILD_DIR=$BUILD_DIR" $args )
+ ( set -x ; make -C "$TEST" "BUILD_DIR=$BUILD_DIR" $args_no_clean )
RESULT=$?
set -e
echo "--x-- Result of $TEST: $RESULT --x--"