minitest 5.11.3 → 5.25.4
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- checksums.yaml.gz.sig +0 -0
- data/History.rdoc +375 -4
- data/Manifest.txt +6 -0
- data/README.rdoc +106 -17
- data/Rakefile +11 -16
- data/lib/hoe/minitest.rb +2 -5
- data/lib/minitest/assertions.rb +255 -93
- data/lib/minitest/autorun.rb +0 -7
- data/lib/minitest/benchmark.rb +13 -16
- data/lib/minitest/compress.rb +94 -0
- data/lib/minitest/error_on_warning.rb +11 -0
- data/lib/minitest/expectations.rb +72 -35
- data/lib/minitest/manual_plugins.rb +16 -0
- data/lib/minitest/mock.rb +151 -44
- data/lib/minitest/parallel.rb +5 -5
- data/lib/minitest/pride_plugin.rb +17 -24
- data/lib/minitest/spec.rb +38 -19
- data/lib/minitest/test.rb +50 -33
- data/lib/minitest/test_task.rb +307 -0
- data/lib/minitest/unit.rb +5 -8
- data/lib/minitest.rb +414 -166
- data/test/minitest/metametameta.rb +65 -17
- data/test/minitest/test_minitest_assertions.rb +1720 -0
- data/test/minitest/test_minitest_benchmark.rb +3 -3
- data/test/minitest/test_minitest_mock.rb +409 -65
- data/test/minitest/test_minitest_reporter.rb +169 -32
- data/test/minitest/test_minitest_spec.rb +369 -193
- data/test/minitest/test_minitest_test.rb +463 -1249
- data/test/minitest/test_minitest_test_task.rb +57 -0
- data.tar.gz.sig +0 -0
- metadata +40 -23
- metadata.gz.sig +0 -0
@@ -3,8 +3,36 @@ require "stringio"
|
|
3
3
|
require "minitest/autorun"
|
4
4
|
|
5
5
|
class Minitest::Test
|
6
|
-
def
|
7
|
-
|
6
|
+
def with_empty_backtrace_filter
|
7
|
+
with_backtrace_filter Minitest::BacktraceFilter.new %r%.% do
|
8
|
+
yield
|
9
|
+
end
|
10
|
+
end
|
11
|
+
|
12
|
+
def with_backtrace_filter filter
|
13
|
+
original = Minitest.backtrace_filter
|
14
|
+
|
15
|
+
Minitest::Test.io_lock.synchronize do # try not to trounce in parallel
|
16
|
+
begin
|
17
|
+
Minitest.backtrace_filter = filter
|
18
|
+
yield
|
19
|
+
ensure
|
20
|
+
Minitest.backtrace_filter = original
|
21
|
+
end
|
22
|
+
end
|
23
|
+
end
|
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
|
8
36
|
end
|
9
37
|
end
|
10
38
|
|
@@ -19,30 +47,43 @@ class FakeNamedTest < Minitest::Test
|
|
19
47
|
end
|
20
48
|
end
|
21
49
|
|
50
|
+
module MyModule; end
|
51
|
+
class AnError < StandardError; include MyModule; end
|
52
|
+
|
22
53
|
class MetaMetaMetaTestCase < Minitest::Test
|
23
54
|
attr_accessor :reporter, :output, :tu
|
24
55
|
|
56
|
+
def with_stderr err
|
57
|
+
old = $stderr
|
58
|
+
$stderr = err
|
59
|
+
yield
|
60
|
+
ensure
|
61
|
+
$stderr = old
|
62
|
+
end
|
63
|
+
|
25
64
|
def run_tu_with_fresh_reporter flags = %w[--seed 42]
|
26
65
|
options = Minitest.process_args flags
|
27
66
|
|
28
|
-
@output = StringIO.new(""
|
67
|
+
@output = StringIO.new(+"")
|
29
68
|
|
30
69
|
self.reporter = Minitest::CompositeReporter.new
|
31
70
|
reporter << Minitest::SummaryReporter.new(@output, options)
|
32
71
|
reporter << Minitest::ProgressReporter.new(@output, options)
|
33
72
|
|
34
|
-
|
73
|
+
with_stderr @output do
|
74
|
+
reporter.start
|
35
75
|
|
36
|
-
|
76
|
+
yield reporter if block_given?
|
37
77
|
|
38
|
-
|
39
|
-
|
40
|
-
|
78
|
+
@tus ||= [@tu]
|
79
|
+
@tus.each do |tu|
|
80
|
+
Minitest::Runnable.runnables.delete tu
|
41
81
|
|
42
|
-
|
43
|
-
|
82
|
+
tu.run reporter, options
|
83
|
+
end
|
44
84
|
|
45
|
-
|
85
|
+
reporter.report
|
86
|
+
end
|
46
87
|
end
|
47
88
|
|
48
89
|
def first_reporter
|
@@ -50,8 +91,8 @@ class MetaMetaMetaTestCase < Minitest::Test
|
|
50
91
|
end
|
51
92
|
|
52
93
|
def assert_report expected, flags = %w[--seed 42], &block
|
53
|
-
header =
|
54
|
-
Run options: #{flags.map { |s| s
|
94
|
+
header = <<~EOM
|
95
|
+
Run options: #{flags.map { |s| s.include?("|") ? s.inspect : s }.join " "}
|
55
96
|
|
56
97
|
# Running:
|
57
98
|
|
@@ -73,14 +114,21 @@ class MetaMetaMetaTestCase < Minitest::Test
|
|
73
114
|
output.gsub!(/0x[A-Fa-f0-9]+/, "0xXXX")
|
74
115
|
output.gsub!(/ +$/, "")
|
75
116
|
|
117
|
+
file = ->(s) { s.start_with?("/") ? "FULLFILE" : "FILE" }
|
118
|
+
|
76
119
|
if windows? then
|
77
120
|
output.gsub!(/\[(?:[A-Za-z]:)?[^\]:]+:\d+\]/, "[FILE:LINE]")
|
78
|
-
output.gsub!(/^(\s+)(?:[A-Za-z]:)?[^:]+:\d+:in/, '\1FILE:LINE:in')
|
121
|
+
output.gsub!(/^(\s+)(?:[A-Za-z]:)?[^:]+:\d+:in [`']/, '\1FILE:LINE:in \'')
|
79
122
|
else
|
80
|
-
output.gsub!(/\[[^\]:]
|
81
|
-
output.gsub!(/^(\s+)[^:]
|
123
|
+
output.gsub!(/\[([^\]:]+):\d+\]/) { "[#{file[$1]}:LINE]" }
|
124
|
+
output.gsub!(/^(\s+)([^:]+):\d+:in [`']/) { "#{$1}#{file[$2]}:LINE:in '" }
|
82
125
|
end
|
83
126
|
|
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?
|
131
|
+
|
84
132
|
output
|
85
133
|
end
|
86
134
|
|
@@ -95,7 +143,7 @@ class MetaMetaMetaTestCase < Minitest::Test
|
|
95
143
|
|
96
144
|
def setup
|
97
145
|
super
|
98
|
-
|
146
|
+
Minitest.seed = 42
|
99
147
|
Minitest::Test.reset
|
100
148
|
@tu = nil
|
101
149
|
end
|