Sha256: cf2cbdc00010311ca57d61a11e4e9ce706895f72eca85546ebdb03340c22de39

Contents?: true

Size: 1011 Bytes

Versions: 38

Compression:

Stored size: 1011 Bytes

Contents

module ParallelTests
  module RSpec
  end
end

require 'rspec/core/formatters/base_text_formatter'

class ParallelTests::RSpec::LoggerBase < RSpec::Core::Formatters::BaseTextFormatter
  RSPEC_2 = RSpec::Core::Version::STRING.start_with?('2')

  def initialize(*args)
    super

    @output ||= args[0]

    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

  #stolen from Rspec
  def close(*args)
    @output.close  if (IO === @output) & (@output != $stdout)
  end

  protected

  # do not let multiple processes get in each others way
  def lock_output
    if File === @output
      begin
        @output.flock File::LOCK_EX
        yield
      ensure
        @output.flock File::LOCK_UN
      end
    else
      yield
    end
  end
end

Version data entries

38 entries across 38 versions & 1 rubygems

Version Path
parallel_tests-3.4.0 lib/parallel_tests/rspec/logger_base.rb
parallel_tests-3.3.0 lib/parallel_tests/rspec/logger_base.rb
parallel_tests-3.2.0 lib/parallel_tests/rspec/logger_base.rb
parallel_tests-3.1.0 lib/parallel_tests/rspec/logger_base.rb
parallel_tests-3.0.0 lib/parallel_tests/rspec/logger_base.rb
parallel_tests-2.32.0 lib/parallel_tests/rspec/logger_base.rb
parallel_tests-2.31.0 lib/parallel_tests/rspec/logger_base.rb
parallel_tests-2.30.1 lib/parallel_tests/rspec/logger_base.rb
parallel_tests-2.30.0 lib/parallel_tests/rspec/logger_base.rb
parallel_tests-2.29.2 lib/parallel_tests/rspec/logger_base.rb
parallel_tests-2.29.1 lib/parallel_tests/rspec/logger_base.rb
parallel_tests-2.29.0 lib/parallel_tests/rspec/logger_base.rb
parallel_tests-2.28.0 lib/parallel_tests/rspec/logger_base.rb
parallel_tests-2.27.1 lib/parallel_tests/rspec/logger_base.rb
parallel_tests-2.27.0 lib/parallel_tests/rspec/logger_base.rb
parallel_tests-2.26.2 lib/parallel_tests/rspec/logger_base.rb
parallel_tests-2.26.0 lib/parallel_tests/rspec/logger_base.rb
parallel_tests-2.25.0 lib/parallel_tests/rspec/logger_base.rb
parallel_tests-2.24.0 lib/parallel_tests/rspec/logger_base.rb
parallel_tests-2.23.0 lib/parallel_tests/rspec/logger_base.rb