-
Notifications
You must be signed in to change notification settings - Fork 61
/
Copy pathrun-tests
executable file
·67 lines (57 loc) · 1.22 KB
/
run-tests
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
#!/usr/bin/env bash
# For each virtual machine where tests run, this script performs the following:
# - starts VM
# - starts the test suite witin a VM
# - stops the VM after the test suite is done
# global variable for script exit value
export EXIT_VALUE=0
register_failing_specs() {
EXIT_VALUE=1
}
run_vagrant() {
local box="$1"
vagrant up "$box"
}
# Halt vagrant after tests are done running, unless KEEP_RUNNING environment
# variable is set to 'true'.
stop_vagrant() {
local box="$1"
if [ -z "$KEEP_RUNNING" ]; then
vagrant halt "$box"
else
echo
echo "KEEP_RUNNING is set. Vagrant not halted."
fi
}
run_tests() {
local box="$1"
local test_file="/vagrant/test/run-tests-within-vm"
echo "Running test suite on $box from: $test_file"
echo
vagrant ssh "$box" -c "cd /vagrant; $test_file"
}
exit_message() {
local exit_val="$1"
echo
if [ $exit_val == 0 ]; then
echo "Success, tests pass!"
else
echo "Tests failed!" 1>&2
fi
}
run_tests_on_vm() {
local vm="$1"
run_vagrant "$vm"
run_tests "$vm"
local tests_exit_value="$?"
stop_vagrant "$vm"
if [ $tests_exit_value -gt 0 ]; then
register_failing_specs
fi
}
main() {
run_tests_on_vm "ubuntu_two_five"
exit_message "$EXIT_VALUE"
exit "$EXIT_VALUE"
}
main