diff --git a/test/100_cross_hosts_test.sh b/test/100_cross_hosts_test.sh index 13789bbd..faa445e5 100755 --- a/test/100_cross_hosts_test.sh +++ b/test/100_cross_hosts_test.sh @@ -18,7 +18,6 @@ weave_on $HOST2 launch $HOST1 weave_on $HOST2 run $C2/24 -t --name=c2 ubuntu weave_on $HOST1 run $C1/24 -t --name=c1 ubuntu -ok=$(exec_on $HOST1 c1 ping -q -c 4 $C2 >&2 && echo ok) -assert "echo $ok" "ok" +assert_raises "exec_on $HOST1 c1 ping -q -c 4 $C2" end_suite diff --git a/test/110_encryption_test.sh b/test/110_encryption_test.sh index 79831acf..2e604984 100755 --- a/test/110_encryption_test.sh +++ b/test/110_encryption_test.sh @@ -18,7 +18,6 @@ weave_on $HOST2 launch -password notverysecure $HOST1 weave_on $HOST2 run $C2/24 -t --name=c2 ubuntu weave_on $HOST1 run $C1/24 -t --name=c1 ubuntu -ok=$(exec_on $HOST1 c1 ping -q -c 4 $C2 >&2 && echo ok) -assert "echo $ok" "ok" +assert_raises "exec_on $HOST1 c1 ping -q -c 4 $C2" end_suite diff --git a/test/config.sh b/test/config.sh index c20f55a6..c67896ba 100644 --- a/test/config.sh +++ b/test/config.sh @@ -2,6 +2,13 @@ set -e +# Protect against being sourced multiple times to prevent +# overwriting assert.sh global state +if ! [ -z "$SOURCED_CONFIG_SH" ]; then + return +fi +SOURCED_CONFIG_SH=true + # these ought to match what is in Vagrantfile N_MACHINES=${N_MACHINES:-2} IP_PREFIX=${IP_PREFIX:-192.168.48} @@ -28,12 +35,29 @@ remote() { $@ > >(while read line; do echo -e "\e[0;34m$rem>\e[0m $line"; done) } +colourise() { + echo -ne '\e['$1'm' + shift + # It's important that we don't do this in a subshell, as some + # commands we execute need to modify global state + "$@" + echo -ne '\e[0m' +} + whitely() { - echo -e '\e[1;37m'`$@`'\e[0m' + colourise '1;37' "$@" } greyly () { - echo -e '\e[0;37m'`$@`'\e[0m' + colourise '0;37' "$@" +} + +redly() { + colourise '1;31' "$@" +} + +greenly() { + colourise '1;32' "$@" } run_on() { diff --git a/test/run_all.sh b/test/run_all.sh index f69977c1..5ea2755d 100755 --- a/test/run_all.sh +++ b/test/run_all.sh @@ -9,6 +9,21 @@ if ! bash ./sanity_check.sh; then fi whitely echo ...ok +# Modified version of _assert_cleanup from assert.sh that +# prints overall status +check_test_status() { + if [ $? -ne 0 ]; then + redly echo "---= !!!ABNORMAL TEST TERMINATION!!! =---" + elif [ $tests_suite_status -ne 0 ]; then + redly echo "---= !!!SUITE FAILURES - SEE ABOVE FOR DETAILS!!! =---" + exit $tests_suite_status + else + greenly echo "---= ALL SUITES PASSED =---" + fi +} +# Overwrite assert.sh _assert_cleanup trap with our own +trap check_test_status EXIT + for t in *_test.sh; do echo greyly echo "---= Running $t =---"