Sha256: 9dc2369e091dcd93a0aebe4c1335c28bbd985a177c03682e45bfefa92c666cc1

Contents?: true

Size: 1.69 KB

Versions: 5

Compression:

Stored size: 1.69 KB

Contents

require 'parallelized_specs/spec_logger_base'

module RSpec

  class ParallelizedSpecs::OutcomeBuilder < ParallelizedSpecs::SpecLoggerBase

    def start(example_count)
      @example_count = example_count
      env_test_number = ENV['TEST_ENV_NUMBER']
      env_test_number = 1 if ENV['TEST_ENV_NUMBER'].blank?
      puts "Thread #{env_test_number.to_s} has #{@example_count} specs"
      File.open("#{Rails.root}/tmp/parallel_log/spec_count/total_specs#{env_test_number}.txt", 'a+') { |f| f.write(@example_count) }
      File.open("#{Rails.root}/tmp/parallel_log/thread_started/thread_#{env_test_number}.txt", 'a+') { |f| f.write("") }
      super
    end


    def dump_summary(duration, example_count, failure_count, pending_count)
      env_test_number = ENV['TEST_ENV_NUMBER']
      env_test_number = 1 if ENV['TEST_ENV_NUMBER'].blank?
      spec_file = "#{Rails.root}/tmp/parallel_log/spec_count/total_specs#{env_test_number}.txt"
      failure_file = "#{Rails.root}/tmp/parallel_log/failed_specs/failed_specs#{env_test_number}.txt"
      expected_example_count = File.open(spec_file, &:readline).to_s
      puts "Expected example count = #{expected_example_count} from rspec example count = #{example_count}"
      File.delete(spec_file) if expected_example_count.to_i - example_count.to_i < 2
      puts "Thread example failure count = #{failure_count}"
      failure_count > 0 ? (File.open(failure_file, 'a+') { |f| f.write(failure_count) }) : (puts "All specs in Thread #{env_test_number} passed")
      puts "Thread #{env_test_number} has completed in #{duration}"
    end

    def dump_failures(*args)
      ;
    end

    def dump_failure(*args)
      ;
    end

    def dump_pending(*args)
      ;
    end
  end
end

Version data entries

5 entries across 5 versions & 1 rubygems

Version Path
parallelized_specs-0.4.47 lib/parallelized_specs/outcome_builder.rb
parallelized_specs-0.4.46 lib/parallelized_specs/outcome_builder.rb
parallelized_specs-0.4.45 lib/parallelized_specs/outcome_builder.rb
parallelized_specs-0.4.44 lib/parallelized_specs/outcome_builder.rb
parallelized_specs-0.4.43 lib/parallelized_specs/outcome_builder.rb