Class: Minitest::Discard

Inherits:
Skip
  • Object
show all
Extended by:
T::Sig
Defined in:
lib/minitest/distributed/result_type.rb

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(message, original_result:) ⇒ Discard

Returns a new instance of Discard.



12
13
14
15
# File 'lib/minitest/distributed/result_type.rb', line 12

def initialize(message, original_result:)
  @original_result = original_result
  super(message)
end

Instance Attribute Details

#original_resultObject (readonly)

Returns the value of attribute original_result.



9
10
11
# File 'lib/minitest/distributed/result_type.rb', line 9

def original_result
  @original_result
end

Class Method Details

.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

Instance Method Details

#result_labelObject



18
19
20
# File 'lib/minitest/distributed/result_type.rb', line 18

def result_label
  "Discarded"
end