#!/bin/bash set -eu export DEBUG=superagent-sync,e2e:* export DEBUG_COLORS=true test_pids=() test_logs=() # before rm -f logs/* echo "Before" if ! ./node_modules/.bin/mocha --bail test/before.js > "logs/before.log" 2>&1; then echo "Before script failed" cat "logs/before.log" exit 1 fi # run tests readonly tests=(app-flow-test cloudron-user-test new-user-test cloudron-backup-test custom-domain-test cloudron-update-test) for t in "${tests[@]}"; do ./node_modules/.bin/mocha --bail "test/${t}.js" > "logs/${t}.log" 2>&1 & test_pids+=("$!") echo "Starting test ${t} with pid ${test_pids[-1]}" test_logs+=("logs/${t}.log") done # stream all the logs (to stderr so that it's not in email but in deploy logs) sleep 10 # wait for cloudron-update-test.log to get created (since it's a background subshell) tail -f ${test_logs[*]} >&2 & tail_pid=$! # wait for tests to finish fail=0 echo "Waiting for jobs to finish" for pid in "${test_pids[@]}"; do if ! wait $pid; then let "fail+=1" echo "$pid failed" fi done kill -9 "${tail_pid}" # after echo "After" if ! ./node_modules/.bin/mocha --bail test/after.js > "logs/after.js" 2>&1; then echo "After script failed" cat "logs/after.log" fi # dump logs for email echo echo for log_file in "${test_logs[@]}"; do echo "=========== ${log_file} ==============" cat "${log_file}" echo echo done if [ "$fail" == "0" ]; then exit 0 else echo "Fail count: ${fail}" exit 1 fi