Better cleanup in autotest.sh
Configs correctly cleaned, even if phpunit fails or autotest interrupted
This commit is contained in:
parent
55142186de
commit
5acbeb9666
|
@ -109,3 +109,5 @@ Vagrantfile
|
||||||
/tests/autotest*
|
/tests/autotest*
|
||||||
/tests/data/lorem-copy.txt
|
/tests/data/lorem-copy.txt
|
||||||
/tests/data/testimage-copy.png
|
/tests/data/testimage-copy.png
|
||||||
|
/config/config-autotest-backup.php
|
||||||
|
/config/autoconfig.php
|
||||||
|
|
|
@ -60,20 +60,25 @@ if [ "$1" ]; then
|
||||||
fi
|
fi
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# Back up existing (dev) config if one exists
|
# Back up existing (dev) config if one exists and backup not already there
|
||||||
if [ -f config/config.php ]; then
|
if [ -f config/config.php ] && [ ! -f config/config-autotest-backup.php ]; then
|
||||||
mv config/config.php config/config-autotest-backup.php
|
mv config/config.php config/config-autotest-backup.php
|
||||||
fi
|
fi
|
||||||
|
|
||||||
function restore_config {
|
function cleanup_config {
|
||||||
|
cd "$BASEDIR"
|
||||||
# Restore existing config
|
# Restore existing config
|
||||||
if [ -f config/config-autotest-backup.php ]; then
|
if [ -f config/config-autotest-backup.php ]; then
|
||||||
mv config/config-autotest-backup.php config/config.php
|
mv config/config-autotest-backup.php config/config.php
|
||||||
fi
|
fi
|
||||||
|
# Remove autotest config
|
||||||
|
if [ -f config/autoconfig.php ]; then
|
||||||
|
rm config/autoconfig.php
|
||||||
|
fi
|
||||||
}
|
}
|
||||||
|
|
||||||
# restore config on exit, even when killed
|
# restore config on exit
|
||||||
trap restore_config SIGINT SIGTERM
|
trap cleanup_config EXIT
|
||||||
|
|
||||||
# use tmpfs for datadir - should speedup unit test execution
|
# use tmpfs for datadir - should speedup unit test execution
|
||||||
if [ -d /dev/shm ]; then
|
if [ -d /dev/shm ]; then
|
||||||
|
@ -278,9 +283,6 @@ else
|
||||||
execute_tests "$1" "$2"
|
execute_tests "$1" "$2"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
cd "$BASEDIR"
|
|
||||||
|
|
||||||
restore_config
|
|
||||||
#
|
#
|
||||||
# NOTES on mysql:
|
# NOTES on mysql:
|
||||||
# - CREATE DATABASE oc_autotest;
|
# - CREATE DATABASE oc_autotest;
|
||||||
|
|
|
@ -66,20 +66,25 @@ if [ "$1" ]; then
|
||||||
fi
|
fi
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# Back up existing (dev) config if one exists
|
# Back up existing (dev) config if one exists and backup not already there
|
||||||
if [ -f config/config.php ]; then
|
if [ -f config/config.php ] && [ ! -f config/config-autotest-backup.php ]; then
|
||||||
mv config/config.php config/config-autotest-backup.php
|
mv config/config.php config/config-autotest-backup.php
|
||||||
fi
|
fi
|
||||||
|
|
||||||
function restore_config {
|
function cleanup_config {
|
||||||
|
cd "$BASEDIR"
|
||||||
# Restore existing config
|
# Restore existing config
|
||||||
if [ -f config/config-autotest-backup.php ]; then
|
if [ -f config/config-autotest-backup.php ]; then
|
||||||
mv config/config-autotest-backup.php config/config.php
|
mv config/config-autotest-backup.php config/config.php
|
||||||
fi
|
fi
|
||||||
|
# Remove autotest config
|
||||||
|
if [ -f config/autoconfig.php ]; then
|
||||||
|
rm config/autoconfig.php
|
||||||
|
fi
|
||||||
}
|
}
|
||||||
|
|
||||||
# restore config on exit, even when killed
|
# restore config on exit
|
||||||
trap restore_config SIGINT SIGTERM
|
trap cleanup_config EXIT
|
||||||
|
|
||||||
# use tmpfs for datadir - should speedup unit test execution
|
# use tmpfs for datadir - should speedup unit test execution
|
||||||
if [ -d /dev/shm ]; then
|
if [ -d /dev/shm ]; then
|
||||||
|
@ -236,9 +241,6 @@ else
|
||||||
execute_tests "$1" "$2" "$3"
|
execute_tests "$1" "$2" "$3"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
cd "$BASEDIR"
|
|
||||||
|
|
||||||
restore_config
|
|
||||||
#
|
#
|
||||||
# NOTES on mysql:
|
# NOTES on mysql:
|
||||||
# - CREATE DATABASE oc_autotest;
|
# - CREATE DATABASE oc_autotest;
|
||||||
|
|
18
autotest.sh
18
autotest.sh
|
@ -60,20 +60,25 @@ if [ "$1" ]; then
|
||||||
fi
|
fi
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# Back up existing (dev) config if one exists
|
# Back up existing (dev) config if one exists and backup not already there
|
||||||
if [ -f config/config.php ]; then
|
if [ -f config/config.php ] && [ ! -f config/config-autotest-backup.php ]; then
|
||||||
mv config/config.php config/config-autotest-backup.php
|
mv config/config.php config/config-autotest-backup.php
|
||||||
fi
|
fi
|
||||||
|
|
||||||
function restore_config {
|
function cleanup_config {
|
||||||
|
cd "$BASEDIR"
|
||||||
# Restore existing config
|
# Restore existing config
|
||||||
if [ -f config/config-autotest-backup.php ]; then
|
if [ -f config/config-autotest-backup.php ]; then
|
||||||
mv config/config-autotest-backup.php config/config.php
|
mv config/config-autotest-backup.php config/config.php
|
||||||
fi
|
fi
|
||||||
|
# Remove autotest config
|
||||||
|
if [ -f config/autoconfig.php ]; then
|
||||||
|
rm config/autoconfig.php
|
||||||
|
fi
|
||||||
}
|
}
|
||||||
|
|
||||||
# restore config on exit, even when killed
|
# restore config on exit
|
||||||
trap restore_config SIGINT SIGTERM
|
trap cleanup_config EXIT
|
||||||
|
|
||||||
# use tmpfs for datadir - should speedup unit test execution
|
# use tmpfs for datadir - should speedup unit test execution
|
||||||
if [ -d /dev/shm ]; then
|
if [ -d /dev/shm ]; then
|
||||||
|
@ -234,9 +239,6 @@ else
|
||||||
execute_tests "$1" "$FILENAME" "$3"
|
execute_tests "$1" "$FILENAME" "$3"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
cd "$BASEDIR"
|
|
||||||
|
|
||||||
restore_config
|
|
||||||
#
|
#
|
||||||
# NOTES on mysql:
|
# NOTES on mysql:
|
||||||
# - CREATE DATABASE oc_autotest;
|
# - CREATE DATABASE oc_autotest;
|
||||||
|
|
Loading…
Reference in New Issue