Last active
October 26, 2015 17:12
-
-
Save jcreixell/ee5ad2e0490e59160f91 to your computer and use it in GitHub Desktop.
Test stability checker for RSpec
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env bash | |
set -e | |
# Default options | |
CONCURRENCY="${CONCURRENCY:-4}" | |
TEST_PATH="${TEST_PATH:-.}" | |
PATTERN="${PATTERN:-*_spec.rb}" | |
REPETITIONS="${REPETITIONS:-1}" | |
setup () { | |
for CURRENT_BUILD_NAME in `seq 1 $CONCURRENCY` | |
do | |
ENGINE_ENV=test TEST_ENV_NUMBER=$CURRENT_BUILD_NAME bundle exec rake db:setup | |
done | |
} | |
run_test () { | |
echo running BUILD_NAME=$1 TEST=$2 | |
(TEST_ENV_NUMBER=$1 bundle exec rspec $2) | |
} | |
run_build () { | |
echo Starting build $1 | |
for CURRENT_TEST in `find $TEST_PATH -name "$PATTERN"` | |
do | |
for CURRENT_BUILD_NAME in `seq 1 $CONCURRENCY` | |
do | |
run_test $CURRENT_BUILD_NAME $CURRENT_TEST & | |
done | |
wait | |
done | |
} | |
echo Running $REPETITIONS builds with concurrency: $CONCURRENCY, PATH: $TEST_PATH, pattern: $PATTERN | |
setup | |
for CURRENT_BUILD in `seq 1 $REPETITIONS` | |
do | |
run_build $CURRENT_BUILD | |
done |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment