Sha256: 46597b953a399f0cd5a2d63cde3e5a5ed7cc06fc4eadba34653f7d913552139d

Contents?: true

Size: 1.42 KB

Versions: 215

Compression:

Stored size: 1.42 KB

Contents

require 'parallelized_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
ParallelizedSpecs::SpecLoggerBaseBase = base

class ParallelizedSpecs::SpecLoggerBase < ParallelizedSpecs::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

215 entries across 215 versions & 1 rubygems

Version Path
parallelized_specs-0.4.84 lib/parallelized_specs/spec_logger_base.rb
parallelized_specs-0.4.83 lib/parallelized_specs/spec_logger_base.rb
parallelized_specs-0.4.82 lib/parallelized_specs/spec_logger_base.rb
parallelized_specs-0.4.81 lib/parallelized_specs/spec_logger_base.rb
parallelized_specs-0.4.80 lib/parallelized_specs/spec_logger_base.rb
parallelized_specs-0.4.79 lib/parallelized_specs/spec_logger_base.rb
parallelized_specs-0.4.78 lib/parallelized_specs/spec_logger_base.rb
parallelized_specs-0.4.77 lib/parallelized_specs/spec_logger_base.rb
parallelized_specs-0.4.76 lib/parallelized_specs/spec_logger_base.rb
parallelized_specs-0.4.75 lib/parallelized_specs/spec_logger_base.rb
parallelized_specs-0.4.74 lib/parallelized_specs/spec_logger_base.rb
parallelized_specs-0.4.73 lib/parallelized_specs/spec_logger_base.rb
parallelized_specs-0.4.72 lib/parallelized_specs/spec_logger_base.rb
parallelized_specs-0.4.71 lib/parallelized_specs/spec_logger_base.rb
parallelized_specs-0.4.70 lib/parallelized_specs/spec_logger_base.rb
parallelized_specs-0.4.69 lib/parallelized_specs/spec_logger_base.rb
parallelized_specs-0.4.68 lib/parallelized_specs/spec_logger_base.rb
parallelized_specs-0.4.67 lib/parallelized_specs/spec_logger_base.rb
parallelized_specs-0.4.66 lib/parallelized_specs/spec_logger_base.rb
parallelized_specs-0.4.65 lib/parallelized_specs/spec_logger_base.rb