minitest 5.26.2 → 6.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- checksums.yaml.gz.sig +2 -2
- data/History.rdoc +74 -0
- data/Manifest.txt +13 -4
- data/README.rdoc +8 -90
- data/Rakefile +7 -1
- data/bin/minitest +5 -0
- data/lib/minitest/assertions.rb +32 -64
- data/lib/minitest/autorun.rb +3 -4
- data/lib/minitest/benchmark.rb +2 -2
- data/lib/minitest/bisect.rb +306 -0
- data/lib/minitest/complete.rb +56 -0
- data/lib/minitest/find_minimal_combination.rb +127 -0
- data/lib/minitest/hell.rb +1 -1
- data/lib/minitest/manual_plugins.rb +4 -16
- data/lib/minitest/parallel.rb +3 -3
- data/lib/minitest/path_expander.rb +418 -0
- data/lib/minitest/pride.rb +2 -2
- data/lib/minitest/pride_plugin.rb +1 -1
- data/lib/minitest/server.rb +45 -0
- data/lib/minitest/server_plugin.rb +84 -0
- data/lib/minitest/spec.rb +4 -33
- data/lib/minitest/sprint.rb +104 -0
- data/lib/minitest/sprint_plugin.rb +39 -0
- data/lib/minitest/test.rb +7 -13
- data/lib/minitest/test_task.rb +6 -13
- data/lib/minitest.rb +62 -91
- data/test/minitest/metametameta.rb +1 -1
- data/test/minitest/test_bisect.rb +235 -0
- data/test/minitest/test_find_minimal_combination.rb +138 -0
- data/test/minitest/test_minitest_assertions.rb +41 -101
- data/test/minitest/test_minitest_reporter.rb +6 -5
- data/test/minitest/test_minitest_spec.rb +41 -117
- data/test/minitest/test_minitest_test.rb +21 -100
- data/test/minitest/test_path_expander.rb +229 -0
- data/test/minitest/test_server.rb +149 -0
- data.tar.gz.sig +1 -1
- metadata +50 -14
- metadata.gz.sig +2 -2
- data/.autotest +0 -34
- data/lib/minitest/mock.rb +0 -327
- data/lib/minitest/unit.rb +0 -42
- data/test/minitest/test_minitest_mock.rb +0 -1213
|
@@ -0,0 +1,235 @@
|
|
|
1
|
+
require "minitest/autorun"
|
|
2
|
+
require "minitest/bisect"
|
|
3
|
+
|
|
4
|
+
module TestMinitest; end
|
|
5
|
+
|
|
6
|
+
class TestMinitest::TestBisect < Minitest::Test
|
|
7
|
+
attr_accessor :bisect
|
|
8
|
+
|
|
9
|
+
def setup
|
|
10
|
+
self.bisect = Minitest::Bisect.new
|
|
11
|
+
bisect.reset
|
|
12
|
+
end
|
|
13
|
+
|
|
14
|
+
def test_class_run
|
|
15
|
+
skip "Need to write test_class_run"
|
|
16
|
+
end
|
|
17
|
+
|
|
18
|
+
def test_bisect_files
|
|
19
|
+
skip "Need to write test_bisect_files"
|
|
20
|
+
end
|
|
21
|
+
|
|
22
|
+
def test_bisect_methods
|
|
23
|
+
skip "Need to write test_bisect_methods"
|
|
24
|
+
end
|
|
25
|
+
|
|
26
|
+
def test_build_files_cmd
|
|
27
|
+
files = %w[a.rb b.rb c.rb]
|
|
28
|
+
rb = %w[-Ilib:test]
|
|
29
|
+
mt = %w[--seed 42]
|
|
30
|
+
|
|
31
|
+
ruby = Minitest::Bisect::RUBY
|
|
32
|
+
body = "require \"./a.rb\" ; require \"./b.rb\" ; require \"./c.rb\""
|
|
33
|
+
|
|
34
|
+
exp = "#{ruby} -Ilib:test -e '#{body}' -- --seed 42"
|
|
35
|
+
act = bisect.build_files_cmd(files, rb, mt)
|
|
36
|
+
|
|
37
|
+
assert_equal exp, act
|
|
38
|
+
end
|
|
39
|
+
|
|
40
|
+
def test_build_methods_cmd
|
|
41
|
+
cmd = "cmd"
|
|
42
|
+
assert_equal "cmd", bisect.build_methods_cmd(cmd)
|
|
43
|
+
end
|
|
44
|
+
|
|
45
|
+
def test_build_methods_cmd_verify
|
|
46
|
+
cmd = "cmd"
|
|
47
|
+
cul = []
|
|
48
|
+
bad = %w[A#test_1 B#test_2]
|
|
49
|
+
|
|
50
|
+
exp = "cmd -n \"/^(?:A#(?:test_1)|B#(?:test_2))$/\""
|
|
51
|
+
|
|
52
|
+
assert_equal exp, bisect.build_methods_cmd(cmd, cul, bad)
|
|
53
|
+
end
|
|
54
|
+
|
|
55
|
+
def test_build_methods_cmd_verify_same
|
|
56
|
+
cmd = "cmd"
|
|
57
|
+
cul = []
|
|
58
|
+
bad = %w[C#test_5 C#test_6]
|
|
59
|
+
|
|
60
|
+
exp = "cmd -n \"/^(?:C#(?:test_5|test_6))$/\""
|
|
61
|
+
|
|
62
|
+
assert_equal exp, bisect.build_methods_cmd(cmd, cul, bad)
|
|
63
|
+
end
|
|
64
|
+
|
|
65
|
+
def test_build_methods_cmd_full
|
|
66
|
+
cmd = "cmd"
|
|
67
|
+
cul = %w[A#test_1 A#test_2 B#test_3 B#test_4]
|
|
68
|
+
bad = %w[C#test_5 C#test_6]
|
|
69
|
+
|
|
70
|
+
a = "A#(?:test_1|test_2)"
|
|
71
|
+
b = "B#(?:test_3|test_4)"
|
|
72
|
+
c = "C#(?:test_5|test_6)"
|
|
73
|
+
exp = "cmd -n \"/^(?:#{a}|#{b}|#{c})$/\""
|
|
74
|
+
|
|
75
|
+
assert_equal exp, bisect.build_methods_cmd(cmd, cul, bad)
|
|
76
|
+
end
|
|
77
|
+
|
|
78
|
+
def test_build_re
|
|
79
|
+
bad = %w[A#test_1 B#test_2]
|
|
80
|
+
|
|
81
|
+
exp = "/^(?:A#(?:test_1)|B#(?:test_2))$/"
|
|
82
|
+
|
|
83
|
+
assert_equal exp, bisect.build_re(bad)
|
|
84
|
+
end
|
|
85
|
+
|
|
86
|
+
def test_build_re_same
|
|
87
|
+
bad = %w[C#test_5 C#test_6]
|
|
88
|
+
|
|
89
|
+
exp = "/^(?:C#(?:test_5|test_6))$/"
|
|
90
|
+
|
|
91
|
+
assert_equal exp, bisect.build_re(bad)
|
|
92
|
+
end
|
|
93
|
+
|
|
94
|
+
def test_build_re_class_escaping
|
|
95
|
+
bad = ["{}#[]"]
|
|
96
|
+
|
|
97
|
+
exp = "/^(?:\\{\\}#(?:\\[\\]))$/"
|
|
98
|
+
|
|
99
|
+
assert_equal exp, bisect.build_re(bad)
|
|
100
|
+
end
|
|
101
|
+
|
|
102
|
+
def test_build_re_method_escaping
|
|
103
|
+
bad = ["Some Class#It shouldn't care what the name is"]
|
|
104
|
+
|
|
105
|
+
exp = "/^(?:Some Class#(?:It shouldn\\'t care what the name is))$/"
|
|
106
|
+
|
|
107
|
+
assert_equal exp, bisect.build_re(bad)
|
|
108
|
+
end
|
|
109
|
+
|
|
110
|
+
def test_map_failures
|
|
111
|
+
bisect.failures =
|
|
112
|
+
{
|
|
113
|
+
"file.rb" => { "Class" => %w[test_method1 test_method2] },
|
|
114
|
+
"blah.rb" => { "Apple" => %w[test_method3 test_method4] },
|
|
115
|
+
}
|
|
116
|
+
|
|
117
|
+
exp = %w[
|
|
118
|
+
Apple#test_method3
|
|
119
|
+
Apple#test_method4
|
|
120
|
+
Class#test_method1
|
|
121
|
+
Class#test_method2
|
|
122
|
+
]
|
|
123
|
+
|
|
124
|
+
assert_equal exp, bisect.map_failures
|
|
125
|
+
end
|
|
126
|
+
|
|
127
|
+
def test_minitest_result
|
|
128
|
+
bisect.minitest_result "file.rb", "TestClass", "test_method", [], 1, 1
|
|
129
|
+
|
|
130
|
+
assert_equal false, bisect.tainted
|
|
131
|
+
assert_empty bisect.failures
|
|
132
|
+
assert_equal ["TestClass#test_method"], bisect.culprits
|
|
133
|
+
end
|
|
134
|
+
|
|
135
|
+
def test_minitest_result_skip
|
|
136
|
+
fail = Minitest::Skip.new("woot")
|
|
137
|
+
|
|
138
|
+
bisect.minitest_result "file.rb", "TestClass", "test_method", [fail], 1, 1
|
|
139
|
+
|
|
140
|
+
assert_equal false, bisect.tainted
|
|
141
|
+
assert_empty bisect.failures
|
|
142
|
+
assert_equal ["TestClass#test_method"], bisect.culprits
|
|
143
|
+
end
|
|
144
|
+
|
|
145
|
+
def test_minitest_result_fail
|
|
146
|
+
fail = Minitest::Assertion.new "msg"
|
|
147
|
+
|
|
148
|
+
bisect.minitest_result "file.rb", "TestClass", "test_method", [fail], 1, 1
|
|
149
|
+
|
|
150
|
+
exp = {"file.rb" => {"TestClass" => ["test_method"] }}
|
|
151
|
+
|
|
152
|
+
assert_equal true, bisect.tainted
|
|
153
|
+
assert_equal exp, bisect.failures
|
|
154
|
+
assert_empty bisect.culprits
|
|
155
|
+
end
|
|
156
|
+
|
|
157
|
+
def test_minitest_result_error
|
|
158
|
+
fail = Minitest::UnexpectedError.new RuntimeError.new("woot")
|
|
159
|
+
|
|
160
|
+
bisect.minitest_result "file.rb", "TestClass", "test_method", [fail], 1, 1
|
|
161
|
+
|
|
162
|
+
exp = {"file.rb" => {"TestClass" => ["test_method"] }}
|
|
163
|
+
|
|
164
|
+
assert_equal true, bisect.tainted
|
|
165
|
+
assert_equal exp, bisect.failures
|
|
166
|
+
assert_empty bisect.culprits
|
|
167
|
+
end
|
|
168
|
+
|
|
169
|
+
def test_minitest_start
|
|
170
|
+
bisect.failures["file.rb"]["Class"] << "test_bad1"
|
|
171
|
+
|
|
172
|
+
bisect.minitest_start
|
|
173
|
+
|
|
174
|
+
assert_empty bisect.failures
|
|
175
|
+
end
|
|
176
|
+
|
|
177
|
+
def test_reset
|
|
178
|
+
bisect.seen_bad = true
|
|
179
|
+
bisect.tainted = true
|
|
180
|
+
bisect.failures["file.rb"]["Class"] << "test_bad1"
|
|
181
|
+
bisect.culprits << "A#test_1" << "B#test_2"
|
|
182
|
+
|
|
183
|
+
bisect.reset
|
|
184
|
+
|
|
185
|
+
assert_equal false, bisect.seen_bad
|
|
186
|
+
assert_equal false, bisect.tainted
|
|
187
|
+
assert_empty bisect.failures
|
|
188
|
+
assert_equal %w[A#test_1 B#test_2], bisect.culprits
|
|
189
|
+
end
|
|
190
|
+
|
|
191
|
+
def test_run
|
|
192
|
+
skip "Need to write test_run"
|
|
193
|
+
end
|
|
194
|
+
|
|
195
|
+
def test_time_it
|
|
196
|
+
exp = /\Ado stuff: in 0.\d\d sec\n\z/
|
|
197
|
+
|
|
198
|
+
assert_output exp, "" do
|
|
199
|
+
bisect.time_it "do stuff:", "echo you should not see me"
|
|
200
|
+
end
|
|
201
|
+
end
|
|
202
|
+
end
|
|
203
|
+
|
|
204
|
+
class TestMinitest::TestBisect::TestPathExpander < Minitest::Test
|
|
205
|
+
def test_sanity
|
|
206
|
+
args = %w[1 -Iblah 2 -d 3 -w 4 5 6]
|
|
207
|
+
|
|
208
|
+
mtbpe = Minitest::Bisect::PathExpander
|
|
209
|
+
expander = mtbpe.new args
|
|
210
|
+
|
|
211
|
+
assert_equal %w[-Itest:lib], expander.rb_flags
|
|
212
|
+
assert_same mtbpe::TEST_GLOB, expander.glob
|
|
213
|
+
end
|
|
214
|
+
|
|
215
|
+
def test_process_flags
|
|
216
|
+
args = %w[1 -Iblah 2 -d 3 -w 4 5 6]
|
|
217
|
+
|
|
218
|
+
expander = Minitest::Bisect::PathExpander.new args
|
|
219
|
+
|
|
220
|
+
exp_files = %w[1 2 3 4 5 6]
|
|
221
|
+
exp_flags = %w[-Itest:lib -Iblah -d -w]
|
|
222
|
+
|
|
223
|
+
files = expander.process_flags(args)
|
|
224
|
+
|
|
225
|
+
assert_equal files, exp_files
|
|
226
|
+
|
|
227
|
+
# process_flags only filters and does not mutate args
|
|
228
|
+
assert_same args, expander.args
|
|
229
|
+
refute_equal args, exp_files
|
|
230
|
+
refute_equal files, args
|
|
231
|
+
|
|
232
|
+
# separates rb_flags out for separate handling
|
|
233
|
+
assert_equal exp_flags, expander.rb_flags
|
|
234
|
+
end
|
|
235
|
+
end
|
|
@@ -0,0 +1,138 @@
|
|
|
1
|
+
#!/usr/bin/ruby -w
|
|
2
|
+
|
|
3
|
+
$: << "." << "lib"
|
|
4
|
+
|
|
5
|
+
require "minitest/autorun"
|
|
6
|
+
require "minitest/find_minimal_combination"
|
|
7
|
+
|
|
8
|
+
describe Array, :find_minimal_combination do
|
|
9
|
+
def check(*bad)
|
|
10
|
+
lambda { |sample| bad & sample == bad }
|
|
11
|
+
end
|
|
12
|
+
|
|
13
|
+
def record_and_check(tests, *bad)
|
|
14
|
+
lambda { |test| tests << test.join; bad & test == bad }
|
|
15
|
+
end
|
|
16
|
+
|
|
17
|
+
def parse_trials s
|
|
18
|
+
s.lines.map { |s| s.chomp.sub(/#.*/, '').delete " " }.reject(&:empty?)
|
|
19
|
+
end
|
|
20
|
+
|
|
21
|
+
def assert_steps input, bad, exp
|
|
22
|
+
tests = []
|
|
23
|
+
|
|
24
|
+
found = input.find_minimal_combination(&record_and_check(tests, *bad))
|
|
25
|
+
|
|
26
|
+
assert_equal bad, found, "algorithm is bad"
|
|
27
|
+
|
|
28
|
+
assert_equal parse_trials(exp), tests
|
|
29
|
+
end
|
|
30
|
+
|
|
31
|
+
HEX = "0123456789ABCDEF".chars.to_a
|
|
32
|
+
|
|
33
|
+
# lvl collection
|
|
34
|
+
#
|
|
35
|
+
# 0 | A
|
|
36
|
+
# 1 | B C
|
|
37
|
+
# 2 | D E F G
|
|
38
|
+
# 3 | H I J K L M N O
|
|
39
|
+
# |
|
|
40
|
+
# 4 | 0123456789ABCDEF
|
|
41
|
+
|
|
42
|
+
def test_ordering_best_case_1
|
|
43
|
+
ary = HEX
|
|
44
|
+
bad = %w[0]
|
|
45
|
+
exp = <<~EOT
|
|
46
|
+
#123456789ABCDEF
|
|
47
|
+
01234567 # HIT! -- level 1 = B, C
|
|
48
|
+
0123 # HIT! -- level 2 = D, E
|
|
49
|
+
01 # HIT! -- level 3 = H, I
|
|
50
|
+
0 # HIT!
|
|
51
|
+
EOT
|
|
52
|
+
|
|
53
|
+
assert_steps ary, bad, exp
|
|
54
|
+
end
|
|
55
|
+
|
|
56
|
+
def test_ordering_best_case_2
|
|
57
|
+
ary = HEX
|
|
58
|
+
bad = %w[0 1]
|
|
59
|
+
exp = <<~EOT
|
|
60
|
+
01234567 # HIT! -- level 1 = B, C
|
|
61
|
+
0123 # HIT! -- level 2 = D, E
|
|
62
|
+
01 # HIT! -- level 3 = H, I
|
|
63
|
+
0 # miss -- level 4 = 0, 1, n_combos = 1
|
|
64
|
+
1 # miss
|
|
65
|
+
01 # HIT! -- level 3 = H, n_combos = 2
|
|
66
|
+
EOT
|
|
67
|
+
|
|
68
|
+
assert_steps ary, bad, exp
|
|
69
|
+
end
|
|
70
|
+
|
|
71
|
+
def test_ordering
|
|
72
|
+
ary = HEX
|
|
73
|
+
bad = %w[1 F]
|
|
74
|
+
exp = <<~EOT
|
|
75
|
+
01234567 # miss -- level 1 = B, C
|
|
76
|
+
89ABCDEF # miss
|
|
77
|
+
0123 89AB # miss -- level 2 = DF, DG, EF, EG
|
|
78
|
+
0123 CDEF # HIT!
|
|
79
|
+
01 CD # miss -- level 3 = HN, HO
|
|
80
|
+
01 EF # HIT!
|
|
81
|
+
0 E # miss -- level 4 = 0E, 0F, 1E, 1F
|
|
82
|
+
0 F # miss
|
|
83
|
+
1 E # miss
|
|
84
|
+
1 F # HIT!
|
|
85
|
+
EOT
|
|
86
|
+
|
|
87
|
+
assert_steps ary, bad, exp
|
|
88
|
+
end
|
|
89
|
+
|
|
90
|
+
def self.test_find_minimal_combination max, *bad
|
|
91
|
+
define_method "%s_%s_%s" % [__method__, max, bad.join("_")] do
|
|
92
|
+
a = (1..max).to_a
|
|
93
|
+
|
|
94
|
+
assert_equal bad, a.find_minimal_combination(&check(*bad))
|
|
95
|
+
end
|
|
96
|
+
end
|
|
97
|
+
|
|
98
|
+
def self.test_find_minimal_combination_and_count max, nsteps, *bad
|
|
99
|
+
define_method "%s_%s_%s_%s" % [__method__, max, nsteps, bad.join("_")] do
|
|
100
|
+
a = (1..max).to_a
|
|
101
|
+
|
|
102
|
+
found, count = a.find_minimal_combination_and_count(&check(*bad))
|
|
103
|
+
|
|
104
|
+
assert_equal bad, found
|
|
105
|
+
assert_equal nsteps, count
|
|
106
|
+
end
|
|
107
|
+
end
|
|
108
|
+
|
|
109
|
+
test_find_minimal_combination 8, 5
|
|
110
|
+
test_find_minimal_combination 8, 2, 7
|
|
111
|
+
test_find_minimal_combination 8, 1, 2, 7
|
|
112
|
+
test_find_minimal_combination 8, 1, 4, 7
|
|
113
|
+
test_find_minimal_combination 8, 1, 3, 5, 7
|
|
114
|
+
|
|
115
|
+
test_find_minimal_combination 9, 5
|
|
116
|
+
test_find_minimal_combination 9, 9
|
|
117
|
+
test_find_minimal_combination 9, 2, 7
|
|
118
|
+
test_find_minimal_combination 9, 1, 2, 7
|
|
119
|
+
test_find_minimal_combination 9, 1, 4, 7
|
|
120
|
+
test_find_minimal_combination 9, 1, 3, 5, 7
|
|
121
|
+
|
|
122
|
+
test_find_minimal_combination 1023, 5
|
|
123
|
+
test_find_minimal_combination 1023, 1005
|
|
124
|
+
test_find_minimal_combination 1023, 802, 907
|
|
125
|
+
test_find_minimal_combination 1023, 7, 15, 166, 1001
|
|
126
|
+
test_find_minimal_combination 1023, 1000, 1001, 1002
|
|
127
|
+
test_find_minimal_combination 1023, 1001, 1003, 1005, 1007
|
|
128
|
+
test_find_minimal_combination 1024, 1001, 1003, 1005, 1007
|
|
129
|
+
test_find_minimal_combination 1024, 1, 1024
|
|
130
|
+
|
|
131
|
+
test_find_minimal_combination_and_count 1024, 12, 1, 2
|
|
132
|
+
test_find_minimal_combination_and_count 1024, 23, 1, 1023
|
|
133
|
+
test_find_minimal_combination_and_count 1024, 24, 1, 1024
|
|
134
|
+
test_find_minimal_combination_and_count 1023, 26, 1, 1023
|
|
135
|
+
|
|
136
|
+
test_find_minimal_combination_and_count 1024, 93, 1001, 1003, 1005, 1007
|
|
137
|
+
test_find_minimal_combination_and_count 1023, 93, 1001, 1003, 1005, 1007
|
|
138
|
+
end
|
|
@@ -165,14 +165,20 @@ class TestMinitestAssertions < Minitest::Test
|
|
|
165
165
|
end
|
|
166
166
|
end
|
|
167
167
|
|
|
168
|
-
def
|
|
168
|
+
def test_assert_equal_string_message
|
|
169
169
|
assert_triggered "whoops.\nExpected: 1\n Actual: 2" do
|
|
170
|
+
@tc.assert_equal 1, 2, "whoops"
|
|
171
|
+
end
|
|
172
|
+
end
|
|
173
|
+
|
|
174
|
+
def test_assert_equal_different_message
|
|
175
|
+
assert_triggered "whoops." do
|
|
170
176
|
@tc.assert_equal 1, 2, message { "whoops" }
|
|
171
177
|
end
|
|
172
178
|
end
|
|
173
179
|
|
|
174
180
|
def test_assert_equal_different_lambda
|
|
175
|
-
assert_triggered "whoops
|
|
181
|
+
assert_triggered "whoops" do
|
|
176
182
|
@tc.assert_equal 1, 2, lambda { "whoops" }
|
|
177
183
|
end
|
|
178
184
|
end
|
|
@@ -283,26 +289,8 @@ class TestMinitestAssertions < Minitest::Test
|
|
|
283
289
|
end
|
|
284
290
|
|
|
285
291
|
def test_assert_equal_does_not_allow_lhs_nil
|
|
286
|
-
if
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
@assertion_count += 1
|
|
290
|
-
assert_triggered(/Use assert_nil if expecting nil/) do
|
|
291
|
-
@tc.assert_equal nil, nil
|
|
292
|
-
end
|
|
293
|
-
else
|
|
294
|
-
err_re = /Use assert_nil if expecting nil from .*test_minitest_\w+.rb/
|
|
295
|
-
err_re = "" if $-w.nil?
|
|
296
|
-
|
|
297
|
-
assert_deprecation err_re do
|
|
298
|
-
@tc.assert_equal nil, nil
|
|
299
|
-
end
|
|
300
|
-
end
|
|
301
|
-
end
|
|
302
|
-
|
|
303
|
-
def test_assert_equal_does_not_allow_lhs_nil_triggered
|
|
304
|
-
assert_triggered "Expected: nil\n Actual: false" do
|
|
305
|
-
@tc.assert_equal nil, false
|
|
292
|
+
assert_triggered(/Use assert_nil if expecting nil/) do
|
|
293
|
+
@tc.assert_equal nil, nil
|
|
306
294
|
end
|
|
307
295
|
end
|
|
308
296
|
|
|
@@ -525,10 +513,14 @@ class TestMinitestAssertions < Minitest::Test
|
|
|
525
513
|
end
|
|
526
514
|
|
|
527
515
|
def test_assert_operator
|
|
516
|
+
@assertion_count += 1
|
|
517
|
+
|
|
528
518
|
@tc.assert_operator 2, :>, 1
|
|
529
519
|
end
|
|
530
520
|
|
|
531
521
|
def test_assert_operator_bad_object
|
|
522
|
+
@assertion_count += 1
|
|
523
|
+
|
|
532
524
|
bad = Object.new
|
|
533
525
|
def bad.== _; true end
|
|
534
526
|
|
|
@@ -536,6 +528,8 @@ class TestMinitestAssertions < Minitest::Test
|
|
|
536
528
|
end
|
|
537
529
|
|
|
538
530
|
def test_assert_operator_triggered
|
|
531
|
+
@assertion_count += 1
|
|
532
|
+
|
|
539
533
|
assert_triggered "Expected 2 to be < 1." do
|
|
540
534
|
@tc.assert_operator 2, :<, 1
|
|
541
535
|
end
|
|
@@ -717,10 +711,14 @@ class TestMinitestAssertions < Minitest::Test
|
|
|
717
711
|
end
|
|
718
712
|
|
|
719
713
|
def test_assert_predicate
|
|
714
|
+
@assertion_count += 1
|
|
715
|
+
|
|
720
716
|
@tc.assert_predicate "", :empty?
|
|
721
717
|
end
|
|
722
718
|
|
|
723
719
|
def test_assert_predicate_triggered
|
|
720
|
+
@assertion_count += 1
|
|
721
|
+
|
|
724
722
|
assert_triggered 'Expected "blah" to be empty?.' do
|
|
725
723
|
@tc.assert_predicate "blah", :empty?
|
|
726
724
|
end
|
|
@@ -962,28 +960,6 @@ class TestMinitestAssertions < Minitest::Test
|
|
|
962
960
|
end
|
|
963
961
|
end
|
|
964
962
|
|
|
965
|
-
def test_assert_send
|
|
966
|
-
@assertion_count = 0 if error_on_warn?
|
|
967
|
-
assert_deprecation(/DEPRECATED: assert_send/) do
|
|
968
|
-
@tc.assert_send [1, :<, 2]
|
|
969
|
-
end
|
|
970
|
-
end
|
|
971
|
-
|
|
972
|
-
def test_assert_send_bad
|
|
973
|
-
if error_on_warn? then
|
|
974
|
-
@assertion_count = 0
|
|
975
|
-
assert_deprecation(/DEPRECATED: assert_send/) do
|
|
976
|
-
@tc.assert_send [1, :>, 2]
|
|
977
|
-
end
|
|
978
|
-
else
|
|
979
|
-
assert_triggered "Expected 1.>(*[2]) to return true." do
|
|
980
|
-
assert_deprecation(/DEPRECATED: assert_send/) do
|
|
981
|
-
@tc.assert_send [1, :>, 2]
|
|
982
|
-
end
|
|
983
|
-
end
|
|
984
|
-
end
|
|
985
|
-
end
|
|
986
|
-
|
|
987
963
|
def test_assert_silent
|
|
988
964
|
@assertion_count = 2
|
|
989
965
|
|
|
@@ -1073,48 +1049,24 @@ class TestMinitestAssertions < Minitest::Test
|
|
|
1073
1049
|
end
|
|
1074
1050
|
|
|
1075
1051
|
def test_assert_pattern
|
|
1076
|
-
|
|
1077
|
-
|
|
1078
|
-
|
|
1079
|
-
"(eval):1: warning: One-line pattern matching is experimental, and the behavior may change in future versions of Ruby!\n"
|
|
1080
|
-
else
|
|
1081
|
-
""
|
|
1082
|
-
end
|
|
1083
|
-
assert_output nil, exp do
|
|
1084
|
-
eval "[1,2,3] => [Integer, Integer, Integer]" # eval to escape parser for ruby<3
|
|
1085
|
-
end
|
|
1086
|
-
end
|
|
1087
|
-
else
|
|
1088
|
-
@assertion_count = 0
|
|
1089
|
-
|
|
1090
|
-
assert_raises NotImplementedError do
|
|
1091
|
-
@tc.assert_pattern do
|
|
1092
|
-
# do nothing
|
|
1093
|
-
end
|
|
1052
|
+
@tc.assert_pattern do
|
|
1053
|
+
assert_output nil, "" do
|
|
1054
|
+
[1,2,3] => [Integer, Integer, Integer]
|
|
1094
1055
|
end
|
|
1095
1056
|
end
|
|
1096
1057
|
end
|
|
1097
1058
|
|
|
1098
1059
|
def test_assert_pattern_traps_nomatchingpatternerror
|
|
1099
|
-
|
|
1100
|
-
exp = if RUBY_VERSION.start_with? "3.0" then
|
|
1101
|
-
"[1, 2, 3]" # terrible error message!
|
|
1102
|
-
else
|
|
1103
|
-
/length mismatch/
|
|
1104
|
-
end
|
|
1060
|
+
exp = /length mismatch/
|
|
1105
1061
|
|
|
1106
1062
|
assert_triggered exp do
|
|
1107
1063
|
@tc.assert_pattern do
|
|
1108
|
-
|
|
1109
|
-
eval "[1,2,3] => [Integer, Integer]" # eval to escape parser for ruby<3
|
|
1110
|
-
end
|
|
1064
|
+
[1,2,3] => [Integer, Integer]
|
|
1111
1065
|
end
|
|
1112
1066
|
end
|
|
1113
1067
|
end
|
|
1114
1068
|
|
|
1115
1069
|
def test_assert_pattern_raises_other_exceptions
|
|
1116
|
-
skip unless RUBY_VERSION >= "3.0"
|
|
1117
|
-
|
|
1118
1070
|
@assertion_count = 0
|
|
1119
1071
|
|
|
1120
1072
|
assert_raises RuntimeError do
|
|
@@ -1125,8 +1077,6 @@ class TestMinitestAssertions < Minitest::Test
|
|
|
1125
1077
|
end
|
|
1126
1078
|
|
|
1127
1079
|
def test_assert_pattern_with_no_block
|
|
1128
|
-
skip unless RUBY_VERSION >= "3.0"
|
|
1129
|
-
|
|
1130
1080
|
assert_triggered "assert_pattern requires a block to capture errors." do
|
|
1131
1081
|
@tc.assert_pattern
|
|
1132
1082
|
end
|
|
@@ -1167,7 +1117,7 @@ class TestMinitestAssertions < Minitest::Test
|
|
|
1167
1117
|
|
|
1168
1118
|
# These don't have corresponding refutes _on purpose_. They're
|
|
1169
1119
|
# useless and will never be added, so don't bother.
|
|
1170
|
-
ignores = %w[assert_output assert_raises
|
|
1120
|
+
ignores = %w[assert_output assert_raises
|
|
1171
1121
|
assert_silent assert_throws assert_mock]
|
|
1172
1122
|
|
|
1173
1123
|
ignores += %w[assert_allocations] # for minitest-gcstats
|
|
@@ -1368,10 +1318,14 @@ class TestMinitestAssertions < Minitest::Test
|
|
|
1368
1318
|
end
|
|
1369
1319
|
|
|
1370
1320
|
def test_refute_operator
|
|
1321
|
+
@assertion_count += 1
|
|
1322
|
+
|
|
1371
1323
|
@tc.refute_operator 2, :<, 1
|
|
1372
1324
|
end
|
|
1373
1325
|
|
|
1374
1326
|
def test_refute_operator_bad_object
|
|
1327
|
+
@assertion_count += 1
|
|
1328
|
+
|
|
1375
1329
|
bad = Object.new
|
|
1376
1330
|
def bad.== _; true end
|
|
1377
1331
|
|
|
@@ -1379,44 +1333,28 @@ class TestMinitestAssertions < Minitest::Test
|
|
|
1379
1333
|
end
|
|
1380
1334
|
|
|
1381
1335
|
def test_refute_operator_triggered
|
|
1336
|
+
@assertion_count += 1
|
|
1337
|
+
|
|
1382
1338
|
assert_triggered "Expected 2 to not be > 1." do
|
|
1383
1339
|
@tc.refute_operator 2, :>, 1
|
|
1384
1340
|
end
|
|
1385
1341
|
end
|
|
1386
1342
|
|
|
1387
1343
|
def test_refute_pattern
|
|
1388
|
-
|
|
1389
|
-
|
|
1390
|
-
capture_io do # 3.0 is noisy
|
|
1391
|
-
eval "[1,2,3] => [Integer, Integer, String]"
|
|
1392
|
-
end
|
|
1393
|
-
end
|
|
1394
|
-
else
|
|
1395
|
-
@assertion_count = 0
|
|
1396
|
-
|
|
1397
|
-
assert_raises NotImplementedError do
|
|
1398
|
-
@tc.refute_pattern do
|
|
1399
|
-
eval "[1,2,3] => [Integer, Integer, String]"
|
|
1400
|
-
end
|
|
1401
|
-
end
|
|
1344
|
+
@tc.refute_pattern do
|
|
1345
|
+
[1,2,3] => [Integer, Integer, String]
|
|
1402
1346
|
end
|
|
1403
1347
|
end
|
|
1404
1348
|
|
|
1405
1349
|
def test_refute_pattern_expects_nomatchingpatternerror
|
|
1406
|
-
skip unless RUBY_VERSION > "3"
|
|
1407
|
-
|
|
1408
1350
|
assert_triggered(/NoMatchingPatternError expected, but nothing was raised./) do
|
|
1409
1351
|
@tc.refute_pattern do
|
|
1410
|
-
|
|
1411
|
-
eval "[1,2,3] => [Integer, Integer, Integer]"
|
|
1412
|
-
end
|
|
1352
|
+
[1,2,3] => [Integer, Integer, Integer]
|
|
1413
1353
|
end
|
|
1414
1354
|
end
|
|
1415
1355
|
end
|
|
1416
1356
|
|
|
1417
1357
|
def test_refute_pattern_raises_other_exceptions
|
|
1418
|
-
skip unless RUBY_VERSION >= "3.0"
|
|
1419
|
-
|
|
1420
1358
|
@assertion_count = 0
|
|
1421
1359
|
|
|
1422
1360
|
assert_raises RuntimeError do
|
|
@@ -1427,18 +1365,20 @@ class TestMinitestAssertions < Minitest::Test
|
|
|
1427
1365
|
end
|
|
1428
1366
|
|
|
1429
1367
|
def test_refute_pattern_with_no_block
|
|
1430
|
-
skip unless RUBY_VERSION >= "3.0"
|
|
1431
|
-
|
|
1432
1368
|
assert_triggered "refute_pattern requires a block to capture errors." do
|
|
1433
1369
|
@tc.refute_pattern
|
|
1434
1370
|
end
|
|
1435
1371
|
end
|
|
1436
1372
|
|
|
1437
1373
|
def test_refute_predicate
|
|
1374
|
+
@assertion_count += 1
|
|
1375
|
+
|
|
1438
1376
|
@tc.refute_predicate "42", :empty?
|
|
1439
1377
|
end
|
|
1440
1378
|
|
|
1441
1379
|
def test_refute_predicate_triggered
|
|
1380
|
+
@assertion_count += 1
|
|
1381
|
+
|
|
1442
1382
|
assert_triggered 'Expected "" to not be empty?.' do
|
|
1443
1383
|
@tc.refute_predicate "", :empty?
|
|
1444
1384
|
end
|
|
@@ -1614,10 +1554,10 @@ class TestMinitestAssertionHelpers < Minitest::Test
|
|
|
1614
1554
|
assert_equal "blah1.\nblah2.", message("blah1") { "blah2" }.call
|
|
1615
1555
|
|
|
1616
1556
|
message = proc { "blah1" }
|
|
1617
|
-
assert_equal "blah1
|
|
1557
|
+
assert_equal "blah1", message(message) { "blah2" }.call
|
|
1618
1558
|
|
|
1619
1559
|
message = message { "blah1" }
|
|
1620
|
-
assert_equal "blah1
|
|
1560
|
+
assert_equal "blah1.", message(message) { "blah2" }.call
|
|
1621
1561
|
end
|
|
1622
1562
|
|
|
1623
1563
|
def test_message_deferred
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
require "minitest/autorun"
|
|
2
|
-
|
|
2
|
+
require_relative "metametameta"
|
|
3
3
|
require "forwardable"
|
|
4
4
|
|
|
5
5
|
class FakeTest < Minitest::Test
|
|
@@ -29,10 +29,11 @@ class TestMinitestReporter < MetaMetaMetaTestCase
|
|
|
29
29
|
super
|
|
30
30
|
self.io = StringIO.new(+"")
|
|
31
31
|
self.r = new_composite_reporter
|
|
32
|
+
@et = @ft = @pt = @st = @sse = nil
|
|
32
33
|
end
|
|
33
34
|
|
|
34
35
|
def error_test
|
|
35
|
-
unless
|
|
36
|
+
unless @et then
|
|
36
37
|
@et = FakeTest.new :woot
|
|
37
38
|
@et.failures << Minitest::UnexpectedError.new(begin
|
|
38
39
|
raise "no"
|
|
@@ -45,7 +46,7 @@ class TestMinitestReporter < MetaMetaMetaTestCase
|
|
|
45
46
|
end
|
|
46
47
|
|
|
47
48
|
def system_stack_error_test
|
|
48
|
-
unless
|
|
49
|
+
unless @sse then
|
|
49
50
|
|
|
50
51
|
ex = SystemStackError.new
|
|
51
52
|
|
|
@@ -64,7 +65,7 @@ class TestMinitestReporter < MetaMetaMetaTestCase
|
|
|
64
65
|
end
|
|
65
66
|
|
|
66
67
|
def fail_test
|
|
67
|
-
unless
|
|
68
|
+
unless @ft then
|
|
68
69
|
@ft = FakeTest.new :woot
|
|
69
70
|
@ft.failures << begin
|
|
70
71
|
raise Minitest::Assertion, "boo"
|
|
@@ -87,7 +88,7 @@ class TestMinitestReporter < MetaMetaMetaTestCase
|
|
|
87
88
|
end
|
|
88
89
|
|
|
89
90
|
def skip_test
|
|
90
|
-
unless
|
|
91
|
+
unless @st then
|
|
91
92
|
@st = FakeTest.new :woot
|
|
92
93
|
@st.failures << begin
|
|
93
94
|
raise Minitest::Skip
|