Sha256: bc7dd3b022c78b686f1960f395240bb574fd18ef65293564223b442bbc78a57d

Contents?: true

Size: 1.47 KB

Versions: 31

Compression:

Stored size: 1.47 KB

Contents

module ParallelTests
  module RSpec
  end
end

begin
  require 'rspec/core/formatters/base_text_formatter'
  base = RSpec::Core::Formatters::BaseTextFormatter
rescue LoadError
  require 'spec/runner/formatter/base_text_formatter'
  base = Spec::Runner::Formatter::BaseTextFormatter
end

ParallelTests::RSpec::LoggerBaseBase = base

class ParallelTests::RSpec::LoggerBase < ParallelTests::RSpec::LoggerBaseBase
  RSPEC_1 = !defined?(RSpec::Core::Formatters::BaseTextFormatter) # do not test for Spec, this will trigger deprecation warning in rspec 2
  RSPEC_2 = !RSPEC_1 && RSpec::Core::Version::STRING.start_with?('2')
  RSPEC_3 = !RSPEC_1 && RSpec::Core::Version::STRING.start_with?('3')

  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

  #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

31 entries across 31 versions & 2 rubygems

Version Path
parallel_tests-2.13.0 lib/parallel_tests/rspec/logger_base.rb
parallel_tests-2.12.0 lib/parallel_tests/rspec/logger_base.rb
parallel_tests-2.11.0 lib/parallel_tests/rspec/logger_base.rb
parallel_tests-2.10.0 lib/parallel_tests/rspec/logger_base.rb
parallel_tests-2.9.0 lib/parallel_tests/rspec/logger_base.rb
parallel_tests-2.8.0 lib/parallel_tests/rspec/logger_base.rb
parallel_tests-2.7.1 lib/parallel_tests/rspec/logger_base.rb
parallel_tests-2.7.0 lib/parallel_tests/rspec/logger_base.rb
parallel_tests-2.6.0 lib/parallel_tests/rspec/logger_base.rb
parallel_tests-2.5.0 lib/parallel_tests/rspec/logger_base.rb
parallel_tests-2.4.1 lib/parallel_tests/rspec/logger_base.rb
parallel_tests-2.4.0 lib/parallel_tests/rspec/logger_base.rb
parallel_tests-2.3.1 lib/parallel_tests/rspec/logger_base.rb
parallel_tests-2.3.0 lib/parallel_tests/rspec/logger_base.rb
parallel_tests-2.2.2 lib/parallel_tests/rspec/logger_base.rb
parallel_tests-2.2.1 lib/parallel_tests/rspec/logger_base.rb
parallel_tests-2.2.0 lib/parallel_tests/rspec/logger_base.rb
parallel_tests-2.1.2 lib/parallel_tests/rspec/logger_base.rb
parallel_tests-2.1.1 lib/parallel_tests/rspec/logger_base.rb
parallel_tests-2.1.0 lib/parallel_tests/rspec/logger_base.rb