require 'parallelized_specs/spec_logger_base' module RSpec class ParallelizedSpecs::FailuresFormatter < ParallelizedSpecs::SpecLoggerBase def start(example_count) @example_count = example_count env_test_number = ENV['TEST_ENV_NUMBER'] env_test_number = 1 if ENV['TEST_ENV_NUMBER'].blank? puts "Thread #{env_test_number.to_s} has #{@example_count} specs" File.open("tmp/parallel_log/spec_count/total_specs#{env_test_number}.txt", 'a+') { |f| f.puts(@example_count) } super end def example_failed(example, counter, failure) lock_output do @output.puts retry_command(example) end end def dump_summary(duration, example_count, failure_count, pending_count) env_test_number = ENV['TEST_ENV_NUMBER'] env_test_number = 1 if ENV['TEST_ENV_NUMBER'].blank? File.open("tmp/parallel_log/spec_count/total_specs#{env_test_number}.txt").each do |line| puts "this is thread #{env_test_number} with #{line} expected examples and #{example} actual examples" if line == example_count @all_specs_ran = true end end if all_specs_ran == true File.delete("tmp/parallel_log/spec_count/total_specs#{env_test_number}.txt") end failure_count > 0 ? File.open("tmp/parallel_log/failed_specs/failed_specs#{env_test_number}.txt", 'a+') { |f| f.puts(failure_count) } : puts "All specs in Thread #{env_test_number} passed" end def dump_failures(*args) ; end def dump_failure(*args) ; end def dump_pending(*args) ; end def retry_command(example) spec_file = example_group.location.gsub("\"", "\\\"").match(/spec.*b/).to_s spec_name = example.description "SPEC=#{Dir.pwd}/#{spec_file} SPEC_OPTS='-e \"#{spec_name}\"'" end end end