Skip to content

Instantly share code, notes, and snippets.

@knoopx
Created April 29, 2015 15:54
Show Gist options
  • Save knoopx/cee46e6267f429cc1fd9 to your computer and use it in GitHub Desktop.
Save knoopx/cee46e6267f429cc1fd9 to your computer and use it in GitHub Desktop.
parallell-rspec
#!/usr/bin/env bash -e
set -euo pipefail
shopt -s globstar
shopt -s extglob
export RUBY_HEAP_MIN_SLOTS=2000000
export RUBY_HEAP_FREE_MIN=20000
export RUBY_GC_MALLOC_LIMIT=100000000
export TZ="Europe/Madrid"
export PGDATA=`mktemp -d`
export PGPORT=$(($RANDOM+2048))
export TMPDISK=$(hdiutil attach -nomount ram://$((512*1024*2)))
trap "pg_ctl -s -w -D $PGDATA stop; diskutil unmount $TMPDISK; hdiutil detach $TMPDISK" EXIT SIGTERM SIGKILL
diskutil erasevolume JHFS+ "tmp" $TMPDISK
pg_ctl -s -w init -D $PGDATA -o "-A trust"
pg_ctl -s -w -D $PGDATA start -o "-c fsync=off -c synchronous_commit=off -c full_page_writes=off -c random_page_cost=1.1 -c checkpoint_segments=64 -c checkpoint_completion_target=0.9 -c unix_socket_directories=$PGDATA"
ls $1/**/*_spec.rb | shuf | parallel -uX "bundle exec rake db:test:prepare && bundle exec rspec"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment