Guest User

Untitled

a guest
Jan 20th, 2018
109
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.43 KB | None | 0 0
  1. diff -r old/lib/minitest.rb new/lib/minitest.rb
  2. --- old/lib/minitest.rb
  3. +++ new/lib/minitest.rb
  4. @@ -436,6 +436,41 @@
  5. end
  6. end
  7.  
  8. + module Thingy
  9. + ##
  10. + # Did this run pass?
  11. + #
  12. + # Note: skipped runs are not considered passing, but they don't
  13. + # cause the process to exit non-zero.
  14. +
  15. + def passed?
  16. + not self.failure
  17. + end
  18. +
  19. + ##
  20. + # The location identifier of this test.
  21. +
  22. + def location
  23. + loc = " [#{self.failure.location}]" unless passed? or error?
  24. + k = self.respond_to?(:klass) ? self.klass : self.class.name
  25. + "#{k}##{self.name}#{loc}"
  26. + end
  27. +
  28. + ##
  29. + # Returns ".", "F", or "E" based on the result of the run.
  30. +
  31. + def result_code
  32. + self.failure and self.failure.result_code or "."
  33. + end
  34. +
  35. + ##
  36. + # Was this run skipped?
  37. +
  38. + def skipped?
  39. + self.failure and Skip === self.failure
  40. + end
  41. + end
  42. +
  43. ##
  44. # This represents a test result in a clean way that can be
  45. # marshalled over a wire. Tests can do anything they want to the
  46. @@ -444,6 +479,8 @@
  47. # that the test result can be marshalled.
  48.  
  49. class Result < Runnable
  50. + include Minitest::Thingy
  51. +
  52. undef_method :marshal_dump
  53. undef_method :marshal_load
  54.  
  55. @@ -481,38 +518,6 @@
  56. self.failures.any? { |f| UnexpectedError === f }
  57. end
  58.  
  59. - ##
  60. - # The location identifier of this test.
  61. -
  62. - def location
  63. - loc = " [#{self.failure.location}]" unless passed? or error?
  64. - "#{self.klass || self.class.name}##{self.name}#{loc}"
  65. - end
  66. -
  67. - ##
  68. - # Did this run pass?
  69. - #
  70. - # Note: skipped runs are not considered passing, but they don't
  71. - # cause the process to exit non-zero.
  72. -
  73. - def passed?
  74. - not self.failure
  75. - end
  76. -
  77. - ##
  78. - # Returns ".", "F", or "E" based on the result of the run.
  79. -
  80. - def result_code
  81. - self.failure and self.failure.result_code or "."
  82. - end
  83. -
  84. - ##
  85. - # Was this run skipped?
  86. -
  87. - def skipped?
  88. - self.failure and Skip === self.failure
  89. - end
  90. -
  91. def to_s # :nodoc:
  92. return location if passed? and not skipped?
  93.  
  94. diff -r old/lib/minitest/test.rb new/lib/minitest/test.rb
  95. --- old/lib/minitest/test.rb
  96. +++ new/lib/minitest/test.rb
  97. @@ -7,9 +7,10 @@
  98. #
  99. # See Minitest::Assertions
  100.  
  101. - class Test < Result
  102. + class Test < Runnable
  103. require "minitest/assertions"
  104. include Minitest::Assertions
  105. + include Minitest::Thingy
  106.  
  107. PASSTHROUGH_EXCEPTIONS = [NoMemoryError, SignalException, SystemExit] # :nodoc:
Add Comment
Please, Sign In to add comment