Skip to content

Instantly share code, notes, and snippets.

@tednaleid
Last active August 29, 2015 14:12
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save tednaleid/97bbe03d877a3da765a0 to your computer and use it in GitHub Desktop.
Save tednaleid/97bbe03d877a3da765a0 to your computer and use it in GitHub Desktop.
run grails tests in parallel
#! /usr/bin/env bash
command -v parallel >/dev/null 2>&1 || { echo >&2 "Please install parallel via brew: brew install parallel"; exit 1; }
BASE_DIR=$(cd "$(dirname "$0")"; pwd -P)/..
PARALLEL_WORKERS=2
export GRAILS_OPTS="-Xmx2G -Xms2g -XX:MaxPermSize=500m"
OPEN_TESTLOG_AND_FAIL="( open target/test-reports/html/index.html && exit 1 )"
TEST_APP="( grails test-app --non-interactive || $OPEN_TESTLOG_AND_FAIL )"
# run all commands in the heredoc in parallel, echo out full lines as they're collected with no more than $PARALLEL_WORKERS at at time
SHELL=/bin/bash parallel --ungroup --line-buffer -j $PARALLEL_WORKERS --no-notice << $EOF
$BASE_DIR/bin/testAllKarma.sh # script in same directory to run karma tests
echo "running test-app" && $TEST_APP
$EOF
PARALLEL_EXIT_CODE=$?
if [[ $PARALLEL_EXIT_CODE != 0 ]]; then
echo "Error running tests"
exit $PARALLEL_EXIT_CODE
else
echo "All tests passed successfully"
fi
@tednaleid
Copy link
Author

If you want to run unit/integration/functional also in parallel, you can by making new lines for those in the parallel EOF heredoc, but you'll want to make sure that you're setting up unique working directories for each of them so they don't collide.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment