parallel_tests 0.9.1 → 0.9.2

Sign up to get free protection for your applications and to get access to all the features.
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- parallel_tests (0.9.1)
4
+ parallel_tests (0.9.2)
5
5
  parallel
6
6
 
7
7
  GEM
@@ -28,7 +28,7 @@ module ParallelTest
28
28
  report_number_of_tests(runner, groups)
29
29
 
30
30
  test_results = Parallel.map(groups, :in_processes => groups.size) do |group|
31
- run_tests(runner, group, groups.index(group), options)
31
+ run_tests(runner, group, groups.index(group), num_processes, options)
32
32
  end
33
33
 
34
34
  report_results(runner, test_results)
@@ -37,11 +37,11 @@ module ParallelTest
37
37
  abort final_fail_message(lib) if any_test_failed?(test_results)
38
38
  end
39
39
 
40
- def self.run_tests(runner, group, process_number, options)
40
+ def self.run_tests(runner, group, process_number, num_processes, options)
41
41
  if group.empty?
42
42
  {:stdout => '', :exit_status => 0}
43
43
  else
44
- runner.run_tests(group, process_number, options)
44
+ runner.run_tests(group, process_number, num_processes, options)
45
45
  end
46
46
  end
47
47
 
@@ -128,11 +128,11 @@ TEXT
128
128
  runs = (0...num_processes).to_a
129
129
  results = if options[:non_parallel]
130
130
  runs.map do |i|
131
- ParallelTests::Test::Runner.execute_command(command, i, options)
131
+ ParallelTests::Test::Runner.execute_command(command, i, num_processes)
132
132
  end
133
133
  else
134
134
  Parallel.map(runs, :in_processes => num_processes) do |i|
135
- ParallelTests::Test::Runner.execute_command(command, i, options)
135
+ ParallelTests::Test::Runner.execute_command(command, i, num_processes)
136
136
  end
137
137
  end.flatten
138
138
 
@@ -3,7 +3,7 @@ require 'parallel_tests/test/runner'
3
3
  module ParallelTests
4
4
  module Cucumber
5
5
  class Runner < ParallelTests::Test::Runner
6
- def self.run_tests(test_files, process_number, options)
6
+ def self.run_tests(test_files, process_number, num_processes, options)
7
7
  color = ($stdout.tty? ? 'AUTOTEST=1 ; export AUTOTEST ;' : '')#display color when we are in a terminal
8
8
  runtime_logging = " --format ParallelTests::Cucumber::RuntimeLogger --out #{runtime_log}"
9
9
  cmd = [
@@ -13,7 +13,7 @@ module ParallelTests
13
13
  cucumber_opts(options[:test_options]),
14
14
  *test_files
15
15
  ].compact.join(" ")
16
- execute_command(cmd, process_number, options)
16
+ execute_command(cmd, process_number, num_processes)
17
17
  end
18
18
 
19
19
  def self.executable
@@ -3,11 +3,11 @@ require 'parallel_tests/test/runner'
3
3
  module ParallelTests
4
4
  module RSpec
5
5
  class Runner < ParallelTests::Test::Runner
6
- def self.run_tests(test_files, process_number, options)
6
+ def self.run_tests(test_files, process_number, num_processes, options)
7
7
  exe = executable # expensive, so we cache
8
8
  version = (exe =~ /\brspec\b/ ? 2 : 1)
9
9
  cmd = "#{rspec_1_color if version == 1}#{exe} #{options[:test_options]} #{rspec_2_color if version == 2}#{spec_opts} #{test_files*' '}"
10
- execute_command(cmd, process_number, options)
10
+ execute_command(cmd, process_number, num_processes)
11
11
  end
12
12
 
13
13
  def self.executable
@@ -15,10 +15,10 @@ module ParallelTests
15
15
  "test"
16
16
  end
17
17
 
