Method: Minitest::Discard.wrap

Defined in:
lib/minitest/distributed/result_type.rb

.wrap(result, test_timeout_seconds:) ⇒ Object



23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
# File 'lib/minitest/distributed/result_type.rb', line 23

def self.wrap(result, test_timeout_seconds:)
  message = +"This test result was discarded, because it could not be committed to the test run coordinator."
  if result.time > test_timeout_seconds
    message << format(
      "\n\nThe test took %0.3fs to run, longer than the test timeout which is configured to be %0.1fs.\n" \
        "Another worker likely claimed ownership of this test, and will commit the result instead.\n" \
        "For best results, make sure that all your tests finish within %0.1fs.",
      result.time,
      test_timeout_seconds,
      test_timeout_seconds,
    )
  end

  discard_assertion = Minitest::Discard.new(message, original_result: result)
  discard_assertion.set_backtrace(caller)
  discarded_result = result.dup
  discarded_result.failures = [discard_assertion]
  discarded_result
end