parallelized_specs 0.3.99.01 → 0.4.00

Sign up to get free protection for your applications and to get access to all the features.
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.3.99.01"
15
+ gem.version = "0.4.00"
16
16
  end
17
17
  Jeweler::GemcutterTasks.new
18
18
  rescue LoadError
@@ -294,7 +294,7 @@ class ParallelizedSpecs
294
294
  end
295
295
 
296
296
  def self.update_rerun_summary(l, file, outcome)
297
- File.open(file, 'a+') { |f| f.puts("Outcome #{outcome} for #{l}") }
297
+ File.open(@file, 'a+') { |f| f.puts("Outcome #{outcome} for #{l}") }
298
298
  end
299
299
 
300
300
  def self.parse_result(result)
@@ -316,86 +316,139 @@ class ParallelizedSpecs
316
316
 
317
317
  def self.print_failures(failure_summary, state = "")
318
318
  puts "*****************INFO: #{state} SUMMARY*****************\n"
319
- state == "RERUN" ? puts("INFO: outcomes of the specs that were rerun") : puts ("INFO: summary of build failures")
320
- file = File.open(failure_summary, "r")
319
+ state == "RERUN" ? puts("INFO: outcomes of the specs that were rerun") : puts("INFO: summary of build failures")
320
+ file = File.open(@failure_summary, "r")
321
321
  content = file.read
322
322
  puts content
323
323
  end
324
324
 
325
- def self.rerun()
326
- puts "INFO: beginning the failed specs rerun process"
327
- rerun_failed_examples = false
328
- rerun_specs = []
329
- filename = "#{RAILS_ROOT}/tmp/parallel_log/rspec.failures"
330
- failure_summary = "#{RAILS_ROOT}/tmp/parallel_log/rerun_failure_summary.log"
325
+ def self.abort_reruns(code)
326
+ case code
327
+ when code == 1
328
+ print_failures("#{RAILS_ROOT}/tmp/parallel_log/error.log")
329
+ abort "SEVERE: shared specs currently are not eligiable for reruns, marking build as a failure"
330
+ when code == 2
331
+ update_rerun_summary(l, @failure_summary, "FAILED")
332
+ print_failures(@failure_summary, "RERUN")
333
+ abort "SEVERE: spec didn't actually run, ending rerun process early"
334
+ when code == 3
335
+ update_rerun_summary(l, @failure_summary, "FAILED")
336
+ print_failures(@failure_summary, "RERUN")
337
+ abort "SEVERE: the spec failed to run on the rerun try, marking build as failed"
338
+ when code == 4
339
+ abort "SEVERE: unexpected outcome on the rerun, marking build as a failure"
340
+ when code == 5
341
+ 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"
342
+ when code == 6
343
+ print_failures("#{RAILS_ROOT}/tmp/parallel_log/error.log")
344
+ abort "SEVERE: #{@error_count} errors are to many to rerun, marking the build as a failure"
345
+ when code == 7
346
+ puts "#Total errors #{@error_count}"
347
+ abort "SEVERE: unexpected error information, please check errors are being written to file correctly"
348
+ when code == 8
349
+ print_failures(@failure_summary, "RERUN")
350
+ abort "SEVERE: some specs failed on rerun, the build will be marked as failed"
351
+ when code == 9
352
+ abort "SEVERE: unexpected situation on rerun, marking build as failure"
353
+ end
354
+ end
355
+
356
+ def self.update_failed
357
+ puts "WARNING: the example failed again"
358
+ update_rerun_summary(l, @failure_summary, "FAILED")
359
+ @rerun_failures << l
360
+ end
331
361
 
362
+ def self.update_passed
363
+ update_rerun_summary(l, @failure_summary, "PASSED")
364
+ puts "INFO: the example passed and is being marked as a success"
365
+ @rerun_passes << l
366
+ end
367
+
368
+ def self.pass_reruns
369
+ print_failures("#{RAILS_ROOT}/tmp/parallel_log/error.log")
370
+ print_failures(@failure_summary, "RERUN")
371
+ puts "INFO: rerun summary all rerun examples passed, rspec will mark this build as passed"
372
+ end
373
+
374
+ def self.calculate_error_count()
332
375
  @error_count = %x{wc -l "#{filename}"}.match(/\d*[^\D]/).to_s #counts the number of lines in the file
333
376
  @error_count = @error_count.to_i
377
+ end
334
378
 