18
- def self.run_tests(test_files, process_number, options)
18
+ def self.run_tests(test_files, process_number, num_processes, options)
19
19
  require_list = test_files.map { |filename| %{"#{File.expand_path filename}"} }.join(",")
20
20
  cmd = "ruby -Itest -e '[#{require_list}].each {|f| require f }' -- #{options[:test_options]}"
21
- execute_command(cmd, process_number, options)
21
+ execute_command(cmd, process_number, num_processes)
22
22
  end
23
23
 
24
24
  def self.line_is_result?(line)
@@ -39,8 +39,9 @@ module ParallelTests
39
39
  Grouper.in_even_groups_by_size(tests, num_groups, options)
40
40
  end
41
41
 
42
- def self.execute_command(cmd, process_number, options)
43
- cmd = "TEST_ENV_NUMBER=#{test_env_number(process_number)} ; export TEST_ENV_NUMBER; #{cmd}"
42
+ def self.execute_command(cmd, process_number, num_processes)
43
+ prefix = "PARALLEL_TEST_GROUPS=#{ num_processes } ; export PARALLEL_TEST_GROUPS;"
44
+ cmd = "#{prefix} TEST_ENV_NUMBER=#{test_env_number(process_number)} ; export TEST_ENV_NUMBER; #{cmd}"
44
45
  f = open("|#{cmd}", 'r')
45
46
  output = fetch_output(f)
46
47
  f.close
@@ -1,3 +1,3 @@
1
1
  module ParallelTests
2
- VERSION = Version = '0.9.1'
2
+ VERSION = Version = '0.9.2'
3
3
  end
@@ -16,41 +16,46 @@ describe ParallelTests::Cucumber do
16
16
 
17
17
  it "uses TEST_ENV_NUMBER=blank when called for process 0" do
18
18
  ParallelTests::Cucumber::Runner.should_receive(:open).with{|x,y| x=~/TEST_ENV_NUMBER= /}.and_return mocked_process
19
- call(['xxx'],0,{})
19
+ call(['xxx'],0,22,{})
20
20
  end
21
21
 
22
22
  it "uses TEST_ENV_NUMBER=2 when called for process 1" do
23
23
  ParallelTests::Cucumber::Runner.should_receive(:open).with{|x,y| x=~/TEST_ENV_NUMBER=2/}.and_return mocked_process
24
- call(['xxx'],1,{})
24
+ call(['xxx'],1,22,{})
25
+ end
26
+
27
+ it 'sets PARALLEL_TEST_GROUPS so child processes know that they are being run under parallel_tests' do
28
+ ParallelTests::Cucumber::Runner.should_receive(:open).with{|x,y| x=~/PARALLEL_TEST_GROUPS=22/}.and_return mocked_process
29
+ call(['xxx'],1,22,{})
25
30
  end
26
31
 
27
32
  it "returns the output" do
28
33
  io = open('spec/spec_helper.rb')
29
34
  $stdout.stub!(:print)
30
35
  ParallelTests::Cucumber::Runner.should_receive(:open).and_return io
31
- call(['xxx'],1,{})[:stdout].should =~ /\$LOAD_PATH << File/
36
+ call(['xxx'],1,22,{})[:stdout].should =~ /\$LOAD_PATH << File/
32
37
  end
33
38
 
34
39
  it "runs bundle exec cucumber when on bundler 0.9" do
35
40
  ParallelTests.stub!(:bundler_enabled?).and_return true
36
41
  ParallelTests::Cucumber::Runner.should_receive(:open).with{|x,y| x =~ %r{bundle exec cucumber}}.and_return mocked_process
37
- call(['xxx'],1,{})
42
+ call(['xxx'],1,22,{})
38
43
  end
39
44
 
40
45
  it "runs script/cucumber when script/cucumber is found" do
41
46
  ParallelTests::Cucumber::Runner.should_receive(:open).with{|x,y| x =~ %r{script/cucumber}}.and_return mocked_process
42
- call(['xxx'],1,{})
47
+ call(['xxx'],1,22,{})
43
48
  end
