parallel_tests 0.4.11 → 0.4.12

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
data/Readme.md CHANGED
@@ -1,4 +1,4 @@
1
- Speedup Test::Unit + RSpec + Cucumber by running parallel on multiple CPUs.
1
+ Speedup Test::Unit + RSpec + Cucumber by running parallel on multiple CPUs(or cores).
2
2
 
3
3
  Setup for Rails
4
4
  ===============
@@ -90,8 +90,9 @@ Options are:
90
90
  -m, --multiply-processes [FLOAT] use given number as a multiplier of processes to run
91
91
  -r, --root [PATH] execute test commands from this path
92
92
  -e, --exec [COMMAND] execute this code parallel and with ENV['TEST_ENV_NUM']
93
- -o, --test-options '[OPTIONS]' execute test commands with those options
93
+ -o, --test-options '[OPTIONS]' execute test commands with those options
94
94
  -t, --type [TYPE] which type of tests to run? test, spec or features
95
+ --non-parallel execute same commands but do not in parallel, needs --exec
95
96
  -v, --version Show Version
96
97
  -h, --help Show this.
97
98
 
@@ -112,14 +113,15 @@ You can run any kind of code with -e / --execute
112
113
  TIPS
113
114
  ====
114
115
  - [Capybara + Selenium] add to env.rb: `Capybara.server_port = 8888 + ENV['TEST_ENV_NUMBER'].to_i`
115
- - [RSpec] add a `spec/parallel_spec.opts` to use different options, e.g. no --drb (default: `spec/spec.opts`)
116
+ - [RSpec] add a `spec/parallel_spec.opts` to use different options, e.g. no --drb (default: `spec/spec.opts`)
116
117
  - [RSpec] if something looks fishy try to delete `script/spec`
117
118
  - [RSpec] if `script/spec` is missing parallel:spec uses just `spec` (which solves some issues with double-loaded environment.rb)
