Sha256: 5ce3b77d04bc772ab75935fe880606e6b722e2ffbb96a7d3a5b5ad86e1e63bff

Contents?: true

Size: 1.44 KB

Versions: 1

Compression:

Stored size: 1.44 KB

Contents

require 'parallelized_specs/spec_logger_base'

class ParallelizedSpecs::TrendingExampleFailures < ParallelizedSpecs::SpecLoggerBase
  def initialize(*args)
    @output ||= args[1] || args[0] # rspec 1 has output as second argument
    @hudson_build_num = File.read("#{RAILS_ROOT}tmp/parallel_log/build_num.txt")
# need to handle clean up in hudson_build.sh
    if String === @output # a path ?
      FileUtils.mkdir_p(File.dirname(@output))
      @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 example_failed(example, counter, failure)
    if RSPEC_1
      super
      if example.location != nil
        @failed_examples ||= {}
        #putting tabs between each output as a delimiter
        @failed_examples["#{example.location.match(/spec.*\d/).to_s}*"] = ["#{example.description}*", "#{failure.header}*", "#{failure.exception.to_s.gsub(/\n/,"")}*", "#{failure.exception.backtrace.to_s.gsub(/\n/,"")}*", "#{Time.now.to_date}*", "#{@hudson_build_num}"]
      end
    else
      super
    end
  end

  # RSpec 1: dumps 1 failed spec
  def dump_failure(*args)
  end

  # RSpec 2: dumps all failed specs
  def dump_failures(*args)
  end

  def dump_summary(*args)
    lock_output do
      (@failed_examples||{}).each_pair do |example, details|
        @output.puts "#{example}#{details}"
      end
      @output.flush
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
parallelized_specs-0.2.97 lib/parallelized_specs/trending_example_failures_logger.rb