parallelized_specs 0.4.42 → 0.4.43
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/Rakefile +1 -1
- data/lib/parallelized_specs/outcome_builder.rb +4 -4
- data/lib/parallelized_specs.rb +43 -36
- data/parallelized_specs.gemspec +1 -1
- metadata +3 -3
data/Rakefile
CHANGED
@@ -12,7 +12,7 @@ begin
|
|
12
12
|
gem.email = "jake@instructure.com"
|
13
13
|
gem.homepage = "http://github.com/jakesorce/#{gem.name}"
|
14
14
|
gem.authors = "Jake Sorce, Bryan Madsen, Shawn Meredith"
|
15
|
-
gem.version = "0.4.
|
15
|
+
gem.version = "0.4.43"
|
16
16
|
end
|
17
17
|
Jeweler::GemcutterTasks.new
|
18
18
|
rescue LoadError
|
@@ -9,8 +9,8 @@ module RSpec
|
|
9
9
|
env_test_number = ENV['TEST_ENV_NUMBER']
|
10
10
|
env_test_number = 1 if ENV['TEST_ENV_NUMBER'].blank?
|
11
11
|
puts "Thread #{env_test_number.to_s} has #{@example_count} specs"
|
12
|
-
File.open("#{
|
13
|
-
File.open("#{
|
12
|
+
File.open("#{Rails.root}/tmp/parallel_log/spec_count/total_specs#{env_test_number}.txt", 'a+') { |f| f.write(@example_count) }
|
13
|
+
File.open("#{Rails.root}/tmp/parallel_log/thread_started/thread_#{env_test_number}.txt", 'a+') { |f| f.write("") }
|
14
14
|
super
|
15
15
|
end
|
16
16
|
|
@@ -18,8 +18,8 @@ module RSpec
|
|
18
18
|
def dump_summary(duration, example_count, failure_count, pending_count)
|
19
19
|
env_test_number = ENV['TEST_ENV_NUMBER']
|
20
20
|
env_test_number = 1 if ENV['TEST_ENV_NUMBER'].blank?
|
21
|
-
spec_file = "#{
|
22
|
-
failure_file = "#{
|
21
|
+
spec_file = "#{Rails.root}/tmp/parallel_log/spec_count/total_specs#{env_test_number}.txt"
|
22
|
+
failure_file = "#{Rails.root}/tmp/parallel_log/failed_specs/failed_specs#{env_test_number}.txt"
|
23
23
|
expected_example_count = File.open(spec_file, &:readline).to_s
|
24
24
|
puts "Expected example count = #{expected_example_count} from rspec example count = #{example_count}"
|
25
25
|
File.delete(spec_file) if expected_example_count.to_i - example_count.to_i < 2
|
data/lib/parallelized_specs.rb
CHANGED
@@ -84,6 +84,7 @@ class ParallelizedSpecs
|
|
84
84
|
end
|
85
85
|
|
86
86
|
def self.run_specs(tests, options)
|
87
|
+
formatters = formatters_used
|
87
88
|
num_processes = options[:count] || Parallel.processor_count
|
88
89
|
name = 'spec'
|
89
90
|
|
@@ -107,55 +108,61 @@ class ParallelizedSpecs
|
|
107
108
|
test_results = Parallel.map(groups, :in_processes => num_processes) do |group|
|
108
109
|
run_tests(group, groups.index(group), options)
|
109
110
|
end
|
110
|
-
|
111
|
-
slowest_spec_determination("#{RAILS_ROOT}/tmp/parallel_log/slowest_specs.log")
|
111
|
+
slowest_spec_determination("#{Rails.root}/tmp/parallel_log/slowest_specs.log")
|
112
112
|
|
113
113
|
#parse and print results
|
114
114
|
results = find_results(test_results.map { |result| result[:stdout] }*"")
|
115
|
-
#puts ""
|
116
115
|
puts summarize_results(results)
|
116
|
+
puts "INFO: Took #{Time.now - start} seconds"
|
117
117
|
|
118
|
+
#determines if any tricky conditions happened that can cause false positives and offers logging into what was the last spec to start or finishing running
|
119
|
+
false_positive_sniffer(num_processes) if formatters.any? { |formatter| formatter.match(/OutcomeBuilder/) }
|
120
|
+
failed = test_results.any? { |result| result[:exit_status] != 0 } #ruby 1.8.7 works breaks on 1.9.3
|
121
|
+
formatters.any? { |formatter| formatter.match(/FailuresFormatter/) } ? rerun_initializer(name, failed) : abort "SEVERE: #{name.capitalize}s Failed" if failed
|
122
|
+
puts "INFO: marking build as PASSED"
|
123
|
+
end
|
118
124
|
|
119
|
-
|
120
|
-
|
121
|
-
|
125
|
+
def self.formatters_used
|
126
|
+
File.open("#{Rails.root}/spec/spec.opts").each_line do |line|
|
127
|
+
formatters << line
|
128
|
+
end
|
129
|
+
formatters
|
130
|
+
end
|
131
|
+
|
132
|
+
def self.rerun_initializer(name, failed)
|
133
|
+
if Dir.glob("#{Rails.root}/tmp/parallel_log/failed_specs/{*,.*}").count > 2 && !File.zero?("#{Rails.root}/tmp/parallel_log/rspec.failures") # works on both 1.8.7\1.9.3
|
134
|
+
puts "INFO: some specs failed, about to start the rerun process\n INFO: no more than 9 specs may be rerun and shared specs are not allowed\n...\n..\n."
|
135
|
+
ParallelizedSpecs.rerun()
|
136
|
+
else
|
137
|
+
#works on both 1.8.7\1.9.3
|
138
|
+
abort "SEVERE: #{name.capitalize}s Failed" if Dir.glob("#{Rails.root}/tmp/parallel_log/failed_specs/{*,.*}").count > 2 || failed
|
139
|
+
end
|
140
|
+
end
|
122
141
|
|
123
|
-
|
142
|
+
def self.false_positive_sniffer(num_processes)
|
143
|
+
if Dir.glob("#{Rails.root}/tmp/parallel_log/spec_count/{*,.*}").count == 2 && Dir.glob("#{Rails.root}/tmp/parallel_log/thread_started/{*,.*}").count == num_processes + 2
|
124
144
|
(puts "INFO: All threads completed")
|
125
|
-
elsif Dir.glob("#{
|
126
|
-
File.open("#{
|
127
|
-
File.open("#{
|
145
|
+
elsif Dir.glob("#{Rails.root}/tmp/parallel_log/thread_started/{*,.*}").count != num_processes + 2
|
146
|
+
File.open("#{Rails.root}/tmp/parallel_log/error.log", 'a+') { |f| f.write "\n\n\n syntax issues" }
|
147
|
+
File.open("#{Rails.root}/tmp/failure_cause.log", 'a+') { |f| f.write "Syntax errors" }
|
128
148
|
abort "SEVERE: one or more threads didn't get started by rspec, this may be caused by a syntax issue in specs, check logs right before specs start running"
|
129
149
|
else
|
130
|
-
threads = Dir["#{
|
150
|
+
threads = Dir["#{Rails.root}/tmp/parallel_log/spec_count/*"]
|
131
151
|
threads.each do |t|
|
132
152
|
failed_thread = t.match(/\d/).to_s
|
133
153
|
if failed_thread == "1"
|
134
154
|
puts "INFO: Thread 1 last spec to start running"
|
135
|
-
last_spec = IO.readlines("#{
|
136
|
-
File.open("#{
|
155
|
+
last_spec = IO.readlines("#{Rails.root}/tmp/parallel_log/thread_.log")[-1]
|
156
|
+
File.open("#{Rails.root}/tmp/parallel_log/error.log", 'a+') { |f| f.write "\n\n\n\nrspec thread #{failed_thread} failed to complete\n the last spec to try to run was #{last_spec}" }
|
137
157
|
else
|
138
158
|
puts "INFO: Thread #{failed_thread} last spec to start running"
|
139
|
-
last_spec = IO.readlines("#{
|
140
|
-
File.open("#{
|
159
|
+
last_spec = IO.readlines("#{Rails.root}/tmp/parallel_log/thread_#{failed_thread}.log")[-1]
|
160
|
+
File.open("#{Rails.root}/tmp/parallel_log/error.log", 'a+') { |f| f.write "\n\n\n\nrspec thread #{failed_thread} failed to complete\n the last spec to try to run was #{last_spec}" }
|
141
161
|
end
|
142
162
|
end
|
143
|
-
File.open("#{
|
163
|
+
File.open("#{Rails.root}/tmp/failure_cause.log", 'a+') { |f| f.write "rspec thread failed to complete" }
|
144
164
|
abort "SEVERE: One or more threads have failed to complete, this may be caused by a rspec runtime crashing prematurely" #works on both 1.8.7\1.9.3
|
145
165
|
end
|
146
|
-
#exit with correct status code so rake parallel:test && echo 123 works
|
147
|
-
|
148
|
-
failed = test_results.any? { |result| result[:exit_status] != 0 } #ruby 1.8.7 works breaks on 1.9.3
|
149
|
-
puts "INFO: this is the exit status of the rspec suites #{failed}"
|
150
|
-
|
151
|
-
if Dir.glob("#{RAILS_ROOT}/tmp/parallel_log/failed_specs/{*,.*}").count > 2 && !File.zero?("#{RAILS_ROOT}/tmp/parallel_log/rspec.failures") # works on both 1.8.7\1.9.3
|
152
|
-
puts "INFO: some specs failed, about to start the rerun process\n INFO: no more than 9 specs may be rerun and shared specs are not allowed\n...\n..\n."
|
153
|
-
ParallelizedSpecs.rerun()
|
154
|
-
else
|
155
|
-
#works on both 1.8.7\1.9.3
|
156
|
-
abort "SEVERE: #{name.capitalize}s Failed" if Dir.glob("#{RAILS_ROOT}/tmp/parallel_log/failed_specs/{*,.*}").count > 2 || failed
|
157
|
-
end
|
158
|
-
puts "INFO: marking build as PASSED"
|
159
166
|
end
|
160
167
|
|
161
168
|
# parallel:spec[:count, :pattern, :options]
|
@@ -303,7 +310,7 @@ class ParallelizedSpecs
|
|
303
310
|
|
304
311
|
def self.update_rerun_summary(l, outcome, stack = "")
|
305
312
|
File.open(@failure_summary, 'a+') { |f| f.puts("Outcome #{outcome} for #{l}\n #{stack}") }
|
306
|
-
File.open("#{
|
313
|
+
File.open("#{Rails.root}/tmp/parallel_log/error.log", 'a+') { |f| f.puts("Outcome #{outcome} for #{l}\n #{stack}") } if outcome == "FAILED"
|
307
314
|
end
|
308
315
|
|
309
316
|
def self.parse_result(result)
|
@@ -336,7 +343,7 @@ class ParallelizedSpecs
|
|
336
343
|
def self.abort_reruns(code, result = "", l = "")
|
337
344
|
case
|
338
345
|
when code == 1
|
339
|
-
print_failures("#{
|
346
|
+
print_failures("#{Rails.root}/tmp/parallel_log/error.log")
|
340
347
|
abort "SEVERE: shared specs currently are not eligiable for reruns, marking build as a failure"
|
341
348
|
when code == 2 # <--- won't ever happen, 2 and 3 are duplicate clean up on refactor
|
342
349
|
update_rerun_summary(l, "FAILED", result)
|
@@ -353,14 +360,14 @@ class ParallelizedSpecs
|
|
353
360
|
when code == 5
|
354
361
|
abort "SEVERE: #{@error_count} errors, but the build failed, errors were not written to the file or there is something else wrong, marking build as a failure"
|
355
362
|
when code == 6
|
356
|
-
print_failures("#{
|
363
|
+
print_failures("#{Rails.root}/tmp/parallel_log/error.log")
|
357
364
|
abort "SEVERE: #{@error_count} errors are to many to rerun, marking the build as a failure. Max errors defined for this build is #{@max_reruns}"
|
358
365
|
when code == 7
|
359
366
|
puts "#Total errors #{@error_count}"
|
360
367
|
abort "SEVERE: unexpected error information, please check errors are being written to file correctly"
|
361
368
|
when code == 8
|
362
369
|
print_failures(@failure_summary, "RERUN")
|
363
|
-
File.open("#{
|
370
|
+
File.open("#{Rails.root}/tmp/failure_cause.log", 'a+') { |f| f.write "#{@rerun_failures.count} failures" }
|
364
371
|
abort "SEVERE: some specs failed on rerun, the build will be marked as failed"
|
365
372
|
when code == 9
|
366
373
|
abort "SEVERE: unexpected situation on rerun, marking build as failure"
|
@@ -422,7 +429,7 @@ class ParallelizedSpecs
|
|
422
429
|
end
|
423
430
|
end
|
424
431
|
puts "INFO: failures meet rerun criteria \n INFO: rerunning #{@error_count} examples"
|
425
|
-
File.open("#{
|
432
|
+
File.open("#{Rails.root}/tmp/parallel_log/error.log", 'a+') { |f| f.puts("\n\n\n\n\n *****RERUN FAILURES*****\n") }
|
426
433
|
end
|
427
434
|
|
428
435
|
def self.start_reruns
|
@@ -470,8 +477,8 @@ class ParallelizedSpecs
|
|
470
477
|
|
471
478
|
def self.runtime_setup
|
472
479
|
@rerun_specs = []
|
473
|
-
@filename = "#{
|
474
|
-
@failure_summary = "#{
|
480
|
+
@filename = "#{Rails.root}/tmp/parallel_log/rspec.failures"
|
481
|
+
@failure_summary = "#{Rails.root}/tmp/parallel_log/rerun_failure_summary.log"
|
475
482
|
end
|
476
483
|
|
477
484
|
def self.rerun()
|
data/parallelized_specs.gemspec
CHANGED
@@ -5,7 +5,7 @@
|
|
5
5
|
|
6
6
|
Gem::Specification.new do |s|
|
7
7
|
s.name = "parallelized_specs"
|
8
|
-
s.version = "0.4.
|
8
|
+
s.version = "0.4.43"
|
9
9
|
|
10
10
|
s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
|
11
11
|
s.authors = ["Jake Sorce, Bryan Madsen, Shawn Meredith"]
|
metadata
CHANGED
@@ -1,13 +1,13 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: parallelized_specs
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
hash:
|
4
|
+
hash: 89
|
5
5
|
prerelease:
|
6
6
|
segments:
|
7
7
|
- 0
|
8
8
|
- 4
|
9
|
-
-
|
10
|
-
version: 0.4.
|
9
|
+
- 43
|
10
|
+
version: 0.4.43
|
11
11
|
platform: ruby
|
12
12
|
authors:
|
13
13
|
- Jake Sorce, Bryan Madsen, Shawn Meredith
|