69 lines
1.6 KiB
Bash
Executable File
69 lines
1.6 KiB
Bash
Executable File
#!/bin/bash
|
|
|
|
set -eu
|
|
|
|
export DEBUG=superagent-sync,e2e:*
|
|
export DEBUG_COLORS=true
|
|
|
|
test_pids=()
|
|
test_logs=()
|
|
|
|
# cleanup
|
|
rm -f logs/*
|
|
echo "Cleaning up"
|
|
if ! ./node_modules/.bin/mocha --bail test/000-cleanup.js > "logs/000-cleanup.log" 2>&1; then
|
|
echo "Cleanup script failed"
|
|
cat "logs/000-cleanup.log"
|
|
exit 1
|
|
fi
|
|
|
|
# run tests
|
|
readonly tests=(app-flow-test cloudron-user-test new-user-test cloudron-backup-test custom-domain-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
|
|
|
|
# update test modifies release file, so run it separately
|
|
sleep 20 # wait for the other tests to have created the cloudron
|
|
./node_modules/.bin/mocha --bail "test/cloudron-update-test.js" > "logs/cloudron-update-test.log" 2>&1 &
|
|
test_pids+=("$!")
|
|
echo "Starting test cloudron-update-test with pid ${test_pids[-1]}"
|
|
test_logs+=("logs/cloudron-update-test.log")
|
|
|
|
# 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}"
|
|
|
|
echo
|
|
echo
|
|
for log_file in "${test_logs[@]}"; do
|
|
echo "=========== ${t} =============="
|
|
cat "${log_file}"
|
|
echo
|
|
echo
|
|
done
|
|
|
|
if [ "$fail" == "0" ]; then
|
|
exit 0
|
|
else
|
|
echo "Fail count: ${fail}"
|
|
exit 1
|
|
fi
|
|
|