44
49
 
45
50
  it "runs cucumber by default" do
46
51
  File.stub!(:file?).with('script/cucumber').and_return false
47
52
  ParallelTests::Cucumber::Runner.should_receive(:open).with{|x,y| x !~ %r{(script/cucumber)|(bundle exec cucumber)}}.and_return mocked_process
48
- call(['xxx'],1,{})
53
+ call(['xxx'],1,22,{})
49
54
  end
50
55
 
51
56
  it "uses options passed in" do
52
57
  ParallelTests::Cucumber::Runner.should_receive(:open).with{|x,y| x =~ %r{script/cucumber .* -p default}}.and_return mocked_process
53
- call(['xxx'],1,:test_options => '-p default')
58
+ call(['xxx'],1,22,:test_options => '-p default')
54
59
  end
55
60
 
56
61
  context "with parallel profile in config/cucumber.yml" do
@@ -62,17 +67,17 @@ describe ParallelTests::Cucumber do
62
67
 
63
68
  it "uses parallel profile" do
64
69
  ParallelTests::Cucumber::Runner.should_receive(:open).with{|x,y| x =~ %r{script/cucumber .* foo bar --profile parallel xxx}}.and_return mocked_process
65
- call(['xxx'],1, :test_options => 'foo bar')
70
+ call(['xxx'],1,22, :test_options => 'foo bar')
66
71
  end
67
72
 
68
73
  it "uses given profile via --profile" do
69
74
  ParallelTests::Cucumber::Runner.should_receive(:open).with{|x,y| x =~ %r{script/cucumber .* --profile foo xxx$}}.and_return mocked_process
70
- call(['xxx'],1, :test_options => '--profile foo')
75
+ call(['xxx'],1,22, :test_options => '--profile foo')
71
76
  end
72
77
 
73
78
  it "uses given profile via -p" do
74
79
  ParallelTests::Cucumber::Runner.should_receive(:open).with{|x,y| x =~ %r{script/cucumber .* -p foo xxx$}}.and_return mocked_process
75
- call(['xxx'],1, :test_options => '-p foo')
80
+ call(['xxx'],1,22, :test_options => '-p foo')
76
81
  end
77
82
  end
78
83
 
@@ -81,13 +86,13 @@ describe ParallelTests::Cucumber do
81
86
  ParallelTests::Cucumber::Runner.should_receive(:open).with{|x,y| x =~ %r{script/cucumber .* foo bar}}.and_return mocked_process
82
87
  Dir.should_receive(:glob).and_return ['config/cucumber.yml']
83
88
  File.should_receive(:read).with('config/cucumber.yml').and_return file_contents
84
- call(['xxx'],1,:test_options => 'foo bar')
89
+ call(['xxx'],1,22,:test_options => 'foo bar')
85
90
  end
86
91
 
87
92
  it "does not use the parallel profile if config/cucumber.yml does not exist" do
88
93
  ParallelTests::Cucumber::Runner.should_receive(:open).with{|x,y| x =~ %r{script/cucumber .*}}.and_return mocked_process
89
94
  Dir.should_receive(:glob).and_return []
90
- call(['xxx'],1,{})
95
+ call(['xxx'],1,22,{})
91
96
  end
92
97
  end
93
98
 
@@ -18,38 +18,43 @@ describe ParallelTests::RSpec::Runner do
18
18
 
19
19
  it "uses TEST_ENV_NUMBER=blank when called for process 0" do
20
20
  ParallelTests::RSpec::Runner.should_receive(:open).with{|x,y|x=~/TEST_ENV_NUMBER= /}.and_return mocked_process
21
- call(['xxx'], 0, {})
21
+ call(['xxx'], 0, 22, {})
22
22
  end
23
23
 
24
24
  it "uses TEST_ENV_NUMBER=2 when called for process 1" do
25
25
  ParallelTests::RSpec::Runner.should_receive(:open).with{|x,y| x=~/TEST_ENV_NUMBER=2/}.and_return mocked_process
