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
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
|
|
1
|
+
require_relative "metametameta"
|
|
2
2
|
require "stringio"
|
|
3
3
|
|
|
4
4
|
class MiniSpecA < Minitest::Spec; end
|
|
@@ -148,25 +148,13 @@ describe Minitest::Spec do
|
|
|
148
148
|
it "needs to pattern match" do
|
|
149
149
|
@assertion_count = 1
|
|
150
150
|
|
|
151
|
-
|
|
152
|
-
expect { good_pattern }.must_pattern_match
|
|
153
|
-
else
|
|
154
|
-
assert_raises NotImplementedError do
|
|
155
|
-
expect {}.must_pattern_match
|
|
156
|
-
end
|
|
157
|
-
end
|
|
151
|
+
expect { good_pattern }.must_pattern_match
|
|
158
152
|
end
|
|
159
153
|
|
|
160
154
|
it "needs to error on bad pattern match" do
|
|
161
|
-
skip unless RUBY_VERSION > "3"
|
|
162
|
-
|
|
163
155
|
@assertion_count = 1
|
|
164
156
|
|
|
165
|
-
exp =
|
|
166
|
-
"[1, 2, 3]" # terrible error message!
|
|
167
|
-
else
|
|
168
|
-
/length mismatch/
|
|
169
|
-
end
|
|
157
|
+
exp = /length mismatch/
|
|
170
158
|
|
|
171
159
|
assert_triggered exp do
|
|
172
160
|
expect { bad_pattern }.must_pattern_match
|
|
@@ -212,11 +200,16 @@ describe Minitest::Spec do
|
|
|
212
200
|
must_raise
|
|
213
201
|
must_respond_to
|
|
214
202
|
must_throw
|
|
215
|
-
must_verify
|
|
216
203
|
path_must_exist]
|
|
217
204
|
|
|
218
205
|
bad = %w[not raise throw send output be_silent verify]
|
|
219
206
|
|
|
207
|
+
if methods.include? "must_infect" then # from test_minitest_mock.rb
|
|
208
|
+
expected_musts += %w[must_infect must_infect_without_flipping]
|
|
209
|
+
expected_musts.sort!
|
|
210
|
+
bad << "infect"
|
|
211
|
+
end
|
|
212
|
+
|
|
220
213
|
expected_wonts = expected_musts.map { |m| m.sub("must", "wont") }.sort
|
|
221
214
|
expected_wonts.reject! { |m| m =~ /wont_#{Regexp.union(*bad)}/ }
|
|
222
215
|
|
|
@@ -237,6 +230,8 @@ describe Minitest::Spec do
|
|
|
237
230
|
end
|
|
238
231
|
|
|
239
232
|
it "needs to verify binary messages" do
|
|
233
|
+
@assertion_count += 3
|
|
234
|
+
|
|
240
235
|
assert_success _(42).wont_be(:<, 24)
|
|
241
236
|
|
|
242
237
|
assert_triggered "Expected 24 to not be < 42." do
|
|
@@ -280,15 +275,9 @@ describe Minitest::Spec do
|
|
|
280
275
|
end
|
|
281
276
|
end
|
|
282
277
|
|
|
283
|
-
it "needs to
|
|
284
|
-
@assertion_count
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
exp = /DEPRECATED: Use assert_nil if expecting nil from .* This will fail in Minitest 6./
|
|
288
|
-
|
|
289
|
-
assert_deprecation exp do
|
|
290
|
-
assert_success _(nil).must_equal(nil)
|
|
291
|
-
end
|
|
278
|
+
it "needs to fail on equality with nil" do
|
|
279
|
+
@assertion_count -= 2
|
|
280
|
+
expect { _(nil).must_equal(nil) }.must_raise Minitest::Assertion
|
|
292
281
|
end
|
|
293
282
|
|
|
294
283
|
it "needs to verify floats outside a delta" do
|
|
@@ -300,12 +289,11 @@ describe Minitest::Spec do
|
|
|
300
289
|
_(6 * 7.0).wont_be_close_to 42
|
|
301
290
|
end
|
|
302
291
|
|
|
303
|
-
|
|
304
|
-
assert_triggered "Expected |42 - 42.0| (0.0) to not be <= #{x}." do
|
|
292
|
+
assert_triggered "Expected |42 - 42.0| (0.0) to not be <= 1.0e-05." do
|
|
305
293
|
_(6 * 7.0).wont_be_close_to 42, 0.00001
|
|
306
294
|
end
|
|
307
295
|
|
|
308
|
-
assert_triggered "msg.\nExpected |42 - 42.0| (0.0) to not be <=
|
|
296
|
+
assert_triggered "msg.\nExpected |42 - 42.0| (0.0) to not be <= 1.0e-05." do
|
|
309
297
|
_(6 * 7.0).wont_be_close_to 42, 0.00001, "msg"
|
|
310
298
|
end
|
|
311
299
|
end
|
|
@@ -315,17 +303,15 @@ describe Minitest::Spec do
|
|
|
315
303
|
|
|
316
304
|
assert_success _(24).wont_be_within_epsilon(42)
|
|
317
305
|
|
|
318
|
-
|
|
319
|
-
assert_triggered "Expected |42 - 42.0| (0.0) to not be <= #{x}." do
|
|
306
|
+
assert_triggered "Expected |42 - 42.0| (0.0) to not be <= 0.042." do
|
|
320
307
|
_(6 * 7.0).wont_be_within_epsilon 42
|
|
321
308
|
end
|
|
322
309
|
|
|
323
|
-
|
|
324
|
-
assert_triggered "Expected |42 - 42.0| (0.0) to not be <= #{x}." do
|
|
310
|
+
assert_triggered "Expected |42 - 42.0| (0.0) to not be <= 0.00042." do
|
|
325
311
|
_(6 * 7.0).wont_be_within_epsilon 42, 0.00001
|
|
326
312
|
end
|
|
327
313
|
|
|
328
|
-
assert_triggered "msg.\nExpected |42 - 42.0| (0.0) to not be <=
|
|
314
|
+
assert_triggered "msg.\nExpected |42 - 42.0| (0.0) to not be <= 0.00042." do
|
|
329
315
|
_(6 * 7.0).wont_be_within_epsilon 42, 0.00001, "msg"
|
|
330
316
|
end
|
|
331
317
|
end
|
|
@@ -339,12 +325,11 @@ describe Minitest::Spec do
|
|
|
339
325
|
_(1.0 / 100).must_be_close_to 0.0
|
|
340
326
|
end
|
|
341
327
|
|
|
342
|
-
|
|
343
|
-
assert_triggered "Expected |0.0 - 0.001| (0.001) to be <= #{x}." do
|
|
328
|
+
assert_triggered "Expected |0.0 - 0.001| (0.001) to be <= 1.0e-06." do
|
|
344
329
|
_(1.0 / 1000).must_be_close_to 0.0, 0.000001
|
|
345
330
|
end
|
|
346
331
|
|
|
347
|
-
assert_triggered "msg.\nExpected |0.0 - 0.001| (0.001) to be <=
|
|
332
|
+
assert_triggered "msg.\nExpected |0.0 - 0.001| (0.001) to be <= 1.0e-06." do
|
|
348
333
|
_(1.0 / 1000).must_be_close_to 0.0, 0.000001, "msg"
|
|
349
334
|
end
|
|
350
335
|
end
|
|
@@ -566,67 +551,6 @@ describe Minitest::Spec do
|
|
|
566
551
|
it "can use expect in a thread" do
|
|
567
552
|
Thread.new { _(1 + 1).must_equal 2 }.join
|
|
568
553
|
end
|
|
569
|
-
|
|
570
|
-
it "can NOT use must_equal in a thread. It must use expect in a thread" do
|
|
571
|
-
skip "N/A" if ENV["MT_NO_EXPECTATIONS"]
|
|
572
|
-
|
|
573
|
-
assert_raises RuntimeError, Minitest::UnexpectedWarning do
|
|
574
|
-
capture_io do
|
|
575
|
-
Thread.new { (1 + 1).must_equal 2 }.join
|
|
576
|
-
end
|
|
577
|
-
end
|
|
578
|
-
end
|
|
579
|
-
|
|
580
|
-
it "fails gracefully when expectation used outside of `it`" do
|
|
581
|
-
skip "N/A" if ENV["MT_NO_EXPECTATIONS"]
|
|
582
|
-
|
|
583
|
-
@assertion_count += 2 # assert_match is compound
|
|
584
|
-
|
|
585
|
-
e = assert_raises RuntimeError, Minitest::UnexpectedWarning do
|
|
586
|
-
capture_io do
|
|
587
|
-
Thread.new { # forces ctx to be nil
|
|
588
|
-
describe "woot" do
|
|
589
|
-
(1 + 1).must_equal 2
|
|
590
|
-
end
|
|
591
|
-
}.join
|
|
592
|
-
end
|
|
593
|
-
end
|
|
594
|
-
|
|
595
|
-
exp = "Calling #must_equal outside of test."
|
|
596
|
-
exp = "DEPRECATED: global use of must_equal from" if error_on_warn?
|
|
597
|
-
|
|
598
|
-
assert_match exp, e.message
|
|
599
|
-
end
|
|
600
|
-
|
|
601
|
-
it "deprecates expectation used without _" do
|
|
602
|
-
skip "N/A" if ENV["MT_NO_EXPECTATIONS"]
|
|
603
|
-
|
|
604
|
-
@assertion_count += 1
|
|
605
|
-
@assertion_count += 2 unless error_on_warn?
|
|
606
|
-
|
|
607
|
-
exp = /DEPRECATED: global use of must_equal from/
|
|
608
|
-
|
|
609
|
-
assert_deprecation exp do
|
|
610
|
-
(1 + 1).must_equal 2
|
|
611
|
-
end
|
|
612
|
-
end
|
|
613
|
-
|
|
614
|
-
# https://github.com/seattlerb/minitest/issues/837
|
|
615
|
-
# https://github.com/rails/rails/pull/39304
|
|
616
|
-
it "deprecates expectation used without _ with empty backtrace_filter" do
|
|
617
|
-
skip "N/A" if ENV["MT_NO_EXPECTATIONS"]
|
|
618
|
-
|
|
619
|
-
@assertion_count += 1
|
|
620
|
-
@assertion_count += 2 unless error_on_warn?
|
|
621
|
-
|
|
622
|
-
exp = /DEPRECATED: global use of must_equal from/
|
|
623
|
-
|
|
624
|
-
with_empty_backtrace_filter do
|
|
625
|
-
assert_deprecation exp do
|
|
626
|
-
(1 + 1).must_equal 2
|
|
627
|
-
end
|
|
628
|
-
end
|
|
629
|
-
end
|
|
630
554
|
end
|
|
631
555
|
|
|
632
556
|
it "needs to verify throw" do
|
|
@@ -667,7 +591,7 @@ describe Minitest::Spec do
|
|
|
667
591
|
end
|
|
668
592
|
|
|
669
593
|
it "needs to verify using any (negative) predicate" do
|
|
670
|
-
@assertion_count
|
|
594
|
+
@assertion_count += 1
|
|
671
595
|
|
|
672
596
|
assert_success _("blah").wont_be(:empty?)
|
|
673
597
|
|
|
@@ -677,7 +601,7 @@ describe Minitest::Spec do
|
|
|
677
601
|
end
|
|
678
602
|
|
|
679
603
|
it "needs to verify using any binary operator" do
|
|
680
|
-
@assertion_count
|
|
604
|
+
@assertion_count += 1
|
|
681
605
|
|
|
682
606
|
assert_success _(41).must_be(:<, 42)
|
|
683
607
|
|
|
@@ -687,7 +611,7 @@ describe Minitest::Spec do
|
|
|
687
611
|
end
|
|
688
612
|
|
|
689
613
|
it "needs to verify using any predicate" do
|
|
690
|
-
@assertion_count
|
|
614
|
+
@assertion_count += 1
|
|
691
615
|
|
|
692
616
|
assert_success _("").must_be(:empty?)
|
|
693
617
|
|
|
@@ -1136,36 +1060,36 @@ class ValueMonadTest < Minitest::Test
|
|
|
1136
1060
|
end
|
|
1137
1061
|
|
|
1138
1062
|
describe Minitest::Spec, :infect_an_assertion do
|
|
1139
|
-
|
|
1140
|
-
|
|
1063
|
+
attr_accessor :infect_mock
|
|
1064
|
+
|
|
1065
|
+
before do
|
|
1066
|
+
mock = Object.new
|
|
1067
|
+
mock.singleton_class.attr_accessor :a, :k
|
|
1068
|
+
def mock.assert_infects *args, **kwargs
|
|
1069
|
+
self.a, self.k = args, kwargs
|
|
1070
|
+
end
|
|
1071
|
+
|
|
1072
|
+
self.infect_mock = mock
|
|
1141
1073
|
end
|
|
1142
1074
|
|
|
1143
1075
|
def assert_infects exp, act, msg = nil, foo: nil, bar: nil
|
|
1144
|
-
self.
|
|
1076
|
+
self.infect_mock.assert_infects exp, act, msg, foo: foo, bar: bar
|
|
1145
1077
|
end
|
|
1146
1078
|
|
|
1147
|
-
infect_an_assertion :assert_infects, :must_infect
|
|
1148
|
-
infect_an_assertion :assert_infects, :must_infect_without_flipping, :dont_flip
|
|
1079
|
+
Minitest::Expectations.infect_an_assertion :assert_infects, :must_infect
|
|
1080
|
+
Minitest::Expectations.infect_an_assertion :assert_infects, :must_infect_without_flipping, :dont_flip
|
|
1149
1081
|
|
|
1150
1082
|
it "infects assertions with kwargs" do
|
|
1151
|
-
mock = Minitest::Mock.new
|
|
1152
|
-
mock.expect :assert_infects, true, [:exp, :act, nil], foo: :foo, bar: :bar
|
|
1153
|
-
|
|
1154
|
-
self.class.infect_mock = mock
|
|
1155
|
-
|
|
1156
1083
|
_(:act).must_infect :exp, foo: :foo, bar: :bar
|
|
1157
1084
|
|
|
1158
|
-
|
|
1085
|
+
assert_equal [:exp, :act, nil], infect_mock.a
|
|
1086
|
+
assert_equal({foo: :foo, bar: :bar}, infect_mock.k)
|
|
1159
1087
|
end
|
|
1160
1088
|
|
|
1161
1089
|
it "infects assertions with kwargs (dont_flip)" do
|
|
1162
|
-
mock = Minitest::Mock.new
|
|
1163
|
-
mock.expect :assert_infects, true, [:act, :exp, nil], foo: :foo, bar: :bar
|
|
1164
|
-
|
|
1165
|
-
self.class.infect_mock = mock
|
|
1166
|
-
|
|
1167
1090
|
_(:act).must_infect_without_flipping :exp, foo: :foo, bar: :bar
|
|
1168
1091
|
|
|
1169
|
-
|
|
1092
|
+
assert_equal [:act, :exp, nil], infect_mock.a
|
|
1093
|
+
assert_equal({foo: :foo, bar: :bar}, infect_mock.k)
|
|
1170
1094
|
end
|
|
1171
1095
|
end
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
|
|
1
|
+
require_relative "metametameta"
|
|
2
2
|
|
|
3
3
|
e = Encoding.default_external
|
|
4
4
|
if e != Encoding::UTF_8 then
|
|
@@ -342,6 +342,20 @@ class TestMinitestRunner < MetaMetaMetaTestCase
|
|
|
342
342
|
assert_instance_of Integer, Minitest.seed
|
|
343
343
|
end
|
|
344
344
|
|
|
345
|
+
def test_filter_runnable_methods
|
|
346
|
+
cls = Class.new Minitest::Runnable
|
|
347
|
+
def cls.runnable_methods
|
|
348
|
+
%w[ x y z ]
|
|
349
|
+
end
|
|
350
|
+
|
|
351
|
+
assert_equal %w[x y z], cls.filter_runnable_methods
|
|
352
|
+
assert_equal %w[x y], cls.filter_runnable_methods(exclude: "z")
|
|
353
|
+
assert_equal %w[x], cls.filter_runnable_methods(include: "x")
|
|
354
|
+
|
|
355
|
+
assert_empty cls.filter_runnable_methods(exclude: "/./")
|
|
356
|
+
assert_empty cls.filter_runnable_methods(include: "x", exclude: "x")
|
|
357
|
+
end
|
|
358
|
+
|
|
345
359
|
def test_run_failing_filtered
|
|
346
360
|
setup_basic_tu
|
|
347
361
|
|
|
@@ -566,7 +580,7 @@ class TestMinitestRunner < MetaMetaMetaTestCase
|
|
|
566
580
|
|
|
567
581
|
def test_run_with_other_runner
|
|
568
582
|
@tu = Class.new FakeNamedTest do
|
|
569
|
-
def self.
|
|
583
|
+
def self.run_suite reporter, options = {}
|
|
570
584
|
@reporter = reporter
|
|
571
585
|
before_my_suite
|
|
572
586
|
super
|
|
@@ -795,40 +809,6 @@ class BetterError < RuntimeError # like better_error w/o infecting RuntimeError
|
|
|
795
809
|
end
|
|
796
810
|
|
|
797
811
|
class TestMinitestRunnable < Minitest::Test
|
|
798
|
-
def setup_marshal klass
|
|
799
|
-
tc = klass.new "whatever"
|
|
800
|
-
tc.assertions = 42
|
|
801
|
-
tc.failures << "a failure"
|
|
802
|
-
|
|
803
|
-
yield tc if block_given?
|
|
804
|
-
|
|
805
|
-
def tc.setup
|
|
806
|
-
@blah = "blah"
|
|
807
|
-
end
|
|
808
|
-
tc.setup
|
|
809
|
-
|
|
810
|
-
@tc = Minitest::Result.from tc
|
|
811
|
-
end
|
|
812
|
-
|
|
813
|
-
def assert_marshal expected_ivars
|
|
814
|
-
new_tc = Marshal.load Marshal.dump @tc
|
|
815
|
-
|
|
816
|
-
ivars = new_tc.instance_variables.map(&:to_s).sort
|
|
817
|
-
ivars.delete "@gc_stats" # only needed if running w/ minitest-gcstats
|
|
818
|
-
assert_equal expected_ivars, ivars
|
|
819
|
-
assert_equal "whatever", new_tc.name
|
|
820
|
-
assert_equal 42, new_tc.assertions
|
|
821
|
-
assert_equal ["a failure"], new_tc.failures
|
|
822
|
-
|
|
823
|
-
yield new_tc if block_given?
|
|
824
|
-
end
|
|
825
|
-
|
|
826
|
-
def test_marshal
|
|
827
|
-
setup_marshal Minitest::Runnable
|
|
828
|
-
|
|
829
|
-
assert_marshal %w[@NAME @assertions @failures @klass @source_location @time]
|
|
830
|
-
end
|
|
831
|
-
|
|
832
812
|
def test_spec_marshal
|
|
833
813
|
klass = describe("whatever") { it("passes") { assert true } }
|
|
834
814
|
rm = klass.runnable_methods.first
|
|
@@ -988,18 +968,6 @@ class TestMinitestRunnable < Minitest::Test
|
|
|
988
968
|
end
|
|
989
969
|
end
|
|
990
970
|
|
|
991
|
-
class TestMinitestTest < TestMinitestRunnable
|
|
992
|
-
def test_dup
|
|
993
|
-
setup_marshal Minitest::Test do |tc|
|
|
994
|
-
tc.time = 3.14
|
|
995
|
-
end
|
|
996
|
-
|
|
997
|
-
assert_marshal %w[@NAME @assertions @failures @klass @source_location @time] do |new_tc|
|
|
998
|
-
assert_in_epsilon 3.14, new_tc.time
|
|
999
|
-
end
|
|
1000
|
-
end
|
|
1001
|
-
end
|
|
1002
|
-
|
|
1003
971
|
class TestMinitestUnitTestCase < Minitest::Test
|
|
1004
972
|
# do not call parallelize_me! - teardown accesses @tc._assertions
|
|
1005
973
|
# which is not threadsafe. Nearly every method in here is an
|
|
@@ -1017,7 +985,7 @@ class TestMinitestUnitTestCase < Minitest::Test
|
|
|
1017
985
|
|
|
1018
986
|
def teardown
|
|
1019
987
|
assert_equal(@assertion_count, @tc.assertions,
|
|
1020
|
-
"expected #{@assertion_count} assertions to be fired during the test, not #{@tc.assertions}") if @tc.passed?
|
|
988
|
+
message { "expected #{@assertion_count} assertions to be fired during the test, not #{@tc.assertions}" }) if @tc.passed?
|
|
1021
989
|
end
|
|
1022
990
|
|
|
1023
991
|
def non_verbose
|
|
@@ -1054,7 +1022,7 @@ class TestMinitestUnitTestCase < Minitest::Test
|
|
|
1054
1022
|
@assertion_count = 0
|
|
1055
1023
|
|
|
1056
1024
|
sample_test_case = Class.new FakeNamedTest do
|
|
1057
|
-
def self.
|
|
1025
|
+
def self.run_order; :sorted end
|
|
1058
1026
|
def test_test3; assert "does not matter" end
|
|
1059
1027
|
def test_test2; assert "does not matter" end
|
|
1060
1028
|
def test_test1; assert "does not matter" end
|
|
@@ -1064,14 +1032,14 @@ class TestMinitestUnitTestCase < Minitest::Test
|
|
|
1064
1032
|
assert_equal expected, sample_test_case.runnable_methods
|
|
1065
1033
|
end
|
|
1066
1034
|
|
|
1067
|
-
def
|
|
1035
|
+
def test_i_suck_and_my_tests_are_order_dependent_bang_sets_run_order_alpha
|
|
1068
1036
|
@assertion_count = 0
|
|
1069
1037
|
|
|
1070
1038
|
shitty_test_case = Class.new FakeNamedTest
|
|
1071
1039
|
|
|
1072
1040
|
shitty_test_case.i_suck_and_my_tests_are_order_dependent!
|
|
1073
1041
|
|
|
1074
|
-
assert_equal :alpha, shitty_test_case.
|
|
1042
|
+
assert_equal :alpha, shitty_test_case.run_order
|
|
1075
1043
|
end
|
|
1076
1044
|
|
|
1077
1045
|
def test_i_suck_and_my_tests_are_order_dependent_bang_does_not_warn
|
|
@@ -1079,7 +1047,7 @@ class TestMinitestUnitTestCase < Minitest::Test
|
|
|
1079
1047
|
|
|
1080
1048
|
shitty_test_case = Class.new FakeNamedTest
|
|
1081
1049
|
|
|
1082
|
-
def shitty_test_case.
|
|
1050
|
+
def shitty_test_case.run_order; :lol end
|
|
1083
1051
|
|
|
1084
1052
|
assert_silent do
|
|
1085
1053
|
shitty_test_case.i_suck_and_my_tests_are_order_dependent!
|
|
@@ -1124,24 +1092,6 @@ class TestMinitestGuard < Minitest::Test
|
|
|
1124
1092
|
assert self.jruby? "java"
|
|
1125
1093
|
end
|
|
1126
1094
|
|
|
1127
|
-
def test_rubinius_eh
|
|
1128
|
-
assert_deprecation do
|
|
1129
|
-
assert self.class.rubinius? "rbx"
|
|
1130
|
-
end
|
|
1131
|
-
assert_deprecation do
|
|
1132
|
-
assert self.rubinius? "rbx"
|
|
1133
|
-
end
|
|
1134
|
-
end
|
|
1135
|
-
|
|
1136
|
-
def test_maglev_eh
|
|
1137
|
-
assert_deprecation do
|
|
1138
|
-
assert self.class.maglev? "maglev"
|
|
1139
|
-
end
|
|
1140
|
-
assert_deprecation do
|
|
1141
|
-
assert self.maglev? "maglev"
|
|
1142
|
-
end
|
|
1143
|
-
end
|
|
1144
|
-
|
|
1145
1095
|
def test_osx_eh
|
|
1146
1096
|
assert self.class.osx? "darwin"
|
|
1147
1097
|
assert self.osx? "darwin"
|
|
@@ -1166,35 +1116,6 @@ class TestMinitestUnitRecording < MetaMetaMetaTestCase
|
|
|
1166
1116
|
assert_equal expected, recorded
|
|
1167
1117
|
end
|
|
1168
1118
|
|
|
1169
|
-
def test_run_with_bogus_reporter
|
|
1170
|
-
# https://github.com/seattlerb/minitest/issues/659
|
|
1171
|
-
# TODO: remove test for minitest 6
|
|
1172
|
-
@tu = Class.new FakeNamedTest do
|
|
1173
|
-
def test_method
|
|
1174
|
-
assert true
|
|
1175
|
-
end
|
|
1176
|
-
end
|
|
1177
|
-
|
|
1178
|
-
bogus_reporter = Class.new do # doesn't subclass AbstractReporter
|
|
1179
|
-
def start; @success = false; end
|
|
1180
|
-
# def prerecord klass, name; end # doesn't define full API
|
|
1181
|
-
def record _result; @success = true; end
|
|
1182
|
-
def report; end
|
|
1183
|
-
def passed?; end
|
|
1184
|
-
def results; end
|
|
1185
|
-
def success?; @success; end
|
|
1186
|
-
end.new
|
|
1187
|
-
|
|
1188
|
-
self.reporter = Minitest::CompositeReporter.new
|
|
1189
|
-
reporter << bogus_reporter
|
|
1190
|
-
|
|
1191
|
-
Minitest::Runnable.runnables.delete @tu
|
|
1192
|
-
|
|
1193
|
-
@tu.run reporter, {}
|
|
1194
|
-
|
|
1195
|
-
assert_predicate bogus_reporter, :success?
|
|
1196
|
-
end
|
|
1197
|
-
|
|
1198
1119
|
def test_record_passing
|
|
1199
1120
|
assert_run_record do
|
|
1200
1121
|
def test_method
|
|
@@ -0,0 +1,229 @@
|
|
|
1
|
+
require "minitest/autorun"
|
|
2
|
+
require "minitest/path_expander"
|
|
3
|
+
|
|
4
|
+
class TestPathExpander < Minitest::Test
|
|
5
|
+
attr_accessor :args
|
|
6
|
+
attr_accessor :expander
|
|
7
|
+
|
|
8
|
+
MT_VPE = Minitest::VendoredPathExpander
|
|
9
|
+
|
|
10
|
+
def setup
|
|
11
|
+
super
|
|
12
|
+
|
|
13
|
+
self.args = []
|
|
14
|
+
|
|
15
|
+
self.expander = MT_VPE.new args, "*.rb"
|
|
16
|
+
|
|
17
|
+
@pe_tmp_path = "test/pe_tmp"
|
|
18
|
+
@pe_tst_path = "test/pe_tmp/test"
|
|
19
|
+
|
|
20
|
+
@orig_pwd = Dir.pwd
|
|
21
|
+
FileUtils.mkdir_p @pe_tst_path
|
|
22
|
+
FileUtils.touch ["#{@pe_tst_path}/test_path_expander.rb", "#{@pe_tst_path}/test_bad.rb"]
|
|
23
|
+
Dir.chdir @pe_tmp_path
|
|
24
|
+
end
|
|
25
|
+
|
|
26
|
+
def teardown
|
|
27
|
+
super
|
|
28
|
+
|
|
29
|
+
Dir.chdir @orig_pwd
|
|
30
|
+
|
|
31
|
+
FileUtils.rm_rf @pe_tmp_path
|
|
32
|
+
end
|
|
33
|
+
|
|
34
|
+
def assert_filter_files exp, filter, files = %w[test/dog_and_cat.rb]
|
|
35
|
+
ignore = StringIO.new filter
|
|
36
|
+
act = expander.filter_files files, ignore
|
|
37
|
+
assert_equal exp, act
|
|
38
|
+
end
|
|
39
|
+
|
|
40
|
+
def assert_filter_files_absolute_paths exp, filter, files = [File.join(Dir.pwd, 'test/dog_and_cat.rb')]
|
|
41
|
+
assert_filter_files exp, filter, files
|
|
42
|
+
end
|
|
43
|
+
|
|
44
|
+
def assert_process_args exp_files, exp_args, *args
|
|
45
|
+
expander.args.concat args
|
|
46
|
+
|
|
47
|
+
assert_equal [exp_files.sort, exp_args], expander.process_args
|
|
48
|
+
end
|
|
49
|
+
|
|
50
|
+
def test_expand_dirs_to_files
|
|
51
|
+
exp = %w[test/test_bad.rb test/test_path_expander.rb]
|
|
52
|
+
|
|
53
|
+
assert_equal exp, expander.expand_dirs_to_files("test")
|
|
54
|
+
assert_equal %w[Rakefile], expander.expand_dirs_to_files("Rakefile")
|
|
55
|
+
end
|
|
56
|
+
|
|
57
|
+
def test_expand_dirs_to_files__sorting
|
|
58
|
+
exp = %w[test/test_bad.rb test/test_path_expander.rb]
|
|
59
|
+
input = %w[test/test_path_expander.rb test/test_bad.rb]
|
|
60
|
+
|
|
61
|
+
assert_equal exp, expander.expand_dirs_to_files(*input)
|
|
62
|
+
assert_equal %w[Rakefile], expander.expand_dirs_to_files("Rakefile")
|
|
63
|
+
end
|
|
64
|
+
|
|
65
|
+
def test_expand_dirs_to_files__leading_dot
|
|
66
|
+
exp = %w[test/test_bad.rb test/test_path_expander.rb]
|
|
67
|
+
|
|
68
|
+
assert_equal exp, expander.expand_dirs_to_files("./test")
|
|
69
|
+
end
|
|
70
|
+
|
|
71
|
+
def test_filter_files_dir
|
|
72
|
+
assert_filter_files [], "test/"
|
|
73
|
+
assert_filter_files_absolute_paths [], "test/"
|
|
74
|
+
end
|
|
75
|
+
|
|
76
|
+
def test_filter_files_files
|
|
77
|
+
example = %w[test/file.rb test/sub/file.rb top/test/perf.rb]
|
|
78
|
+
example_absolute_paths = example.map { |e| File.join(Dir.pwd, e) }
|
|
79
|
+
|
|
80
|
+
assert_filter_files [], "test/*.rb"
|
|
81
|
+
|
|
82
|
+
assert_filter_files example[1..-1], "test/*.rb", example
|
|
83
|
+
|
|
84
|
+
assert_filter_files_absolute_paths [], "test/*.rb"
|
|
85
|
+
|
|
86
|
+
assert_filter_files_absolute_paths example_absolute_paths[1..-1], "test/*.rb", example_absolute_paths
|
|
87
|
+
end
|
|
88
|
+
|
|
89
|
+
def test_filter_files_glob
|
|
90
|
+
assert_filter_files [], "test*"
|
|
91
|
+
assert_filter_files [], "test*", ["test/lib/woot.rb"]
|
|
92
|
+
assert_filter_files [], "*.rb"
|
|
93
|
+
assert_filter_files [], "*dog*.rb"
|
|
94
|
+
|
|
95
|
+
assert_filter_files_absolute_paths [], "test*"
|
|
96
|
+
assert_filter_files_absolute_paths [], "test*", [File.join(Dir.pwd, "test/lib/woot.rb")]
|
|
97
|
+
assert_filter_files_absolute_paths [], "*.rb"
|
|
98
|
+
assert_filter_files_absolute_paths [], "*dog*.rb"
|
|
99
|
+
end
|
|
100
|
+
|
|
101
|
+
def test_filter_files_glob_miss
|
|
102
|
+
miss = %w[test/dog_and_cat.rb]
|
|
103
|
+
miss_absolute = [File.join(Dir.pwd, 'test/dog_and_cat.rb')]
|
|
104
|
+
|
|
105
|
+
assert_filter_files miss, "test"
|
|
106
|
+
assert_filter_files miss, "nope"
|
|
107
|
+
|
|
108
|
+
assert_filter_files_absolute_paths miss_absolute, "test"
|
|
109
|
+
assert_filter_files_absolute_paths miss_absolute, "nope"
|
|
110
|
+
end
|
|
111
|
+
|
|
112
|
+
def test_filter_files__ignore_file
|
|
113
|
+
files = expander.expand_dirs_to_files "test"
|
|
114
|
+
|
|
115
|
+
File.write ".mtignore", "test/*.rb"
|
|
116
|
+
|
|
117
|
+
act = expander.filter_files files, ".mtignore"
|
|
118
|
+
|
|
119
|
+
assert_equal [], act
|
|
120
|
+
end
|
|
121
|
+
|
|
122
|
+
def test_process
|
|
123
|
+
self.args.concat %w[test --seed 42]
|
|
124
|
+
|
|
125
|
+
act = expander.process
|
|
126
|
+
|
|
127
|
+
assert_kind_of Enumerator, act
|
|
128
|
+
assert_equal %w[test/test_bad.rb test/test_path_expander.rb], act.to_a
|
|
129
|
+
assert_equal %w[--seed 42], expander.args
|
|
130
|
+
assert_equal %w[--seed 42], args # affected our original array (eg, ARGV)
|
|
131
|
+
end
|
|
132
|
+
|
|
133
|
+
def test_process__block
|
|
134
|
+
self.args.concat %w[test --seed 42]
|
|
135
|
+
|
|
136
|
+
act = []
|
|
137
|
+
result = expander.process { |x| act << x }
|
|
138
|
+
|
|
139
|
+
assert_same expander, result
|
|
140
|
+
assert_equal %w[test/test_bad.rb test/test_path_expander.rb], act.to_a
|
|
141
|
+
assert_equal %w[--seed 42], expander.args
|
|
142
|
+
assert_equal %w[--seed 42], args # affected our original array (eg, ARGV)
|
|
143
|
+
end
|
|
144
|
+
|
|
145
|
+
def with_tempfile *lines
|
|
146
|
+
require "tempfile"
|
|
147
|
+
|
|
148
|
+
Tempfile.open("tmp") do |f|
|
|
149
|
+
f.puts lines
|
|
150
|
+
f.flush
|
|
151
|
+
f.rewind
|
|
152
|
+
|
|
153
|
+
yield f
|
|
154
|
+
end
|
|
155
|
+
end
|
|
156
|
+
|
|
157
|
+
def test_process_args_at
|
|
158
|
+
with_tempfile %w[test -test/test_bad.rb --seed 24] do |f|
|
|
159
|
+
assert_process_args(%w[test/test_path_expander.rb],
|
|
160
|
+
%w[--seed 24],
|
|
161
|
+
"@#{f.path}")
|
|
162
|
+
end
|
|
163
|
+
end
|
|
164
|
+
|
|
165
|
+
def test_process_args_dash_dir
|
|
166
|
+
assert_process_args(%w[],
|
|
167
|
+
%w[],
|
|
168
|
+
"test", "-test")
|
|
169
|
+
end
|
|
170
|
+
|
|
171
|
+
def test_process_args_dash_file
|
|
172
|
+
assert_process_args(%w[test/test_path_expander.rb],
|
|
173
|
+
%w[],
|
|
174
|
+
"test", "-test/test_bad.rb")
|
|
175
|
+
|
|
176
|
+
end
|
|
177
|
+
|
|
178
|
+
def test_process_args_dash_other
|
|
179
|
+
assert_process_args(%w[],
|
|
180
|
+
%w[--verbose],
|
|
181
|
+
"--verbose")
|
|
182
|
+
end
|
|
183
|
+
|
|
184
|
+
def test_process_args_dir
|
|
185
|
+
assert_process_args(%w[test/test_bad.rb test/test_path_expander.rb],
|
|
186
|
+
%w[],
|
|
187
|
+
"test")
|
|
188
|
+
end
|
|
189
|
+
|
|
190
|
+
def test_process_args_file
|
|
191
|
+
assert_process_args(%w[test/test_path_expander.rb],
|
|
192
|
+
%w[],
|
|
193
|
+
"test/test_path_expander.rb")
|
|
194
|
+
end
|
|
195
|
+
|
|
196
|
+
def test_process_args_other
|
|
197
|
+
assert_process_args(%w[],
|
|
198
|
+
%w[42],
|
|
199
|
+
"42")
|
|
200
|
+
end
|
|
201
|
+
|
|
202
|
+
def test_process_args_root
|
|
203
|
+
assert_process_args(%w[],
|
|
204
|
+
%w[-n /./],
|
|
205
|
+
"-n",
|
|
206
|
+
"/./")
|
|
207
|
+
end
|
|
208
|
+
|
|
209
|
+
def test_process_args_no_files
|
|
210
|
+
self.expander = MT_VPE.new args, "*.rb", "test" # extra test default
|
|
211
|
+
|
|
212
|
+
assert_process_args(%w[test/test_bad.rb test/test_path_expander.rb],
|
|
213
|
+
%w[-v],
|
|
214
|
+
"-v")
|
|
215
|
+
end
|
|
216
|
+
|
|
217
|
+
def test_process_args_dash
|
|
218
|
+
assert_process_args(%w[-],
|
|
219
|
+
%w[-v],
|
|
220
|
+
"-", "-v")
|
|
221
|
+
end
|
|
222
|
+
|
|
223
|
+
def test_process_flags
|
|
224
|
+
exp = %w[a b c]
|
|
225
|
+
act = expander.process_flags %w[a b c]
|
|
226
|
+
|
|
227
|
+
assert_equal exp, act
|
|
228
|
+
end
|
|
229
|
+
end
|