Class: ParallelSpecs::SpecRuntimeLogger

Inherits:
SpecLoggerBase show all
Defined in:
lib/parallel_specs/spec_runtime_logger.rb

Constant Summary

Constants inherited from SpecLoggerBase

ParallelSpecs::SpecLoggerBase::RSPEC_1

Instance Method Summary collapse

Methods inherited from SpecLoggerBase

#close, #lock_output

Constructor Details

#initialize(*args) ⇒ SpecRuntimeLogger

Returns a new instance of SpecRuntimeLogger.



4
5
6
7
# File 'lib/parallel_specs/spec_runtime_logger.rb', line 4

def initialize(*args)
  super
  @example_times = Hash.new(0)
end

Instance Method Details

#dump_failure(*args) ⇒ Object



20
# File 'lib/parallel_specs/spec_runtime_logger.rb', line 20

def dump_failure(*args);end

#dump_failures(*args) ⇒ Object



19
# File 'lib/parallel_specs/spec_runtime_logger.rb', line 19

def dump_failures(*args);end

#dump_pending(*args) ⇒ Object



21
# File 'lib/parallel_specs/spec_runtime_logger.rb', line 21

def dump_pending(*args);end

#dump_summary(*args) ⇒ Object



18
# File 'lib/parallel_specs/spec_runtime_logger.rb', line 18

def dump_summary(*args);end

#example_passed(example) ⇒ Object



13
14
15
16
# File 'lib/parallel_specs/spec_runtime_logger.rb', line 13

def example_passed(example)
  file = example.location.split(':').first
  @example_times[file] += Time.now - @time
end

#example_started(*args) ⇒ Object



9
10
11
# File 'lib/parallel_specs/spec_runtime_logger.rb', line 9

def example_started(*args)
  @time = Time.now
end

#start_dump(*args) ⇒ Object



23
24
25
26
27
28
29
30
31
32
33
# File 'lib/parallel_specs/spec_runtime_logger.rb', line 23

def start_dump(*args)
  return unless ENV['TEST_ENV_NUMBER'] #only record when running in parallel
  # TODO: Figure out why sometimes time can be less than 0
  lock_output do
    @example_times.each do |file, time|
      relative_path = file.sub(/^#{Regexp.escape Dir.pwd}\//,'')
      @output.puts "#{relative_path}:#{time > 0 ? time : 0}"
    end
  end
  @output.flush
end