parallel_tests 0.4.10 → 0.4.11

Sign up to get free protection for your applications and to get access to all the features.
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.4.10
1
+ 0.4.11
@@ -63,22 +63,21 @@ else
63
63
  num_tests = groups.inject(0){|sum,item| sum + item.size }
64
64
  puts "#{num_processes} processes for #{num_tests} #{name}s, ~ #{num_tests / groups.size} #{name}s per process"
65
65
 
66
- output = Parallel.map(groups, :in_processes => num_processes) do |group|
66
+ test_results = Parallel.map(groups, :in_processes => num_processes) do |group|
67
67
  klass.run_tests(group, groups.index(group), options[:test_options])
68
68
  end
69
69
 
70
70
  #parse and print results
71
- results = klass.find_results(output*"")
71
+ results = klass.find_results(test_results.map{|result| result[:stdout] }*"")
72
72
  puts ""
73
73
  puts "Results:"
74
- results.each{|r| puts r}
74
+ results.each{|r| puts r }
75
75
 
76
76
  #report total time taken
77
77
  puts ""
78
78
  puts "Took #{Time.now - start} seconds"
79
79
 
80
- #exit with correct status code
81
- # - rake parallel:test && echo 123 ==> 123 should not show up when test failed
82
- # - rake parallel:test db:reset ==> works when tests succeed
83
- abort "#{name.capitalize}s Failed" if klass.failed?(results)
80
+ #exit with correct status code so rake parallel:test && echo 123 works
81
+ failed = test_results.any?{|result| result[:exit_status] != 0 }
82
+ abort "#{name.capitalize}s Failed" if failed
84
83
  end
@@ -4,7 +4,7 @@ class ParallelCucumber < ParallelTests
4
4
  def self.run_tests(test_files, process_number, options)
5
5
  color = ($stdout.tty? ? 'AUTOTEST=1 ; export AUTOTEST ;' : '')#display color when we are in a terminal
6
6
  cmd = "#{color} #{executable} #{options} #{test_files*' '}"
7
- execute_command(cmd, process_number)[:stdout]
7
+ execute_command(cmd, process_number)
8
8
  end
9
9
 
10
10
  def self.executable
@@ -26,8 +26,4 @@ class ParallelCucumber < ParallelTests
26
26
  def self.line_is_result?(line)
27
27
  line =~ /^\d+ (steps|scenarios)/
28
28
  end
29
-
30
- def self.line_is_failure?(line)
31
- line =~ /^\d+ (steps|scenarios).*(\d{2,}|[1-9]) failed/
32
- end
33
29
  end
@@ -4,7 +4,7 @@ class ParallelSpecs < ParallelTests
4
4
  def self.run_tests(test_files, process_number, options)
5
5
  exe = executable # its expensive with bundler, so do not call it twice
6
6
  cmd = "#{color} #{exe} #{options} #{spec_opts(exe)} #{test_files*' '}"
7
- execute_command(cmd, process_number)[:stdout]
7
+ execute_command(cmd, process_number)
8
8
  end
9
9
 
10
10
  def self.executable
@@ -31,7 +31,7 @@ class ParallelTests
31
31
  def self.run_tests(test_files, process_number, options)
32
32
  require_list = test_files.map { |filename| "\"#{filename}\"" }.join(",")
33
33
  cmd = "ruby -Itest #{options} -e '[#{require_list}].each {|f| require f }'"
34
- execute_command(cmd, process_number)[:stdout]
34
+ execute_command(cmd, process_number)
35
35
  end
36
36
 
37
37
  def self.execute_command(cmd, process_number)
@@ -56,11 +56,6 @@ class ParallelTests
56
56
  }.compact
57
57
  end
58
58
 
59
- def self.failed?(results)
60
- return true if results.empty?
61
- !! results.detect{|line| line_is_failure?(line)}
62
- end
63
-
64
59
  def self.test_env_number(process_number)
65
60
  process_number == 0 ? '' : process_number + 1
66
61
  end
@@ -87,10 +82,6 @@ class ParallelTests
87
82
  line =~ /\d+ failure/
88
83
  end
89
84
 
90
- def self.line_is_failure?(line)
91
- line =~ /(\d{2,}|[1-9]) (failure|error)/
92
- end
93
-
94
85
  def self.test_suffix
95
86
  "_test.rb"
96
87
  end
@@ -120,4 +111,4 @@ class ParallelTests
120
111
  Dir["#{root}**/**/*#{self.test_suffix}"]
121
112
  end
122
113
  end
