]> git.ipfire.org Git - thirdparty/squid.git/blobdiff - test-builds.sh
SourceFormat Enforcement
[thirdparty/squid.git] / test-builds.sh
index 68f2b2b3ab1089da5763fd18f9f2b71fc1ae5cf4..f94ef0e16d0fa9ec97a941b30a891bb3d02b1bf6 100755 (executable)
@@ -1,5 +1,12 @@
 #!/bin/sh
 #
+##
+## Copyright (C) 1996-2015 The Squid Software Foundation and contributors
+##
+## Squid software is distributed under GPLv2+ license and includes
+## contributions from numerous individuals and organizations.
+## Please see the COPYING and CONTRIBUTORS files for details.
+##
 #  Run all or some build tests for a given OS environment.
 #
 top=`dirname $0`
@@ -9,6 +16,7 @@ globalResult=0
 cleanup="no"
 verbose="no"
 keepGoing="no"
+remove_cache_file="true"
 while [ $# -ge 1 ]; do
     case "$1" in
     --cleanup)
@@ -23,6 +31,20 @@ while [ $# -ge 1 ]; do
        keepGoing="yes"
        shift
        ;;
+    --use-config-cache)
+        #environment variable will be picked up by buildtest.sh
+        cache_file=/tmp/config.cache.$$
+        export cache_file
+        shift
+        ;;
+    --aggressively-use-config-cache)
+        #environment variable will be picked up by buildtest.sh
+        #note: use ONLY if you know what you're doing
+        cache_file=/tmp/config.cache
+        remove_cache_file="false"
+        export cache_file
+        shift
+        ;;
     *)
        break
        ;;
@@ -43,8 +65,11 @@ buildtest() {
     btlayer="bt${layer}"
     log=${btlayer}.log
     echo "TESTING: ${layer}"
-    chmod -R 777 ${btlayer}
-    rm -f -r ${btlayer} && mkdir ${btlayer}
+    if test -e ${btlayer}; then
+       chmod -R 777 ${btlayer};
+    fi
+    rm -f -r ${btlayer} || ( echo "FATAL: Failed to prepare test build sandpit." ; exit 1 )
+    mkdir ${btlayer}
     if test "${verbose}" = "yes" ; then
         ls -la ${btlayer}
     fi
@@ -78,19 +103,20 @@ buildtest() {
     errors="^ERROR|\ error:|\ Error\ |No\ such|assertion\ failed|FAIL:|:\ undefined"
     grep -E "${errors}" ${log}
 
-    if test "${cleanup}" = "yes" ; then
-       echo "REMOVE DATA: ${btlayer}"
-       chmod -R 777 ${btlayer}
-       rm -f -r ${btlayer}
-    fi
-
     if test $result -eq 0; then
        # successful execution
        if test "${verbose}" = "yes"; then
            echo "Build OK. Global result is $globalResult."
        fi
+       if test "${cleanup}" = "yes" ; then
+           echo "REMOVE DATA: ${btlayer}"
+           chmod -R 777 ${btlayer}
+           rm -f -r ${btlayer}
+           echo "REMOVE LOG: ${log}"
+           rm -f -r ${log}
+       fi
     else
-        if test "${verbose}" = "yes" ; then
+        if test "${verbose}" != "yes" ; then
             echo "Build Failed. Last log lines are:"
             tail -20 ${log}
         else
@@ -98,13 +124,13 @@ buildtest() {
         fi
         globalResult=1
     fi
-
-    if test "${cleanup}" = "yes" ; then
-       echo "REMOVE LOG: ${log}"
-       rm -f -r ${log}
-    fi
 }
 
+# if using cache, make sure to clear it up first
+if [ -n "$cache_file" -a -e "$cache_file" -a "$remove_cache_file" = "true" ]; then
+    rm $cache_file
+fi
+
 # Decide what tests to run, $* contains test spec names or filenames.
 # Use all knows specs if $* is empty or a special macro called 'all'.
 if test -n "$*" -a "$*" != all; then
@@ -137,4 +163,9 @@ for t in $tests; do
     fi
 done
 
+# if using cache, make sure to clear it up first
+if [ -n "$cache_file" -a -e "$cache_file" -a "$remove_cache_file" = "true" ]; then
+    rm $cache_file
+fi
+
 exit $globalResult