class Tryouts::TestBatch

def execute_test_case_with_container(test_case, container)

Common test execution logic shared by both context modes
def execute_test_case_with_container(test_case, container)
  # Individual test timeout protection
  test_timeout = @options[:test_timeout] || 30 # 30 second default
  if test_case.exception_expectations?
    # For exception tests, don't execute code here - let evaluate_expectations handle it
    expectations_result = execute_with_timeout(test_timeout, test_case) do
      evaluate_expectations(test_case, nil, container)
    end
    build_test_result(test_case, nil, expectations_result)
  else
    # Regular execution for non-exception tests with timing and output capture
    code  = test_case.code
    path  = test_case.path
    range = test_case.line_range
    # Check if we need output capture for any expectations
    needs_output_capture = test_case.expectations.any?(&:output?)
    result_value, _, _, _, expectations_result =
      execute_with_timeout(test_timeout, test_case) do
        if needs_output_capture
          # Execute with output capture using Fiber-local isolation
          result_value, execution_time_ns, stdout_content, stderr_content =
            execute_with_output_capture(container, code, path, range)
          expectations_result = evaluate_expectations(
            test_case, result_value, container, execution_time_ns, stdout_content, stderr_content
          )
          [result_value, execution_time_ns, stdout_content, stderr_content, expectations_result]
        else
          # Regular execution with timing capture only
          execution_start_ns = Process.clock_gettime(Process::CLOCK_MONOTONIC, :nanosecond)
          result_value       = container.instance_eval(code, path, range.first + 1)
          execution_end_ns   = Process.clock_gettime(Process::CLOCK_MONOTONIC, :nanosecond)
          execution_time_ns  = execution_end_ns - execution_start_ns
          expectations_result = evaluate_expectations(test_case, result_value, container, execution_time_ns)
          [result_value, execution_time_ns, nil, nil, expectations_result]
        end
      end
    build_test_result(test_case, result_value, expectations_result)
  end
rescue StandardError => ex
  build_error_result(test_case, ex)
rescue SystemExit, SignalException => ex
  # Handle process control exceptions gracefully
  Tryouts.debug "Test received #{ex.class}: #{ex.message}"
  build_error_result(test_case, StandardError.new("Test terminated by #{ex.class}: #{ex.message}"))
end