379
+ def self.determine_rerun_eligibility
380
+ File.open(@filename).each_line do |line|
381
+ if line =~ /spec\/selenium\/helpers/ || line =~ /spec\/selenium\/shared_examples/
382
+ abort_reruns(1)
383
+ else
384
+ @rerun_specs.push line
385
+ end
386
+ end
387
+ @rerun_failed_examples = true
388
+ puts "INFO: failures meet rerun criteria \n INFO: rerunning #{@error_count} examples"
389
+ end
390
+
391
+ def self.start_reruns(error_count)
335
392
  case
336
393
  when @error_count.between?(1, 9)
337
- File.open(filename).each_line do |line|
338
- if line =~ /spec\/selenium\/helpers/ || line =~ /spec\/selenium\/shared_examples/
339
- print_failures("#{RAILS_ROOT}/tmp/parallel_log/error.log")
340
- abort "SEVERE: shared specs currently are not eligiable for reruns, marking build as a failure"
341
- else
342
- rerun_specs.push line
343
- end
344
- end
394
+ determine_rerun_eligibility
345
395
 
346
- rerun_failed_examples = true
347
- puts "INFO: failures meet rerun criteria \n INFO: rerunning #{@error_count} examples"
348
396
  @rerun_failures ||= []
349
397
  @rerun_passes ||= []
350
398
 
351
- rerun_specs.each do |l|
352
- result = rerun_spec(l)
399
+ @rerun_specs.each do |l|
400
+ rerun_spec(l)
353
401
 
354
402
  if @examples == 0 and @failures == 0
355
- update_rerun_summary(l, failure_summary, "FAILED")
356
- print_failures(failure_summary, "RERUN")
357
- abort "SEVERE: spec didn't actually run, ending rerun process early"
403
+ abort_reruns(2)
358
404
  end
359
405
 
360
406
  if @examples == 0 #when specs fail to run it exits with 0 examples, 0 failures and won't be matched by the previous regex
361
- update_rerun_summary(l, failure_summary, "FAILED")
362
- print_failures(failure_summary, "RERUN")
363
- abort "SEVERE: the spec failed to run on the rerun try, marking build as failed"
407
+ abort_reruns(3)
364
408
  elsif @failures > 0
365
- puts "WARNING: the example failed again"
366
- update_rerun_summary(l, failure_summary, "FAILED")
367
- @rerun_failures << l
409
+ update_failed
368
410
  elsif @examples > 0 && @failures == 0
369
- update_rerun_summary(l, failure_summary, "PASSED")
370
- puts "INFO: the example passed and is being marked as a success"
371
- @rerun_passes << l
411
+ update_passed
372
412
  else
373
- abort "SEVERE: unexpected outcome on the rerun, marking build as a failure"
413
+ abort_reruns(4)
374
414
  end
375
415
  end #end file loop
376
416
 
377
417
  when @error_count == 0
378
- 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"
418
+ abort_reruns(5)
379
419
  when @error_count > 9
380
- print_failures("#{RAILS_ROOT}/tmp/parallel_log/error.log")
381
- abort "SEVERE: #{@error_count} errors are to many to rerun, marking the build as a failure"
420
+ abort_reruns(6)
421
+
382
422
  else
383
- puts "#Total errors #{@error_count}"
384
- abort "SEVERE: unexpected error information, please check errors are being written to file correctly"
423
+ abort_reruns(7)
385
424
  end
425
+ end
386
426
 
387
- if rerun_failed_examples
427
+ def self.determine_rerun_outcome
428
+ if @rerun_failed_examples
388
429
  if @rerun_failures.count > 0
389
- print_failures(failure_summary, "RERUN")
390
- abort "SEVERE: some specs failed on rerun, the build will be marked as failed"
430
+ abort_reruns(8)
391
431
  elsif @rerun_passes.count >= @error_count
392
- print_failures("#{RAILS_ROOT}/tmp/parallel_log/error.log")
393
- print_failures(failure_summary, "RERUN")
394
- puts "INFO: rerun summary all rerun examples passed, rspec will mark this build as passed"
432
+ pass_reruns
395
433
  else
396
- abort "SEVERE: unexpected situation on rerun, marking build as failure"
434
+ abort_reruns(9)
397
435
  end
398
436
  end
399
437
  end
