class ParallelTests::RSpec::LoggerBase

Constants

RSPEC_1
RSPEC_2
RSPEC_3

Public Class Methods

new(*args) click to toggle source
Calls superclass method
# File lib/parallel_tests/rspec/logger_base.rb, line 21
def initialize(*args)
  super

  @output ||= args[1] || args[0] # rspec 1 has output as second argument

  if String === @output # a path ?
    FileUtils.mkdir_p(File.dirname(@output))
    File.open(@output, 'w'){} # overwrite previous results
    @output = File.open(@output, 'a')
  elsif File === @output # close and restart in append mode
    @output.close
    @output = File.open(@output.path, 'a')
  end
end

Public Instance Methods

close(*args) click to toggle source

stolen from Rspec

# File lib/parallel_tests/rspec/logger_base.rb, line 37
def close(*args)
  @output.close  if (IO === @output) & (@output != $stdout)
end

Protected Instance Methods

lock_output() { || ... } click to toggle source

do not let multiple processes get in each others way

# File lib/parallel_tests/rspec/logger_base.rb, line 44
def lock_output
  if File === @output
    begin
      @output.flock File::LOCK_EX
      yield
    ensure
      @output.flock File::LOCK_UN
    end
  else
    yield
  end
end