26
- call(['xxx'],1,{})
26
+ call(['xxx'],1,22,{})
27
+ end
28
+
29
+ it 'sets PARALLEL_TEST_GROUPS so child processes know that they are being run under parallel_tests' do
30
+ ParallelTests::RSpec::Runner.should_receive(:open).with{|x,y| x=~/PARALLEL_TEST_GROUPS=22/}.and_return mocked_process
31
+ call(['xxx'],1,22,{})
27
32
  end
28
33
 
29
34
  it "runs with color when called from cmdline" do
30
35
  ParallelTests::RSpec::Runner.should_receive(:open).with{|x,y| x=~/ --tty /}.and_return mocked_process
31
36
  $stdout.should_receive(:tty?).and_return true
32
- call(['xxx'],1,{})
37
+ call(['xxx'],1,22,{})
33
38
  end
34
39
 
35
40
  it "runs without color when not called from cmdline" do
36
41
  ParallelTests::RSpec::Runner.should_receive(:open).with{|x,y| x !~ / --tty /}.and_return mocked_process
37
42
  $stdout.should_receive(:tty?).and_return false
38
- call(['xxx'],1,{})
43
+ call(['xxx'],1,22,{})
39
44
  end
40
45
 
41
46
  it "runs with color for rspec 1 when called for the cmdline" do
42
47
  File.should_receive(:file?).with('script/spec').and_return true
43
48
  ParallelTests::RSpec::Runner.should_receive(:open).with{|x,y| x=~/ RSPEC_COLOR=1 /}.and_return mocked_process
44
49
  $stdout.should_receive(:tty?).and_return true
45
- call(['xxx'],1,{})
50
+ call(['xxx'],1,22,{})
46
51
  end
47
52
 
48
53
  it "runs without color for rspec 1 when not called for the cmdline" do
49
54
  File.should_receive(:file?).with('script/spec').and_return true
50
55
  ParallelTests::RSpec::Runner.should_receive(:open).with{|x,y| x !~ / RSPEC_COLOR=1 /}.and_return mocked_process
51
56
  $stdout.should_receive(:tty?).and_return false
52
- call(['xxx'],1,{})
57
+ call(['xxx'],1,22,{})
53
58
  end
54
59
 
55
60
  it "run bundle exec spec when on bundler rspec 1" do
@@ -57,7 +62,7 @@ describe ParallelTests::RSpec::Runner do
57
62
  ParallelTests.stub!(:bundler_enabled?).and_return true
58
63
  ParallelTests::RSpec::Runner.stub!(:run).with("bundle show rspec").and_return "/foo/bar/rspec-1.0.2"
59
64
  ParallelTests::RSpec::Runner.should_receive(:open).with{|x,y| x =~ %r{bundle exec spec}}.and_return mocked_process
60
- call(['xxx'],1,{})
65
+ call(['xxx'],1,22,{})
61
66
  end
62
67
 
63
68
  it "run bundle exec rspec when on bundler rspec 2" do
@@ -65,46 +70,46 @@ describe ParallelTests::RSpec::Runner do
65
70
  ParallelTests.stub!(:bundler_enabled?).and_return true
66
71
  ParallelTests::RSpec::Runner.stub!(:run).with("bundle show rspec").and_return "/foo/bar/rspec-2.0.2"
67
72
  ParallelTests::RSpec::Runner.should_receive(:open).with{|x,y| x =~ %r{bundle exec rspec}}.and_return mocked_process
68
- call(['xxx'],1,{})
73
+ call(['xxx'],1,22,{})
69
74
  end
70
75
 
71
76
  it "runs script/spec when script/spec can be found" do
72
77
  File.should_receive(:file?).with('script/spec').and_return true
73
78
  ParallelTests::RSpec::Runner.should_receive(:open).with{|x,y| x =~ %r{script/spec}}.and_return mocked_process