123
- end
114
+ end
@@ -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.10"
8
+ s.version = "0.4.11"
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-01-21}
12
+ s.date = %q{2011-02-04}
13
13
  s.email = %q{grosser.michael@gmail.com}
14
14
  s.executables = ["parallel_spec", "parallel_cucumber", "parallel_test"]
15
15
  s.files = [
@@ -29,7 +29,7 @@ describe 'CLI' do
29
29
  end
30
30
 
31
31
  def run_specs(options={})
32
- `cd #{folder} && #{executable} -t spec -n #{options[:processes]||2} #{options[:add]} 2>&1 && echo 'i ran!'`
32
+ `cd #{folder} && #{executable} -t spec -n #{options[:processes]||2} #{options[:add]} 2>&1`
33
33
  end
34
34
 
35
35
  it "runs tests in parallel" do
@@ -45,8 +45,7 @@ describe 'CLI' do
45
45
  result.scan('1 example, 0 failure').size.should == 4 # 2 results + 2 result summary
46
46
  result.scan(/Finished in \d+\.\d+ seconds/).size.should == 2
47
47
  result.scan(/Took \d+\.\d+ seconds/).size.should == 1 # parallel summary
48
-
49
- result.should include('i ran!')
48
+ $?.success?.should == true
50
49
  end
51
50
 
52
51
  it "fails when tests fail" do
@@ -56,8 +55,7 @@ describe 'CLI' do
56
55
 
57
56
  result.scan('1 example, 1 failure').size.should == 2
58
57
  result.scan('1 example, 0 failure').size.should == 2
59
- result.should =~ /specs failed/i
60
- result.should_not include('i ran!')
58
+ $?.success?.should == false
61
59
  end
62
60
 
63
61
  it "can exec given commands with ENV['TEST_ENV_NUM']" do
@@ -24,7 +24,7 @@ describe ParallelCucumber do
24
24
  io = open('spec/spec_helper.rb')
25
25
  ParallelCucumber.stub!(:print)
26
26
  ParallelCucumber.should_receive(:open).and_return io
27
- ParallelCucumber.run_tests(['xxx'],1,'').should =~ /\$LOAD_PATH << File/
27
+ ParallelCucumber.run_tests(['xxx'],1,'')[:stdout].should =~ /\$LOAD_PATH << File/
28
28
  end
29
29
 
30
30
  it "runs bundle exec cucumber when on bundler 0.9" do
@@ -69,34 +69,4 @@ EOF
69
69
  ParallelCucumber.find_results(output).should == ["7 scenarios (3 failed, 4 passed)", "33 steps (3 failed, 2 skipped, 28 passed)", "4 scenarios (4 passed)", "40 steps (40 passed)"]
70
70
  end
71
71
  end
72
-
73
- describe :failed do
74
- it "fails with single failed" do
75
- ParallelCucumber.failed?(['40 steps (40 passed)','33 steps (3 failed, 2 skipped, 28 passed)']).should == true
76
- end
77
-
78
- it "fails with multiple failed tests" do
79
- ParallelCucumber.failed?(['33 steps (3 failed, 2 skipped, 28 passed)','33 steps (3 failed, 2 skipped, 28 passed)']).should == true
80
- end
81
-
82
- it "fails with a single scenario failure during setup phase" do
83
- ParallelCucumber.failed?(['1 scenarios (1 failed)']).should == true
84
- end
85
-
86
- it "fails with scenario failures during setup phase when other steps pass" do
87
- ParallelCucumber.failed?(['7 scenarios (3 failed, 4 passed)','40 steps (40 passed)']).should == true
88
- end
89
-
90
- it "does not fail with successful tests" do
91
- ParallelCucumber.failed?(['4 scenarios (4 passed)','40 steps (40 passed)','4 scenarios (4 passed)','40 steps (40 passed)']).should == false
92
- end
93
-
94
- it "does not fail with 0 failures" do
95
- ParallelCucumber.failed?(['4 scenarios (4 passed 0 failed)','40 steps (40 passed 0 failed)','4 scenarios (4 passed 0 failed)','40 steps (40 passed)']).should == false
96
- end
97
-
98
- it "does fail with 10 failures" do
99
- ParallelCucumber.failed?(['40 steps (40 passed 10 failed)','40 steps (40 passed)']).should == true
100
- end
101
- end
102
- end
72
+ end
@@ -111,7 +111,7 @@ describe ParallelSpecs do
111
111
  io = open('spec/spec_helper.rb')
112
112
  ParallelSpecs.stub!(:print)
113
113
  ParallelSpecs.should_receive(:open).and_return io
114
- ParallelSpecs.run_tests(['xxx'],1,'').should =~ /\$LOAD_PATH << File/
114
+ ParallelSpecs.run_tests(['xxx'],1,'')[:stdout].should =~ /\$LOAD_PATH << File/
115
115
  end
116
116
  end
117
117
 
@@ -146,23 +146,4 @@ EOF
146
146
  ParallelSpecs.find_results(output).should == ['0 examples, 0 failures, 0 pending','1 examples, 1 failures, 1 pending']
147
147
  end
148
148
  end
149
-
150
- describe :failed do
151
- it "fails with single failed specs" do
152
- ParallelSpecs.failed?(['0 examples, 0 failures, 0 pending','1 examples, 1 failure, 1 pending']).should == true
153
- end
154
-
155
- it "fails with multiple failed specs" do
156
- ParallelSpecs.failed?(['0 examples, 1 failure, 0 pending','1 examples, 111 failures, 1 pending']).should == true
157
- end
158
-
159
- it "does not fail with successful specs" do
160
- ParallelSpecs.failed?(['0 examples, 0 failures, 0 pending','1 examples, 0 failures, 1 pending']).should == false
161
- end
162
-
163
- it "does fail with 10 failures" do
164
- ParallelSpecs.failed?(['0 examples, 10 failures, 0 pending','1 examples, 0 failures, 1 pending']).should == true
165
- end
166
-
167
- end
168
- end
149
+ end
@@ -45,7 +45,7 @@ describe ParallelTests do
45
45
  io = open('spec/spec_helper.rb')
46
46
  ParallelTests.stub!(:print)
47
47
  ParallelTests.should_receive(:open).and_return io
48
- ParallelTests.run_tests(['xxx'],1,'').should =~ /\$LOAD_PATH << File/
48
+ ParallelTests.run_tests(['xxx'],1,'')[:stdout].should =~ /\$LOAD_PATH << File/
49
49
  end
50
50
  end
51
51
 
@@ -103,40 +103,6 @@ EOF
103
103
  end
104
104
  end
105
105
 
106
- describe :failed do
107
- it "fails with single failed" do
108
- ParallelTests.failed?(['10 tests, 20 assertions, 0 failures, 0 errors','10 tests, 20 assertions, 1 failure, 0 errors']).should == true
109
- end
110
-
111
- it "fails with single error" do
112
- ParallelTests.failed?(['10 tests, 20 assertions, 0 failures, 1 errors','10 tests, 20 assertions, 0 failures, 0 errors']).should == true
113
- end
114
-
115
- it "fails with failed and error" do
116
- ParallelTests.failed?(['10 tests, 20 assertions, 0 failures, 1 errors','10 tests, 20 assertions, 1 failures, 1 errors']).should == true
117
- end
118
-
119
- it "fails with multiple failed tests" do
120
- ParallelTests.failed?(['10 tests, 20 assertions, 2 failures, 0 errors','10 tests, 1 assertion, 1 failures, 0 errors']).should == true
121
- end
122
-
123
- it "does not fail with successful tests" do
124
- ParallelTests.failed?(['10 tests, 20 assertions, 0 failures, 0 errors','10 tests, 20 assertions, 0 failures, 0 errors']).should == false
125
- end
126
-
127
- it "does fail with 10 failures" do
128
- ParallelTests.failed?(['10 tests, 20 assertions, 10 failures, 0 errors','10 tests, 20 assertions, 0 failures, 0 errors']).should == true
129
- end
130
-
131
- it "is not failed with empty results" do
132
- ParallelTests.failed?(['0 tests, 0 assertions, 0 failures, 0 errors']).should == false
133
- end
134
-
135
- it "is failed when there are no results" do
136
- ParallelTests.failed?([]).should == true
137
- end
138
- end
139
-
140
106
  describe :bundler_enabled? do
141
107
  before do
142
108
  Object.stub!(:const_defined?).with(:Bundler).and_return false
@@ -173,4 +139,4 @@ EOF
173
139
  it "has a version" do
174
140
  ParallelTests::VERSION.should =~ /^\d+\.\d+\.\d+$/
175
141
  end
176
- end
142
+ 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: 27
4
+ hash: 25
5
5
  prerelease:
6
6
  segments:
7
7
  - 0
8
8
  - 4
9
- - 10
10
- version: 0.4.10
9
+ - 11
10
+ version: 0.4.11
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-01-21 00:00:00 +01:00
18
+ date: 2011-02-04 00:00:00 +01:00
19
19
  default_executable:
20
20
  dependencies:
21
21
  - !ruby/object:Gem::Dependency