Sha256: 1b96a5c5d7c9c93bd1fef9a93a6398844ce04e451bf0572d3955e64f020079b2

Contents?: true

Size: 1.19 KB

Versions: 25

Compression:

Stored size: 1.19 KB

Contents

require 'spec/runner/formatter/progress_bar_formatter'

class ParallelSpecs::SpecRuntimeLogger < Spec::Runner::Formatter::BaseTextFormatter
  def initialize(options, output)
    if String === output
      FileUtils.mkdir_p(File.dirname(output))
      File.open(output,'w'){|f| f.write ''} # clean the file
      @output = File.open(output, 'a+') #append so that multiple processes can write at once
    else
      @output = output
    end
    @example_times = Hash.new(0)
  end

  def example_started(*args)
    @time = Time.now
  end

  def example_passed(example)
    file = example.location.split(':').first
    @example_times[file] += Time.now - @time
  end

  def start_dump(*args)
    return unless ENV['TEST_ENV_NUMBER'] #only record when running in parallel
    # TODO: Figure out why sometimes time can be less than 0
    @output.puts @example_times.map { |file, time| "#{file}:#{time > 0 ? time : 0}" }
    @output.flush
  end

  # stubs so that rspec doe not crash

  def example_pending(*args)
  end

  def dump_summary(*args)
  end

  def dump_pending(*args)
  end

  def dump_failure(*args)
  end

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

Version data entries

25 entries across 25 versions & 2 rubygems

Version Path
moxiesoft_parallel_tests-0.4.13 lib/parallel_specs/spec_runtime_logger.rb
parallel_tests-0.4.13 lib/parallel_specs/spec_runtime_logger.rb
moxiesoft_parallel_tests-0.4.12 lib/parallel_specs/spec_runtime_logger.rb
parallel_tests-0.4.12 lib/parallel_specs/spec_runtime_logger.rb
parallel_tests-0.4.11 lib/parallel_specs/spec_runtime_logger.rb
parallel_tests-0.4.10 lib/parallel_specs/spec_runtime_logger.rb
parallel_tests-0.4.9 lib/parallel_specs/spec_runtime_logger.rb
parallel_tests-0.4.8 lib/parallel_specs/spec_runtime_logger.rb
parallel_tests-0.4.7 lib/parallel_specs/spec_runtime_logger.rb
parallel_tests-0.4.6 lib/parallel_specs/spec_runtime_logger.rb
parallel_tests-0.4.5 lib/parallel_specs/spec_runtime_logger.rb
parallel_tests-0.4.4 lib/parallel_specs/spec_runtime_logger.rb
parallel_tests-0.4.3 lib/parallel_specs/spec_runtime_logger.rb
parallel_tests-0.4.2 lib/parallel_specs/spec_runtime_logger.rb
parallel_tests-0.4.1 lib/parallel_specs/spec_runtime_logger.rb
parallel_tests-0.4.0 lib/parallel_specs/spec_runtime_logger.rb
parallel_tests-0.3.8 lib/parallel_specs/spec_runtime_logger.rb
parallel_tests-0.3.7 lib/parallel_specs/spec_runtime_logger.rb
parallel_tests-0.3.6 lib/parallel_specs/spec_runtime_logger.rb
parallel_tests-0.3.5 lib/parallel_specs/spec_runtime_logger.rb