# frozen_string_literal: truemoduleTurboTestsclassReporterattr_writer:load_timedefself.from_config(formatter_config,start_time,seed,seed_used)reporter=new(start_time,seed,seed_used)formatter_config.eachdo|config|name,outputs=config.values_at(:name,:outputs)outputs.map!do|filename|filename=="-"?$stdout:File.open(filename,"w")endreporter.add(name,outputs)endreporterendattr_reader:pending_examplesattr_reader:failed_examplesdefinitialize(start_time,seed,seed_used)@formatters=[]@pending_examples=[]@failed_examples=[]@all_examples=[]@messages=[]@start_time=start_time@seed=seed@seed_used=seed_used@load_time=0@errors_outside_of_examples_count=0enddefadd(name,outputs)outputs.eachdo|output|formatter_class=casenamewhen"p","progress"RSpec::Core::Formatters::ProgressFormatterwhen"d","documentation"RSpec::Core::Formatters::DocumentationFormatterelseKernel.const_get(name)end@formatters<<formatter_class.new(output)endend# Borrowed from RSpec::Core::Reporter# https://github.com/rspec/rspec-core/blob/5699fcdc4723087ff6139af55bd155ad9ad61a7b/lib/rspec/core/reporter.rb#L71defreport(example_groups)start(example_groups)beginyieldselfensurefinishendenddefstart(example_groups,time=RSpec::Core::Time.now)@start=time@load_time=(@start-@start_time).to_freport_number_of_tests(example_groups)expected_example_count=example_groups.flatten(1).countdelegate_to_formatters(:seed,RSpec::Core::Notifications::SeedNotification.new(@seed,@seed_used))delegate_to_formatters(:start,RSpec::Core::Notifications::StartNotification.new(expected_example_count,@load_time))enddefreport_number_of_tests(groups)name=ParallelTests::RSpec::Runner.test_file_namenum_processes=groups.sizenum_tests=groups.map(&:size).sumtests_per_process=(num_processes==0?0:num_tests.to_f/num_processes).roundputs"#{num_processes} processes for #{num_tests}#{name}s, ~ #{tests_per_process}#{name}s per process"enddefgroup_started(notification)delegate_to_formatters(:example_group_started,notification)enddefgroup_finisheddelegate_to_formatters(:example_group_finished,nil)enddefexample_passed(example)delegate_to_formatters(:example_passed,example.notification)@all_examples<<exampleenddefexample_pending(example)delegate_to_formatters(:example_pending,example.notification)@all_examples<<example@pending_examples<<exampleenddefexample_failed(example)delegate_to_formatters(:example_failed,example.notification)@all_examples<<example@failed_examples<<exampleenddefmessage(message)delegate_to_formatters(:message,RSpec::Core::Notifications::MessageNotification.new(message))@messages<<messageenddeferror_outside_of_examples(error_message)@errors_outside_of_examples_count+=1messageerror_messageenddeffinishend_time=RSpec::Core::Time.now@duration=end_time-@start_timedelegate_to_formatters:stop,RSpec::Core::Notifications::ExamplesNotification.new(self)delegate_to_formatters:start_dump,RSpec::Core::Notifications::NullNotificationdelegate_to_formatters(:dump_pending,RSpec::Core::Notifications::ExamplesNotification.new(self))delegate_to_formatters(:dump_failures,RSpec::Core::Notifications::ExamplesNotification.new(self))delegate_to_formatters(:dump_summary,RSpec::Core::Notifications::SummaryNotification.new(end_time-@start_time,@all_examples,@failed_examples,@pending_examples,@load_time,@errors_outside_of_examples_count))delegate_to_formatters(:seed,RSpec::Core::Notifications::SeedNotification.new(@seed,@seed_used,))ensuredelegate_to_formatters:close,RSpec::Core::Notifications::NullNotificationendprotecteddefdelegate_to_formatters(method,*args)@formatters.eachdo|formatter|formatter.send(method,*args)ifformatter.respond_to?(method)endendendend