Class: TurboTests::RuntimeLogger
- Inherits:
-
Object
- Object
- TurboTests::RuntimeLogger
- Defined in:
- lib/turbo_tests/runtime_logger.rb
Overview
RSpec formatter that records per-file runtimes into a runtime log
(TurboGroups path:seconds format, read back by RuntimeGroups::Grouping).
Semantics retained from parallel_tests’ RuntimeLogger:
- only records when running in parallel (TEST_ENV_NUMBER is set)
- accumulates time across nested example groups per top-level file
- appends at dump time, sorted slowest-first
Min-merging across re-runs happens in RuntimeGroups::RuntimeLog.read via
last-write-wins per line, and worker groups are disjoint, so concurrent
workers never write the same file.
Instance Method Summary collapse
-
#close ⇒ Object
-
#dump_failures ⇒ Object
-
#dump_pending ⇒ Object
-
#dump_summary ⇒ Object
-
#example_group_finished(notification) ⇒ Object
-
#example_group_started(_notification) ⇒ Object
-
#initialize(output) ⇒ RuntimeLogger
constructor
A new instance of RuntimeLogger.
-
#message ⇒ Object
-
#seed ⇒ Object
-
#start_dump ⇒ Object
Constructor Details
#initialize(output) ⇒ RuntimeLogger
Returns a new instance of RuntimeLogger.
18 19 20 21 22 23 |
# File 'lib/turbo_tests/runtime_logger.rb', line 18 def initialize(output) @output = output @example_times = Hash.new(0) @group_nesting = 0 @time = 0.0 end |
Instance Method Details
#close ⇒ Object
52 53 |
# File 'lib/turbo_tests/runtime_logger.rb', line 52 def close(*) end |
#dump_failures ⇒ Object
43 44 |
# File 'lib/turbo_tests/runtime_logger.rb', line 43 def dump_failures(*) end |
#dump_pending ⇒ Object
46 47 |
# File 'lib/turbo_tests/runtime_logger.rb', line 46 def dump_pending(*) end |
#dump_summary ⇒ Object
40 41 |
# File 'lib/turbo_tests/runtime_logger.rb', line 40 def dump_summary(*) end |
#example_group_finished(notification) ⇒ Object
30 31 32 33 34 35 |
# File 'lib/turbo_tests/runtime_logger.rb', line 30 def example_group_finished(notification) @group_nesting -= 1 if @group_nesting.zero? @example_times[notification.group.file_path] += monotonic - @time end end |
#example_group_started(_notification) ⇒ Object
25 26 27 28 |
# File 'lib/turbo_tests/runtime_logger.rb', line 25 def example_group_started(_notification) @group_nesting += 1 @time = monotonic if @group_nesting == 1 end |
#message ⇒ Object
49 50 |
# File 'lib/turbo_tests/runtime_logger.rb', line 49 def (*) end |
#seed ⇒ Object
37 38 |
# File 'lib/turbo_tests/runtime_logger.rb', line 37 def seed(*) end |
#start_dump ⇒ Object
55 56 57 58 59 60 61 62 63 64 65 66 |
# File 'lib/turbo_tests/runtime_logger.rb', line 55 def start_dump(*) return unless ENV["TEST_ENV_NUMBER"] # only record when running in parallel log_path = output_path return unless log_path log = RuntimeGroups::RuntimeLog.new(log_path) @example_times.sort_by(&:last).reverse_each do |file, time| relative_path = file.sub(%r{^#{Regexp.escape(Dir.pwd)}/}, "").sub(%r{^\./}, "") log.log(relative_path, [time, 0].max) end end |