]> source.dussan.org Git - nextcloud-server.git/commitdiff
Restore autotest config on SIGINT or SIGTERM
authorVincent Petry <pvince81@owncloud.com>
Tue, 19 Aug 2014 20:46:24 +0000 (22:46 +0200)
committerVincent Petry <pvince81@owncloud.com>
Tue, 19 Aug 2014 20:46:24 +0000 (22:46 +0200)
When hitting Ctrl+C to interrupt unit test running, the old
configuration was not restored properly.

This fix traps the signal to properly restore the configuration after an
interruption.

autotest.sh

index 4030fc0250e95bc2a42d2890cf251294c6307b4c..d359aed91e7c190e55eb03295e724d7a00faaeed 100755 (executable)
@@ -63,6 +63,16 @@ if [ -f config/config.php ]; then
        mv config/config.php config/config-autotest-backup.php
 fi
 
+function restore_config {
+       # Restore existing config
+       if [ -f config/config-autotest-backup.php ]; then
+               mv config/config-autotest-backup.php config/config.php
+       fi
+}
+
+# restore config on exit, even when killed
+trap restore_config SIGINT SIGTERM
+
 # use tmpfs for datadir - should speedup unit test execution
 if [ -d /dev/shm ]; then
   DATADIR=/dev/shm/data-autotest$EXECUTOR_NUMBER
@@ -220,11 +230,7 @@ fi
 
 cd $BASEDIR
 
-# Restore existing config
-if [ -f config/config-autotest-backup.php ]; then
-       mv config/config-autotest-backup.php config/config.php
-fi
-
+restore_config
 #
 # NOTES on mysql:
 #  - CREATE DATABASE oc_autotest;