class Tryouts::TestExecutor

def execute_direct_mode

def execute_direct_mode
  batch = TestBatch.new(
    @testrun,
    shared_context: @options[:shared_context],
    verbose: @options[:verbose],
    fails_only: @options[:fails_only],
    output_manager: @output_manager,
    global_tally: @global_tally,
  )
  # TestBatch handles file output, so don't duplicate it here
  unless @options[:verbose]
    context_mode = @options[:shared_context] ? 'shared' : 'fresh'
    @output_manager.file_execution_start(@file, @testrun.total_tests, context_mode)
  end
  test_results = []
  success      = batch.run do
    last_result = batch.results.last
    test_results << last_result if last_result
  end
  file_failed_count                 = test_results.count { |r| r.failed? }
  file_error_count                  = test_results.count { |r| r.error? }
  executed_test_count               = test_results.size
  @global_tally[:total_tests]      += executed_test_count
  @global_tally[:total_failed]     += file_failed_count
  @global_tally[:total_errors]     += file_error_count
  @global_tally[:successful_files] += 1 if success
  duration = Time.now.to_f - @file_start.to_f
  @output_manager.file_success(@file, executed_test_count, file_failed_count, file_error_count, duration)
  # Combine failures and errors to determine the exit code.
  success ? 0 : (file_failed_count + file_error_count)
end