joakimk / parallel_specs forked from grosser/parallel_specs

Rails: 2 CPUs + Parallel Specs = 2x Testing Speed

This URL has Read+Write access

joakimk (author)
Sun Jun 07 10:34:41 -0700 2009
commit  aa997b5d335b2d51bce86b613cae4cae44e85b6a
tree    b6f62bb900be319a8a801c6e011c108311b8a57b
parent  5d9bfaaf442cad9969f2a5b2d41276a75e2c5e0e
name age message
file .gitignore Thu Jun 04 00:18:17 -0700 2009 Added ignore for local scripts. [joakimk]
file README.markdown Loading commit data...
file Rakefile Sun May 17 22:52:33 -0700 2009 starting TDD approach [grosser]
directory lib/
directory spec/
directory tasks/
README.markdown

Rake tasks to run specs in parallel, to use multiple CPUs and speedup test runtime.

NOTE: This is a clone of http://github.com/grosser/parallel_specs

Setup

script/plugin install git://github.com/joakimk/parallel_specs.git

Add <%= ENV['TEST_ENV_NUMBER'] %> to the database name for the test environment in config/database.yml,
it is '' for process 1, and '2' for process 2.

test:
  adapter: mysql
  database: xxx_test<%= ENV['TEST_ENV_NUMBER'] %>
  username: root

For each environment, create the databases

mysql -u root -> create database xxx_test2;

Run like hell :D

rake spec:parallel:prepare[2] #db:reset for each database

rake spec:parallel[1] --> 86 seconds
rake spec:parallel    --> 47 seconds (default = 2)
rake spec:parallel[4] --> 26 seconds
...

Example output

2 processes for 210 specs, ~ 105 specs per process
... test output ...
Took 29.925333 seconds

TIPS

  • ./script/generate rspec if you are running rspec from gems (this plugin uses script/spec which may fail if rspec files are outdated)
  • with zsh this would be rake "spec:parallel:prepare[3]"

TODO

  • find out how many CPUs the user has here
  • grab the 'xxx examples ..' line and display them after all tests have finished

Authors

inspired by pivotal labs

Contributors

Michael Grosser
grosser.michael@gmail.com
Hereby placed under public domain, do what you want, just do not hold me accountable...