Class: ParallelTests::RSpec::RuntimeLogger
- Inherits:
-
LoggerBase
- Object
- RSpec::Core::Formatters::BaseTextFormatter
- LoggerBase
- ParallelTests::RSpec::RuntimeLogger
- Defined in:
- lib/parallel_tests/rspec/runtime_logger.rb
Instance Method Summary collapse
- #dump_failure ⇒ Object
- #dump_failures ⇒ Object
- #dump_pending ⇒ Object
- #dump_summary ⇒ Object
- #example_group_finished(notification) ⇒ Object
- #example_group_started(example_group) ⇒ Object
-
#initialize(*args) ⇒ RuntimeLogger
constructor
A new instance of RuntimeLogger.
- #start_dump ⇒ Object
Methods inherited from LoggerBase
Constructor Details
#initialize(*args) ⇒ RuntimeLogger
Returns a new instance of RuntimeLogger.
6 7 8 9 10 |
# File 'lib/parallel_tests/rspec/runtime_logger.rb', line 6 def initialize(*args) super @example_times = Hash.new(0) @group_nesting = 0 end |
Instance Method Details
#dump_failure ⇒ Object
32 |
# File 'lib/parallel_tests/rspec/runtime_logger.rb', line 32 def dump_failure(*); end |
#dump_failures ⇒ Object
30 |
# File 'lib/parallel_tests/rspec/runtime_logger.rb', line 30 def dump_failures(*); end |
#dump_pending ⇒ Object
34 |
# File 'lib/parallel_tests/rspec/runtime_logger.rb', line 34 def dump_pending(*); end |
#dump_summary ⇒ Object
28 |
# File 'lib/parallel_tests/rspec/runtime_logger.rb', line 28 def dump_summary(*); end |
#example_group_finished(notification) ⇒ Object
20 21 22 23 24 25 26 |
# File 'lib/parallel_tests/rspec/runtime_logger.rb', line 20 def example_group_finished(notification) @group_nesting -= 1 if @group_nesting == 0 @example_times[notification.group.file_path] += ParallelTests.now - @time end super if defined?(super) end |
#example_group_started(example_group) ⇒ Object
14 15 16 17 18 |
# File 'lib/parallel_tests/rspec/runtime_logger.rb', line 14 def example_group_started(example_group) @time = ParallelTests.now if @group_nesting == 0 @group_nesting += 1 super end |
#start_dump ⇒ Object
36 37 38 39 40 41 42 43 44 45 46 47 |
# File 'lib/parallel_tests/rspec/runtime_logger.rb', line 36 def start_dump(*) return unless ENV['TEST_ENV_NUMBER'] # only record when running in parallel lock_output do # Order the output from slowest to fastest @example_times = @example_times.sort_by(&:last).reverse @example_times.each do |file, time| relative_path = file.sub(%r{^#{Regexp.escape Dir.pwd}/}, '').sub(%r{^\./}, "") @output.puts "#{relative_path}:#{[time, 0].max}" end end @output.flush end |