Created
June 1, 2017 19:53
-
-
Save nocash/d465f9101031c6e5ee272dc9db4249fd to your computer and use it in GitHub Desktop.
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
#!/bin/bash | |
relaxing=false | |
if [ "$1" = "--relax" ]; then | |
relaxing=true | |
shift | |
fi | |
iteration=0 | |
rspec_opts="$@" | |
function chill_out { | |
killall stress | |
} | |
function interrupted { | |
echo -en "\n*** Stress-spec is taking a chill pill... ***\n" | |
chill_out | |
print_run_count | |
exit $? | |
} | |
function print_run_count { | |
echo "*** Ran $iteration times. ***" | |
} | |
function check_stress { | |
command -v stress >&- | |
if [[ $? -gt 0 ]]; then | |
echo "You must install \"stress\" before running this script." | |
exit 1 | |
fi | |
} | |
function start_stressing { | |
stress --cpu 4 & | |
} | |
function run_spec { | |
local runner="bundle exec rspec $rspec_opts" | |
while true; do | |
let iteration=( $iteration + 1 ) | |
eval $runner || break | |
done | |
print_run_count | |
} | |
if [ "$relaxing" = false ]; then | |
trap interrupted SIGINT | |
check_stress | |
start_stressing | |
fi | |
run_spec | |
if [ "$relaxing" = false ]; then | |
chill_out | |
fi |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment