minitest 5.16.3 → 5.25.1

Sign up to get free protection for your applications and to get access to all the features.
@@ -3,29 +3,38 @@ require "stringio"
3
3
  require "minitest/autorun"
4
4
 
5
5
  class Minitest::Test
6
- def clean s
7
- s.gsub(/^ {6}/, "")
6
+ def with_empty_backtrace_filter
7
+ with_backtrace_filter Minitest::BacktraceFilter.new %r%.% do
8
+ yield
9
+ end
8
10
  end
9
11
 
10
- def with_empty_backtrace_filter
12
+ def with_backtrace_filter filter
11
13
  original = Minitest.backtrace_filter
12
14
 
13
- obj = Minitest::BacktraceFilter.new
14
- def obj.filter _bt
15
- []
16
- end
17
-
18
15
  Minitest::Test.io_lock.synchronize do # try not to trounce in parallel
19
16
  begin
20
- Minitest.backtrace_filter = obj
17
+ Minitest.backtrace_filter = filter
21
18
  yield
22
19
  ensure
23
20
  Minitest.backtrace_filter = original
24
21
  end
25
22
  end
26
23
  end
27
- end
28
24
 
25
+ def error_on_warn?
26
+ defined?(Minitest::ErrorOnWarning)
27
+ end
28
+
29
+ def assert_deprecation re = /DEPRECATED/
30
+ re = // if $-w.nil? # "skip" if running `rake testW0`
31
+ assert_output "", re do
32
+ yield
33
+ end
34
+ rescue Minitest::UnexpectedWarning => e # raised if -Werror was used
35
+ assert_match re, e.message
36
+ end
37
+ end
29
38
 
30
39
  class FakeNamedTest < Minitest::Test
31
40
  @@count = 0
@@ -55,7 +64,7 @@ class MetaMetaMetaTestCase < Minitest::Test
55
64
  def run_tu_with_fresh_reporter flags = %w[--seed 42]
56
65
  options = Minitest.process_args flags
57
66
 
58
- @output = StringIO.new("".encode('UTF-8'))
67
+ @output = StringIO.new(+"")
59
68
 
60
69
  self.reporter = Minitest::CompositeReporter.new
61
70
  reporter << Minitest::SummaryReporter.new(@output, options)
@@ -64,7 +73,7 @@ class MetaMetaMetaTestCase < Minitest::Test
64
73
  with_stderr @output do
65
74
  reporter.start
66
75
 
67
- yield(reporter) if block_given?
76
+ yield reporter if block_given?
68
77
 
69
78
  @tus ||= [@tu]
70
79
  @tus.each do |tu|
@@ -82,8 +91,8 @@ class MetaMetaMetaTestCase < Minitest::Test
82
91
  end
83
92
 
84
93
  def assert_report expected, flags = %w[--seed 42], &block
85
- header = clean <<-EOM
86
- Run options: #{flags.map { |s| s =~ /\|/ ? s.inspect : s }.join " "}
94
+ header = <<~EOM
95
+ Run options: #{flags.map { |s| s.include?("|") ? s.inspect : s }.join " "}
87
96
 
88
97
  # Running:
89
98
 
@@ -105,15 +114,20 @@ class MetaMetaMetaTestCase < Minitest::Test
105
114
  output.gsub!(/0x[A-Fa-f0-9]+/, "0xXXX")
106
115
  output.gsub!(/ +$/, "")
107
116
 
117
+ file = ->(s) { s.start_with?("/") ? "FULLFILE" : "FILE" }
118
+
108
119
  if windows? then
109
120
  output.gsub!(/\[(?:[A-Za-z]:)?[^\]:]+:\d+\]/, "[FILE:LINE]")
110
- output.gsub!(/^(\s+)(?:[A-Za-z]:)?[^:]+:\d+:in/, '\1FILE:LINE:in')
121
+ output.gsub!(/^(\s+)(?:[A-Za-z]:)?[^:]+:\d+:in [`']/, '\1FILE:LINE:in \'')
111
122
  else
112
- output.gsub!(/\[[^\]:]+:\d+\]/, "[FILE:LINE]")
113
- output.gsub!(/^(\s+)[^:]+:\d+:in/, '\1FILE:LINE:in')
123
+ output.gsub!(/\[([^\]:]+):\d+\]/) { "[#{file[$1]}:LINE]" }
124
+ output.gsub!(/^(\s+)([^:]+):\d+:in [`']/) { "#{$1}#{file[$2]}:LINE:in '" }
114
125
  end
115
126
 
116
- output.gsub!(/( at )[^:]+:\d+/, '\1[FILE:LINE]')
127
+ output.gsub!(/in [`']block in (?:([^']+)[#.])?/, "in 'block in")
128
+ output.gsub!(/in [`'](?:([^']+)[#.])?/, "in '")
129
+
130
+ output.gsub!(/( at )([^:]+):\d+/) { "#{$1}[#{file[$2]}:LINE]" } # eval?
117
131
 
118
132
  output
119
133
  end