minitest 5.10.3 → 5.15.0

Sign up to get free protection for your applications and to get access to all the features.
@@ -6,8 +6,27 @@ class Minitest::Test
6
6
  def clean s
7
7
  s.gsub(/^ {6}/, "")
8
8
  end
9
+
10
+ def with_empty_backtrace_filter
11
+ original = Minitest.backtrace_filter
12
+
13
+ obj = Minitest::BacktraceFilter.new
14
+ def obj.filter _bt
15
+ []
16
+ end
17
+
18
+ Minitest::Test.io_lock.synchronize do # try not to trounce in parallel
19
+ begin
20
+ Minitest.backtrace_filter = obj
21
+ yield
22
+ ensure
23
+ Minitest.backtrace_filter = original
24
+ end
25
+ end
26
+ end
9
27
  end
10
28
 
29
+
11
30
  class FakeNamedTest < Minitest::Test
12
31
  @@count = 0
13
32
 
@@ -19,9 +38,20 @@ class FakeNamedTest < Minitest::Test
19
38
  end
20
39
  end
21
40
 
41
+ module MyModule; end
42
+ class AnError < StandardError; include MyModule; end
43
+
22
44
  class MetaMetaMetaTestCase < Minitest::Test
23
45
  attr_accessor :reporter, :output, :tu
24
46
 
47
+ def with_stderr err
48
+ old = $stderr
49
+ $stderr = err
50
+ yield
51
+ ensure
52
+ $stderr = old
53
+ end
54
+
25
55
  def run_tu_with_fresh_reporter flags = %w[--seed 42]
26
56
  options = Minitest.process_args flags
27
57
 
@@ -31,18 +61,20 @@ class MetaMetaMetaTestCase < Minitest::Test
31
61
  reporter << Minitest::SummaryReporter.new(@output, options)
32
62
  reporter << Minitest::ProgressReporter.new(@output, options)
33
63
 
34
- reporter.start
64
+ with_stderr @output do
65
+ reporter.start
35
66
 
36
- yield(reporter) if block_given?
67
+ yield(reporter) if block_given?
37
68
 
38
- @tus ||= [@tu]
39
- @tus.each do |tu|
40
- Minitest::Runnable.runnables.delete tu
69
+ @tus ||= [@tu]
70
+ @tus.each do |tu|
71
+ Minitest::Runnable.runnables.delete tu
41
72
 
42
- tu.run reporter, options
43
- end
73
+ tu.run reporter, options
74
+ end
44
75
 
45
- reporter.report
76
+ reporter.report
77
+ end
46
78
  end
47
79
 
48
80
  def first_reporter
@@ -68,6 +100,7 @@ class MetaMetaMetaTestCase < Minitest::Test
68
100
  output.sub!(/Finished in .*/, "Finished in 0.00")
69
101
  output.sub!(/Loaded suite .*/, "Loaded suite blah")
70
102
 
103
+ output.gsub!(/FakeNamedTest\d+/, "FakeNamedTestXX")
71
104
  output.gsub!(/ = \d+.\d\d s = /, " = 0.00 s = ")
72
105
  output.gsub!(/0x[A-Fa-f0-9]+/, "0xXXX")
73
106
  output.gsub!(/ +$/, "")
@@ -80,6 +113,8 @@ class MetaMetaMetaTestCase < Minitest::Test
80
113
  output.gsub!(/^(\s+)[^:]+:\d+:in/, '\1FILE:LINE:in')
81
114
  end
82
115
 
116
+ output.gsub!(/( at )[^:]+:\d+/, '\1[FILE:LINE]')
117
+
83
118
  output
84
119
  end
85
120