forked from Islandora-Devops/isle-dc
-
Notifications
You must be signed in to change notification settings - Fork 6
/
Copy pathrun-tests.sh
executable file
·67 lines (58 loc) · 1.99 KB
/
run-tests.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
#!/bin/sh
#set -vx
warn() {
if [ -t 1 ] ; then
echo "WARNING: running the test suite will result in resetting the stack's state "
echo "to the SNAPSHOT_TAG specified in .env. This will wipe out all local changes "
echo "to Drupal's databases and remove any active content or configuration added since"
echo "the last snapshot."
echo ""
echo "WARNING: continue? [Y/n]"
read line; line=$(echo "$line" | tr a-z A-Z); if [ $line != "Y" ]; then echo aborting; exit 1 ; fi
fi
}
reset() {
printf "\nResetting state to last snapshot\n"
docker-compose down -v 2>/dev/null || true
make -s up 2>/dev/null
}
# Execute the specified test in a subshell, provided the contents of .env as its environment and tests/.funcs.sh for
# common shell functions
execute() {
local testscript="$1"
if [ ! -f "${testscript}" ] ; then
origtestscript="${testscript}"
testscript="${testscript}.sh"
fi
if [ ! -f "${testscript}" ] ; then
echo "Checked for the presence of ${origtestscript} and ${testscript}, but neither existed."
echo "exiting"
exit 1
fi
bash -c "set -a && \
sed -e 's/^REQUIRED_SERIVCES=\(.*\)/REQUIRED_SERIVCES="\1"/' < .env > /tmp/test-env && \
source /tmp/test-env && \
export ENV_FILE=/tmp/test-env && \
source tests/.includes.sh && \
${testscript}" || { FAILURES="${FAILURES} $testscript" && echo "FAIL: $testscript"; }
}
# If a test is specified, execute it using the existing state, otherwise run all tests, resetting the state for each
if [ -n "$1" ] ; then
reset
testscript="$1"
printf "\n\nRunning ${testscript} using the current Drupal state (i.e. no reset of the environment will occur)\n"
execute tests/${testscript}
else
warn
for testscript in tests/*.sh; do
reset
printf "\n\nRunning ${testscript}\n"
execute ${testscript}
done
reset
fi
if [ ! -z "${FAILURES}" ] ; then
printf "\nFAIL: ${FAILURES}\n"
exit 1
fi
printf "\nSUCCESS: All test passed\n"