Permalink
Browse files

Merge branch 'refactor'

  • Loading branch information...
2 parents 31adff9 + ed58eba commit a97d53d8ef886f7742a73b1b153535adbec1da9e @grosser committed Mar 3, 2012
Showing with 1,304 additions and 1,137 deletions.
  1. +2 −4 Gemfile
  2. +8 −8 Gemfile.lock
  3. +18 −16 Rakefile
  4. +31 −61 Readme.md
  5. +48 −0 ReadmeRails2.md
  6. +0 −1 VERSION
  7. +1 −1 bin/parallel_cucumber
  8. +2 −0 bin/parallel_rspec
  9. +0 −2 bin/parallel_spec
  10. +2 −98 bin/parallel_test
  11. +0 −36 lib/parallel_cucumber.rb
  12. +0 −57 lib/parallel_cucumber/runtime_logger.rb
  13. +0 −52 lib/parallel_specs.rb
  14. +3 −125 lib/parallel_tests.rb
  15. +127 −0 lib/parallel_tests/cli.rb
  16. +42 −0 lib/parallel_tests/cucumber/runner.rb
  17. +58 −0 lib/parallel_tests/cucumber/runtime_logger.rb
  18. +2 −2 lib/parallel_tests/grouper.rb
  19. +5 −7 lib/parallel_tests/railtie.rb
  20. +4 −3 lib/{parallel_specs/spec_failures_logger.rb → parallel_tests/rspec/failures_logger.rb}
  21. +7 −3 lib/{parallel_specs/spec_logger_base.rb → parallel_tests/rspec/logger_base.rb}
  22. +59 −0 lib/parallel_tests/rspec/runner.rb
  23. +2 −2 lib/{parallel_specs/spec_runtime_logger.rb → parallel_tests/rspec/runtime_logger.rb}
  24. +2 −2 lib/{parallel_specs/spec_summary_logger.rb → parallel_tests/rspec/summary_logger.rb}
  25. +0 −78 lib/parallel_tests/runtime_logger.rb
  26. +6 −26 lib/parallel_tests/tasks.rb
  27. +139 −0 lib/parallel_tests/test/runner.rb
  28. +92 −0 lib/parallel_tests/test/runtime_logger.rb
  29. +3 −0 lib/parallel_tests/version.rb
  30. +0 −1 lib/tasks/parallel_tests.rake
  31. +11 −62 parallel_tests.gemspec
  32. +76 −37 spec/integration_spec.rb
  33. +0 −72 spec/parallel_cucumber_spec.rb
  34. +0 −173 spec/parallel_specs_spec.rb
  35. +76 −0 spec/parallel_tests/cucumber/runner_spec.rb
  36. +8 −8 spec/{parallel_specs/spec_failure_logger_spec.rb → parallel_tests/rspec/failure_logger_spec.rb}
  37. +178 −0 spec/parallel_tests/rspec/runner_spec.rb
  38. +4 −4 spec/{parallel_specs/spec_runtime_logger_spec.rb → parallel_tests/rspec/runtime_logger_spec.rb}
  39. +2 −2 spec/{parallel_specs/spec_summary_logger_spec.rb → parallel_tests/rspec/summary_logger_spec.rb}
  40. +243 −0 spec/parallel_tests/test/runner_spec.rb
  41. +19 −16 spec/parallel_tests/{ → test}/runtime_logger_spec.rb
  42. +2 −158 spec/parallel_tests_spec.rb
  43. +22 −20 spec/spec_helper.rb