438
+
439
+ def self.runtime_setup
440
+ @rerun_failed_examples = false
441
+ @rerun_specs = []
442
+ @filename = "#{RAILS_ROOT}/tmp/parallel_log/rspec.failures"
443
+ @failure_summary = "#{RAILS_ROOT}/tmp/parallel_log/rerun_failure_summary.log"
444
+ end
445
+
446
+ def self.rerun()
447
+ puts "INFO: beginning the failed specs rerun process"
448
+ runtime_setup
449
+ @error_count = calculate_error_count
450
+ start_reruns(@error_count)
451
+ determine_rerun_outcomes
452
+ end
400
453
  end
401
454
 
@@ -5,11 +5,11 @@
5
5
 
6
6
  Gem::Specification.new do |s|
7
7
  s.name = "parallelized_specs"
8
- s.version = "0.3.99.01"
8
+ s.version = "0.4.00"
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"]
12
- s.date = "2013-02-03"
12
+ s.date = "2013-02-04"
13
13
  s.email = "jake@instructure.com"
14
14
  s.files = [
15
15
  "Gemfile",
metadata CHANGED
@@ -1,46 +1,38 @@
1
- --- !ruby/object:Gem::Specification
1
+ --- !ruby/object:Gem::Specification
2
2
  name: parallelized_specs
3
- version: !ruby/object:Gem::Version
4
- hash: 473
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.4.00
5
5
  prerelease:
6
- segments:
7
- - 0
8
- - 3
9
- - 99
10
- - 1
11
- version: 0.3.99.01
12
6
  platform: ruby
13
- authors:
7
+ authors:
14
8
  - Jake Sorce, Bryan Madsen, Shawn Meredith
15
9
  autorequire:
16
10
  bindir: bin
17
11
  cert_chain: []
18
-
19
- date: 2013-02-03 00:00:00 Z
20
- dependencies:
21
- - !ruby/object:Gem::Dependency
12
+ date: 2013-02-04 00:00:00.000000000 Z
13
+ dependencies:
14
+ - !ruby/object:Gem::Dependency
22
15
  name: parallel
23
- prerelease: false
24
- requirement: &id001 !ruby/object:Gem::Requirement
16
+ requirement: !ruby/object:Gem::Requirement
25
17
  none: false
26
- requirements:
27
- - - ">="
28
- - !ruby/object:Gem::Version
29
- hash: 3
30
- segments:
31
- - 0
32
- version: "0"
18
+ requirements:
19
+ - - ! '>='
20
+ - !ruby/object:Gem::Version
21
+ version: '0'
33
22
  type: :runtime
34
- version_requirements: *id001
23
+ prerelease: false
24
+ version_requirements: !ruby/object:Gem::Requirement
25
+ none: false
26
+ requirements:
27
+ - - ! '>='
28
+ - !ruby/object:Gem::Version
29
+ version: '0'
35
30
  description:
36
31
  email: jake@instructure.com
37
32
  executables: []
38
-
39
33
  extensions: []
40
-
41
34
  extra_rdoc_files: []
42
-
43
- files:
35
+ files:
44
36
  - Gemfile
45
37
  - Gemfile.lock
46
38
  - Rakefile
@@ -72,37 +64,27 @@ files:
72
64
  - spec/spec_helper.rb
73
65
  homepage: http://github.com/jakesorce/parallelized_specs
74
66
  licenses: []
75
-
76
67
  post_install_message:
77
68
  rdoc_options: []
78
-
79
- require_paths:
69
+ require_paths:
80
70
  - lib
81
- required_ruby_version: !ruby/object:Gem::Requirement
71
+ required_ruby_version: !ruby/object:Gem::Requirement
82
72
  none: false
83
- requirements:
84
- - - ">="
85
- - !ruby/object:Gem::Version
86
- hash: 3
87
- segments:
88
- - 0
89
- version: "0"
90
- required_rubygems_version: !ruby/object:Gem::Requirement
73
+ requirements:
74
+ - - ! '>='
75
+ - !ruby/object:Gem::Version
76
+ version: '0'
77
+ required_rubygems_version: !ruby/object:Gem::Requirement
91
78
  none: false
92
- requirements:
93
- - - ">="
94
- - !ruby/object:Gem::Version
95
- hash: 3
96
- segments:
97
- - 0
98
- version: "0"
79
+ requirements:
80
+ - - ! '>='
81
+ - !ruby/object:Gem::Version
82
+ version: '0'
99
83
  requirements: []
100
-
101
84
  rubyforge_project:
102
85
  rubygems_version: 1.8.24
103
86
  signing_key:
104
87
  specification_version: 3
105
88
  summary: Run rspec tests in parallel
106
89
  test_files: []
107
-
108
90
  has_rdoc: