class ParallelTests::Cucumber::RuntimeLogger
Public Class Methods
new(step_mother, path_or_io, options=nil)
click to toggle source
# File lib/parallel_tests/cucumber/runtime_logger.rb, line 4 def initialize(step_mother, path_or_io, options=nil) @io = prepare_io(path_or_io) @example_times = Hash.new(0) end
Public Instance Methods
after_feature(feature)
click to toggle source
# File lib/parallel_tests/cucumber/runtime_logger.rb, line 13 def after_feature(feature) @example_times[feature.file] += Time.now.to_f - @start_at end
after_features(*args)
click to toggle source
# File lib/parallel_tests/cucumber/runtime_logger.rb, line 17 def after_features(*args) lock_output do @io.puts @example_times.map { |file, time| "#{file}:#{time}" } end end
before_feature(_)
click to toggle source
# File lib/parallel_tests/cucumber/runtime_logger.rb, line 9 def before_feature(_) @start_at = Time.now.to_f end
Private Instance Methods
lock_output() { || ... }
click to toggle source
do not let multiple processes get in each others way
# File lib/parallel_tests/cucumber/runtime_logger.rb, line 44 def lock_output if File === @io begin @io.flock File::LOCK_EX yield ensure @io.flock File::LOCK_UN end else yield end end
prepare_io(path_or_io)
click to toggle source
# File lib/parallel_tests/cucumber/runtime_logger.rb, line 25 def prepare_io(path_or_io) if path_or_io.respond_to?(:write) path_or_io else # its a path File.open(path_or_io, 'w').close # clean out the file file = File.open(path_or_io, 'a') at_exit do unless file.closed? file.flush file.close end end file end end