View
@@ -1,11 +1,9 @@
source :rubygems
+gemspec
-gem 'parallel'
-
-group :dev do
+group :development do
gem 'test-unit', :platform => :ruby_19
gem 'rspec', '>=2.4'
gem 'cucumber'
gem 'rake'
- gem 'jeweler'
end
View
@@ -1,3 +1,9 @@
+PATH
+ remote: .
+ specs:
+ parallel_tests (0.7.0.rc3)
+ parallel
+
GEM
remote: http://rubygems.org/
specs:
@@ -11,13 +17,8 @@ GEM
diff-lcs (1.1.2)
gherkin (2.7.6)
json (>= 1.4.6)
- git (1.2.5)
- jeweler (1.6.3)
- bundler (~> 1.0)
- git (>= 1.2.5)
- rake
json (1.6.4)
- parallel (0.5.1)
+ parallel (0.5.15)
rake (0.8.7)
rspec (2.6.0)
rspec-core (~> 2.6.0)
@@ -35,8 +36,7 @@ PLATFORMS
DEPENDENCIES
cucumber
- jeweler
- parallel
+ parallel_tests!
rake
rspec (>= 2.4)
test-unit
View
@@ -1,20 +1,22 @@
-task :default => :spec
-require "rspec/core/rake_task"
-RSpec::Core::RakeTask.new(:spec) do |t|
- t.rspec_opts = '--backtrace --color'
+require 'bundler/gem_tasks'
+
+task :default do
+ sh "rspec spec/"
end
-begin
- require 'jeweler'
- Jeweler::Tasks.new do |gem|
- gem.name = "parallel_tests"
- gem.summary = "Run tests / specs / features in parallel"
- gem.email = "grosser.michael@gmail.com"
- gem.homepage = "http://github.com/grosser/#{gem.name}"
- gem.authors = "Michael Grosser"
- end
+# extracted from https://github.com/grosser/project_template
+rule /^version:bump:.*/ do |t|
+ sh "git status | grep 'nothing to commit'" # ensure we are not dirty
+ index = ['major', 'minor','patch'].index(t.name.split(':').last)
+ file = 'lib/GEM_NAME/version.rb'
+
+ version_file = File.read(file)
+ old_version, *version_parts = version_file.match(/(\d+)\.(\d+)\.(\d+)/).to_a
+ version_parts[index] = version_parts[index].to_i + 1
+ version_parts[2] = 0 if index < 2 # remove patch for minor
+ version_parts[1] = 0 if index < 1 # remove minor for major
+ new_version = version_parts * '.'
+ File.open(file,'w'){|f| f.write(version_file.sub(old_version, new_version)) }
- Jeweler::GemcutterTasks.new
-rescue LoadError
- puts "Jeweler, or one of its dependencies, is not available. Install it with: sudo gem install jeweler"
+ sh "bundle && git add #{file} Gemfile.lock && git commit -m 'bump version to #{new_version}'"
end
View
@@ -1,10 +1,13 @@
Speedup Test::Unit + RSpec + Cucumber by running parallel on multiple CPUs (or cores).<br/>
ParallelTests splits tests into even groups(by number of tests or runtime) and runs each group in a single process with its own database.
+[upgrading from 0.6 ?](https://github.com/grosser/parallel_tests/wiki/Upgrading-0.6.x-to-0.7.x)
+
Setup for Rails
===============
+[still using Rails 2?](https://github.com/grosser/parallel_tests/blob/master/ReadmeRails2.md)
+
## Install
-### Rails 3
If you use RSpec: ensure you got >= 2.4
As gem
@@ -19,28 +22,6 @@ OR as plugin
# add to Gemfile
gem "parallel", :group => :development
-
-### Rails 2
-
-As gem
-
- gem install parallel_tests
-
- # add to config/environments/development.rb
- config.gem "parallel_tests"
-
- # add to Rakefile
- begin; require 'parallel_tests/tasks'; rescue LoadError; end
-
-OR as plugin
-
- gem install parallel
-
- # add to config/environments/development.rb
- config.gem "parallel"
-
- ./script/plugin install git://github.com/grosser/parallel_tests.git
-
## Setup
ParallelTests uses 1 database per test-process, 2 processes will use `*_test` and `*_test2`.
@@ -67,7 +48,7 @@ ParallelTests uses 1 database per test-process, 2 processes will use `*_test` an
Test by pattern (e.g. use one integration server per subfolder / see if you broke any 'user'-related tests)
- rake parallel:test[^unit] # everything in test/unit folder (every test file matching /^unit/)
+ rake parallel:test[^test/unit] # every test file in test/unit folder
rake parallel:test[user] # run users_controller + user_helper + user tests
rake parallel:test['user|product'] # run user and product related tests
@@ -89,36 +70,29 @@ Even process runtimes
Log test runtime to give each process the same runtime.
-Rspec: Add to your `spec/parallel_spec.opts` (or `spec/spec.opts`) :
+Rspec: Add to your `.rspec_parallel` (or `.rspec`) :
- RSpec 1.x:
- --format progress
- --require parallel_specs/spec_runtime_logger
- --format ParallelSpecs::SpecRuntimeLogger:tmp/parallel_profile.log
- RSpec >= 2.4:
+ RSpec
If installed as plugin: -I vendor/plugins/parallel_tests/lib
--format progress
- --format ParallelSpecs::SpecRuntimeLogger --out tmp/parallel_profile.log
+ --format ParallelTests::RSpec::RuntimeLogger --out tmp/parallel_runtime_rspec.log
Test::Unit: Add to your `test_helper.rb`:
- require 'parallel_tests/runtime_logger'
+
+ require 'parallel_tests/test/runtime_logger'
SpecSummaryLogger
--------------------
This logger logs the test output without the different processes overwriting each other.
-Add the following to your `spec/parallel_spec.opts` (or `spec/spec.opts`) :
+Add the following to your `.rspec_parallel` (or `.rspec`) :
- RSpec 1.x:
- --format progress
- --require parallel_specs/spec_summary_logger
- --format ParallelSpecs::SpecSummaryLogger:tmp/spec_summary.log
- RSpec >= 2.2:
+ RSpec:
If installed as plugin: -I vendor/plugins/parallel_tests/lib
--format progress
- --format ParallelSpecs::SpecSummaryLogger --out tmp/spec_summary.log
+ --format ParallelTests::RSpec::SummaryLogger --out tmp/spec_summary.log
SpecFailuresLogger
-----------------------
@@ -129,25 +103,23 @@ E.g.
rspec /path/to/my_spec.rb:123 # should do something
-Add the following to your `spec/parallel_spec.opts` (or `spec/spec.opts`) :
+Add the following to your `.rspec_parallel` (or `.rspec`) :
- RSpec 1.x:
- --format progress
- --require parallel_specs/spec_failures_logger
- --format ParallelSpecs::SpecFailuresLogger:tmp/failing_specs.log
- RSpec >= 2.4:
+ RSpec:
If installed as plugin: -I vendor/plugins/parallel_tests/lib
--format progress
- --format ParallelSpecs::SpecFailuresLogger --out tmp/failing_specs.log
+ --format ParallelTests::RSpec::FailuresLogger --out tmp/failing_specs.log
Setup for non-rails
===================
- sudo gem install parallel_tests
+ gem install parallel_tests
# go to your project dir
- parallel_test OR parallel_spec OR parallel_cucumber
- # [Optional] use ENV['TEST_ENV_NUMBER'] inside your tests to select separate db/memcache/etc.
+ parallel_test test/
+ parallel_rspec spec/
+ parallel_cucumber features/
-[optional] Only run selected files & folders:
+ - use ENV['TEST_ENV_NUMBER'] inside your tests to select separate db/memcache/etc.
+ - Only run selected files & folders:
parallel_test test/bar test/baz/foo_text.rb
@@ -157,15 +129,14 @@ Options are:
-p, --path [PATH] run tests inside this path only
--no-sort do not sort files before running them
-m, --multiply-processes [FLOAT] use given number as a multiplier of processes to run
- -r, --root [PATH] execute test commands from this path
-e, --exec [COMMAND] execute this code parallel and with ENV['TEST_ENV_NUM']
-o, --test-options '[OPTIONS]' execute test commands with those options
- -t, --type [TYPE] which type of tests to run? test, spec or features
+ -t, --type [TYPE] test(default) / spec / cucumber
--non-parallel execute same commands but do not in parallel, needs --exec
-v, --version Show Version
-h, --help Show this.
-You can run any kind of code with -e / --execute
+You can run any kind of code in parallel with -e / --execute
parallel_test -n 5 -e 'ruby -e "puts %[hello from process #{ENV[:TEST_ENV_NUMBER.to_s].inspect}]"'
hello from process "2"
@@ -183,11 +154,9 @@ You can run any kind of code with -e / --execute
TIPS
====
- [Capybara + Selenium] add to env.rb: `Capybara.server_port = 8888 + ENV['TEST_ENV_NUMBER'].to_i`
- - [RSpec] add a `spec/parallel_spec.opts` to use different options, e.g. no --drb (default: `spec/spec.opts`)
- - [RSpec] if something looks fishy try to delete `script/spec`
- - [RSpec] if `script/spec` is missing parallel:spec uses just `spec` (which solves some issues with double-loaded environment.rb)
- - [RSpec] 'script/spec_server' or [spork](http://github.com/timcharper/spork/tree/master) do not work in parallel
- - [RSpec] `./script/generate rspec` if you are running rspec from gems (this plugin uses script/spec which may fail if rspec files are outdated)
+ - [RSpec] add a `.rspec_parallel` to use different options, e.g. **no --drb**
+ - [RSpec] delete `script/spec`
+ - [RSpec] [spork](https://github.com/timcharper/spork) does not work in parallel
- [RSpec] remove --loadby from you spec/*.opts
- [RSpec] Instantly see failures (instead of just a red F) with [rspec-instafail](https://github.com/grosser/rspec-instafail)
- [Bundler] if you have a `Gemfile` then `bundle exec` will be used to run tests
@@ -197,10 +166,12 @@ TIPS
- [SQL schema format] use :ruby schema format to get faster parallel:prepare`
- [ActiveRecord] if you do not have `db:abort_if_pending_migrations` add this to your Rakefile: `task('db:abort_if_pending_migrations'){}`
- `export PARALLEL_TEST_PROCESSORS=X` in your environment and parallel_tests will use this number of processors by default
- - with zsh this would be `rake "parallel:prepare[3]"`
+ - [ZSH] use quotes to use rake arguments `rake "parallel:prepare[3]"`
TODO
====
+ - document how to use cucumber runtime logger
+ - add tests for cucumber runtime formatter
- make jRuby compatible [basics](http://yehudakatz.com/2009/07/01/new-rails-isolation-testing/)
- make windows compatible
@@ -238,5 +209,4 @@ inspired by [pivotal labs](http://pivotallabs.com/users/miked/blog/articles/849-
[Michael Grosser](http://grosser.it)<br/>
michael@grosser.it<br/>
-Hereby placed under public domain, do what you want, just do not hold me accountable...<br/>
-[![Flattr](http://api.flattr.com/button/flattr-badge-large.png)](https://flattr.com/submit/auto?user_id=grosser&url=https://github.com/grosser/parallel_tests&title=parallel_tests&language=en_GB&tags=github&category=software)
+License: MIT
View
@@ -0,0 +1,48 @@
+### Install
+
+As gem
+
+ gem install parallel_tests
+
+ # add to config/environments/development.rb
+ config.gem "parallel_tests"
+
+ # add to Rakefile
+ begin; require 'parallel_tests/tasks'; rescue LoadError; end
+
+OR as plugin
+
+ gem install parallel
+
+ # add to config/environments/development.rb
+ config.gem "parallel"
+
+ ./script/plugin install git://github.com/grosser/parallel_tests.git
+
+ # add to Rakefile
+ begin; require 'vendor/plugins/parallel_tests/lib/parallel_tests/tasks'; rescue LoadError; end
+
+
+Even process runtimes
+-----------------
+
+ RSpec 1.x:
+ --format progress
+ --require parallel_tests/rspec/runtime_logger
+ --format ParallelTests::RSpec::RuntimeLogger:tmp/parallel_runtime_rspec.log
+
+SpecSummaryLogger
+--------------------
+
+ RSpec 1.x:
+ --format progress
+ --require parallel_tests/rspec/summary_logger
+ --format ParallelTests::RSpec::SummaryLogger:tmp/spec_summary.log
+
+SpecFailuresLogger
+-----------------------
+
+ RSpec 1.x:
+ --format progress
+ --require parallel_tests/rspec/failures_logger
+ --format ParallelTests::RSpec::FailuresLogger:tmp/failing_specs.log
View
@@ -1 +0,0 @@
-0.6.20
@@ -1,2 +1,2 @@
#!/usr/bin/env ruby
-exec "#{File.join(File.dirname(__FILE__), 'parallel_test')} -t features #{ARGV * ' '}"
+exec "#{File.join(File.dirname(__FILE__), 'parallel_test')} -t cucumber #{ARGV.map{|a| "'#{a}'" } * ' '}"
View
@@ -0,0 +1,2 @@
+#!/usr/bin/env ruby
+exec "#{File.join(File.dirname(__FILE__), 'parallel_test')} -t rspec #{ARGV.map{|a| "'#{a}'" } * ' '}"
View
@@ -1,2 +0,0 @@
-#!/usr/bin/env ruby
-exec "#{File.join(File.dirname(__FILE__), 'parallel_test')} -t spec #{ARGV * ' '}"
Oops, something went wrong. Retry.

0 comments on commit a97d53d

Please sign in to comment.