Skip to content

Instantly share code, notes, and snippets.

@movitto
Created January 28, 2017 01:49
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save movitto/6107bf9bbe6b6e229ce09a5a42814701 to your computer and use it in GitHub Desktop.
Save movitto/6107bf9bbe6b6e229ce09a5a42814701 to your computer and use it in GitHub Desktop.
Parallel Catch - Invokes philsquared/Catch tests in a parallel fashion (https://github.com/philsquared/Catch)
# runs tests in parallel
TEST_CMD="./build/test/run_unit_tests"
JOBS="8"
TAGS="$($TEST_CMD -l | grep Scenario -A 1 | grep -v Scenario | sort -u)"
IFS=' ' read -a SPLIT <<< $TAGS
NUM_TAGS=${#SPLIT[@]}
# so as to round up
PER_JOB=`expr $NUM_TAGS + $JOBS - 1`
PER_JOB=`expr $PER_JOB / $JOBS`
echo "$NUM_TAGS total tags / $PER_JOB per job"
tag=0
for j in $(seq 1 $JOBS)
do
job=""
for t in $(seq 1 $PER_JOB)
do
if [ "$tag" -ge "$NUM_TAGS" ]
then
continue
fi
if [ "$job" != "" ]
then
job="$job,"
fi
job="$job${SPLIT[$tag]}"
tag=`expr $tag + 1`
done
echo $TEST_CMD $job
$TEST_CMD $job&
done
wait
echo
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment