Class: ParallelTests::Test::RuntimeLogger

Inherits:
Object
  • Object
show all
Defined in:
lib/parallel_tests/test/runtime_logger.rb

Constant Summary collapse

@@prepared =
false

Class Method Summary collapse

Class Method Details

.log_test_run(test) ⇒ Object



11
12
13
14
15
16
17
18
19
# File 'lib/parallel_tests/test/runtime_logger.rb', line 11

def log_test_run(test)
  prepare

  result = nil
  time = ParallelTests.delta { result = yield }
  log(test, time)

  result
end

.unique_logObject



21
22
23
24
25
26
27
28
29
30
31
32
33
# File 'lib/parallel_tests/test/runtime_logger.rb', line 21

def unique_log
  with_locked_log do |logfile|
    separator = "\n"
    groups = logfile.read.split(separator).map { |line| line.split(":") }.group_by(&:first)
    lines = groups.map do |file, times|
      time = "%.2f" % times.map(&:last).map(&:to_f).sum
      "#{file}:#{time}"
    end
    logfile.rewind
    logfile.write(lines.join(separator) + separator)
    logfile.truncate(logfile.pos)
  end
end