diff --git a/e2etestrunner.js b/e2etestrunner.js index 8b3c858..e235cc3 100755 --- a/e2etestrunner.js +++ b/e2etestrunner.js @@ -80,7 +80,7 @@ function getLatestBoxVersion(callback) { function runTests(latestVersionInfo, callback) { debug('Running tests for %j', latestVersionInfo); - gNpmTest = shell.system('e2etestrunner', 'npm test', function (error, stdout, stderr) { + gNpmTest = shell.system('e2etestrunner', 'npm run-script parallel_test', function (error, stdout, stderr) { gNpmTest = null; debug('Final test result', error); diff --git a/logs/.gitignore b/logs/.gitignore new file mode 100644 index 0000000..e69de29 diff --git a/package.json b/package.json index d5478e1..4267901 100644 --- a/package.json +++ b/package.json @@ -4,7 +4,8 @@ "description": "End to end testing", "main": "test.js", "scripts": { - "test": "DEBUG=superagent-sync,e2e:* DEBUG_COLORS=true ./node_modules/.bin/mocha --bail test/*" + "test": "DEBUG=superagent-sync,e2e:* DEBUG_COLORS=true ./node_modules/.bin/mocha --bail test/*", + "parallel_test": "./parallel_test.sh" }, "repository": { "type": "git", diff --git a/parallel_test.sh b/parallel_test.sh new file mode 100755 index 0000000..475488f --- /dev/null +++ b/parallel_test.sh @@ -0,0 +1,43 @@ +#!/bin/bash + +set -eu + +export DEBUG=superagent-sync,e2e:* +export DEBUG_COLORS=true + +readonly tests=(app-flow-test cloudron-update-test cloudron-user-test new-user-test) + +# cleanup +rm -f logs/* +echo "Cleaning up" +./node_modules/.bin/mocha test/000-cleanup.js > "logs/000-cleanup.log" 2>&1 + +# run tests +for t in "${tests[@]}"; do + echo "Starting test ${t}" + ./node_modules/.bin/mocha "test/${t}.js" > "logs/${t}.log" 2>&1 & +done + +# wait for tests to finish +fail=0 +echo "Waiting for jobs to finish" +for job in `jobs -p`; do + wait $job || let "fail+=1" +done + +echo +echo +for t in "${tests[@]}"; do + echo "=========== ${t} ==============" + cat "test/${t}.log" + echo + echo +done + +if [ "$fail" == "0" ]; then + exit 0 +else + echo "Fail count: ${fail}" + exit 1 +fi +