minitest 5.17.0 → 5.23.1
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 +0 -0
- data/History.rdoc +125 -1
- data/Manifest.txt +3 -0
- data/README.rdoc +22 -18
- data/Rakefile +7 -0
- data/lib/minitest/assertions.rb +65 -13
- data/lib/minitest/compress.rb +94 -0
- data/lib/minitest/error_on_warning.rb +11 -0
- data/lib/minitest/expectations.rb +18 -0
- data/lib/minitest/manual_plugins.rb +16 -0
- data/lib/minitest/mock.rb +5 -3
- data/lib/minitest/parallel.rb +1 -1
- data/lib/minitest/pride_plugin.rb +7 -10
- data/lib/minitest/test.rb +6 -13
- data/lib/minitest/test_task.rb +5 -9
- data/lib/minitest.rb +152 -33
- data/test/minitest/metametameta.rb +29 -12
- data/test/minitest/test_minitest_assertions.rb +158 -29
- data/test/minitest/test_minitest_mock.rb +15 -13
- data/test/minitest/test_minitest_reporter.rb +131 -3
- data/test/minitest/test_minitest_spec.rb +60 -17
- data/test/minitest/test_minitest_test.rb +126 -23
- data/test/minitest/test_minitest_test_task.rb +2 -0
- data.tar.gz.sig +0 -0
- metadata +20 -16
- 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: eea239479abe950b2b6ac7881a88c73088fd9efc7dcddd5f54ceb7717830e7d7
|
|
4
|
+
data.tar.gz: 645ac4943b4bb6d1a4cca710d10bfe6d6526ce78a99d5393aae1a91152a0bded
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 6eb63425f42af466e8d839fa5de4f4dc57da32bc2a6798d40421ac99cc41b9c782a3fa7e91113463de0a261d1af6e8ddf2d3316fba5a141413f15b7fd4aedf73
|
|
7
|
+
data.tar.gz: 8c60d2666e50e2c683b9f32363702ba5b529c7170b9c3d32df077fbc912430e6de76b1cc3f0fcdb72d03d0abaa75cda2b90c742ed9937115d7416008e45a45f1
|
checksums.yaml.gz.sig
CHANGED
|
Binary file
|
data/History.rdoc
CHANGED
|
@@ -1,3 +1,127 @@
|
|
|
1
|
+
=== 5.23.1 / 2024-05-21
|
|
2
|
+
|
|
3
|
+
* 1 bug fix:
|
|
4
|
+
|
|
5
|
+
* Fully qualify the Queue class to avoid conflicts with other libraries. (rafaelfranca)
|
|
6
|
+
|
|
7
|
+
=== 5.23.0 / 2024-05-15
|
|
8
|
+
|
|
9
|
+
* 3 minor enhancements:
|
|
10
|
+
|
|
11
|
+
* Added -Werror to raise on any warning output. (byroot)
|
|
12
|
+
* Added UnexpectedWarning as a failure summary type, added count to output if activated.
|
|
13
|
+
* Added minitest/manual_plugins.rb w/ new Minitest.load method. (tenderlove)
|
|
14
|
+
|
|
15
|
+
* 2 bug fixes:
|
|
16
|
+
|
|
17
|
+
* Allow empty_run! and reporter to display summary for empty runs. (zzak)
|
|
18
|
+
* Make test task verbose using either rake's -v or -t (was just -t).
|
|
19
|
+
|
|
20
|
+
=== 5.22.3 / 2024-03-13
|
|
21
|
+
|
|
22
|
+
* 1 minor enhancement:
|
|
23
|
+
|
|
24
|
+
* MASSIVE improvement of minitest's pride plugin output: Frequencies doubled! Sine waves shifted!! Comments improved!!! Colors rotated!!!! (havenwood)
|
|
25
|
+
|
|
26
|
+
* 3 bug fixes:
|
|
27
|
+
|
|
28
|
+
* Improved wording on Minitest::Test#parallelize_me! to clarify it goes INSIDE your test class/describe.
|
|
29
|
+
* Minor changes to tests to pass when tests ran with extra flags (eg -p).
|
|
30
|
+
* Support Ruby 3.4's new error message format. (mame)
|
|
31
|
+
|
|
32
|
+
=== 5.22.2 / 2024-02-07
|
|
33
|
+
|
|
34
|
+
* 1 bug fix:
|
|
35
|
+
|
|
36
|
+
* Third time's a charm? Remember: 'ensure' is almost always the
|
|
37
|
+
wrong way to go (for results... it's great for cleaning up).
|
|
38
|
+
|
|
39
|
+
=== 5.22.1 / 2024-02-06
|
|
40
|
+
|
|
41
|
+
* 1 bug fix:
|
|
42
|
+
|
|
43
|
+
* Don't exit non-zero if no tests ran and no filter (aka, the test file is empty).
|
|
44
|
+
(I'm starting to think the exit 1 thing for @tenderlove was a mistake...)
|
|
45
|
+
|
|
46
|
+
=== 5.22.0 / 2024-02-05
|
|
47
|
+
|
|
48
|
+
* 1 minor enhancement:
|
|
49
|
+
|
|
50
|
+
* Added "did you mean" output if your --name filter matches nothing. (tenderlove)
|
|
51
|
+
|
|
52
|
+
* 2 bug fixes:
|
|
53
|
+
|
|
54
|
+
* Big cleanup of test filtering. Much prettier / more functional.
|
|
55
|
+
* Fix situation where Assertion#location can't find the location. (pftg)
|
|
56
|
+
|
|
57
|
+
=== 5.21.2 / 2024-01-17
|
|
58
|
+
|
|
59
|
+
* 1 bug fix:
|
|
60
|
+
|
|
61
|
+
* Fixed bug in Minitest::Compress#compress formatting w/ nested patterns. Now recurses properly.
|
|
62
|
+
|
|
63
|
+
=== 5.21.1 / 2024-01-11
|
|
64
|
+
|
|
65
|
+
* 1 bug fix:
|
|
66
|
+
|
|
67
|
+
* Rails' default backtrace filter can't currently work with caller_locations, so reverting back to caller.
|
|
68
|
+
|
|
69
|
+
=== 5.21.0 / 2024-01-11
|
|
70
|
+
|
|
71
|
+
* 10 minor enhancements:
|
|
72
|
+
|
|
73
|
+
* Add include_all kw arg to assert_respond_to and refute_respond_to.
|
|
74
|
+
* Added --quiet flag to skip ProgressReporter (prints the dots). Minor speedup.
|
|
75
|
+
* Added Minitest::Compress#compress and added it to UnexpectedError.
|
|
76
|
+
* Added ability to initialize BacktraceFilter w/ custom regexp.
|
|
77
|
+
* Filter failure backtraces using backtrace_filter before calculating location. (thomasmarshall)
|
|
78
|
+
* Make BacktraceFilter#filter compatible with locations (still compares strings).
|
|
79
|
+
* Optimized Assertion#location ~30%.
|
|
80
|
+
* Output relative paths for all failures/errors/backtraces.
|
|
81
|
+
* Refactored location information in assertions, now using locations.
|
|
82
|
+
* Removed thread and mutex_m dependencies. (hsbt, eregon)
|
|
83
|
+
|
|
84
|
+
* 2 bug fixes:
|
|
85
|
+
|
|
86
|
+
* Drop undocumented bt arg in #skip. Dunno why that ever happened, prolly for testing?
|
|
87
|
+
* Fix mock to work with ruby debugger enabled. (keithlayne)
|
|
88
|
+
|
|
89
|
+
=== 5.20.0 / 2023-09-06
|
|
90
|
+
|
|
91
|
+
* 1 minor enhancement:
|
|
92
|
+
|
|
93
|
+
* Optionally allow autorun exit hook to remain active in forked child. (casperisfine)
|
|
94
|
+
|
|
95
|
+
=== 5.19.0 / 2023-07-26
|
|
96
|
+
|
|
97
|
+
* 2 minor enhancements:
|
|
98
|
+
|
|
99
|
+
* Add metadata lazy accessor to Runnable / Result. (matteeyah)
|
|
100
|
+
* Only load minitest/unit (aka ancient MiniTest compatibility layer) if \ENV[\"MT_COMPAT\"]
|
|
101
|
+
|
|
102
|
+
* 1 bug fix:
|
|
103
|
+
|
|
104
|
+
* Minitest::TestTask enthusiastically added itself to default. (ParadoxV5)
|
|
105
|
+
|
|
106
|
+
=== 5.18.1 / 2023-06-16
|
|
107
|
+
|
|
108
|
+
* 3 bug fixes:
|
|
109
|
+
|
|
110
|
+
* Avoid extra string allocations when filtering tests. (tenderlove)
|
|
111
|
+
* Only mention deprecated \ENV[\'N\'] if it is an integer string.
|
|
112
|
+
* Push up test_order to Minitest::Runnable to fix minitest/hell. (koic)
|
|
113
|
+
|
|
114
|
+
=== 5.18.0 / 2023-03-04
|
|
115
|
+
|
|
116
|
+
* 2 major enhancements:
|
|
117
|
+
|
|
118
|
+
* Added assert_pattern & refute_pattern for pattern matching. (flavorjones)
|
|
119
|
+
* Added matching must_pattern_match & wont_pattern_match to minitest/spec.
|
|
120
|
+
|
|
121
|
+
* 1 bug fix:
|
|
122
|
+
|
|
123
|
+
* Support the new message format of NameError in Ruby 3.3 (mame)
|
|
124
|
+
|
|
1
125
|
=== 5.17.0 / 2022-12-31
|
|
2
126
|
|
|
3
127
|
* 1 minor enhancement:
|
|
@@ -178,7 +302,7 @@
|
|
|
178
302
|
|
|
179
303
|
* 3 bug fixes:
|
|
180
304
|
|
|
181
|
-
* Check
|
|
305
|
+
* Check \option[:filter] klass before match. Fixes 2.6 warning. (y-yagi)
|
|
182
306
|
* Fixed Assertions#diff from recalculating if set to nil
|
|
183
307
|
* Fixed spec section of readme to not use deprecated global expectations. (CheezItMan)
|
|
184
308
|
|
data/Manifest.txt
CHANGED
|
@@ -9,8 +9,11 @@ lib/minitest.rb
|
|
|
9
9
|
lib/minitest/assertions.rb
|
|
10
10
|
lib/minitest/autorun.rb
|
|
11
11
|
lib/minitest/benchmark.rb
|
|
12
|
+
lib/minitest/compress.rb
|
|
13
|
+
lib/minitest/error_on_warning.rb
|
|
12
14
|
lib/minitest/expectations.rb
|
|
13
15
|
lib/minitest/hell.rb
|
|
16
|
+
lib/minitest/manual_plugins.rb
|
|
14
17
|
lib/minitest/mock.rb
|
|
15
18
|
lib/minitest/parallel.rb
|
|
16
19
|
lib/minitest/pride.rb
|
data/README.rdoc
CHANGED
|
@@ -1,8 +1,9 @@
|
|
|
1
1
|
= minitest/{test,spec,mock,benchmark}
|
|
2
2
|
|
|
3
|
-
home :: https://github.com/
|
|
4
|
-
bugs :: https://github.com/
|
|
3
|
+
home :: https://github.com/minitest/minitest
|
|
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
|
|
|
@@ -405,36 +406,39 @@ Using our example above, here is how we might implement MyCI:
|
|
|
405
406
|
|
|
406
407
|
=== What versions are compatible with what? Or what versions are supported?
|
|
407
408
|
|
|
408
|
-
Minitest is a dependency of rails, which until
|
|
409
|
+
Minitest is a dependency of rails, which until very recently had an
|
|
409
410
|
overzealous backwards compatibility policy. As such, I'm stuck
|
|
410
411
|
supporting versions of ruby that are long past EOL. Hopefully I'll be
|
|
411
412
|
able to support only current versions of ruby sometime in the near
|
|
412
413
|
future.
|
|
413
414
|
|
|
414
|
-
(As of
|
|
415
|
+
(As of 2024-05-10)
|
|
415
416
|
|
|
416
417
|
Current versions of rails: (https://endoflife.date/rails)
|
|
417
418
|
|
|
418
|
-
| rails | min ruby |
|
|
419
|
-
|
|
420
|
-
| 7.
|
|
421
|
-
|
|
|
422
|
-
| 6.
|
|
423
|
-
|
|
|
419
|
+
| rails | min ruby | minitest | status | EOL Date |
|
|
420
|
+
|-------+----------+----------+----------+------------|
|
|
421
|
+
| 7.1 | >= 2.7 | >= 5.1 | Current | 2026-06-01?|
|
|
422
|
+
| 7.0 | >= 2.7 | >= 5.1 | Maint | 2025-06-01?|
|
|
423
|
+
| 6.1 | >= 2.5 | >= 5.1 | Security | 2024-06-01?|
|
|
424
|
+
| 6.0 | >= 2.5 | >= 5.1 | EOL | 2023-06-01 |
|
|
425
|
+
| 5.2 | >= 2.2.2 | ~> 5.1 | EOL | 2022-06-01 |
|
|
426
|
+
|
|
427
|
+
If you want to look at the requirements for a specific version, run:
|
|
428
|
+
|
|
429
|
+
gem spec -r --ruby rails -v 7.0.0
|
|
424
430
|
|
|
425
431
|
Current versions of ruby: (https://endoflife.date/ruby)
|
|
426
432
|
|
|
427
433
|
| ruby | Status | EOL Date |
|
|
428
434
|
|------+---------+------------|
|
|
429
|
-
| 3.
|
|
430
|
-
| 3.
|
|
431
|
-
|
|
|
435
|
+
| 3.3 | Current | 2027-03-31 |
|
|
436
|
+
| 3.2 | Maint | 2026-03-31 |
|
|
437
|
+
| 3.1 | Security| 2025-03-31 |
|
|
438
|
+
| 3.0 | EOL | 2024-03-31 |
|
|
439
|
+
| 2.7 | EOL | 2023-03-31 |
|
|
432
440
|
| 2.6 | EOL | 2022-03-31 |
|
|
433
|
-
| 2.5 | EOL | 2021-03-31 |
|
|
434
|
-
|
|
435
|
-
See also:
|
|
436
|
-
|
|
437
|
-
* https://www.fastruby.io/blog/ruby/rails/versions/compatibility-table.html
|
|
441
|
+
| 2.5 | EOL | 2021-03-31 | DO YOU SEE WHAT I'M STUCK WITH???
|
|
438
442
|
|
|
439
443
|
=== How to test SimpleDelegates?
|
|
440
444
|
|
data/Rakefile
CHANGED
|
@@ -2,6 +2,7 @@
|
|
|
2
2
|
|
|
3
3
|
require "rubygems"
|
|
4
4
|
require "hoe"
|
|
5
|
+
$:.unshift "lib" # to pick up lib/minitest/test_task.rb when minitest not installed
|
|
5
6
|
|
|
6
7
|
Hoe.plugin :seattlerb
|
|
7
8
|
Hoe.plugin :rdoc
|
|
@@ -32,6 +33,7 @@ task :specs do
|
|
|
32
33
|
/_includes/ => "_include",
|
|
33
34
|
/(must|wont)_(.*_of|nil|silent|empty)/ => '\1_be_\2',
|
|
34
35
|
/must_raises/ => "must_raise",
|
|
36
|
+
/(must|wont)_pattern/ => '\1_pattern_match',
|
|
35
37
|
/(must|wont)_predicate/ => '\1_be',
|
|
36
38
|
/(must|wont)_path_exists/ => 'path_\1_exist',
|
|
37
39
|
}
|
|
@@ -71,4 +73,9 @@ task :bugs do
|
|
|
71
73
|
sh "for f in bug*.rb ; do echo $f; echo; #{Gem.ruby} -Ilib $f && rm $f ; done"
|
|
72
74
|
end
|
|
73
75
|
|
|
76
|
+
Minitest::TestTask.create :testW0 do |t|
|
|
77
|
+
t.warning = false
|
|
78
|
+
t.test_prelude = "$-w = nil"
|
|
79
|
+
end
|
|
80
|
+
|
|
74
81
|
# vim: syntax=Ruby
|
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
|
|
|
@@ -357,6 +359,32 @@ module Minitest
|
|
|
357
359
|
assert File.exist?(path), msg
|
|
358
360
|
end
|
|
359
361
|
|
|
362
|
+
##
|
|
363
|
+
# For testing with pattern matching (only supported with Ruby 3.0 and later)
|
|
364
|
+
#
|
|
365
|
+
# # pass
|
|
366
|
+
# assert_pattern { [1,2,3] => [Integer, Integer, Integer] }
|
|
367
|
+
#
|
|
368
|
+
# # fail "length mismatch (given 3, expected 1)"
|
|
369
|
+
# assert_pattern { [1,2,3] => [Integer] }
|
|
370
|
+
#
|
|
371
|
+
# The bare <tt>=></tt> pattern will raise a NoMatchingPatternError on failure, which would
|
|
372
|
+
# normally be counted as a test error. This assertion rescues NoMatchingPatternError and
|
|
373
|
+
# generates a test failure. Any other exception will be raised as normal and generate a test
|
|
374
|
+
# error.
|
|
375
|
+
|
|
376
|
+
def assert_pattern
|
|
377
|
+
raise NotImplementedError, "only available in Ruby 3.0+" unless RUBY_VERSION >= "3.0"
|
|
378
|
+
flunk "assert_pattern requires a block to capture errors." unless block_given?
|
|
379
|
+
|
|
380
|
+
begin # TODO: remove after ruby 2.6 dropped
|
|
381
|
+
yield
|
|
382
|
+
pass
|
|
383
|
+
rescue NoMatchingPatternError => e
|
|
384
|
+
flunk e.message
|
|
385
|
+
end
|
|
386
|
+
end
|
|
387
|
+
|
|
360
388
|
##
|
|
361
389
|
# For testing with predicates. Eg:
|
|
362
390
|
#
|
|
@@ -423,12 +451,13 @@ module Minitest
|
|
|
423
451
|
|
|
424
452
|
##
|
|
425
453
|
# Fails unless +obj+ responds to +meth+.
|
|
454
|
+
# include_all defaults to false to match Object#respond_to?
|
|
426
455
|
|
|
427
|
-
def assert_respond_to obj, meth, msg = nil
|
|
456
|
+
def assert_respond_to obj, meth, msg = nil, include_all: false
|
|
428
457
|
msg = message(msg) {
|
|
429
458
|
"Expected #{mu_pp(obj)} (#{obj.class}) to respond to ##{meth}"
|
|
430
459
|
}
|
|
431
|
-
assert obj.respond_to?(meth), msg
|
|
460
|
+
assert obj.respond_to?(meth, include_all), msg
|
|
432
461
|
end
|
|
433
462
|
|
|
434
463
|
##
|
|
@@ -448,9 +477,7 @@ module Minitest
|
|
|
448
477
|
# Fails unless the call returns a true value
|
|
449
478
|
|
|
450
479
|
def assert_send send_ary, m = nil
|
|
451
|
-
|
|
452
|
-
where = where.split(/:in /, 2).first # clean up noise
|
|
453
|
-
warn "DEPRECATED: assert_send. From #{where}"
|
|
480
|
+
warn "DEPRECATED: assert_send. From #{_where}"
|
|
454
481
|
|
|
455
482
|
recv, msg, *args = send_ary
|
|
456
483
|
m = message(m) {
|
|
@@ -721,6 +748,30 @@ module Minitest
|
|
|
721
748
|
refute obj.nil?, msg
|
|
722
749
|
end
|
|
723
750
|
|
|
751
|
+
##
|
|
752
|
+
# For testing with pattern matching (only supported with Ruby 3.0 and later)
|
|
753
|
+
#
|
|
754
|
+
# # pass
|
|
755
|
+
# refute_pattern { [1,2,3] => [String] }
|
|
756
|
+
#
|
|
757
|
+
# # fail "NoMatchingPatternError expected, but nothing was raised."
|
|
758
|
+
# refute_pattern { [1,2,3] => [Integer, Integer, Integer] }
|
|
759
|
+
#
|
|
760
|
+
# This assertion expects a NoMatchingPatternError exception, and will fail if none is raised. Any
|
|
761
|
+
# other exceptions will be raised as normal and generate a test error.
|
|
762
|
+
|
|
763
|
+
def refute_pattern
|
|
764
|
+
raise NotImplementedError, "only available in Ruby 3.0+" unless RUBY_VERSION >= "3.0"
|
|
765
|
+
flunk "refute_pattern requires a block to capture errors." unless block_given?
|
|
766
|
+
|
|
767
|
+
begin
|
|
768
|
+
yield
|
|
769
|
+
flunk("NoMatchingPatternError expected, but nothing was raised.")
|
|
770
|
+
rescue NoMatchingPatternError
|
|
771
|
+
pass
|
|
772
|
+
end
|
|
773
|
+
end
|
|
774
|
+
|
|
724
775
|
##
|
|
725
776
|
# Fails if +o1+ is not +op+ +o2+. Eg:
|
|
726
777
|
#
|
|
@@ -757,11 +808,12 @@ module Minitest
|
|
|
757
808
|
|
|
758
809
|
##
|
|
759
810
|
# Fails if +obj+ responds to the message +meth+.
|
|
811
|
+
# include_all defaults to false to match Object#respond_to?
|
|
760
812
|
|
|
761
|
-
def refute_respond_to obj, meth, msg = nil
|
|
813
|
+
def refute_respond_to obj, meth, msg = nil, include_all: false
|
|
762
814
|
msg = message(msg) { "Expected #{mu_pp(obj)} to not respond to #{meth}" }
|
|
763
815
|
|
|
764
|
-
refute obj.respond_to?(meth), msg
|
|
816
|
+
refute obj.respond_to?(meth, include_all), msg
|
|
765
817
|
end
|
|
766
818
|
|
|
767
819
|
##
|
|
@@ -780,10 +832,10 @@ module Minitest
|
|
|
780
832
|
# gets listed at the end of the run but doesn't cause a failure
|
|
781
833
|
# exit code.
|
|
782
834
|
|
|
783
|
-
def skip msg = nil,
|
|
835
|
+
def skip msg = nil, _ignored = nil
|
|
784
836
|
msg ||= "Skipped, no message given"
|
|
785
837
|
@skip = true
|
|
786
|
-
raise Minitest::Skip, msg
|
|
838
|
+
raise Minitest::Skip, msg
|
|
787
839
|
end
|
|
788
840
|
|
|
789
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
|
|
@@ -124,6 +124,15 @@ module Minitest::Expectations
|
|
|
124
124
|
|
|
125
125
|
infect_an_assertion :assert_output, :must_output, :block
|
|
126
126
|
|
|
127
|
+
##
|
|
128
|
+
# See Minitest::Assertions#assert_pattern_match
|
|
129
|
+
#
|
|
130
|
+
# _ { ... }.must_pattern_match [...]
|
|
131
|
+
#
|
|
132
|
+
# :method: must_pattern_match
|
|
133
|
+
|
|
134
|
+
infect_an_assertion :assert_pattern, :must_pattern_match, :block
|
|
135
|
+
|
|
127
136
|
##
|
|
128
137
|
# See Minitest::Assertions#assert_raises
|
|
129
138
|
#
|
|
@@ -283,6 +292,15 @@ module Minitest::Expectations
|
|
|
283
292
|
|
|
284
293
|
infect_an_assertion :refute_operator, :wont_be, :reverse
|
|
285
294
|
|
|
295
|
+
##
|
|
296
|
+
# See Minitest::Assertions#refute_pattern_match
|
|
297
|
+
#
|
|
298
|
+
# _ { ... }.wont_pattern_match [...]
|
|
299
|
+
#
|
|
300
|
+
# :method: wont_pattern_match
|
|
301
|
+
|
|
302
|
+
infect_an_assertion :refute_pattern, :wont_pattern_match, :block
|
|
303
|
+
|
|
286
304
|
##
|
|
287
305
|
# See Minitest::Assertions#refute_respond_to
|
|
288
306
|
#
|
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|
|
|
@@ -55,7 +57,7 @@ module Minitest # :nodoc:
|
|
|
55
57
|
|
|
56
58
|
##
|
|
57
59
|
# Expect that method +name+ is called, optionally with +args+ (and
|
|
58
|
-
# +kwargs+ or a +blk
|
|
60
|
+
# +kwargs+ or a +blk+), and returns +retval+.
|
|
59
61
|
#
|
|
60
62
|
# @mock.expect(:meaning_of_life, 42)
|
|
61
63
|
# @mock.meaning_of_life # => 42
|
data/lib/minitest/parallel.rb
CHANGED
|
@@ -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
|
|
@@ -80,14 +81,6 @@ module Minitest
|
|
|
80
81
|
end
|
|
81
82
|
end
|
|
82
83
|
|
|
83
|
-
##
|
|
84
|
-
# Defines the order to run tests (:random by default). Override
|
|
85
|
-
# this or use a convenience method to change it for your tests.
|
|
86
|
-
|
|
87
|
-
def self.test_order
|
|
88
|
-
:random
|
|
89
|
-
end
|
|
90
|
-
|
|
91
84
|
##
|
|
92
85
|
# Runs a single test with setup/teardown hooks.
|
|
93
86
|
|
|
@@ -149,7 +142,7 @@ module Minitest
|
|
|
149
142
|
# end
|
|
150
143
|
# end
|
|
151
144
|
#
|
|
152
|
-
# class
|
|
145
|
+
# class Minitest::Test
|
|
153
146
|
# include MyMinitestPlugin
|
|
154
147
|
# end
|
|
155
148
|
|
|
@@ -253,4 +246,4 @@ module Minitest
|
|
|
253
246
|
end # Test
|
|
254
247
|
end
|
|
255
248
|
|
|
256
|
-
require "minitest/unit"
|
|
249
|
+
require "minitest/unit" if ENV["MT_COMPAT"] # compatibility layer only
|