minitest 5.20.0 → 5.22.3
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 -4
- data/History.rdoc +60 -3
- data/Manifest.txt +1 -0
- data/README.rdoc +1 -0
- data/lib/minitest/assertions.rb +15 -13
- data/lib/minitest/compress.rb +94 -0
- data/lib/minitest/mock.rb +4 -2
- data/lib/minitest/pride_plugin.rb +7 -10
- data/lib/minitest/test.rb +4 -3
- data/lib/minitest/test_task.rb +0 -1
- data/lib/minitest.rb +80 -36
- data/test/minitest/metametameta.rb +16 -10
- data/test/minitest/test_minitest_assertions.rb +30 -10
- data/test/minitest/test_minitest_mock.rb +2 -2
- data/test/minitest/test_minitest_reporter.rb +101 -2
- data/test/minitest/test_minitest_test.rb +109 -16
- data/test/minitest/test_minitest_test_task.rb +2 -0
- data.tar.gz.sig +2 -4
- metadata +15 -13
- metadata.gz.sig +0 -0
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 549d1470d48f7424db415007d45cfd317ad88104e1e5004e97c46afa4d760a1a
|
4
|
+
data.tar.gz: f6f2e952c63cb9074d2fccf45148ab5c5045aec5bdbeadfadcbbf8338107ec2d
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: da1e40c0087e97affdab34c247b98d5d4482ba47d3a0b677dcef4ebf0839827e304fba101a02fcebd38008a8d9ba9eaa163e98545d13927b276dcb461dac7237
|
7
|
+
data.tar.gz: c4074d137040f0362af40a5cd9c637492ba983a0a8ab5341c2acb8d531725b10192c40b6002570695aca6da1c0c1bdb389a6eac94cefcda8a6b60d48b49c960d
|
checksums.yaml.gz.sig
CHANGED
@@ -1,4 +1,2 @@
|
|
1
|
-
|
2
|
-
|
3
|
-
<�N��䀡IA�/k��_ ��H��'��\8���tR�
|
4
|
-
p�TPڜ�p6��^��O��sR��-R���z@��������^JoP4���d_��� H��x|��
|
1
|
+
#E�ЍJJa�;�nT!�N{��Q��H_�0���T*�ݥ'�Р�O�
|
2
|
+
��Q��c��8]�j �源�O���š��:�[I��a2T����'IU .�8��Q�'�*��g�`��%W^5L��(A&�'����Eb7������_} �??
|
data/History.rdoc
CHANGED
@@ -1,3 +1,60 @@
|
|
1
|
+
=== 5.22.2 / 2024-02-07
|
2
|
+
|
3
|
+
* 1 bug fix:
|
4
|
+
|
5
|
+
* Third time's a charm? Remember: 'ensure' is almost always the
|
6
|
+
wrong way to go (for results... it's great for cleaning up).
|
7
|
+
|
8
|
+
=== 5.22.1 / 2024-02-06
|
9
|
+
|
10
|
+
* 1 bug fix:
|
11
|
+
|
12
|
+
* Don't exit non-zero if no tests ran and no filter (aka, the test file is empty).
|
13
|
+
(I'm starting to think the exit 1 thing for @tenderlove was a mistake...)
|
14
|
+
|
15
|
+
=== 5.22.0 / 2024-02-05
|
16
|
+
|
17
|
+
* 1 minor enhancement:
|
18
|
+
|
19
|
+
* Added "did you mean" output if your --name filter matches nothing. (tenderlove)
|
20
|
+
|
21
|
+
* 2 bug fixes:
|
22
|
+
|
23
|
+
* Big cleanup of test filtering. Much prettier / more functional.
|
24
|
+
* Fix situation where Assertion#location can't find the location. (pftg)
|
25
|
+
|
26
|
+
=== 5.21.2 / 2024-01-17
|
27
|
+
|
28
|
+
* 1 bug fix:
|
29
|
+
|
30
|
+
* Fixed bug in Minitest::Compress#compress formatting w/ nested patterns. Now recurses properly.
|
31
|
+
|
32
|
+
=== 5.21.1 / 2024-01-11
|
33
|
+
|
34
|
+
* 1 bug fix:
|
35
|
+
|
36
|
+
* Rails' default backtrace filter can't currently work with caller_locations, so reverting back to caller.
|
37
|
+
|
38
|
+
=== 5.21.0 / 2024-01-11
|
39
|
+
|
40
|
+
* 10 minor enhancements:
|
41
|
+
|
42
|
+
* Add include_all kw arg to assert_respond_to and refute_respond_to.
|
43
|
+
* Added --quiet flag to skip ProgressReporter (prints the dots). Minor speedup.
|
44
|
+
* Added Minitest::Compress#compress and added it to UnexpectedError.
|
45
|
+
* Added ability to initialize BacktraceFilter w/ custom regexp.
|
46
|
+
* Filter failure backtraces using backtrace_filter before calculating location. (thomasmarshall)
|
47
|
+
* Make BacktraceFilter#filter compatible with locations (still compares strings).
|
48
|
+
* Optimized Assertion#location ~30%.
|
49
|
+
* Output relative paths for all failures/errors/backtraces.
|
50
|
+
* Refactored location information in assertions, now using locations.
|
51
|
+
* Removed thread and mutex_m dependencies. (hsbt, eregon)
|
52
|
+
|
53
|
+
* 2 bug fixes:
|
54
|
+
|
55
|
+
* Drop undocumented bt arg in #skip. Dunno why that ever happened, prolly for testing?
|
56
|
+
* Fix mock to work with ruby debugger enabled. (keithlayne)
|
57
|
+
|
1
58
|
=== 5.20.0 / 2023-09-06
|
2
59
|
|
3
60
|
* 1 minor enhancement:
|
@@ -9,7 +66,7 @@
|
|
9
66
|
* 2 minor enhancements:
|
10
67
|
|
11
68
|
* Add metadata lazy accessor to Runnable / Result. (matteeyah)
|
12
|
-
* Only load minitest/unit (aka ancient MiniTest compatibility layer) if ENV["MT_COMPAT"]
|
69
|
+
* Only load minitest/unit (aka ancient MiniTest compatibility layer) if \ENV[\"MT_COMPAT\"]
|
13
70
|
|
14
71
|
* 1 bug fix:
|
15
72
|
|
@@ -20,7 +77,7 @@
|
|
20
77
|
* 3 bug fixes:
|
21
78
|
|
22
79
|
* Avoid extra string allocations when filtering tests. (tenderlove)
|
23
|
-
* Only mention deprecated ENV['N'] if it is an integer string.
|
80
|
+
* Only mention deprecated \ENV[\'N\'] if it is an integer string.
|
24
81
|
* Push up test_order to Minitest::Runnable to fix minitest/hell. (koic)
|
25
82
|
|
26
83
|
=== 5.18.0 / 2023-03-04
|
@@ -214,7 +271,7 @@
|
|
214
271
|
|
215
272
|
* 3 bug fixes:
|
216
273
|
|
217
|
-
* Check
|
274
|
+
* Check \option[:filter] klass before match. Fixes 2.6 warning. (y-yagi)
|
218
275
|
* Fixed Assertions#diff from recalculating if set to nil
|
219
276
|
* Fixed spec section of readme to not use deprecated global expectations. (CheezItMan)
|
220
277
|
|
data/Manifest.txt
CHANGED
data/README.rdoc
CHANGED
@@ -3,6 +3,7 @@
|
|
3
3
|
home :: https://github.com/minitest/minitest
|
4
4
|
bugs :: https://github.com/minitest/minitest/issues
|
5
5
|
rdoc :: https://docs.seattlerb.org/minitest
|
6
|
+
clog :: https://github.com/minitest/minitest/blob/master/History.rdoc
|
6
7
|
vim :: https://github.com/sunaku/vim-ruby-minitest
|
7
8
|
emacs:: https://github.com/arthurnn/minitest-emacs
|
8
9
|
|
data/lib/minitest/assertions.rb
CHANGED
@@ -198,6 +198,11 @@ module Minitest
|
|
198
198
|
assert obj.empty?, msg
|
199
199
|
end
|
200
200
|
|
201
|
+
def _where # :nodoc:
|
202
|
+
where = Minitest.filter_backtrace(caller).first
|
203
|
+
where = where.split(/:in /, 2).first # clean up noise
|
204
|
+
end
|
205
|
+
|
201
206
|
E = "" # :nodoc:
|
202
207
|
|
203
208
|
##
|
@@ -221,10 +226,7 @@ module Minitest
|
|
221
226
|
if Minitest::VERSION =~ /^6/ then
|
222
227
|
refute_nil exp, "Use assert_nil if expecting nil."
|
223
228
|
else
|
224
|
-
|
225
|
-
where = where.split(/:in /, 2).first # clean up noise
|
226
|
-
|
227
|
-
warn "DEPRECATED: Use assert_nil if expecting nil from #{where}. This will fail in Minitest 6."
|
229
|
+
warn "DEPRECATED: Use assert_nil if expecting nil from #{_where}. This will fail in Minitest 6."
|
228
230
|
end
|
229
231
|
end
|
230
232
|
|
@@ -449,12 +451,13 @@ module Minitest
|
|
449
451
|
|
450
452
|
##
|
451
453
|
# Fails unless +obj+ responds to +meth+.
|
454
|
+
# include_all defaults to false to match Object#respond_to?
|
452
455
|
|
453
|
-
def assert_respond_to obj, meth, msg = nil
|
456
|
+
def assert_respond_to obj, meth, msg = nil, include_all: false
|
454
457
|
msg = message(msg) {
|
455
458
|
"Expected #{mu_pp(obj)} (#{obj.class}) to respond to ##{meth}"
|
456
459
|
}
|
457
|
-
assert obj.respond_to?(meth), msg
|
460
|
+
assert obj.respond_to?(meth, include_all), msg
|
458
461
|
end
|
459
462
|
|
460
463
|
##
|
@@ -474,9 +477,7 @@ module Minitest
|
|
474
477
|
# Fails unless the call returns a true value
|
475
478
|
|
476
479
|
def assert_send send_ary, m = nil
|
477
|
-
|
478
|
-
where = where.split(/:in /, 2).first # clean up noise
|
479
|
-
warn "DEPRECATED: assert_send. From #{where}"
|
480
|
+
warn "DEPRECATED: assert_send. From #{_where}"
|
480
481
|
|
481
482
|
recv, msg, *args = send_ary
|
482
483
|
m = message(m) {
|
@@ -807,11 +808,12 @@ module Minitest
|
|
807
808
|
|
808
809
|
##
|
809
810
|
# Fails if +obj+ responds to the message +meth+.
|
811
|
+
# include_all defaults to false to match Object#respond_to?
|
810
812
|
|
811
|
-
def refute_respond_to obj, meth, msg = nil
|
813
|
+
def refute_respond_to obj, meth, msg = nil, include_all: false
|
812
814
|
msg = message(msg) { "Expected #{mu_pp(obj)} to not respond to #{meth}" }
|
813
815
|
|
814
|
-
refute obj.respond_to?(meth), msg
|
816
|
+
refute obj.respond_to?(meth, include_all), msg
|
815
817
|
end
|
816
818
|
|
817
819
|
##
|
@@ -830,10 +832,10 @@ module Minitest
|
|
830
832
|
# gets listed at the end of the run but doesn't cause a failure
|
831
833
|
# exit code.
|
832
834
|
|
833
|
-
def skip msg = nil,
|
835
|
+
def skip msg = nil, _ignored = nil
|
834
836
|
msg ||= "Skipped, no message given"
|
835
837
|
@skip = true
|
836
|
-
raise Minitest::Skip, msg
|
838
|
+
raise Minitest::Skip, msg
|
837
839
|
end
|
838
840
|
|
839
841
|
##
|
@@ -0,0 +1,94 @@
|
|
1
|
+
module Minitest
|
2
|
+
##
|
3
|
+
# Compresses backtraces.
|
4
|
+
|
5
|
+
module Compress
|
6
|
+
|
7
|
+
##
|
8
|
+
# Takes a backtrace (array of strings) and compresses repeating
|
9
|
+
# cycles in it to make it more readable.
|
10
|
+
|
11
|
+
def compress orig
|
12
|
+
ary = orig
|
13
|
+
|
14
|
+
eswo = ->(ary, n, off) { # each_slice_with_offset
|
15
|
+
if off.zero? then
|
16
|
+
ary.each_slice n
|
17
|
+
else
|
18
|
+
# [ ...off... [...n...] [...n...] ... ]
|
19
|
+
front, back = ary.take(off), ary.drop(off)
|
20
|
+
[front].chain back.each_slice n
|
21
|
+
end
|
22
|
+
}
|
23
|
+
|
24
|
+
3.times do # maybe don't use loop do here?
|
25
|
+
index = ary # [ a b c b c b c d ]
|
26
|
+
.size
|
27
|
+
.times # 0...size
|
28
|
+
.group_by { |i| ary[i] } # { a: [0] b: [1 3 5], c: [2 4 6], d: [7] }
|
29
|
+
|
30
|
+
order = index
|
31
|
+
.reject { |k, v| v.size == 1 } # { b: [1 3 5], c: [2 4 6] }
|
32
|
+
.sort_by { |k, ary| ### sort by max dist + min offset
|
33
|
+
d = ary.each_cons(2).sum { |a, b| b-a }
|
34
|
+
[-d, ary.first]
|
35
|
+
} # b: [1 3 5] c: [2 4 6]
|
36
|
+
|
37
|
+
ranges = order
|
38
|
+
.map { |k, ary| # [[1..2 3..4] [2..3 4..5]]
|
39
|
+
ary
|
40
|
+
.each_cons(2)
|
41
|
+
.map { |a, b| a..b-1 }
|
42
|
+
}
|
43
|
+
|
44
|
+
big_ranges = ranges
|
45
|
+
.flat_map { |a| # [1..2 3..4 2..3 4..5]
|
46
|
+
a.sort_by { |r| [-r.size, r.first] }.first 5
|
47
|
+
}
|
48
|
+
.first(100)
|
49
|
+
|
50
|
+
culprits = big_ranges
|
51
|
+
.map { |r|
|
52
|
+
eswo[ary, r.size, r.begin] # [o1 s1 s1 s2 s2]
|
53
|
+
.chunk_while { |a,b| a == b } # [[o1] [s1 s1] [s2 s2]]
|
54
|
+
.map { |a| [a.size, a.first] } # [[1 o1] [2 s1] [2 s2]]
|
55
|
+
}
|
56
|
+
.select { |chunks|
|
57
|
+
chunks.any? { |a| a.first > 1 } # compressed anything?
|
58
|
+
}
|
59
|
+
|
60
|
+
min = culprits
|
61
|
+
.min_by { |a| a.flatten.size } # most compressed
|
62
|
+
|
63
|
+
break unless min
|
64
|
+
|
65
|
+
ary = min.flat_map { |(n, lines)|
|
66
|
+
if n > 1 then
|
67
|
+
[[n, compress(lines)]] # [o1 [2 s1] [2 s2]]
|
68
|
+
else
|
69
|
+
lines
|
70
|
+
end
|
71
|
+
}
|
72
|
+
end
|
73
|
+
|
74
|
+
format = ->(lines) {
|
75
|
+
lines.flat_map { |line|
|
76
|
+
case line
|
77
|
+
when Array then
|
78
|
+
n, lines = line
|
79
|
+
lines = format[lines]
|
80
|
+
[
|
81
|
+
" +->> #{n} cycles of #{lines.size} lines:",
|
82
|
+
*lines.map { |s| " | #{s}" },
|
83
|
+
" +-<<",
|
84
|
+
]
|
85
|
+
else
|
86
|
+
line
|
87
|
+
end
|
88
|
+
}
|
89
|
+
}
|
90
|
+
|
91
|
+
format[ary]
|
92
|
+
end
|
93
|
+
end
|
94
|
+
end
|
data/lib/minitest/mock.rb
CHANGED
@@ -10,7 +10,7 @@ module Minitest # :nodoc:
|
|
10
10
|
class Mock
|
11
11
|
alias :__respond_to? :respond_to?
|
12
12
|
|
13
|
-
overridden_methods = %
|
13
|
+
overridden_methods = %i[
|
14
14
|
===
|
15
15
|
class
|
16
16
|
inspect
|
@@ -23,8 +23,10 @@ module Minitest # :nodoc:
|
|
23
23
|
to_s
|
24
24
|
]
|
25
25
|
|
26
|
+
overridden_methods << :singleton_method_added if defined?(::DEBUGGER__)
|
27
|
+
|
26
28
|
instance_methods.each do |m|
|
27
|
-
undef_method m unless overridden_methods.include?(m
|
29
|
+
undef_method m unless overridden_methods.include?(m) || m =~ /^__/
|
28
30
|
end
|
29
31
|
|
30
32
|
overridden_methods.map(&:to_sym).each do |method_id|
|
@@ -113,19 +113,16 @@ module Minitest
|
|
113
113
|
#
|
114
114
|
# plot (3*sin(x)+3), (3*sin(x+2*pi/3)+3), (3*sin(x+4*pi/3)+3)
|
115
115
|
|
116
|
-
|
117
|
-
|
118
|
-
n *= 1.0 / 6
|
116
|
+
@colors = (6 * 7).times.map { |n|
|
117
|
+
n *= 1.0 / 3
|
119
118
|
r = (3 * Math.sin(n ) + 3).to_i
|
120
|
-
g = (3 * Math.sin(n +
|
121
|
-
b = (3 * Math.sin(n +
|
122
|
-
|
123
|
-
# Then we take rgb and encode them in a single number using base 6.
|
124
|
-
# For some mysterious reason, we add 16... to clear the bottom 4 bits?
|
125
|
-
# Yes... they're ugly.
|
119
|
+
g = (3 * Math.sin(n + 4 * PI_3) + 3).to_i
|
120
|
+
b = (3 * Math.sin(n + 2 * PI_3) + 3).to_i
|
126
121
|
|
122
|
+
# Then we take rgb and encode them in a single number using
|
123
|
+
# base 6, shifted by 16 for the base 16 ansi colors.
|
127
124
|
36 * r + 6 * g + b + 16
|
128
|
-
}
|
125
|
+
}.rotate(4) # puts "red" first
|
129
126
|
|
130
127
|
super
|
131
128
|
end
|
data/lib/minitest/test.rb
CHANGED
@@ -52,9 +52,10 @@ module Minitest
|
|
52
52
|
end
|
53
53
|
|
54
54
|
##
|
55
|
-
# Call this at the top of your tests
|
56
|
-
#
|
57
|
-
#
|
55
|
+
# Call this at the top of your tests (inside the +Minitest::Test+
|
56
|
+
# subclass or +describe+ block) when you want to run your tests in
|
57
|
+
# parallel. In doing so, you're admitting that you rule and your
|
58
|
+
# tests are awesome.
|
58
59
|
|
59
60
|
def self.parallelize_me!
|
60
61
|
include Minitest::Parallel::Test
|
data/lib/minitest/test_task.rb
CHANGED
data/lib/minitest.rb
CHANGED
@@ -1,15 +1,15 @@
|
|
1
1
|
require "optparse"
|
2
|
-
require "thread"
|
3
|
-
require "mutex_m"
|
4
|
-
require "minitest/parallel"
|
5
2
|
require "stringio"
|
6
3
|
require "etc"
|
7
4
|
|
5
|
+
require_relative "minitest/parallel"
|
6
|
+
require_relative "minitest/compress"
|
7
|
+
|
8
8
|
##
|
9
9
|
# :include: README.rdoc
|
10
10
|
|
11
11
|
module Minitest
|
12
|
-
VERSION = "5.
|
12
|
+
VERSION = "5.22.2" # :nodoc:
|
13
13
|
|
14
14
|
@@installed_at_exit ||= false
|
15
15
|
@@after_run = []
|
@@ -134,7 +134,7 @@ module Minitest
|
|
134
134
|
# Minitest.run(args)
|
135
135
|
# Minitest.__run(reporter, options)
|
136
136
|
# Runnable.runnables.each
|
137
|
-
#
|
137
|
+
# runnable_klass.run(reporter, options)
|
138
138
|
# self.runnable_methods.each
|
139
139
|
# self.run_one_method(self, runnable_method, reporter)
|
140
140
|
# Minitest.run_one_method(klass, runnable_method)
|
@@ -150,7 +150,7 @@ module Minitest
|
|
150
150
|
|
151
151
|
reporter = CompositeReporter.new
|
152
152
|
reporter << SummaryReporter.new(options[:io], options)
|
153
|
-
reporter << ProgressReporter.new(options[:io], options)
|
153
|
+
reporter << ProgressReporter.new(options[:io], options) unless options[:quiet]
|
154
154
|
|
155
155
|
self.reporter = reporter # this makes it available to plugins
|
156
156
|
self.init_plugins options
|
@@ -164,11 +164,32 @@ module Minitest
|
|
164
164
|
warn "Interrupted. Exiting..."
|
165
165
|
end
|
166
166
|
self.parallel_executor.shutdown
|
167
|
+
|
168
|
+
# might have been removed/replaced during init_plugins:
|
169
|
+
summary = reporter.reporters.grep(SummaryReporter).first
|
170
|
+
return empty_run! options if summary && summary.count == 0
|
171
|
+
|
167
172
|
reporter.report
|
168
173
|
|
169
174
|
reporter.passed?
|
170
175
|
end
|
171
176
|
|
177
|
+
def self.empty_run! options # :nodoc:
|
178
|
+
filter = options[:filter]
|
179
|
+
return true unless filter # no filter, but nothing ran == success
|
180
|
+
|
181
|
+
warn "Nothing ran for filter: %s" % [filter]
|
182
|
+
|
183
|
+
require "did_you_mean" # soft dependency, punt if it doesn't load
|
184
|
+
|
185
|
+
ms = Runnable.runnables.flat_map(&:runnable_methods)
|
186
|
+
cs = DidYouMean::SpellChecker.new(dictionary: ms).correct filter
|
187
|
+
|
188
|
+
warn DidYouMean::Formatter.message_for cs unless cs.empty?
|
189
|
+
rescue LoadError
|
190
|
+
# do nothing
|
191
|
+
end
|
192
|
+
|
172
193
|
##
|
173
194
|
# Internal run method. Responsible for telling all Runnable
|
174
195
|
# sub-classes to run.
|
@@ -212,6 +233,10 @@ module Minitest
|
|
212
233
|
options[:verbose] = true
|
213
234
|
end
|
214
235
|
|
236
|
+
opts.on "-q", "--quiet", "Quiet. Show no progress processing files." do
|
237
|
+
options[:quiet] = true
|
238
|
+
end
|
239
|
+
|
215
240
|
opts.on "--show-skips", "Show skipped at the end of run." do
|
216
241
|
options[:show_skips] = true
|
217
242
|
end
|
@@ -334,25 +359,15 @@ module Minitest
|
|
334
359
|
# reporter to record.
|
335
360
|
|
336
361
|
def self.run reporter, options = {}
|
337
|
-
|
338
|
-
|
339
|
-
filter = Regexp.new $1 if filter.is_a?(String) && filter =~ %r%/(.*)/%
|
340
|
-
|
341
|
-
self.runnable_methods.find_all { |m|
|
342
|
-
filter === m || filter === "#{self}##{m}"
|
343
|
-
}
|
344
|
-
else
|
345
|
-
self.runnable_methods
|
346
|
-
end
|
362
|
+
pos = options[:filter]
|
363
|
+
neg = options[:exclude]
|
347
364
|
|
348
|
-
if
|
349
|
-
|
350
|
-
exclude = Regexp.new $1 if exclude =~ %r%/(.*)/%
|
365
|
+
pos = Regexp.new $1 if pos.is_a?(String) && pos =~ %r%/(.*)/%
|
366
|
+
neg = Regexp.new $1 if neg.is_a?(String) && neg =~ %r%/(.*)/%
|
351
367
|
|
352
|
-
|
353
|
-
|
354
|
-
}
|
355
|
-
end
|
368
|
+
filtered_methods = self.runnable_methods
|
369
|
+
.select { |m| !pos || pos === m || pos === "#{self}##{m}" }
|
370
|
+
.reject { |m| neg && (neg === m || neg === "#{self}##{m}") }
|
356
371
|
|
357
372
|
return if filtered_methods.empty?
|
358
373
|
|
@@ -525,12 +540,14 @@ module Minitest
|
|
525
540
|
not self.failure
|
526
541
|
end
|
527
542
|
|
543
|
+
BASE_DIR = "#{Dir.pwd}/" # :nodoc:
|
544
|
+
|
528
545
|
##
|
529
546
|
# The location identifier of this test. Depends on a method
|
530
547
|
# existing called class_name.
|
531
548
|
|
532
549
|
def location
|
533
|
-
loc = " [#{self.failure.location}]" unless passed? or error?
|
550
|
+
loc = " [#{self.failure.location.delete_prefix BASE_DIR}]" unless passed? or error?
|
534
551
|
"#{self.class_name}##{self.name}#{loc}"
|
535
552
|
end
|
536
553
|
|
@@ -619,7 +636,10 @@ module Minitest
|
|
619
636
|
# you want. Go nuts.
|
620
637
|
|
621
638
|
class AbstractReporter
|
622
|
-
|
639
|
+
|
640
|
+
def initialize # :nodoc:
|
641
|
+
@mutex = Mutex.new
|
642
|
+
end
|
623
643
|
|
624
644
|
##
|
625
645
|
# Starts reporting on the run.
|
@@ -655,6 +675,10 @@ module Minitest
|
|
655
675
|
def passed?
|
656
676
|
true
|
657
677
|
end
|
678
|
+
|
679
|
+
def synchronize(&block) # :nodoc:
|
680
|
+
@mutex.synchronize(&block)
|
681
|
+
end
|
658
682
|
end
|
659
683
|
|
660
684
|
class Reporter < AbstractReporter # :nodoc:
|
@@ -828,7 +852,7 @@ module Minitest
|
|
828
852
|
io.puts "# Running:"
|
829
853
|
io.puts
|
830
854
|
|
831
|
-
self.sync = io.respond_to? :"sync="
|
855
|
+
self.sync = io.respond_to? :"sync="
|
832
856
|
self.old_sync, io.sync = io.sync, true if self.sync
|
833
857
|
end
|
834
858
|
|
@@ -936,6 +960,8 @@ module Minitest
|
|
936
960
|
# Represents run failures.
|
937
961
|
|
938
962
|
class Assertion < Exception
|
963
|
+
RE = /in [`'](?:[^']+[#.])?(?:assert|refute|flunk|pass|fail|raise|must|wont)/ # :nodoc:
|
964
|
+
|
939
965
|
def error # :nodoc:
|
940
966
|
self
|
941
967
|
end
|
@@ -944,12 +970,11 @@ module Minitest
|
|
944
970
|
# Where was this run before an assertion was raised?
|
945
971
|
|
946
972
|
def location
|
947
|
-
|
948
|
-
|
949
|
-
|
950
|
-
|
951
|
-
|
952
|
-
last_before_assertion.sub(/:in .*$/, "")
|
973
|
+
bt = Minitest.filter_backtrace self.backtrace
|
974
|
+
idx = bt.rindex { |s| s.match? RE } || -1 # fall back to first item
|
975
|
+
loc = bt[idx+1] || bt.last || "unknown:-1"
|
976
|
+
|
977
|
+
loc.sub(/:in .*$/, "")
|
953
978
|
end
|
954
979
|
|
955
980
|
def result_code # :nodoc:
|
@@ -974,11 +999,21 @@ module Minitest
|
|
974
999
|
# Assertion wrapping an unexpected error that was raised during a run.
|
975
1000
|
|
976
1001
|
class UnexpectedError < Assertion
|
1002
|
+
include Minitest::Compress
|
1003
|
+
|
977
1004
|
# TODO: figure out how to use `cause` instead
|
978
1005
|
attr_accessor :error # :nodoc:
|
979
1006
|
|
980
1007
|
def initialize error # :nodoc:
|
981
1008
|
super "Unexpected exception"
|
1009
|
+
|
1010
|
+
if SystemStackError === error then
|
1011
|
+
bt = error.backtrace
|
1012
|
+
new_bt = compress bt
|
1013
|
+
error = error.exception "#{bt.size} -> #{new_bt.size}"
|
1014
|
+
error.set_backtrace new_bt
|
1015
|
+
end
|
1016
|
+
|
982
1017
|
self.error = error
|
983
1018
|
end
|
984
1019
|
|
@@ -986,8 +1021,11 @@ module Minitest
|
|
986
1021
|
self.error.backtrace
|
987
1022
|
end
|
988
1023
|
|
1024
|
+
BASE_RE = %r%#{Dir.pwd}/% # :nodoc:
|
1025
|
+
|
989
1026
|
def message # :nodoc:
|
990
|
-
bt = Minitest.filter_backtrace(self.backtrace).join
|
1027
|
+
bt = Minitest.filter_backtrace(self.backtrace).join("\n ")
|
1028
|
+
.gsub(BASE_RE, "")
|
991
1029
|
"#{self.error.class}: #{self.error.message}\n #{bt}"
|
992
1030
|
end
|
993
1031
|
|
@@ -1071,6 +1109,12 @@ module Minitest
|
|
1071
1109
|
|
1072
1110
|
MT_RE = %r%lib/minitest% #:nodoc:
|
1073
1111
|
|
1112
|
+
attr_accessor :regexp
|
1113
|
+
|
1114
|
+
def initialize regexp = MT_RE
|
1115
|
+
self.regexp = regexp
|
1116
|
+
end
|
1117
|
+
|
1074
1118
|
##
|
1075
1119
|
# Filter +bt+ to something useful. Returns the whole thing if
|
1076
1120
|
# $DEBUG (ruby) or $MT_DEBUG (env).
|
@@ -1080,9 +1124,9 @@ module Minitest
|
|
1080
1124
|
|
1081
1125
|
return bt.dup if $DEBUG || ENV["MT_DEBUG"]
|
1082
1126
|
|
1083
|
-
new_bt = bt.take_while { |line| line !~
|
1084
|
-
new_bt = bt.select { |line| line !~
|
1085
|
-
new_bt = bt.dup
|
1127
|
+
new_bt = bt.take_while { |line| line.to_s !~ regexp }
|
1128
|
+
new_bt = bt.select { |line| line.to_s !~ regexp } if new_bt.empty?
|
1129
|
+
new_bt = bt.dup if new_bt.empty?
|
1086
1130
|
|
1087
1131
|
new_bt
|
1088
1132
|
end
|
@@ -8,16 +8,17 @@ class Minitest::Test
|
|
8
8
|
end
|
9
9
|
|
10
10
|
def with_empty_backtrace_filter
|
11
|
-
|
12
|
-
|
13
|
-
obj = Minitest::BacktraceFilter.new
|
14
|
-
def obj.filter _bt
|
15
|
-
[]
|
11
|
+
with_backtrace_filter Minitest::BacktraceFilter.new %r%.% do
|
12
|
+
yield
|
16
13
|
end
|
14
|
+
end
|
15
|
+
|
16
|
+
def with_backtrace_filter filter
|
17
|
+
original = Minitest.backtrace_filter
|
17
18
|
|
18
19
|
Minitest::Test.io_lock.synchronize do # try not to trounce in parallel
|
19
20
|
begin
|
20
|
-
Minitest.backtrace_filter =
|
21
|
+
Minitest.backtrace_filter = filter
|
21
22
|
yield
|
22
23
|
ensure
|
23
24
|
Minitest.backtrace_filter = original
|
@@ -105,15 +106,20 @@ class MetaMetaMetaTestCase < Minitest::Test
|
|
105
106
|
output.gsub!(/0x[A-Fa-f0-9]+/, "0xXXX")
|
106
107
|
output.gsub!(/ +$/, "")
|
107
108
|
|
109
|
+
file = ->(s) { s.start_with?("/") ? "FULLFILE" : "FILE" }
|
110
|
+
|
108
111
|
if windows? then
|
109
112
|
output.gsub!(/\[(?:[A-Za-z]:)?[^\]:]+:\d+\]/, "[FILE:LINE]")
|
110
|
-
output.gsub!(/^(\s+)(?:[A-Za-z]:)?[^:]+:\d+:in/, '\1FILE:LINE:in')
|
113
|
+
output.gsub!(/^(\s+)(?:[A-Za-z]:)?[^:]+:\d+:in [`']/, '\1FILE:LINE:in \'')
|
111
114
|
else
|
112
|
-
output.gsub!(/\[[^\]:]
|
113
|
-
output.gsub!(/^(\s+)[^:]
|
115
|
+
output.gsub!(/\[([^\]:]+):\d+\]/) { "[#{file[$1]}:LINE]" }
|
116
|
+
output.gsub!(/^(\s+)([^:]+):\d+:in [`']/) { "#{$1}#{file[$2]}:LINE:in '" }
|
114
117
|
end
|
115
118
|
|
116
|
-
output.gsub!(/
|
119
|
+
output.gsub!(/in [`']block in (?:([^']+)[#.])?/, "in 'block in")
|
120
|
+
output.gsub!(/in [`'](?:([^']+)[#.])?/, "in '")
|
121
|
+
|
122
|
+
output.gsub!(/( at )[^:]+:\d+/) { "#{$1}[#{file[$2]}:LINE]" } # eval?
|
117
123
|
|
118
124
|
output
|
119
125
|
end
|
@@ -762,12 +762,13 @@ class TestMinitestAssertions < Minitest::Test
|
|
762
762
|
Class: <SomeError>
|
763
763
|
Message: <\"blah\">
|
764
764
|
---Backtrace---
|
765
|
-
FILE:LINE:in
|
765
|
+
FILE:LINE:in \'block in test_assert_raises_default_triggered\'
|
766
766
|
---------------
|
767
767
|
EOM
|
768
768
|
|
769
769
|
actual = e.message.gsub(/^.+:\d+/, "FILE:LINE")
|
770
770
|
actual.gsub!(RE_LEVELS, "") unless jruby?
|
771
|
+
actual.gsub!(/[`']block in (?:TestMinitestAssertions#)?/, "'block in ")
|
771
772
|
|
772
773
|
assert_equal expected, actual
|
773
774
|
end
|
@@ -841,12 +842,13 @@ class TestMinitestAssertions < Minitest::Test
|
|
841
842
|
Class: <AnError>
|
842
843
|
Message: <\"some message\">
|
843
844
|
---Backtrace---
|
844
|
-
FILE:LINE:in
|
845
|
+
FILE:LINE:in \'block in test_assert_raises_subclass_triggered\'
|
845
846
|
---------------
|
846
847
|
EOM
|
847
848
|
|
848
849
|
actual = e.message.gsub(/^.+:\d+/, "FILE:LINE")
|
849
850
|
actual.gsub!(RE_LEVELS, "") unless jruby?
|
851
|
+
actual.gsub!(/[`']block in (?:TestMinitestAssertions#)?/, "'block in ")
|
850
852
|
|
851
853
|
assert_equal expected.chomp, actual
|
852
854
|
end
|
@@ -863,12 +865,13 @@ class TestMinitestAssertions < Minitest::Test
|
|
863
865
|
Class: <SyntaxError>
|
864
866
|
Message: <\"icky\">
|
865
867
|
---Backtrace---
|
866
|
-
FILE:LINE:in
|
868
|
+
FILE:LINE:in \'block in test_assert_raises_triggered_different\'
|
867
869
|
---------------
|
868
870
|
EOM
|
869
871
|
|
870
872
|
actual = e.message.gsub(/^.+:\d+/, "FILE:LINE")
|
871
873
|
actual.gsub!(RE_LEVELS, "") unless jruby?
|
874
|
+
actual.gsub!(/[`']block in (?:TestMinitestAssertions#)?/, "'block in ")
|
872
875
|
|
873
876
|
assert_equal expected, actual
|
874
877
|
end
|
@@ -886,12 +889,13 @@ class TestMinitestAssertions < Minitest::Test
|
|
886
889
|
Class: <SyntaxError>
|
887
890
|
Message: <\"icky\">
|
888
891
|
---Backtrace---
|
889
|
-
FILE:LINE:in
|
892
|
+
FILE:LINE:in \'block in test_assert_raises_triggered_different_msg\'
|
890
893
|
---------------
|
891
894
|
EOM
|
892
895
|
|
893
896
|
actual = e.message.gsub(/^.+:\d+/, "FILE:LINE")
|
894
897
|
actual.gsub!(RE_LEVELS, "") unless jruby?
|
898
|
+
actual.gsub!(/[`']block in (?:TestMinitestAssertions#)?/, "'block in ")
|
895
899
|
|
896
900
|
assert_equal expected.chomp, actual
|
897
901
|
end
|
@@ -936,6 +940,16 @@ class TestMinitestAssertions < Minitest::Test
|
|
936
940
|
end
|
937
941
|
end
|
938
942
|
|
943
|
+
def test_assert_respond_to__include_all
|
944
|
+
@tc.assert_respond_to @tc, :exit, include_all: true
|
945
|
+
end
|
946
|
+
|
947
|
+
def test_assert_respond_to__include_all_triggered
|
948
|
+
assert_triggered(/Expected .+::DummyTest. to respond to #exit\?/) do
|
949
|
+
@tc.assert_respond_to @tc, :exit?, include_all: true
|
950
|
+
end
|
951
|
+
end
|
952
|
+
|
939
953
|
def test_assert_same
|
940
954
|
@assertion_count = 3
|
941
955
|
|
@@ -1153,18 +1167,14 @@ class TestMinitestAssertions < Minitest::Test
|
|
1153
1167
|
def test_class_asserts_match_refutes
|
1154
1168
|
@assertion_count = 0
|
1155
1169
|
|
1156
|
-
methods = Minitest::Assertions.public_instance_methods
|
1157
|
-
methods.map!(&:to_s) if Symbol === methods.first
|
1170
|
+
methods = Minitest::Assertions.public_instance_methods.map(&:to_s)
|
1158
1171
|
|
1159
1172
|
# These don't have corresponding refutes _on purpose_. They're
|
1160
1173
|
# useless and will never be added, so don't bother.
|
1161
1174
|
ignores = %w[assert_output assert_raises assert_send
|
1162
1175
|
assert_silent assert_throws assert_mock]
|
1163
1176
|
|
1164
|
-
|
1165
|
-
ignores += %w[assert_no_match assert_not_equal assert_not_nil
|
1166
|
-
assert_not_same assert_nothing_raised
|
1167
|
-
assert_nothing_thrown assert_raise]
|
1177
|
+
ignores += %w[assert_allocations] # for minitest-gcstats
|
1168
1178
|
|
1169
1179
|
asserts = methods.grep(/^assert/).sort - ignores
|
1170
1180
|
refutes = methods.grep(/^refute/).sort - ignores
|
@@ -1444,6 +1454,16 @@ class TestMinitestAssertions < Minitest::Test
|
|
1444
1454
|
end
|
1445
1455
|
end
|
1446
1456
|
|
1457
|
+
def test_refute_respond_to__include_all
|
1458
|
+
@tc.refute_respond_to "blah", :missing, include_all: true
|
1459
|
+
end
|
1460
|
+
|
1461
|
+
def test_refute_respond_to__include_all_triggered
|
1462
|
+
assert_triggered(/Expected .*DummyTest.* to not respond to exit./) do
|
1463
|
+
@tc.refute_respond_to @tc, :exit, include_all: true
|
1464
|
+
end
|
1465
|
+
end
|
1466
|
+
|
1447
1467
|
def test_refute_same
|
1448
1468
|
@tc.refute_same 1, 2
|
1449
1469
|
end
|
@@ -728,7 +728,7 @@ class TestMinitestStub < Minitest::Test
|
|
728
728
|
end
|
729
729
|
|
730
730
|
exp = jruby? ? /Undefined method nope_nope_nope for '#{self.class}::Time'/ :
|
731
|
-
/undefined method `nope_nope_nope' for( class)?
|
731
|
+
/undefined method [`']nope_nope_nope' for( class)? [`']#{self.class}::Time'/
|
732
732
|
assert_match exp, e.message
|
733
733
|
end
|
734
734
|
|
@@ -1083,7 +1083,7 @@ class TestMinitestStub < Minitest::Test
|
|
1083
1083
|
end
|
1084
1084
|
end
|
1085
1085
|
end
|
1086
|
-
exp = /undefined method `write' for nil/
|
1086
|
+
exp = /undefined method [`']write' for nil/
|
1087
1087
|
assert_match exp, e.message
|
1088
1088
|
end
|
1089
1089
|
|
@@ -48,6 +48,25 @@ class TestMinitestReporter < MetaMetaMetaTestCase
|
|
48
48
|
@et
|
49
49
|
end
|
50
50
|
|
51
|
+
def system_stack_error_test
|
52
|
+
unless defined? @sse then
|
53
|
+
|
54
|
+
ex = SystemStackError.new
|
55
|
+
|
56
|
+
pre = ("a".."c").to_a
|
57
|
+
mid = ("aa".."ad").to_a * 67
|
58
|
+
post = ("d".."f").to_a
|
59
|
+
ary = pre + mid + post
|
60
|
+
|
61
|
+
ex.set_backtrace ary
|
62
|
+
|
63
|
+
@sse = Minitest::Test.new(:woot)
|
64
|
+
@sse.failures << Minitest::UnexpectedError.new(ex)
|
65
|
+
@sse = Minitest::Result.from @sse
|
66
|
+
end
|
67
|
+
@sse
|
68
|
+
end
|
69
|
+
|
51
70
|
def fail_test
|
52
71
|
unless defined? @ft then
|
53
72
|
@ft = Minitest::Test.new(:woot)
|
@@ -305,8 +324,44 @@ class TestMinitestReporter < MetaMetaMetaTestCase
|
|
305
324
|
1) Error:
|
306
325
|
Minitest::Test#woot:
|
307
326
|
RuntimeError: no
|
308
|
-
FILE:LINE:in
|
309
|
-
FILE:LINE:in
|
327
|
+
FILE:LINE:in 'error_test'
|
328
|
+
FILE:LINE:in 'test_report_error'
|
329
|
+
|
330
|
+
1 runs, 0 assertions, 0 failures, 1 errors, 0 skips
|
331
|
+
EOM
|
332
|
+
|
333
|
+
assert_equal exp, normalize_output(io.string)
|
334
|
+
end
|
335
|
+
|
336
|
+
def test_report_error__sse
|
337
|
+
r.start
|
338
|
+
r.record system_stack_error_test
|
339
|
+
r.report
|
340
|
+
|
341
|
+
exp = clean <<-EOM
|
342
|
+
Run options:
|
343
|
+
|
344
|
+
# Running:
|
345
|
+
|
346
|
+
E
|
347
|
+
|
348
|
+
Finished in 0.00
|
349
|
+
|
350
|
+
1) Error:
|
351
|
+
Minitest::Test#woot:
|
352
|
+
SystemStackError: 274 -> 12
|
353
|
+
a
|
354
|
+
b
|
355
|
+
c
|
356
|
+
+->> 67 cycles of 4 lines:
|
357
|
+
| aa
|
358
|
+
| ab
|
359
|
+
| ac
|
360
|
+
| ad
|
361
|
+
+-<<
|
362
|
+
d
|
363
|
+
e
|
364
|
+
f
|
310
365
|
|
311
366
|
1 runs, 0 assertions, 0 failures, 1 errors, 0 skips
|
312
367
|
EOM
|
@@ -338,4 +393,48 @@ class TestMinitestReporter < MetaMetaMetaTestCase
|
|
338
393
|
|
339
394
|
assert_equal exp, normalize_output(io.string)
|
340
395
|
end
|
396
|
+
|
397
|
+
def test_report_failure_uses_backtrace_filter
|
398
|
+
filter = Minitest::BacktraceFilter.new
|
399
|
+
def filter.filter _bt
|
400
|
+
["foo.rb:123:in 'foo'"]
|
401
|
+
end
|
402
|
+
|
403
|
+
with_backtrace_filter filter do
|
404
|
+
r.start
|
405
|
+
r.record fail_test
|
406
|
+
r.report
|
407
|
+
end
|
408
|
+
|
409
|
+
exp = "Minitest::Test#woot [foo.rb:123]"
|
410
|
+
|
411
|
+
assert_includes io.string, exp
|
412
|
+
end
|
413
|
+
|
414
|
+
def test_report_failure_uses_backtrace_filter_complex_sorbet
|
415
|
+
backtrace = <<~EOBT
|
416
|
+
/Users/user/.gem/ruby/3.2.2/gems/minitest-5.20.0/lib/minitest/assertions.rb:183:in 'assert'
|
417
|
+
example_test.rb:9:in 'assert_false'
|
418
|
+
/Users/user/.gem/ruby/3.2.2/gems/sorbet-runtime-0.5.11068/lib/types/private/methods/call_validation.rb:256:in 'bind_call'
|
419
|
+
/Users/user/.gem/ruby/3.2.2/gems/sorbet-runtime-0.5.11068/lib/types/private/methods/call_validation.rb:256:in 'validate_call'
|
420
|
+
/Users/user/.gem/ruby/3.2.2/gems/sorbet-runtime-0.5.11068/lib/types/private/methods/_methods.rb:275:in 'block in _on_method_added'
|
421
|
+
example_test.rb:25:in 'test_something'
|
422
|
+
/Users/user/.gem/ruby/3.2.2/gems/minitest-5.20.0/lib/minitest/test.rb:94:in 'block (3 levels) in run'
|
423
|
+
/Users/user/.gem/ruby/3.2.2/gems/minitest-5.20.0/lib/minitest/test.rb:191:in 'capture_exceptions'
|
424
|
+
/Users/user/.gem/ruby/3.2.2/gems/minitest-5.20.0/lib/minitest/test.rb:89:in 'block (2 levels) in run'
|
425
|
+
... so many lines ...
|
426
|
+
EOBT
|
427
|
+
|
428
|
+
filter = Minitest::BacktraceFilter.new %r%lib/minitest|gems/sorbet%
|
429
|
+
|
430
|
+
with_backtrace_filter filter do
|
431
|
+
begin
|
432
|
+
assert_equal 1, 2
|
433
|
+
rescue Minitest::Assertion => e
|
434
|
+
e.set_backtrace backtrace.lines.map(&:chomp)
|
435
|
+
|
436
|
+
assert_match "example_test.rb:25", e.location
|
437
|
+
end
|
438
|
+
end
|
439
|
+
end
|
341
440
|
end
|
@@ -28,24 +28,24 @@ class TestMinitestUnit < MetaMetaMetaTestCase
|
|
28
28
|
basedir = Pathname.new(File.expand_path "lib/minitest") + "mini"
|
29
29
|
basedir = basedir.relative_path_from(pwd).to_s
|
30
30
|
MINITEST_BASE_DIR = basedir[/\A\./] ? basedir : "./#{basedir}"
|
31
|
-
BT_MIDDLE = ["#{MINITEST_BASE_DIR}/test.rb:161:in
|
32
|
-
"#{MINITEST_BASE_DIR}/test.rb:158:in
|
33
|
-
"#{MINITEST_BASE_DIR}/test.rb:139:in
|
34
|
-
"#{MINITEST_BASE_DIR}/test.rb:106:in
|
31
|
+
BT_MIDDLE = ["#{MINITEST_BASE_DIR}/test.rb:161:in 'each'",
|
32
|
+
"#{MINITEST_BASE_DIR}/test.rb:158:in 'each'",
|
33
|
+
"#{MINITEST_BASE_DIR}/test.rb:139:in 'run'",
|
34
|
+
"#{MINITEST_BASE_DIR}/test.rb:106:in 'run'"]
|
35
35
|
|
36
36
|
def test_filter_backtrace
|
37
37
|
# this is a semi-lame mix of relative paths.
|
38
38
|
# I cheated by making the autotest parts not have ./
|
39
|
-
bt = (["lib/autotest.rb:571:in
|
40
|
-
"test/test_autotest.rb:62:in
|
41
|
-
"#{MINITEST_BASE_DIR}/test.rb:165:in
|
39
|
+
bt = (["lib/autotest.rb:571:in 'add_exception'",
|
40
|
+
"test/test_autotest.rb:62:in 'test_add_exception'",
|
41
|
+
"#{MINITEST_BASE_DIR}/test.rb:165:in '__send__'"] +
|
42
42
|
BT_MIDDLE +
|
43
43
|
["#{MINITEST_BASE_DIR}/test.rb:29",
|
44
44
|
"test/test_autotest.rb:422"])
|
45
45
|
bt = util_expand_bt bt
|
46
46
|
|
47
|
-
ex = ["lib/autotest.rb:571:in
|
48
|
-
"test/test_autotest.rb:62:in
|
47
|
+
ex = ["lib/autotest.rb:571:in 'add_exception'",
|
48
|
+
"test/test_autotest.rb:62:in 'test_add_exception'"]
|
49
49
|
ex = util_expand_bt ex
|
50
50
|
|
51
51
|
Minitest::Test.io_lock.synchronize do # try not to trounce in parallel
|
@@ -56,7 +56,7 @@ class TestMinitestUnit < MetaMetaMetaTestCase
|
|
56
56
|
end
|
57
57
|
|
58
58
|
def test_filter_backtrace_all_unit
|
59
|
-
bt = (["#{MINITEST_BASE_DIR}/test.rb:165:in
|
59
|
+
bt = (["#{MINITEST_BASE_DIR}/test.rb:165:in '__send__'"] +
|
60
60
|
BT_MIDDLE +
|
61
61
|
["#{MINITEST_BASE_DIR}/test.rb:29"])
|
62
62
|
ex = bt.clone
|
@@ -65,7 +65,7 @@ class TestMinitestUnit < MetaMetaMetaTestCase
|
|
65
65
|
end
|
66
66
|
|
67
67
|
def test_filter_backtrace_unit_starts
|
68
|
-
bt = (["#{MINITEST_BASE_DIR}/test.rb:165:in
|
68
|
+
bt = (["#{MINITEST_BASE_DIR}/test.rb:165:in '__send__'"] +
|
69
69
|
BT_MIDDLE +
|
70
70
|
["#{MINITEST_BASE_DIR}/mini/test.rb:29",
|
71
71
|
"-e:1"])
|
@@ -111,7 +111,7 @@ class TestMinitestUnit < MetaMetaMetaTestCase
|
|
111
111
|
2) Error:
|
112
112
|
FakeNamedTestXX#test_this_is_non_ascii_failure_message:
|
113
113
|
RuntimeError: ЁЁЁ
|
114
|
-
FILE:LINE:in
|
114
|
+
FILE:LINE:in 'test_this_is_non_ascii_failure_message'
|
115
115
|
|
116
116
|
2 runs, 1 assertions, 1 failures, 1 errors, 0 skips
|
117
117
|
EOM
|
@@ -263,7 +263,7 @@ class TestMinitestRunner < MetaMetaMetaTestCase
|
|
263
263
|
1) Error:
|
264
264
|
FakeNamedTestXX#test_error:
|
265
265
|
RuntimeError: unhandled exception
|
266
|
-
FILE:LINE:in
|
266
|
+
FILE:LINE:in \'test_error\'
|
267
267
|
|
268
268
|
2 runs, 1 assertions, 0 failures, 1 errors, 0 skips
|
269
269
|
EOM
|
@@ -291,7 +291,7 @@ class TestMinitestRunner < MetaMetaMetaTestCase
|
|
291
291
|
1) Error:
|
292
292
|
FakeNamedTestXX#test_something:
|
293
293
|
RuntimeError: unhandled exception
|
294
|
-
FILE:LINE:in
|
294
|
+
FILE:LINE:in \'teardown\'
|
295
295
|
|
296
296
|
1 runs, 1 assertions, 0 failures, 1 errors, 0 skips
|
297
297
|
EOM
|
@@ -1261,12 +1261,12 @@ class TestMinitestUnitRecording < MetaMetaMetaTestCase
|
|
1261
1261
|
Error:
|
1262
1262
|
FakeNamedTestXX#test_method:
|
1263
1263
|
AnError: AnError
|
1264
|
-
FILE:LINE:in
|
1264
|
+
FILE:LINE:in 'test_method'
|
1265
1265
|
|
1266
1266
|
Error:
|
1267
1267
|
FakeNamedTestXX#test_method:
|
1268
1268
|
RuntimeError: unhandled exception
|
1269
|
-
FILE:LINE:in
|
1269
|
+
FILE:LINE:in 'teardown'
|
1270
1270
|
"
|
1271
1271
|
|
1272
1272
|
assert_equal exp.strip, normalize_output(first_reporter.results.first.to_s).strip
|
@@ -1280,3 +1280,96 @@ class TestMinitestUnitRecording < MetaMetaMetaTestCase
|
|
1280
1280
|
end
|
1281
1281
|
end
|
1282
1282
|
end
|
1283
|
+
|
1284
|
+
class TestUnexpectedError < Minitest::Test
|
1285
|
+
def assert_compress exp, input
|
1286
|
+
e = Minitest::UnexpectedError.new RuntimeError.new
|
1287
|
+
|
1288
|
+
exp = exp.lines.map(&:chomp) if String === exp
|
1289
|
+
act = e.compress input
|
1290
|
+
|
1291
|
+
assert_equal exp, act
|
1292
|
+
end
|
1293
|
+
|
1294
|
+
ACT1 = %w[ a b c b c b c b c d ]
|
1295
|
+
|
1296
|
+
def test_normal
|
1297
|
+
assert_compress <<~EXP, %w[ a b c b c b c b c d ]
|
1298
|
+
a
|
1299
|
+
+->> 4 cycles of 2 lines:
|
1300
|
+
| b
|
1301
|
+
| c
|
1302
|
+
+-<<
|
1303
|
+
d
|
1304
|
+
EXP
|
1305
|
+
end
|
1306
|
+
|
1307
|
+
def test_normal2
|
1308
|
+
assert_compress <<~EXP, %w[ a b c b c b c b c ]
|
1309
|
+
a
|
1310
|
+
+->> 4 cycles of 2 lines:
|
1311
|
+
| b
|
1312
|
+
| c
|
1313
|
+
+-<<
|
1314
|
+
EXP
|
1315
|
+
end
|
1316
|
+
|
1317
|
+
def test_longer_c_than_b
|
1318
|
+
# the extra c in the front makes the overall length longer sorting it first
|
1319
|
+
assert_compress <<~EXP, %w[ c a b c b c b c b c b d ]
|
1320
|
+
c
|
1321
|
+
a
|
1322
|
+
b
|
1323
|
+
+->> 4 cycles of 2 lines:
|
1324
|
+
| c
|
1325
|
+
| b
|
1326
|
+
+-<<
|
1327
|
+
d
|
1328
|
+
EXP
|
1329
|
+
end
|
1330
|
+
|
1331
|
+
def test_1_line_cycles
|
1332
|
+
assert_compress <<~EXP, %w[ c a b c b c b c b c b b b d ]
|
1333
|
+
c
|
1334
|
+
a
|
1335
|
+
+->> 4 cycles of 2 lines:
|
1336
|
+
| b
|
1337
|
+
| c
|
1338
|
+
+-<<
|
1339
|
+
+->> 3 cycles of 1 lines:
|
1340
|
+
| b
|
1341
|
+
+-<<
|
1342
|
+
d
|
1343
|
+
EXP
|
1344
|
+
end
|
1345
|
+
|
1346
|
+
def test_sanity3
|
1347
|
+
pre = ("aa".."am").to_a
|
1348
|
+
mid = ("a".."z").to_a * 67
|
1349
|
+
post = ("aa".."am").to_a
|
1350
|
+
ary = pre + mid + post
|
1351
|
+
|
1352
|
+
exp = pre +
|
1353
|
+
[" +->> 67 cycles of 26 lines:"] +
|
1354
|
+
("a".."z").map { |s| " | #{s}" } +
|
1355
|
+
[" +-<<"] +
|
1356
|
+
post
|
1357
|
+
|
1358
|
+
assert_compress exp, ary
|
1359
|
+
end
|
1360
|
+
|
1361
|
+
def test_absurd_patterns
|
1362
|
+
assert_compress <<~EXP, %w[ a b c b c a b c b c a b c ]
|
1363
|
+
+->> 2 cycles of 5 lines:
|
1364
|
+
| a
|
1365
|
+
| +->> 2 cycles of 2 lines:
|
1366
|
+
| | b
|
1367
|
+
| | c
|
1368
|
+
| +-<<
|
1369
|
+
+-<<
|
1370
|
+
a
|
1371
|
+
b
|
1372
|
+
c
|
1373
|
+
EXP
|
1374
|
+
end
|
1375
|
+
end
|
@@ -26,6 +26,7 @@ class TestHoeTest < Minitest::Test
|
|
26
26
|
end
|
27
27
|
|
28
28
|
assert_equal MT_EXPECTED % [framework].join("; "), @tester.make_test_cmd
|
29
|
+
.sub(/ -- .+/, " -- ")
|
29
30
|
end
|
30
31
|
|
31
32
|
def test_make_test_cmd_for_minitest_prelude
|
@@ -42,5 +43,6 @@ class TestHoeTest < Minitest::Test
|
|
42
43
|
end
|
43
44
|
|
44
45
|
assert_equal MT_EXPECTED % [prelude, framework].join("; "), @tester.make_test_cmd
|
46
|
+
.sub(/ -- .+/, " -- ")
|
45
47
|
end
|
46
48
|
end
|
data.tar.gz.sig
CHANGED
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: minitest
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 5.
|
4
|
+
version: 5.22.3
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Ryan Davis
|
@@ -10,9 +10,9 @@ bindir: bin
|
|
10
10
|
cert_chain:
|
11
11
|
- |
|
12
12
|
-----BEGIN CERTIFICATE-----
|
13
|
-
|
13
|
+
MIIDPjCCAiagAwIBAgIBCDANBgkqhkiG9w0BAQsFADBFMRMwEQYDVQQDDApyeWFu
|
14
14
|
ZC1ydWJ5MRkwFwYKCZImiZPyLGQBGRYJemVuc3BpZGVyMRMwEQYKCZImiZPyLGQB
|
15
|
-
|
15
|
+
GRYDY29tMB4XDTI0MDEwMjIxMjEyM1oXDTI1MDEwMTIxMjEyM1owRTETMBEGA1UE
|
16
16
|
AwwKcnlhbmQtcnVieTEZMBcGCgmSJomT8ixkARkWCXplbnNwaWRlcjETMBEGCgmS
|
17
17
|
JomT8ixkARkWA2NvbTCCASIwDQYJKoZIhvcNAQEBBQADggEPADCCAQoCggEBALda
|
18
18
|
b9DCgK+627gPJkB6XfjZ1itoOQvpqH1EXScSaba9/S2VF22VYQbXU1xQXL/WzCkx
|
@@ -22,14 +22,14 @@ cert_chain:
|
|
22
22
|
qhtV7HJxNKuPj/JFH0D2cswvzznE/a5FOYO68g+YCuFi5L8wZuuM8zzdwjrWHqSV
|
23
23
|
gBEfoTEGr7Zii72cx+sCAwEAAaM5MDcwCQYDVR0TBAIwADALBgNVHQ8EBAMCBLAw
|
24
24
|
HQYDVR0OBBYEFEfFe9md/r/tj/Wmwpy+MI8d9k/hMA0GCSqGSIb3DQEBCwUAA4IB
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
25
|
+
AQCygvpmncmkiSs9r/Kceo4bBPDszhTv6iBi4LwMReqnFrpNLMOWJw7xi8x+3eL2
|
26
|
+
XS09ZPNOt2zm70KmFouBMgOysnDY4k2dE8uF6B8JbZOO8QfalW+CoNBliefOTcn2
|
27
|
+
bg5IOP7UoGM5lC174/cbDJrJnRG9bzig5FAP0mvsgA8zgTRXQzIUAZEo92D5K7p4
|
28
|
+
B4/O998ho6BSOgYBI9Yk1ttdCtti6Y+8N9+fZESsjtWMykA+WXWeGUScHqiU+gH8
|
29
|
+
S7043fq9EbQdBr2AXdj92+CDwuTfHI6/Hj5FVBDULufrJaan4xUgL70Hvc6pTTeW
|
30
|
+
deKfBjgVAq7EYHu1AczzlUly
|
31
31
|
-----END CERTIFICATE-----
|
32
|
-
date:
|
32
|
+
date: 2024-03-13 00:00:00.000000000 Z
|
33
33
|
dependencies:
|
34
34
|
- !ruby/object:Gem::Dependency
|
35
35
|
name: rdoc
|
@@ -57,14 +57,14 @@ dependencies:
|
|
57
57
|
requirements:
|
58
58
|
- - "~>"
|
59
59
|
- !ruby/object:Gem::Version
|
60
|
-
version: '4.
|
60
|
+
version: '4.2'
|
61
61
|
type: :development
|
62
62
|
prerelease: false
|
63
63
|
version_requirements: !ruby/object:Gem::Requirement
|
64
64
|
requirements:
|
65
65
|
- - "~>"
|
66
66
|
- !ruby/object:Gem::Version
|
67
|
-
version: '4.
|
67
|
+
version: '4.2'
|
68
68
|
description: |-
|
69
69
|
minitest provides a complete suite of testing facilities supporting
|
70
70
|
TDD, BDD, mocking, and benchmarking.
|
@@ -139,6 +139,7 @@ files:
|
|
139
139
|
- lib/minitest/assertions.rb
|
140
140
|
- lib/minitest/autorun.rb
|
141
141
|
- lib/minitest/benchmark.rb
|
142
|
+
- lib/minitest/compress.rb
|
142
143
|
- lib/minitest/expectations.rb
|
143
144
|
- lib/minitest/hell.rb
|
144
145
|
- lib/minitest/mock.rb
|
@@ -163,6 +164,7 @@ licenses:
|
|
163
164
|
metadata:
|
164
165
|
homepage_uri: https://github.com/minitest/minitest
|
165
166
|
bug_tracker_uri: https://github.com/minitest/minitest/issues
|
167
|
+
changelog_uri: https://github.com/minitest/minitest/blob/master/History.rdoc
|
166
168
|
post_install_message:
|
167
169
|
rdoc_options:
|
168
170
|
- "--main"
|
@@ -183,7 +185,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
183
185
|
- !ruby/object:Gem::Version
|
184
186
|
version: '0'
|
185
187
|
requirements: []
|
186
|
-
rubygems_version: 3.
|
188
|
+
rubygems_version: 3.5.3
|
187
189
|
signing_key:
|
188
190
|
specification_version: 4
|
189
191
|
summary: minitest provides a complete suite of testing facilities supporting TDD,
|
metadata.gz.sig
CHANGED
Binary file
|