74
- call(['xxx'],1,{})
79
+ call(['xxx'],1,22,{})
75
80
  end
76
81
 
77
82
  it "runs spec when script/spec cannot be found" do
78
83
  File.stub!(:file?).with('script/spec').and_return false
79
84
  ParallelTests::RSpec::Runner.should_receive(:open).with{|x,y| x !~ %r{script/spec}}.and_return mocked_process
80
- call(['xxx'],1,{})
85
+ call(['xxx'],1,22,{})
81
86
  end
82
87
 
83
88
  it "uses no -O when no opts where found" do
84
89
  File.stub!(:file?).with('spec/spec.opts').and_return false
85
90
  ParallelTests::RSpec::Runner.should_receive(:open).with{|x,y| x !~ %r{spec/spec.opts}}.and_return mocked_process
86
- call(['xxx'],1,{})
91
+ call(['xxx'],1,22,{})
87
92
  end
88
93
 
89
94
  it "uses -O spec/spec.opts when found (with script/spec)" do
90
95
  File.stub!(:file?).with('script/spec').and_return true
91
96
  File.stub!(:file?).with('spec/spec.opts').and_return true
92
97
  ParallelTests::RSpec::Runner.should_receive(:open).with{|x,y| x =~ %r{script/spec\s+ -O spec/spec.opts}}.and_return mocked_process
93
- call(['xxx'],1,{})
98
+ call(['xxx'],1,22,{})
94
99
  end
95
100
 
96
101
  it "uses -O spec/parallel_spec.opts when found (with script/spec)" do
97
102
  File.stub!(:file?).with('script/spec').and_return true
98
103
  File.should_receive(:file?).with('spec/parallel_spec.opts').and_return true
99
104
  ParallelTests::RSpec::Runner.should_receive(:open).with{|x,y| x =~ %r{script/spec\s+ -O spec/parallel_spec.opts}}.and_return mocked_process
100
- call(['xxx'],1,{})
105
+ call(['xxx'],1,22,{})
101
106
  end
102
107
 
103
108
  it "uses -O .rspec_parallel when found (with script/spec)" do
104
109
  File.stub!(:file?).with('script/spec').and_return true
105
110
  File.should_receive(:file?).with('.rspec_parallel').and_return true
106
111
  ParallelTests::RSpec::Runner.should_receive(:open).with{|x,y| x =~ %r{script/spec\s+ -O .rspec_parallel}}.and_return mocked_process
107
- call(['xxx'],1,{})
112
+ call(['xxx'],1,22,{})
108
113
  end
109
114
 
110
115
  it "uses -O spec/parallel_spec.opts with rspec1" do
@@ -114,7 +119,7 @@ describe ParallelTests::RSpec::Runner do
114
119
  ParallelTests::RSpec::Runner.stub!(:run).with("bundle show rspec").and_return "/foo/bar/rspec-1.0.2"
115
120
 
116
121
  ParallelTests::RSpec::Runner.should_receive(:open).with{|x,y| x =~ %r{spec\s+ -O spec/parallel_spec.opts}}.and_return mocked_process
117
- call(['xxx'],1,{})
122
+ call(['xxx'],1,22,{})
118
123
  end
119
124
 
120
125
  it "uses -O spec/parallel_spec.opts with rspec2" do
@@ -124,19 +129,19 @@ describe ParallelTests::RSpec::Runner do
124
129
  ParallelTests::RSpec::Runner.stub!(:run).with("bundle show rspec").and_return "/foo/bar/rspec-2.4.2"
125
130
 
126
131
  ParallelTests::RSpec::Runner.should_receive(:open).with{|x,y| x =~ %r{rspec\s+ --color --tty -O spec/parallel_spec.opts}}.and_return mocked_process
127
- call(['xxx'],1,{})
132
+ call(['xxx'],1,22,{})
128
133
  end
129
134
 
130
135
  it "uses options passed in" do
131
136
  ParallelTests::RSpec::Runner.should_receive(:open).with{|x,y| x =~ %r{rspec -f n}}.and_return mocked_process
