Sha256: d2ff91b9111f9a71a4c77b5057bcaf9d953029b584ce6041f4dd1191bdbf40ca

Contents?: true

Size: 1.41 KB

Versions: 4

Compression:

Stored size: 1.41 KB

Contents

require 'parallel_specs'

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
ParallelSpecs::SpecLoggerBaseBase = base

class ParallelSpecs::SpecLoggerBase < ParallelSpecs::SpecLoggerBaseBase
  RSPEC_1 = !defined?(RSpec::Core::Formatters::BaseTextFormatter) # do not test for Spec, this will trigger deprecation warning in rspec 2

  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

  def dump_summary(*args);end

  def dump_failures(*args);end

  def dump_failure(*args);end

  def dump_pending(*args);end

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

  # 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

4 entries across 4 versions & 2 rubygems

Version Path
parallelized_specs-0.0.1 lib/parallel_specs/spec_logger_base.rb
parallel_tests-instructure-0.6.19 lib/parallel_specs/spec_logger_base.rb
parallel_tests-instructure-0.6.18 lib/parallel_specs/spec_logger_base.rb
parallel_tests-instructure-0.6.17 lib/parallel_specs/spec_logger_base.rb