118
119
  - [RSpec] 'script/spec_server' or [spork](http://github.com/timcharper/spork/tree/master) do not work in parallel
119
120
  - [RSpec] `./script/generate rspec` if you are running rspec from gems (this plugin uses script/spec which may fail if rspec files are outdated)
120
121
  - [Bundler] if you have a `Gemfile` then `bundle exec` will be used to run tests
121
122
  - [Capybara setup](https://github.com/grosser/parallel_tests/wiki)
122
- - [Sphinx setup](https://github.com/grosser/parallel_tests/wiki)
123
+ - [Sphinx setup](https://github.com/grosser/parallel_tests/wiki)
124
+ - [SQL schema format] use :ruby schema format to get faster parallel:prepare`
123
125
  - with zsh this would be `rake "parallel:prepare[3]"`
124
126
 
125
127
  TODO
@@ -129,7 +131,7 @@ TODO
129
131
 
130
132
  Authors
131
133
  ====
132
- inspired by [pivotal labs](http://pivotallabs.com/users/miked/blog/articles/849-parallelize-your-rspec-suite)
134
+ inspired by [pivotal labs](http://pivotallabs.com/users/miked/blog/articles/849-parallelize-your-rspec-suite)
133
135
 
134
136
  ### [Contributors](http://github.com/grosser/parallel_tests/contributors)
135
137
  - [Charles Finkel](http://charlesfinkel.com/)
@@ -149,6 +151,6 @@ inspired by [pivotal labs](http://pivotallabs.com/users/miked/blog/articles/849-
149
151
  - [xxx](https://github.com/xxx)
150
152
  - [Levent Ali](http://purebreeze.com/)
151
153
 
152
- [Michael Grosser](http://pragmatig.wordpress.com)
153
- grosser.michael@gmail.com
154
+ [Michael Grosser](http://grosser.it)<br/>
155
+ michael@grosser.it<br/>
154
156
  Hereby placed under public domain, do what you want, just do not hold me accountable...
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.4.11
1
+ 0.4.12
@@ -24,6 +24,7 @@ BANNER
24
24
  opts.on("-e", '--exec [COMMAND]', "execute this code parallel and with ENV['TEST_ENV_NUM']"){|path| options[:execute] = path }
25
25
  opts.on("-o", "--test-options '[OPTIONS]'", "execute test commands with those options"){|arg| options[:test_options] = arg }
26
26
  opts.on("-t", "--type [TYPE]", "which type of tests to run? test, spec or features"){|type| options[:type] = type }
27
+ opts.on("--non-parallel", "execute same commands but do not in parallel, needs --exec"){|type| options[:non_parallel] = true }
27
28
  opts.on('-v', '--version', 'Show Version'){ puts ParallelTests::VERSION; exit}
28
29
  opts.on("-h", "--help", "Show this.") { puts opts; exit }
29
30
  end.parse!
@@ -35,8 +36,15 @@ num_processes = options[:count] || Parallel.processor_count
35
36
  num_processes = num_processes * (options[:multiply] || 1)
36
37
 
37
38
  if options[:execute]
38
- results = Parallel.map(0...num_processes, :in_processes => num_processes) do |i|
39
- ParallelTests.execute_command(options[:execute], i)
39
+ runs = (0...num_processes).to_a
40
+ results = if options[:non_parallel]
41
+ runs.map do |i|
42
+ ParallelTests.execute_command(options[:execute], i)
43
+ end
44
+ else
45
+ Parallel.map(runs, :in_processes => num_processes) do |i|
46
+ ParallelTests.execute_command(options[:execute], i)
47
+ end
40
48
  end.flatten
41
49
  abort if results.any?{|r| r[:exit_status] != 0 }
42
50
  else
@@ -2,7 +2,7 @@ namespace :parallel do
2
2
  def run_in_parallel(cmd, options)
3
3
  count = (options[:count] ? options[:count].to_i : nil)
4
4
  executable = File.join(File.dirname(__FILE__), '..', '..', 'bin', 'parallel_test')
5
- command = "#{executable} --exec '#{cmd}' -n #{count}"
5
+ command = "#{executable} --exec '#{cmd}' -n #{count} #{'--non-parallel' if options[:non_parallel]}"
6
6
  abort unless system(command)
7
7
  end
8
8
 
@@ -23,8 +23,9 @@ namespace :parallel do
23
23
  Rake::Task['db:schema:dump'].invoke
24
24
  Rake::Task['parallel:load_schema'].invoke(args[:count])
25
25
  else
26
- # there is no separate dump / load for schema_format :sql, schema file can get corrupted
27
- run_in_parallel('rake db:test:prepare', args)
26
+ # there is no separate dump / load for schema_format :sql -> do it safe and slow
27
+ args = args.to_hash.merge(:non_parallel => true) # normal merge returns nil
28
+ run_in_parallel('rake db:test:prepare --trace', args)
28
29
  end
29
30
  end
30
31
 
@@ -37,7 +38,6 @@ namespace :parallel do
37
38
  # just load the schema (good for integration server <-> no development db)
38
39
  desc "load dumped schema for test databases via db:schema:load --> parallel:load_schema[num_cpus]"
39
40
  task :load_schema, :count do |t,args|
40
- puts args.inspect
41
41
  run_in_parallel('rake db:test:load', args)
42
42
  end
43
43
 
@@ -5,11 +5,11 @@
5
5
 
6
6
  Gem::Specification.new do |s|
7
7
  s.name = %q{parallel_tests}
8
- s.version = "0.4.11"
8
+ s.version = "0.4.12"
9
9
 
10
10
  s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
11
11
  s.authors = ["Michael Grosser"]
12
- s.date = %q{2011-02-04}
12
+ s.date = %q{2011-02-18}
13
13
  s.email = %q{grosser.michael@gmail.com}
14
14
  s.executables = ["parallel_spec", "parallel_cucumber", "parallel_test"]
15
15
  s.files = [
@@ -63,6 +63,11 @@ describe 'CLI' do
63
63
  result.split("\n").sort.should == %w["" "2" "3" "4"]
64
64
  end
65
65
 
66
+ it "can exec given command non-parallel" do
67
+ result = `#{executable} -e 'ruby -e "sleep(rand(10)/100.0); puts ENV[:TEST_ENV_NUMBER.to_s].inspect"' -n 4 --non-parallel`
68
+ result.split("\n").should == %w["" "2" "3" "4"]
69
+ end
70
+
66
71
  it "exists with success if all sub-processes returned success" do
67
72
  system("#{executable} -e 'cat /dev/null' -n 4").should == true
68
73
  end
metadata CHANGED
@@ -1,13 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: parallel_tests
3
3
  version: !ruby/object:Gem::Version
4
- hash: 25
4
+ hash: 23
5
5
  prerelease:
6
6
  segments:
7
7
  - 0
8
8
  - 4
9
- - 11
10
- version: 0.4.11
9
+ - 12
10
+ version: 0.4.12
11
11
  platform: ruby
12
12
  authors:
13
13
  - Michael Grosser
@@ -15,7 +15,7 @@ autorequire:
15
15
  bindir: bin
16
16
  cert_chain: []
17
17
 
18
- date: 2011-02-04 00:00:00 +01:00
18
+ date: 2011-02-18 00:00:00 +01:00
19
19
  default_executable:
20
20
  dependencies:
21
21
  - !ruby/object:Gem::Dependency