132
- call(['xxx'],1, :test_options => '-f n')
137
+ call(['xxx'],1,22, :test_options => '-f n')
133
138
  end
134
139
 
135
140
  it "returns the output" do
136
141
  io = open('spec/spec_helper.rb')
137
142
  $stdout.stub!(:print)
138
143
  ParallelTests::RSpec::Runner.should_receive(:open).and_return io
139
- call(['xxx'],1,{})[:stdout].should =~ /\$LOAD_PATH << File/
144
+ call(['xxx'],1,22,{})[:stdout].should =~ /\$LOAD_PATH << File/
140
145
  end
141
146
  end
142
147
 
@@ -10,24 +10,31 @@ describe ParallelTests::Test::Runner do
10
10
 
11
11
  it "uses TEST_ENV_NUMBER=blank when called for process 0" do
12
12
  ParallelTests::Test::Runner.should_receive(:open).with{|x,y|x=~/TEST_ENV_NUMBER= /}.and_return mocked_process
13
- call(['xxx'],0,{})
13
+ call(['xxx'],0,22,{})
14
14
  end
15
15
 
16
16
  it "uses TEST_ENV_NUMBER=2 when called for process 1" do
17
17
  ParallelTests::Test::Runner.should_receive(:open).with{|x,y| x=~/TEST_ENV_NUMBER=2/}.and_return mocked_process
18
- call(['xxx'],1,{})
18
+ call(['xxx'],1,22,{})
19
+ end
20
+
21
+ it 'sets PARALLEL_TEST_GROUPS so child processes know that they are being run under parallel_tests' do
22
+ ENV['PARALLEL_TEST_PROCESSORS'] = '22'
23
+ ParallelTests::Test::Runner.should_receive(:open).with{|x,y| x=~/PARALLEL_TEST_GROUPS=22/}.and_return mocked_process
24
+ call(['xxx'],1,22,{})
25
+ ENV.delete('PARALLEL_TEST_PROCESSORS')
19
26
  end
20
27
 
21
28
  it "uses options" do
22
29
  ParallelTests::Test::Runner.should_receive(:open).with{|x,y| x=~ %r{ruby -Itest .* -- -v}}.and_return mocked_process
23
- call(['xxx'],1,:test_options => '-v')
30
+ call(['xxx'],1,22,:test_options => '-v')
24
31
  end
25
32
 
26
33
  it "returns the output" do
27
34
  io = open('spec/spec_helper.rb')
28
35
  $stdout.stub!(:print)
29
36
  ParallelTests::Test::Runner.should_receive(:open).and_return io
30
- call(['xxx'],1,{})[:stdout].should =~ /\$LOAD_PATH << File/
37
+ call(['xxx'],1,22,{})[:stdout].should =~ /\$LOAD_PATH << File/
31
38
  end
32
39
  end
33
40
 
metadata CHANGED
@@ -2,14 +2,14 @@
2
2
  name: parallel_tests
3
3
  version: !ruby/object:Gem::Version
4
4
  prerelease:
5
- version: 0.9.1
5
+ version: 0.9.2
6
6
  platform: ruby
7
7
  authors:
8
8
  - Michael Grosser
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2013-01-03 00:00:00.000000000 Z
12
+ date: 2013-01-04 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  version_requirements: !ruby/object:Gem::Requirement
@@ -90,7 +90,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
90
90
  version: '0'
91
91
  segments:
92
92
  - 0
93
- hash: 3154313804102056863
93
+ hash: -1348773835990268798
94
94
  none: false
95
95
  required_rubygems_version: !ruby/object:Gem::Requirement
96
96
  requirements:
@@ -99,7 +99,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
99
99
  version: '0'
100
100
  segments:
101
101
  - 0
102
- hash: 3154313804102056863
102
+ hash: -1348773835990268798
103
103
  none: false
104
104
  requirements: []
105
105
  rubyforge_project: