minitest 5.10.3 → 5.18.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 +5 -5
- checksums.yaml.gz.sig +0 -0
- data/History.rdoc +267 -4
- data/Manifest.txt +3 -0
- data/README.rdoc +123 -22
- data/Rakefile +5 -16
- data/lib/hoe/minitest.rb +0 -4
- data/lib/minitest/assertions.rb +197 -32
- data/lib/minitest/benchmark.rb +39 -8
- data/lib/minitest/expectations.rb +72 -35
- data/lib/minitest/mock.rb +118 -34
- data/lib/minitest/parallel.rb +1 -1
- data/lib/minitest/pride_plugin.rb +1 -1
- data/lib/minitest/spec.rb +27 -9
- data/lib/minitest/test.rb +38 -66
- data/lib/minitest/test_task.rb +305 -0
- data/lib/minitest/unit.rb +5 -8
- data/lib/minitest.rb +271 -52
- data/test/minitest/metametameta.rb +44 -9
- data/test/minitest/test_minitest_assertions.rb +1701 -0
- data/test/minitest/test_minitest_benchmark.rb +2 -2
- data/test/minitest/test_minitest_mock.rb +648 -14
- data/test/minitest/test_minitest_reporter.rb +46 -21
- data/test/minitest/test_minitest_spec.rb +317 -156
- data/test/minitest/test_minitest_test.rb +308 -1146
- data/test/minitest/test_minitest_test_task.rb +46 -0
- data.tar.gz.sig +1 -2
- metadata +36 -24
- metadata.gz.sig +0 -0
@@ -15,10 +15,11 @@ if defined? Encoding then
|
|
15
15
|
end
|
16
16
|
end
|
17
17
|
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
18
|
+
class Minitest::Runnable
|
19
|
+
def whatever # faked for testing
|
20
|
+
assert true
|
21
|
+
end
|
22
|
+
end
|
22
23
|
|
23
24
|
class TestMinitestUnit < MetaMetaMetaTestCase
|
24
25
|
parallelize_me!
|
@@ -47,9 +48,11 @@ class TestMinitestUnit < MetaMetaMetaTestCase
|
|
47
48
|
"test/test_autotest.rb:62:in `test_add_exception'"]
|
48
49
|
ex = util_expand_bt ex
|
49
50
|
|
50
|
-
|
51
|
+
Minitest::Test.io_lock.synchronize do # try not to trounce in parallel
|
52
|
+
fu = Minitest.filter_backtrace(bt)
|
51
53
|
|
52
|
-
|
54
|
+
assert_equal ex, fu
|
55
|
+
end
|
53
56
|
end
|
54
57
|
|
55
58
|
def test_filter_backtrace_all_unit
|
@@ -70,16 +73,22 @@ class TestMinitestUnit < MetaMetaMetaTestCase
|
|
70
73
|
bt = util_expand_bt bt
|
71
74
|
|
72
75
|
ex = ["-e:1"]
|
73
|
-
|
74
|
-
|
76
|
+
Minitest::Test.io_lock.synchronize do # try not to trounce in parallel
|
77
|
+
fu = Minitest.filter_backtrace bt
|
78
|
+
assert_equal ex, fu
|
79
|
+
end
|
75
80
|
end
|
76
81
|
|
77
|
-
|
78
|
-
|
79
|
-
|
82
|
+
def test_filter_backtrace__empty
|
83
|
+
with_empty_backtrace_filter do
|
84
|
+
bt = %w[first second third]
|
85
|
+
fu = Minitest.filter_backtrace bt.dup
|
86
|
+
assert_equal bt, fu
|
87
|
+
end
|
88
|
+
end
|
80
89
|
|
81
90
|
def test_infectious_binary_encoding
|
82
|
-
@tu = Class.new
|
91
|
+
@tu = Class.new FakeNamedTest do
|
83
92
|
def test_this_is_not_ascii_assertion
|
84
93
|
assert_equal "ЁЁЁ", "ёёё"
|
85
94
|
end
|
@@ -90,24 +99,26 @@ class TestMinitestUnit < MetaMetaMetaTestCase
|
|
90
99
|
end
|
91
100
|
|
92
101
|
expected = clean <<-EOM
|
93
|
-
|
102
|
+
FE
|
94
103
|
|
95
104
|
Finished in 0.00
|
96
105
|
|
97
|
-
1)
|
98
|
-
|
99
|
-
RuntimeError: ЁЁЁ
|
100
|
-
FILE:LINE:in `test_this_is_non_ascii_failure_message'
|
101
|
-
|
102
|
-
2) Failure:
|
103
|
-
#<Class:0xXXX>#test_this_is_not_ascii_assertion [FILE:LINE]:
|
106
|
+
1) Failure:
|
107
|
+
FakeNamedTestXX#test_this_is_not_ascii_assertion [FILE:LINE]:
|
104
108
|
Expected: \"ЁЁЁ\"
|
105
109
|
Actual: \"ёёё\"
|
106
110
|
|
111
|
+
2) Error:
|
112
|
+
FakeNamedTestXX#test_this_is_non_ascii_failure_message:
|
113
|
+
RuntimeError: ЁЁЁ
|
114
|
+
FILE:LINE:in `test_this_is_non_ascii_failure_message'
|
115
|
+
|
107
116
|
2 runs, 1 assertions, 1 failures, 1 errors, 0 skips
|
108
117
|
EOM
|
109
118
|
|
110
|
-
|
119
|
+
Minitest::Test.io_lock.synchronize do # try not to trounce in parallel
|
120
|
+
assert_report expected
|
121
|
+
end
|
111
122
|
end
|
112
123
|
|
113
124
|
def test_passed_eh_teardown_good
|
@@ -118,7 +129,10 @@ class TestMinitestUnit < MetaMetaMetaTestCase
|
|
118
129
|
|
119
130
|
test = test_class.new :test_omg
|
120
131
|
test.run
|
121
|
-
|
132
|
+
|
133
|
+
refute_predicate test, :error?
|
134
|
+
assert_predicate test, :passed?
|
135
|
+
refute_predicate test, :skipped?
|
122
136
|
end
|
123
137
|
|
124
138
|
def test_passed_eh_teardown_skipped
|
@@ -130,8 +144,9 @@ class TestMinitestUnit < MetaMetaMetaTestCase
|
|
130
144
|
test = test_class.new :test_omg
|
131
145
|
test.run
|
132
146
|
|
133
|
-
|
134
|
-
|
147
|
+
refute_predicate test, :error?
|
148
|
+
refute_predicate test, :passed?
|
149
|
+
assert_predicate test, :skipped?
|
135
150
|
end
|
136
151
|
|
137
152
|
def test_passed_eh_teardown_flunked
|
@@ -142,15 +157,14 @@ class TestMinitestUnit < MetaMetaMetaTestCase
|
|
142
157
|
|
143
158
|
test = test_class.new :test_omg
|
144
159
|
test.run
|
145
|
-
|
160
|
+
|
161
|
+
refute_predicate test, :error?
|
162
|
+
refute_predicate test, :passed?
|
163
|
+
refute_predicate test, :skipped?
|
146
164
|
end
|
147
165
|
|
148
166
|
def util_expand_bt bt
|
149
|
-
|
150
|
-
bt.map { |f| (f =~ /^\./) ? File.expand_path(f) : f }
|
151
|
-
else
|
152
|
-
bt
|
153
|
-
end
|
167
|
+
bt.map { |f| (f =~ /^\./) ? File.expand_path(f) : f }
|
154
168
|
end
|
155
169
|
end
|
156
170
|
|
@@ -207,10 +221,10 @@ class TestMinitestRunner < MetaMetaMetaTestCase
|
|
207
221
|
|
208
222
|
def run
|
209
223
|
@foo = "hi mom!"
|
210
|
-
super
|
224
|
+
r = super
|
211
225
|
@foo = "okay"
|
212
226
|
|
213
|
-
|
227
|
+
r
|
214
228
|
end
|
215
229
|
|
216
230
|
def test_something
|
@@ -242,12 +256,12 @@ class TestMinitestRunner < MetaMetaMetaTestCase
|
|
242
256
|
end
|
243
257
|
|
244
258
|
expected = clean <<-EOM
|
245
|
-
E
|
259
|
+
.E
|
246
260
|
|
247
261
|
Finished in 0.00
|
248
262
|
|
249
263
|
1) Error:
|
250
|
-
|
264
|
+
FakeNamedTestXX#test_error:
|
251
265
|
RuntimeError: unhandled exception
|
252
266
|
FILE:LINE:in \`test_error\'
|
253
267
|
|
@@ -275,7 +289,7 @@ class TestMinitestRunner < MetaMetaMetaTestCase
|
|
275
289
|
Finished in 0.00
|
276
290
|
|
277
291
|
1) Error:
|
278
|
-
|
292
|
+
FakeNamedTestXX#test_something:
|
279
293
|
RuntimeError: unhandled exception
|
280
294
|
FILE:LINE:in \`teardown\'
|
281
295
|
|
@@ -289,12 +303,12 @@ class TestMinitestRunner < MetaMetaMetaTestCase
|
|
289
303
|
setup_basic_tu
|
290
304
|
|
291
305
|
expected = clean <<-EOM
|
292
|
-
F
|
306
|
+
.F
|
293
307
|
|
294
308
|
Finished in 0.00
|
295
309
|
|
296
310
|
1) Failure:
|
297
|
-
|
311
|
+
FakeNamedTestXX#test_failure [FILE:LINE]:
|
298
312
|
Expected false to be truthy.
|
299
313
|
|
300
314
|
2 runs, 2 assertions, 1 failures, 0 errors, 0 skips
|
@@ -316,6 +330,10 @@ class TestMinitestRunner < MetaMetaMetaTestCase
|
|
316
330
|
end
|
317
331
|
end
|
318
332
|
|
333
|
+
def test_seed # this is set for THIS run, so I'm not testing it's actual value
|
334
|
+
assert_instance_of Integer, Minitest.seed
|
335
|
+
end
|
336
|
+
|
319
337
|
def test_run_failing_filtered
|
320
338
|
setup_basic_tu
|
321
339
|
|
@@ -473,7 +491,7 @@ class TestMinitestRunner < MetaMetaMetaTestCase
|
|
473
491
|
end
|
474
492
|
|
475
493
|
expected = clean <<-EOM
|
476
|
-
S
|
494
|
+
.S
|
477
495
|
|
478
496
|
Finished in 0.00
|
479
497
|
|
@@ -500,13 +518,13 @@ class TestMinitestRunner < MetaMetaMetaTestCase
|
|
500
518
|
end
|
501
519
|
|
502
520
|
expected = clean <<-EOM
|
503
|
-
|
504
|
-
|
521
|
+
FakeNamedTestXX#test_something = 0.00 s = .
|
522
|
+
FakeNamedTestXX#test_skip = 0.00 s = S
|
505
523
|
|
506
524
|
Finished in 0.00
|
507
525
|
|
508
526
|
1) Skipped:
|
509
|
-
|
527
|
+
FakeNamedTestXX#test_skip [FILE:LINE]:
|
510
528
|
not yet
|
511
529
|
|
512
530
|
2 runs, 1 assertions, 0 failures, 0 errors, 1 skips
|
@@ -515,6 +533,33 @@ class TestMinitestRunner < MetaMetaMetaTestCase
|
|
515
533
|
assert_report expected, %w[--seed 42 --verbose]
|
516
534
|
end
|
517
535
|
|
536
|
+
def test_run_skip_show_skips
|
537
|
+
@tu =
|
538
|
+
Class.new FakeNamedTest do
|
539
|
+
def test_something
|
540
|
+
assert true
|
541
|
+
end
|
542
|
+
|
543
|
+
def test_skip
|
544
|
+
skip "not yet"
|
545
|
+
end
|
546
|
+
end
|
547
|
+
|
548
|
+
expected = clean <<-EOM
|
549
|
+
.S
|
550
|
+
|
551
|
+
Finished in 0.00
|
552
|
+
|
553
|
+
1) Skipped:
|
554
|
+
FakeNamedTestXX#test_skip [FILE:LINE]:
|
555
|
+
not yet
|
556
|
+
|
557
|
+
2 runs, 1 assertions, 0 failures, 0 errors, 1 skips
|
558
|
+
EOM
|
559
|
+
|
560
|
+
assert_report expected, %w[--seed 42 --show-skips]
|
561
|
+
end
|
562
|
+
|
518
563
|
def test_run_with_other_runner
|
519
564
|
@tu =
|
520
565
|
Class.new FakeNamedTest do
|
@@ -574,8 +619,6 @@ class TestMinitestRunner < MetaMetaMetaTestCase
|
|
574
619
|
end
|
575
620
|
|
576
621
|
def test_run_parallel
|
577
|
-
skip "I don't have ParallelEach debugged yet" if maglev?
|
578
|
-
|
579
622
|
test_count = 2
|
580
623
|
test_latch = Latch.new test_count
|
581
624
|
wait_latch = Latch.new test_count
|
@@ -617,6 +660,8 @@ class TestMinitestRunner < MetaMetaMetaTestCase
|
|
617
660
|
2 runs, 2 assertions, 0 failures, 0 errors, 0 skips
|
618
661
|
EOM
|
619
662
|
|
663
|
+
skip if Minitest.parallel_executor.size < 2 # locks up test runner if 1 CPU
|
664
|
+
|
620
665
|
assert_report(expected) do |reporter|
|
621
666
|
reporter.extend(Module.new {
|
622
667
|
define_method("record") do |result|
|
@@ -741,6 +786,13 @@ class TestMinitestUnitOrder < MetaMetaMetaTestCase
|
|
741
786
|
end
|
742
787
|
end
|
743
788
|
|
789
|
+
class BetterError < RuntimeError # like better_error w/o infecting RuntimeError
|
790
|
+
def set_backtrace bt
|
791
|
+
super
|
792
|
+
@bad_ivar = binding
|
793
|
+
end
|
794
|
+
end
|
795
|
+
|
744
796
|
class TestMinitestRunnable < Minitest::Test
|
745
797
|
def setup_marshal klass
|
746
798
|
tc = klass.new "whatever"
|
@@ -754,7 +806,7 @@ class TestMinitestRunnable < Minitest::Test
|
|
754
806
|
end
|
755
807
|
tc.setup
|
756
808
|
|
757
|
-
@tc = tc
|
809
|
+
@tc = Minitest::Result.from tc
|
758
810
|
end
|
759
811
|
|
760
812
|
def assert_marshal expected_ivars
|
@@ -772,1208 +824,318 @@ class TestMinitestRunnable < Minitest::Test
|
|
772
824
|
def test_marshal
|
773
825
|
setup_marshal Minitest::Runnable
|
774
826
|
|
775
|
-
assert_marshal %w[@NAME @assertions @failures]
|
776
|
-
end
|
777
|
-
end
|
778
|
-
|
779
|
-
class TestMinitestTest < TestMinitestRunnable
|
780
|
-
def test_dup
|
781
|
-
setup_marshal Minitest::Test do |tc|
|
782
|
-
tc.time = 3.14
|
783
|
-
end
|
784
|
-
|
785
|
-
assert_marshal %w[@NAME @assertions @failures @time] do |new_tc|
|
786
|
-
assert_in_epsilon 3.14, new_tc.time
|
787
|
-
end
|
788
|
-
end
|
789
|
-
end
|
790
|
-
|
791
|
-
class TestMinitestUnitTestCase < Minitest::Test
|
792
|
-
# do not call parallelize_me! - teardown accesses @tc._assertions
|
793
|
-
# which is not threadsafe. Nearly every method in here is an
|
794
|
-
# assertion test so it isn't worth splitting it out further.
|
795
|
-
|
796
|
-
RUBY18 = !defined? Encoding
|
797
|
-
|
798
|
-
def setup
|
799
|
-
super
|
800
|
-
|
801
|
-
Minitest::Test.reset
|
802
|
-
|
803
|
-
@tc = Minitest::Test.new "fake tc"
|
804
|
-
@zomg = "zomg ponies!"
|
805
|
-
@assertion_count = 1
|
806
|
-
end
|
807
|
-
|
808
|
-
def teardown
|
809
|
-
assert_equal(@assertion_count, @tc.assertions,
|
810
|
-
"expected #{@assertion_count} assertions to be fired during the test, not #{@tc.assertions}") if @tc.passed?
|
827
|
+
assert_marshal %w[@NAME @assertions @failures @klass @source_location @time]
|
811
828
|
end
|
812
829
|
|
813
|
-
def
|
814
|
-
|
815
|
-
|
830
|
+
def test_spec_marshal
|
831
|
+
klass = describe("whatever") { it("passes") { assert true } }
|
832
|
+
rm = klass.runnable_methods.first
|
816
833
|
|
817
|
-
|
818
|
-
|
819
|
-
$VERBOSE = orig_verbose
|
820
|
-
end
|
834
|
+
# Run the test
|
835
|
+
@tc = klass.new(rm).run
|
821
836
|
|
822
|
-
|
823
|
-
@assertion_count = 2
|
837
|
+
assert_kind_of Minitest::Result, @tc
|
824
838
|
|
825
|
-
|
826
|
-
|
839
|
+
# Pass it over the wire
|
840
|
+
over_the_wire = Marshal.load Marshal.dump @tc
|
827
841
|
|
828
|
-
|
829
|
-
|
830
|
-
|
831
|
-
|
842
|
+
assert_equal @tc.time, over_the_wire.time
|
843
|
+
assert_equal @tc.name, over_the_wire.name
|
844
|
+
assert_equal @tc.assertions, over_the_wire.assertions
|
845
|
+
assert_equal @tc.failures, over_the_wire.failures
|
846
|
+
assert_equal @tc.klass, over_the_wire.klass
|
832
847
|
end
|
833
848
|
|
834
|
-
def
|
835
|
-
|
836
|
-
|
837
|
-
|
838
|
-
|
849
|
+
def test_spec_marshal_with_exception
|
850
|
+
klass = describe("whatever") {
|
851
|
+
it("raises, badly") {
|
852
|
+
raise Class.new(StandardError), "this is bad!"
|
853
|
+
}
|
854
|
+
}
|
839
855
|
|
840
|
-
|
841
|
-
@assertion_count = 2
|
856
|
+
rm = klass.runnable_methods.first
|
842
857
|
|
843
|
-
|
844
|
-
|
858
|
+
# Run the test
|
859
|
+
@tc = klass.new(rm).run
|
845
860
|
|
846
|
-
|
847
|
-
|
861
|
+
assert_kind_of Minitest::Result, @tc
|
862
|
+
assert_instance_of Minitest::UnexpectedError, @tc.failure
|
848
863
|
|
849
|
-
|
850
|
-
|
851
|
-
|
852
|
-
end
|
864
|
+
msg = @tc.failure.error.message
|
865
|
+
assert_includes msg, "Neutered Exception #<Class:"
|
866
|
+
assert_includes msg, "this is bad!"
|
853
867
|
|
854
|
-
|
855
|
-
|
856
|
-
end
|
868
|
+
# Pass it over the wire
|
869
|
+
over_the_wire = Marshal.load Marshal.dump @tc
|
857
870
|
|
858
|
-
|
859
|
-
|
860
|
-
|
861
|
-
|
862
|
-
|
863
|
-
[#<Object:0xXXXXXX>]".gsub(/^ +/, "")
|
864
|
-
assert_triggered msg do
|
865
|
-
@tc.assert_equal [object1], [object2]
|
866
|
-
end
|
871
|
+
assert_equal @tc.time, over_the_wire.time
|
872
|
+
assert_equal @tc.name, over_the_wire.name
|
873
|
+
assert_equal @tc.assertions, over_the_wire.assertions
|
874
|
+
assert_equal @tc.failures, over_the_wire.failures
|
875
|
+
assert_equal @tc.klass, over_the_wire.klass
|
867
876
|
end
|
868
877
|
|
869
|
-
def
|
870
|
-
|
871
|
-
|
872
|
-
|
873
|
-
|
874
|
-
|
875
|
-
{1=>#<Object:0xXXXXXX>}".gsub(/^ +/, "")
|
878
|
+
def test_spec_marshal_with_exception_nameerror
|
879
|
+
klass = describe("whatever") {
|
880
|
+
it("raises nameerror") {
|
881
|
+
NOPE::does_not_exist
|
882
|
+
}
|
883
|
+
}
|
876
884
|
|
877
|
-
|
878
|
-
@tc.assert_equal h1, h2
|
879
|
-
end
|
880
|
-
end
|
885
|
+
rm = klass.runnable_methods.first
|
881
886
|
|
882
|
-
|
883
|
-
|
884
|
-
--- expected
|
885
|
-
+++ actual
|
886
|
-
@@ -1 +1,2 @@
|
887
|
-
+# encoding: ASCII-8BIT
|
888
|
-
"bad-utf8-\\xF1.txt"
|
889
|
-
EOM
|
887
|
+
# Run the test
|
888
|
+
@tc = klass.new(rm).run
|
890
889
|
|
891
|
-
|
892
|
-
|
893
|
-
y = x.dup.force_encoding "binary" # TODO: switch to .b when 1.9 dropped
|
894
|
-
@tc.assert_equal x, y
|
895
|
-
end
|
896
|
-
end unless RUBY18
|
897
|
-
|
898
|
-
def test_assert_equal_string_encodings_both_different
|
899
|
-
msg = <<-EOM.gsub(/^ {10}/, "")
|
900
|
-
--- expected
|
901
|
-
+++ actual
|
902
|
-
@@ -1,2 +1,2 @@
|
903
|
-
-# encoding: US-ASCII
|
904
|
-
+# encoding: ASCII-8BIT
|
905
|
-
"bad-utf8-\\xF1.txt"
|
906
|
-
EOM
|
907
|
-
|
908
|
-
assert_triggered msg do
|
909
|
-
x = "bad-utf8-\xF1.txt".force_encoding "ASCII"
|
910
|
-
y = x.dup.force_encoding "binary" # TODO: switch to .b when 1.9 dropped
|
911
|
-
@tc.assert_equal x, y
|
912
|
-
end
|
913
|
-
end unless RUBY18
|
890
|
+
assert_kind_of Minitest::Result, @tc
|
891
|
+
assert_instance_of Minitest::UnexpectedError, @tc.failure
|
914
892
|
|
915
|
-
|
916
|
-
|
893
|
+
msg = @tc.failure.error.message
|
894
|
+
assert_includes msg, "uninitialized constant TestMinitestRunnable::NOPE"
|
917
895
|
|
918
|
-
|
919
|
-
|
920
|
-
o1 = "haha" * 10
|
921
|
-
o2 = "blah" * 10
|
896
|
+
# Pass it over the wire
|
897
|
+
over_the_wire = Marshal.load Marshal.dump @tc
|
922
898
|
|
923
|
-
|
924
|
-
|
925
|
-
|
899
|
+
assert_equal @tc.time, over_the_wire.time
|
900
|
+
assert_equal @tc.name, over_the_wire.name
|
901
|
+
assert_equal @tc.assertions, over_the_wire.assertions
|
902
|
+
assert_equal @tc.failures, over_the_wire.failures
|
903
|
+
assert_equal @tc.klass, over_the_wire.klass
|
926
904
|
end
|
927
905
|
|
928
|
-
def
|
929
|
-
|
930
|
-
|
931
|
-
|
932
|
-
|
933
|
-
|
934
|
-
|
935
|
-
|
936
|
-
+++ actual
|
937
|
-
@@ -1 +1 @@
|
938
|
-
-#<#<Class:0xXXXXXX>:0xXXXXXX @name=\"a\">
|
939
|
-
+#<#<Class:0xXXXXXX>:0xXXXXXX @name=\"b\">
|
940
|
-
".gsub(/^ +/, "")
|
941
|
-
|
942
|
-
assert_triggered msg do
|
943
|
-
@tc.assert_equal o1, o2
|
944
|
-
end
|
906
|
+
def with_runtime_error klass
|
907
|
+
old_runtime = RuntimeError
|
908
|
+
Object.send :remove_const, :RuntimeError
|
909
|
+
Object.const_set :RuntimeError, klass
|
910
|
+
yield
|
911
|
+
ensure
|
912
|
+
Object.send :remove_const, :RuntimeError
|
913
|
+
Object.const_set :RuntimeError, old_runtime
|
945
914
|
end
|
946
915
|
|
947
|
-
def
|
948
|
-
|
949
|
-
|
916
|
+
def test_spec_marshal_with_exception__better_error_typeerror
|
917
|
+
klass = describe("whatever") {
|
918
|
+
it("raises with binding") {
|
919
|
+
raise BetterError, "boom"
|
920
|
+
}
|
921
|
+
}
|
950
922
|
|
951
|
-
|
952
|
-
You should look at the implementation of #== on Object or its members.
|
953
|
-
#<Object:0xXXXXXX>".gsub(/^ +/, "")
|
923
|
+
rm = klass.runnable_methods.first
|
954
924
|
|
955
|
-
|
956
|
-
|
925
|
+
# Run the test
|
926
|
+
@tc = with_runtime_error BetterError do
|
927
|
+
klass.new(rm).run
|
957
928
|
end
|
958
|
-
end
|
959
929
|
|
960
|
-
|
961
|
-
|
962
|
-
+++ actual
|
963
|
-
@@ -1 +1 @@
|
964
|
-
-\"hahahahahahahahahahahahahahahahahahahaha\"
|
965
|
-
+\"blahblahblahblahblahblahblahblahblahblah\"
|
966
|
-
".gsub(/^ +/, "")
|
930
|
+
assert_kind_of Minitest::Result, @tc
|
931
|
+
assert_instance_of Minitest::UnexpectedError, @tc.failure
|
967
932
|
|
968
|
-
|
969
|
-
|
970
|
-
o2 = "blah" * 10
|
933
|
+
msg = @tc.failure.error.message
|
934
|
+
assert_equal "Neutered Exception BetterError: boom", msg
|
971
935
|
|
972
|
-
|
973
|
-
|
936
|
+
# Pass it over the wire
|
937
|
+
over_the_wire = Marshal.load Marshal.dump @tc
|
938
|
+
|
939
|
+
assert_equal @tc.time, over_the_wire.time
|
940
|
+
assert_equal @tc.name, over_the_wire.name
|
941
|
+
assert_equal @tc.assertions, over_the_wire.assertions
|
942
|
+
assert_equal @tc.failures, over_the_wire.failures
|
943
|
+
assert_equal @tc.klass, over_the_wire.klass
|
974
944
|
end
|
975
945
|
|
976
|
-
def
|
977
|
-
|
978
|
-
|
979
|
-
|
946
|
+
def test_spec_marshal_with_exception__worse_error_typeerror
|
947
|
+
worse_error_klass = Class.new(StandardError) do
|
948
|
+
# problem #1: anonymous subclass can'tmarshal, fails sanitize_exception
|
949
|
+
def initialize(record = nil)
|
980
950
|
|
981
|
-
|
982
|
-
o1 = "blah" * 10
|
983
|
-
o2 = "blah" * 10
|
984
|
-
def o1.== _
|
985
|
-
false
|
951
|
+
super(record.first)
|
986
952
|
end
|
987
|
-
@tc.assert_equal o1, o2
|
988
953
|
end
|
989
|
-
end
|
990
954
|
|
991
|
-
|
992
|
-
|
993
|
-
|
994
|
-
|
995
|
-
|
996
|
-
|
997
|
-
|
998
|
-
|
955
|
+
klass = describe("whatever") {
|
956
|
+
it("raises with NoMethodError") {
|
957
|
+
# problem #2: instantiated with a NON-string argument
|
958
|
+
#
|
959
|
+
# problem #3: arg responds to #first, but it becomes message
|
960
|
+
# which gets passed back in via new_exception
|
961
|
+
# that passes a string to worse_error_klass#initialize
|
962
|
+
# which calls first on it, which raises NoMethodError
|
963
|
+
raise worse_error_klass.new(["boom"])
|
964
|
+
}
|
965
|
+
}
|
999
966
|
|
1000
|
-
|
1001
|
-
o1 = "haha" * 10
|
1002
|
-
o2 = "blah" * 10
|
1003
|
-
@tc.assert_equal o1, o2, "message"
|
1004
|
-
end
|
1005
|
-
end
|
967
|
+
rm = klass.runnable_methods.first
|
1006
968
|
|
1007
|
-
|
1008
|
-
|
1009
|
-
@tc.assert_equal 1, 2
|
1010
|
-
end
|
1011
|
-
end
|
969
|
+
# Run the test
|
970
|
+
@tc = klass.new(rm).run
|
1012
971
|
|
1013
|
-
|
1014
|
-
|
1015
|
-
@tc.assert_equal 1, 2, "message"
|
1016
|
-
end
|
1017
|
-
end
|
972
|
+
assert_kind_of Minitest::Result, @tc
|
973
|
+
assert_instance_of Minitest::UnexpectedError, @tc.failure
|
1018
974
|
|
1019
|
-
|
1020
|
-
msg = "--- expected\n+++ actual\n@@ -1,2 +1,2 @@\n \"a\n-b\"\n+c\"\n"
|
1021
|
-
assert_triggered msg do
|
1022
|
-
@tc.assert_equal "a\nb", "a\nc"
|
1023
|
-
end
|
1024
|
-
end
|
975
|
+
msg = @tc.failure.error.message.gsub(/0x[A-Fa-f0-9]+/, "0xXXX")
|
1025
976
|
|
1026
|
-
|
1027
|
-
if Minitest::VERSION =~ /^6/ then
|
1028
|
-
warn "Time to strip the MT5 test"
|
977
|
+
assert_equal "Neutered Exception #<Class:0xXXX>: boom", msg
|
1029
978
|
|
1030
|
-
|
1031
|
-
|
1032
|
-
@tc.assert_equal nil, nil
|
1033
|
-
end
|
1034
|
-
else
|
1035
|
-
err_re = /Use assert_nil if expecting nil from .*test_minitest_test.rb/
|
1036
|
-
err_re = "" if $-w.nil?
|
979
|
+
# Pass it over the wire
|
980
|
+
over_the_wire = Marshal.load Marshal.dump @tc
|
1037
981
|
|
1038
|
-
|
1039
|
-
|
1040
|
-
|
1041
|
-
|
982
|
+
assert_equal @tc.time, over_the_wire.time
|
983
|
+
assert_equal @tc.name, over_the_wire.name
|
984
|
+
assert_equal @tc.assertions, over_the_wire.assertions
|
985
|
+
assert_equal @tc.failures, over_the_wire.failures
|
986
|
+
assert_equal @tc.klass, over_the_wire.klass
|
1042
987
|
end
|
988
|
+
end
|
1043
989
|
|
1044
|
-
|
1045
|
-
|
1046
|
-
|
990
|
+
class TestMinitestTest < TestMinitestRunnable
|
991
|
+
def test_dup
|
992
|
+
setup_marshal Minitest::Test do |tc|
|
993
|
+
tc.time = 3.14
|
1047
994
|
end
|
1048
|
-
end
|
1049
|
-
|
1050
|
-
def test_assert_in_delta
|
1051
|
-
@tc.assert_in_delta 0.0, 1.0 / 1000, 0.1
|
1052
|
-
end
|
1053
995
|
|
1054
|
-
|
1055
|
-
|
1056
|
-
|
1057
|
-
@tc.assert_in_delta 0, 1, 1
|
1058
|
-
|
1059
|
-
assert_triggered "Expected |0 - 1| (1) to not be <= 1." do
|
1060
|
-
@tc.refute_in_delta 0, 1, 1
|
996
|
+
assert_marshal %w[@NAME @assertions @failures @klass @source_location @time] do |new_tc|
|
997
|
+
assert_in_epsilon 3.14, new_tc.time
|
1061
998
|
end
|
1062
999
|
end
|
1000
|
+
end
|
1063
1001
|
|
1064
|
-
|
1065
|
-
|
1066
|
-
|
1067
|
-
|
1068
|
-
end
|
1069
|
-
end
|
1002
|
+
class TestMinitestUnitTestCase < Minitest::Test
|
1003
|
+
# do not call parallelize_me! - teardown accesses @tc._assertions
|
1004
|
+
# which is not threadsafe. Nearly every method in here is an
|
1005
|
+
# assertion test so it isn't worth splitting it out further.
|
1070
1006
|
|
1071
|
-
|
1072
|
-
@assertion_count = 10
|
1007
|
+
RUBY18 = !defined? Encoding
|
1073
1008
|
|
1074
|
-
|
1075
|
-
|
1076
|
-
@tc.assert_in_epsilon 1.0, 1.001
|
1077
|
-
@tc.assert_in_epsilon 1.001, 1.0
|
1009
|
+
def setup
|
1010
|
+
super
|
1078
1011
|
|
1079
|
-
|
1080
|
-
@tc.assert_in_epsilon 9999.1, 10_000, 0.0001
|
1081
|
-
@tc.assert_in_epsilon 1.0, 1.0001, 0.0001
|
1082
|
-
@tc.assert_in_epsilon 1.0001, 1.0, 0.0001
|
1012
|
+
Minitest::Test.reset
|
1083
1013
|
|
1084
|
-
@tc.
|
1085
|
-
@
|
1014
|
+
@tc = Minitest::Test.new "fake tc"
|
1015
|
+
@zomg = "zomg ponies!"
|
1016
|
+
@assertion_count = 1
|
1086
1017
|
end
|
1087
1018
|
|
1088
|
-
def
|
1089
|
-
@assertion_count
|
1090
|
-
|
1091
|
-
@tc.assert_in_epsilon 1.0, 1.001
|
1092
|
-
|
1093
|
-
msg = "Expected |1.0 - 1.001| (0.000999xxx) to not be <= 0.001."
|
1094
|
-
assert_triggered msg do
|
1095
|
-
@tc.refute_in_epsilon 1.0, 1.001
|
1096
|
-
end
|
1019
|
+
def teardown
|
1020
|
+
assert_equal(@assertion_count, @tc.assertions,
|
1021
|
+
"expected #{@assertion_count} assertions to be fired during the test, not #{@tc.assertions}") if @tc.passed?
|
1097
1022
|
end
|
1098
1023
|
|
1099
|
-
def
|
1100
|
-
|
1101
|
-
|
1102
|
-
end
|
1103
|
-
end
|
1024
|
+
def non_verbose
|
1025
|
+
orig_verbose = $VERBOSE
|
1026
|
+
$VERBOSE = false
|
1104
1027
|
|
1105
|
-
|
1106
|
-
|
1107
|
-
|
1108
|
-
assert_triggered "Expected |-1.1 - -1| (#{x}) to be <= #{y}." do
|
1109
|
-
@tc.assert_in_epsilon(-1.1, -1, 0.1)
|
1110
|
-
end
|
1028
|
+
yield
|
1029
|
+
ensure
|
1030
|
+
$VERBOSE = orig_verbose
|
1111
1031
|
end
|
1112
1032
|
|
1113
|
-
def
|
1114
|
-
|
1115
|
-
|
1116
|
-
|
1033
|
+
def sample_test_case(rand)
|
1034
|
+
srand rand
|
1035
|
+
Class.new FakeNamedTest do
|
1036
|
+
100.times do |i|
|
1037
|
+
define_method("test_#{i}") { assert true }
|
1038
|
+
end
|
1039
|
+
end.runnable_methods
|
1117
1040
|
end
|
1118
1041
|
|
1119
|
-
|
1120
|
-
|
1121
|
-
|
1122
|
-
e = @tc.assert_raises Minitest::Assertion do
|
1123
|
-
@tc.assert_includes [true], false
|
1124
|
-
end
|
1125
|
-
|
1126
|
-
expected = "Expected [true] to include false."
|
1127
|
-
assert_equal expected, e.message
|
1128
|
-
end
|
1042
|
+
# srand varies with OS
|
1043
|
+
def test_runnable_methods_random
|
1044
|
+
@assertion_count = 0
|
1129
1045
|
|
1130
|
-
|
1131
|
-
|
1132
|
-
|
1046
|
+
random_tests_1 = sample_test_case 42
|
1047
|
+
random_tests_2 = sample_test_case 42
|
1048
|
+
random_tests_3 = sample_test_case 1_000
|
1133
1049
|
|
1134
|
-
|
1135
|
-
|
1136
|
-
@tc.assert_instance_of Array, "blah"
|
1137
|
-
end
|
1050
|
+
assert_equal random_tests_1, random_tests_2
|
1051
|
+
assert_equal random_tests_1, random_tests_3
|
1138
1052
|
end
|
1139
1053
|
|
1140
|
-
def
|
1141
|
-
@
|
1142
|
-
end
|
1054
|
+
def test_runnable_methods_sorted
|
1055
|
+
@assertion_count = 0
|
1143
1056
|
|
1144
|
-
|
1145
|
-
|
1146
|
-
|
1057
|
+
sample_test_case = Class.new FakeNamedTest do
|
1058
|
+
def self.test_order; :sorted end
|
1059
|
+
def test_test3; assert "does not matter" end
|
1060
|
+
def test_test2; assert "does not matter" end
|
1061
|
+
def test_test1; assert "does not matter" end
|
1147
1062
|
end
|
1148
|
-
end
|
1149
1063
|
|
1150
|
-
|
1151
|
-
|
1152
|
-
@tc.assert_match(/\w+/, "blah blah blah")
|
1064
|
+
expected = %w[test_test1 test_test2 test_test3]
|
1065
|
+
assert_equal expected, sample_test_case.runnable_methods
|
1153
1066
|
end
|
1154
1067
|
|
1155
|
-
def
|
1156
|
-
@assertion_count =
|
1157
|
-
|
1158
|
-
pattern = Object.new
|
1159
|
-
def pattern.=~ _; true end
|
1160
|
-
|
1161
|
-
@tc.assert_match pattern, 5
|
1162
|
-
end
|
1068
|
+
def test_i_suck_and_my_tests_are_order_dependent_bang_sets_test_order_alpha
|
1069
|
+
@assertion_count = 0
|
1163
1070
|
|
1164
|
-
|
1165
|
-
@assertion_count = 2
|
1071
|
+
shitty_test_case = Class.new FakeNamedTest
|
1166
1072
|
|
1167
|
-
|
1168
|
-
def obj.to_str; "blah" end
|
1073
|
+
shitty_test_case.i_suck_and_my_tests_are_order_dependent!
|
1169
1074
|
|
1170
|
-
|
1075
|
+
assert_equal :alpha, shitty_test_case.test_order
|
1171
1076
|
end
|
1172
1077
|
|
1173
|
-
def
|
1174
|
-
@assertion_count =
|
1175
|
-
|
1176
|
-
pattern = Object.new
|
1177
|
-
def pattern.=~ _; false end
|
1178
|
-
def pattern.inspect; "[Object]" end
|
1179
|
-
|
1180
|
-
assert_triggered "Expected [Object] to match 5." do
|
1181
|
-
@tc.assert_match pattern, 5
|
1182
|
-
end
|
1183
|
-
end
|
1078
|
+
def test_i_suck_and_my_tests_are_order_dependent_bang_does_not_warn
|
1079
|
+
@assertion_count = 0
|
1184
1080
|
|
1185
|
-
|
1186
|
-
@assertion_count = 2
|
1187
|
-
assert_triggered 'Expected /\d+/ to match "blah blah blah".' do
|
1188
|
-
@tc.assert_match(/\d+/, "blah blah blah")
|
1189
|
-
end
|
1190
|
-
end
|
1081
|
+
shitty_test_case = Class.new FakeNamedTest
|
1191
1082
|
|
1192
|
-
|
1193
|
-
@tc.assert_nil nil
|
1194
|
-
end
|
1083
|
+
def shitty_test_case.test_order; :lol end
|
1195
1084
|
|
1196
|
-
|
1197
|
-
|
1198
|
-
@tc.assert_nil 42
|
1085
|
+
assert_silent do
|
1086
|
+
shitty_test_case.i_suck_and_my_tests_are_order_dependent!
|
1199
1087
|
end
|
1200
1088
|
end
|
1201
1089
|
|
1202
|
-
def
|
1203
|
-
@
|
1204
|
-
|
1205
|
-
|
1206
|
-
|
1207
|
-
bad = Object.new
|
1208
|
-
def bad.== _; true end
|
1209
|
-
|
1210
|
-
@tc.assert_operator bad, :equal?, bad
|
1211
|
-
end
|
1212
|
-
|
1213
|
-
def test_assert_operator_triggered
|
1214
|
-
assert_triggered "Expected 2 to be < 1." do
|
1215
|
-
@tc.assert_operator 2, :<, 1
|
1216
|
-
end
|
1090
|
+
def test_autorun_does_not_affect_fork_success_status
|
1091
|
+
@assertion_count = 0
|
1092
|
+
skip "windows doesn't have skip" unless Process.respond_to?(:fork)
|
1093
|
+
Process.waitpid(fork {})
|
1094
|
+
assert_equal true, $?.success?
|
1217
1095
|
end
|
1218
1096
|
|
1219
|
-
def
|
1220
|
-
@assertion_count =
|
1221
|
-
|
1222
|
-
|
1223
|
-
|
1224
|
-
$stderr.print "blah"
|
1225
|
-
end
|
1097
|
+
def test_autorun_does_not_affect_fork_exit_status
|
1098
|
+
@assertion_count = 0
|
1099
|
+
skip "windows doesn't have skip" unless Process.respond_to?(:fork)
|
1100
|
+
Process.waitpid(fork { exit 42 })
|
1101
|
+
assert_equal 42, $?.exitstatus
|
1226
1102
|
end
|
1103
|
+
end
|
1227
1104
|
|
1228
|
-
|
1229
|
-
|
1230
|
-
|
1231
|
-
@tc.assert_output(/y.y/, /bl.h/) do
|
1232
|
-
print "yay"
|
1233
|
-
$stderr.print "blah"
|
1234
|
-
end
|
1235
|
-
end
|
1105
|
+
class TestMinitestGuard < Minitest::Test
|
1106
|
+
parallelize_me!
|
1236
1107
|
|
1237
|
-
def
|
1238
|
-
|
1239
|
-
|
1240
|
-
end
|
1108
|
+
def test_mri_eh
|
1109
|
+
assert self.class.mri? "ruby blah"
|
1110
|
+
assert self.mri? "ruby blah"
|
1241
1111
|
end
|
1242
1112
|
|
1243
|
-
def
|
1244
|
-
|
1245
|
-
|
1246
|
-
@tc.assert_output do
|
1247
|
-
# do nothing
|
1248
|
-
end
|
1113
|
+
def test_jruby_eh
|
1114
|
+
assert self.class.jruby? "java"
|
1115
|
+
assert self.jruby? "java"
|
1249
1116
|
end
|
1250
1117
|
|
1251
|
-
def
|
1252
|
-
|
1253
|
-
|
1118
|
+
def test_rubinius_eh
|
1119
|
+
assert_output "", /DEPRECATED/ do
|
1120
|
+
assert self.class.rubinius? "rbx"
|
1254
1121
|
end
|
1255
|
-
|
1256
|
-
|
1257
|
-
def test_assert_output_triggered_both
|
1258
|
-
assert_triggered util_msg("blah", "blah blah", "In stderr") do
|
1259
|
-
@tc.assert_output "yay", "blah" do
|
1260
|
-
print "boo"
|
1261
|
-
$stderr.print "blah blah"
|
1262
|
-
end
|
1122
|
+
assert_output "", /DEPRECATED/ do
|
1123
|
+
assert self.rubinius? "rbx"
|
1263
1124
|
end
|
1264
1125
|
end
|
1265
1126
|
|
1266
|
-
def
|
1267
|
-
|
1268
|
-
|
1269
|
-
$stderr.print "blah blah"
|
1270
|
-
end
|
1127
|
+
def test_maglev_eh
|
1128
|
+
assert_output "", /DEPRECATED/ do
|
1129
|
+
assert self.class.maglev? "maglev"
|
1271
1130
|
end
|
1272
|
-
|
1273
|
-
|
1274
|
-
def test_assert_output_triggered_out
|
1275
|
-
assert_triggered util_msg("blah", "blah blah", "In stdout") do
|
1276
|
-
@tc.assert_output "blah" do
|
1277
|
-
print "blah blah"
|
1278
|
-
end
|
1131
|
+
assert_output "", /DEPRECATED/ do
|
1132
|
+
assert self.maglev? "maglev"
|
1279
1133
|
end
|
1280
1134
|
end
|
1281
1135
|
|
1282
|
-
def
|
1283
|
-
|
1284
|
-
|
1285
|
-
|
1286
|
-
def test_assert_predicate_triggered
|
1287
|
-
assert_triggered 'Expected "blah" to be empty?.' do
|
1288
|
-
@tc.assert_predicate "blah", :empty?
|
1289
|
-
end
|
1290
|
-
end
|
1291
|
-
|
1292
|
-
def test_assert_raises
|
1293
|
-
@tc.assert_raises RuntimeError do
|
1294
|
-
raise "blah"
|
1295
|
-
end
|
1296
|
-
end
|
1297
|
-
|
1298
|
-
def test_assert_raises_default
|
1299
|
-
@tc.assert_raises do
|
1300
|
-
raise StandardError, "blah"
|
1301
|
-
end
|
1302
|
-
end
|
1303
|
-
|
1304
|
-
def test_assert_raises_default_triggered
|
1305
|
-
e = assert_raises Minitest::Assertion do
|
1306
|
-
@tc.assert_raises do
|
1307
|
-
raise SomeError, "blah"
|
1308
|
-
end
|
1309
|
-
end
|
1310
|
-
|
1311
|
-
expected = clean <<-EOM.chomp
|
1312
|
-
[StandardError] exception expected, not
|
1313
|
-
Class: <SomeError>
|
1314
|
-
Message: <\"blah\">
|
1315
|
-
---Backtrace---
|
1316
|
-
FILE:LINE:in \`test_assert_raises_default_triggered\'
|
1317
|
-
---------------
|
1318
|
-
EOM
|
1319
|
-
|
1320
|
-
actual = e.message.gsub(/^.+:\d+/, "FILE:LINE")
|
1321
|
-
actual.gsub!(/block \(\d+ levels\) in /, "") if RUBY_VERSION >= "1.9.0"
|
1322
|
-
|
1323
|
-
assert_equal expected, actual
|
1324
|
-
end
|
1325
|
-
|
1326
|
-
def test_assert_raises_module
|
1327
|
-
@tc.assert_raises MyModule do
|
1328
|
-
raise AnError
|
1329
|
-
end
|
1330
|
-
end
|
1331
|
-
|
1332
|
-
##
|
1333
|
-
# *sigh* This is quite an odd scenario, but it is from real (albeit
|
1334
|
-
# ugly) test code in ruby-core:
|
1335
|
-
#
|
1336
|
-
# http://svn.ruby-lang.org/cgi-bin/viewvc.cgi?view=rev&revision=29259
|
1337
|
-
|
1338
|
-
def test_assert_raises_skip
|
1339
|
-
@assertion_count = 0
|
1340
|
-
|
1341
|
-
assert_triggered "skipped", Minitest::Skip do
|
1342
|
-
@tc.assert_raises ArgumentError do
|
1343
|
-
begin
|
1344
|
-
raise "blah"
|
1345
|
-
rescue
|
1346
|
-
skip "skipped"
|
1347
|
-
end
|
1348
|
-
end
|
1349
|
-
end
|
1350
|
-
end
|
1351
|
-
|
1352
|
-
def test_assert_raises_triggered_different
|
1353
|
-
e = assert_raises Minitest::Assertion do
|
1354
|
-
@tc.assert_raises RuntimeError do
|
1355
|
-
raise SyntaxError, "icky"
|
1356
|
-
end
|
1357
|
-
end
|
1358
|
-
|
1359
|
-
expected = clean <<-EOM.chomp
|
1360
|
-
[RuntimeError] exception expected, not
|
1361
|
-
Class: <SyntaxError>
|
1362
|
-
Message: <\"icky\">
|
1363
|
-
---Backtrace---
|
1364
|
-
FILE:LINE:in \`test_assert_raises_triggered_different\'
|
1365
|
-
---------------
|
1366
|
-
EOM
|
1367
|
-
|
1368
|
-
actual = e.message.gsub(/^.+:\d+/, "FILE:LINE")
|
1369
|
-
actual.gsub!(/block \(\d+ levels\) in /, "") if RUBY_VERSION >= "1.9.0"
|
1370
|
-
|
1371
|
-
assert_equal expected, actual
|
1372
|
-
end
|
1373
|
-
|
1374
|
-
def test_assert_raises_triggered_different_msg
|
1375
|
-
e = assert_raises Minitest::Assertion do
|
1376
|
-
@tc.assert_raises RuntimeError, "XXX" do
|
1377
|
-
raise SyntaxError, "icky"
|
1378
|
-
end
|
1379
|
-
end
|
1380
|
-
|
1381
|
-
expected = clean <<-EOM
|
1382
|
-
XXX.
|
1383
|
-
[RuntimeError] exception expected, not
|
1384
|
-
Class: <SyntaxError>
|
1385
|
-
Message: <\"icky\">
|
1386
|
-
---Backtrace---
|
1387
|
-
FILE:LINE:in \`test_assert_raises_triggered_different_msg\'
|
1388
|
-
---------------
|
1389
|
-
EOM
|
1390
|
-
|
1391
|
-
actual = e.message.gsub(/^.+:\d+/, "FILE:LINE")
|
1392
|
-
actual.gsub!(/block \(\d+ levels\) in /, "") if RUBY_VERSION >= "1.9.0"
|
1393
|
-
|
1394
|
-
assert_equal expected.chomp, actual
|
1395
|
-
end
|
1396
|
-
|
1397
|
-
def test_assert_raises_triggered_none
|
1398
|
-
e = assert_raises Minitest::Assertion do
|
1399
|
-
@tc.assert_raises Minitest::Assertion do
|
1400
|
-
# do nothing
|
1401
|
-
end
|
1402
|
-
end
|
1403
|
-
|
1404
|
-
expected = "Minitest::Assertion expected but nothing was raised."
|
1405
|
-
|
1406
|
-
assert_equal expected, e.message
|
1407
|
-
end
|
1408
|
-
|
1409
|
-
def test_assert_raises_triggered_none_msg
|
1410
|
-
e = assert_raises Minitest::Assertion do
|
1411
|
-
@tc.assert_raises Minitest::Assertion, "XXX" do
|
1412
|
-
# do nothing
|
1413
|
-
end
|
1414
|
-
end
|
1415
|
-
|
1416
|
-
expected = "XXX.\nMinitest::Assertion expected but nothing was raised."
|
1417
|
-
|
1418
|
-
assert_equal expected, e.message
|
1419
|
-
end
|
1420
|
-
|
1421
|
-
def test_assert_raises_subclass
|
1422
|
-
@tc.assert_raises StandardError do
|
1423
|
-
raise AnError
|
1424
|
-
end
|
1425
|
-
end
|
1426
|
-
|
1427
|
-
def test_assert_raises_subclass_triggered
|
1428
|
-
e = assert_raises Minitest::Assertion do
|
1429
|
-
@tc.assert_raises SomeError do
|
1430
|
-
raise AnError, "some message"
|
1431
|
-
end
|
1432
|
-
end
|
1433
|
-
|
1434
|
-
expected = clean <<-EOM
|
1435
|
-
[SomeError] exception expected, not
|
1436
|
-
Class: <AnError>
|
1437
|
-
Message: <\"some message\">
|
1438
|
-
---Backtrace---
|
1439
|
-
FILE:LINE:in \`test_assert_raises_subclass_triggered\'
|
1440
|
-
---------------
|
1441
|
-
EOM
|
1442
|
-
|
1443
|
-
actual = e.message.gsub(/^.+:\d+/, "FILE:LINE")
|
1444
|
-
actual.gsub!(/block \(\d+ levels\) in /, "") if RUBY_VERSION >= "1.9.0"
|
1445
|
-
|
1446
|
-
assert_equal expected.chomp, actual
|
1447
|
-
end
|
1448
|
-
|
1449
|
-
def test_assert_raises_exit
|
1450
|
-
@tc.assert_raises SystemExit do
|
1451
|
-
exit 1
|
1452
|
-
end
|
1453
|
-
end
|
1454
|
-
|
1455
|
-
def test_assert_raises_signals
|
1456
|
-
@tc.assert_raises SignalException do
|
1457
|
-
raise SignalException, :INT
|
1458
|
-
end
|
1459
|
-
end
|
1460
|
-
|
1461
|
-
def test_assert_respond_to
|
1462
|
-
@tc.assert_respond_to "blah", :empty?
|
1463
|
-
end
|
1464
|
-
|
1465
|
-
def test_assert_respond_to_triggered
|
1466
|
-
assert_triggered 'Expected "blah" (String) to respond to #rawr!.' do
|
1467
|
-
@tc.assert_respond_to "blah", :rawr!
|
1468
|
-
end
|
1469
|
-
end
|
1470
|
-
|
1471
|
-
def test_assert_same
|
1472
|
-
@assertion_count = 3
|
1473
|
-
|
1474
|
-
o = "blah"
|
1475
|
-
@tc.assert_same 1, 1
|
1476
|
-
@tc.assert_same :blah, :blah
|
1477
|
-
@tc.assert_same o, o
|
1478
|
-
end
|
1479
|
-
|
1480
|
-
def test_assert_same_triggered
|
1481
|
-
@assertion_count = 2
|
1482
|
-
|
1483
|
-
assert_triggered "Expected 2 (oid=N) to be the same as 1 (oid=N)." do
|
1484
|
-
@tc.assert_same 1, 2
|
1485
|
-
end
|
1486
|
-
|
1487
|
-
s1 = "blah"
|
1488
|
-
s2 = "blah"
|
1489
|
-
|
1490
|
-
assert_triggered 'Expected "blah" (oid=N) to be the same as "blah" (oid=N).' do
|
1491
|
-
@tc.assert_same s1, s2
|
1492
|
-
end
|
1493
|
-
end
|
1494
|
-
|
1495
|
-
def assert_deprecated name
|
1496
|
-
dep = /DEPRECATED: #{name}. From #{__FILE__}:\d+(?::.*)?/
|
1497
|
-
dep = "" if $-w.nil?
|
1498
|
-
|
1499
|
-
assert_output nil, dep do
|
1500
|
-
yield
|
1501
|
-
end
|
1502
|
-
end
|
1503
|
-
|
1504
|
-
def test_assert_send
|
1505
|
-
assert_deprecated :assert_send do
|
1506
|
-
@tc.assert_send [1, :<, 2]
|
1507
|
-
end
|
1508
|
-
end
|
1509
|
-
|
1510
|
-
def test_assert_send_bad
|
1511
|
-
assert_deprecated :assert_send do
|
1512
|
-
assert_triggered "Expected 1.>(*[2]) to return true." do
|
1513
|
-
@tc.assert_send [1, :>, 2]
|
1514
|
-
end
|
1515
|
-
end
|
1516
|
-
end
|
1517
|
-
|
1518
|
-
def test_assert_silent
|
1519
|
-
@assertion_count = 2
|
1520
|
-
|
1521
|
-
@tc.assert_silent do
|
1522
|
-
# do nothing
|
1523
|
-
end
|
1524
|
-
end
|
1525
|
-
|
1526
|
-
def test_assert_silent_triggered_err
|
1527
|
-
assert_triggered util_msg("", "blah blah", "In stderr") do
|
1528
|
-
@tc.assert_silent do
|
1529
|
-
$stderr.print "blah blah"
|
1530
|
-
end
|
1531
|
-
end
|
1532
|
-
end
|
1533
|
-
|
1534
|
-
def test_assert_silent_triggered_out
|
1535
|
-
@assertion_count = 2
|
1536
|
-
|
1537
|
-
assert_triggered util_msg("", "blah blah", "In stdout") do
|
1538
|
-
@tc.assert_silent do
|
1539
|
-
print "blah blah"
|
1540
|
-
end
|
1541
|
-
end
|
1542
|
-
end
|
1543
|
-
|
1544
|
-
def test_assert_throws
|
1545
|
-
@tc.assert_throws :blah do
|
1546
|
-
throw :blah
|
1547
|
-
end
|
1548
|
-
end
|
1549
|
-
|
1550
|
-
def test_assert_throws_name_error
|
1551
|
-
@tc.assert_raises NameError do
|
1552
|
-
@tc.assert_throws :blah do
|
1553
|
-
raise NameError
|
1554
|
-
end
|
1555
|
-
end
|
1556
|
-
end
|
1557
|
-
|
1558
|
-
def test_assert_throws_argument_exception
|
1559
|
-
@tc.assert_raises ArgumentError do
|
1560
|
-
@tc.assert_throws :blah do
|
1561
|
-
raise ArgumentError
|
1562
|
-
end
|
1563
|
-
end
|
1564
|
-
end
|
1565
|
-
|
1566
|
-
def test_assert_throws_different
|
1567
|
-
assert_triggered "Expected :blah to have been thrown, not :not_blah." do
|
1568
|
-
@tc.assert_throws :blah do
|
1569
|
-
throw :not_blah
|
1570
|
-
end
|
1571
|
-
end
|
1572
|
-
end
|
1573
|
-
|
1574
|
-
def test_assert_throws_unthrown
|
1575
|
-
assert_triggered "Expected :blah to have been thrown." do
|
1576
|
-
@tc.assert_throws :blah do
|
1577
|
-
# do nothing
|
1578
|
-
end
|
1579
|
-
end
|
1580
|
-
end
|
1581
|
-
|
1582
|
-
def test_capture_io
|
1583
|
-
@assertion_count = 0
|
1584
|
-
|
1585
|
-
non_verbose do
|
1586
|
-
out, err = capture_io do
|
1587
|
-
puts "hi"
|
1588
|
-
$stderr.puts "bye!"
|
1589
|
-
end
|
1590
|
-
|
1591
|
-
assert_equal "hi\n", out
|
1592
|
-
assert_equal "bye!\n", err
|
1593
|
-
end
|
1594
|
-
end
|
1595
|
-
|
1596
|
-
def test_capture_subprocess_io
|
1597
|
-
@assertion_count = 0
|
1598
|
-
|
1599
|
-
non_verbose do
|
1600
|
-
out, err = capture_subprocess_io do
|
1601
|
-
system("echo hi")
|
1602
|
-
system("echo bye! 1>&2")
|
1603
|
-
end
|
1604
|
-
|
1605
|
-
assert_equal "hi\n", out
|
1606
|
-
assert_equal "bye!", err.strip
|
1607
|
-
end
|
1608
|
-
end
|
1609
|
-
|
1610
|
-
def test_class_asserts_match_refutes
|
1611
|
-
@assertion_count = 0
|
1612
|
-
|
1613
|
-
methods = Minitest::Assertions.public_instance_methods
|
1614
|
-
methods.map!(&:to_s) if Symbol === methods.first
|
1615
|
-
|
1616
|
-
# These don't have corresponding refutes _on purpose_. They're
|
1617
|
-
# useless and will never be added, so don't bother.
|
1618
|
-
ignores = %w[assert_output assert_raises assert_send
|
1619
|
-
assert_silent assert_throws assert_mock]
|
1620
|
-
|
1621
|
-
# These are test/unit methods. I'm not actually sure why they're still here
|
1622
|
-
ignores += %w[assert_no_match assert_not_equal assert_not_nil
|
1623
|
-
assert_not_same assert_nothing_raised
|
1624
|
-
assert_nothing_thrown assert_raise]
|
1625
|
-
|
1626
|
-
asserts = methods.grep(/^assert/).sort - ignores
|
1627
|
-
refutes = methods.grep(/^refute/).sort - ignores
|
1628
|
-
|
1629
|
-
assert_empty refutes.map { |n| n.sub(/^refute/, "assert") } - asserts
|
1630
|
-
assert_empty asserts.map { |n| n.sub(/^assert/, "refute") } - refutes
|
1631
|
-
end
|
1632
|
-
|
1633
|
-
def test_flunk
|
1634
|
-
assert_triggered "Epic Fail!" do
|
1635
|
-
@tc.flunk
|
1636
|
-
end
|
1637
|
-
end
|
1638
|
-
|
1639
|
-
def test_flunk_message
|
1640
|
-
assert_triggered @zomg do
|
1641
|
-
@tc.flunk @zomg
|
1642
|
-
end
|
1643
|
-
end
|
1644
|
-
|
1645
|
-
def test_message
|
1646
|
-
@assertion_count = 0
|
1647
|
-
|
1648
|
-
assert_equal "blah2.", @tc.message { "blah2" }.call
|
1649
|
-
assert_equal "blah2.", @tc.message("") { "blah2" }.call
|
1650
|
-
assert_equal "blah1.\nblah2.", @tc.message(:blah1) { "blah2" }.call
|
1651
|
-
assert_equal "blah1.\nblah2.", @tc.message("blah1") { "blah2" }.call
|
1652
|
-
|
1653
|
-
message = proc { "blah1" }
|
1654
|
-
assert_equal "blah1.\nblah2.", @tc.message(message) { "blah2" }.call
|
1655
|
-
|
1656
|
-
message = @tc.message { "blah1" }
|
1657
|
-
assert_equal "blah1.\nblah2.", @tc.message(message) { "blah2" }.call
|
1658
|
-
end
|
1659
|
-
|
1660
|
-
def test_message_message
|
1661
|
-
assert_triggered "whoops.\nExpected: 1\n Actual: 2" do
|
1662
|
-
@tc.assert_equal 1, 2, message { "whoops" }
|
1663
|
-
end
|
1664
|
-
end
|
1665
|
-
|
1666
|
-
def test_message_lambda
|
1667
|
-
assert_triggered "whoops.\nExpected: 1\n Actual: 2" do
|
1668
|
-
@tc.assert_equal 1, 2, lambda { "whoops" }
|
1669
|
-
end
|
1670
|
-
end
|
1671
|
-
|
1672
|
-
def test_message_deferred
|
1673
|
-
@assertion_count, var = 0, nil
|
1674
|
-
|
1675
|
-
msg = message { var = "blah" }
|
1676
|
-
|
1677
|
-
assert_nil var
|
1678
|
-
|
1679
|
-
msg.call
|
1680
|
-
|
1681
|
-
assert_equal "blah", var
|
1682
|
-
end
|
1683
|
-
|
1684
|
-
def test_pass
|
1685
|
-
@tc.pass
|
1686
|
-
end
|
1687
|
-
|
1688
|
-
def test_prints
|
1689
|
-
printer = Class.new { extend Minitest::Assertions }
|
1690
|
-
@tc.assert_equal '"test"', printer.mu_pp(ImmutableString.new "test")
|
1691
|
-
end
|
1692
|
-
|
1693
|
-
def test_refute
|
1694
|
-
@assertion_count = 2
|
1695
|
-
|
1696
|
-
@tc.assert_equal false, @tc.refute(false), "returns false on success"
|
1697
|
-
end
|
1698
|
-
|
1699
|
-
def test_refute_empty
|
1700
|
-
@assertion_count = 2
|
1701
|
-
|
1702
|
-
@tc.refute_empty [1]
|
1703
|
-
end
|
1704
|
-
|
1705
|
-
def test_refute_empty_triggered
|
1706
|
-
@assertion_count = 2
|
1707
|
-
|
1708
|
-
assert_triggered "Expected [] to not be empty." do
|
1709
|
-
@tc.refute_empty []
|
1710
|
-
end
|
1711
|
-
end
|
1712
|
-
|
1713
|
-
def test_refute_equal
|
1714
|
-
@tc.refute_equal "blah", "yay"
|
1715
|
-
end
|
1716
|
-
|
1717
|
-
def test_refute_equal_triggered
|
1718
|
-
assert_triggered 'Expected "blah" to not be equal to "blah".' do
|
1719
|
-
@tc.refute_equal "blah", "blah"
|
1720
|
-
end
|
1721
|
-
end
|
1722
|
-
|
1723
|
-
def test_refute_in_delta
|
1724
|
-
@tc.refute_in_delta 0.0, 1.0 / 1000, 0.000001
|
1725
|
-
end
|
1726
|
-
|
1727
|
-
def test_refute_in_delta_triggered
|
1728
|
-
x = maglev? ? "0.100000xxx" : "0.1"
|
1729
|
-
assert_triggered "Expected |0.0 - 0.001| (0.001) to not be <= #{x}." do
|
1730
|
-
@tc.refute_in_delta 0.0, 1.0 / 1000, 0.1
|
1731
|
-
end
|
1732
|
-
end
|
1733
|
-
|
1734
|
-
def test_refute_in_epsilon
|
1735
|
-
@tc.refute_in_epsilon 10_000, 9990-1
|
1736
|
-
end
|
1737
|
-
|
1738
|
-
def test_refute_in_epsilon_triggered
|
1739
|
-
assert_triggered "Expected |10000 - 9990| (10) to not be <= 10.0." do
|
1740
|
-
@tc.refute_in_epsilon 10_000, 9990
|
1741
|
-
flunk
|
1742
|
-
end
|
1743
|
-
end
|
1744
|
-
|
1745
|
-
def test_refute_includes
|
1746
|
-
@assertion_count = 2
|
1747
|
-
|
1748
|
-
@tc.refute_includes [true], false
|
1749
|
-
end
|
1750
|
-
|
1751
|
-
def test_refute_includes_triggered
|
1752
|
-
@assertion_count = 3
|
1753
|
-
|
1754
|
-
e = @tc.assert_raises Minitest::Assertion do
|
1755
|
-
@tc.refute_includes [true], true
|
1756
|
-
end
|
1757
|
-
|
1758
|
-
expected = "Expected [true] to not include true."
|
1759
|
-
assert_equal expected, e.message
|
1760
|
-
end
|
1761
|
-
|
1762
|
-
def test_refute_instance_of
|
1763
|
-
@tc.refute_instance_of Array, "blah"
|
1764
|
-
end
|
1765
|
-
|
1766
|
-
def test_refute_instance_of_triggered
|
1767
|
-
assert_triggered 'Expected "blah" to not be an instance of String.' do
|
1768
|
-
@tc.refute_instance_of String, "blah"
|
1769
|
-
end
|
1770
|
-
end
|
1771
|
-
|
1772
|
-
def test_refute_kind_of
|
1773
|
-
@tc.refute_kind_of Array, "blah"
|
1774
|
-
end
|
1775
|
-
|
1776
|
-
def test_refute_kind_of_triggered
|
1777
|
-
assert_triggered 'Expected "blah" to not be a kind of String.' do
|
1778
|
-
@tc.refute_kind_of String, "blah"
|
1779
|
-
end
|
1780
|
-
end
|
1781
|
-
|
1782
|
-
def test_refute_match
|
1783
|
-
@assertion_count = 2
|
1784
|
-
@tc.refute_match(/\d+/, "blah blah blah")
|
1785
|
-
end
|
1786
|
-
|
1787
|
-
def test_refute_match_matcher_object
|
1788
|
-
@assertion_count = 2
|
1789
|
-
@tc.refute_match Object.new, 5 # default #=~ returns false
|
1790
|
-
end
|
1791
|
-
|
1792
|
-
def test_refute_match_object_triggered
|
1793
|
-
@assertion_count = 2
|
1794
|
-
|
1795
|
-
pattern = Object.new
|
1796
|
-
def pattern.=~ _; true end
|
1797
|
-
def pattern.inspect; "[Object]" end
|
1798
|
-
|
1799
|
-
assert_triggered "Expected [Object] to not match 5." do
|
1800
|
-
@tc.refute_match pattern, 5
|
1801
|
-
end
|
1802
|
-
end
|
1803
|
-
|
1804
|
-
def test_refute_match_triggered
|
1805
|
-
@assertion_count = 2
|
1806
|
-
assert_triggered 'Expected /\w+/ to not match "blah blah blah".' do
|
1807
|
-
@tc.refute_match(/\w+/, "blah blah blah")
|
1808
|
-
end
|
1809
|
-
end
|
1810
|
-
|
1811
|
-
def test_refute_nil
|
1812
|
-
@tc.refute_nil 42
|
1813
|
-
end
|
1814
|
-
|
1815
|
-
def test_refute_nil_triggered
|
1816
|
-
assert_triggered "Expected nil to not be nil." do
|
1817
|
-
@tc.refute_nil nil
|
1818
|
-
end
|
1819
|
-
end
|
1820
|
-
|
1821
|
-
def test_refute_predicate
|
1822
|
-
@tc.refute_predicate "42", :empty?
|
1823
|
-
end
|
1824
|
-
|
1825
|
-
def test_refute_predicate_triggered
|
1826
|
-
assert_triggered 'Expected "" to not be empty?.' do
|
1827
|
-
@tc.refute_predicate "", :empty?
|
1828
|
-
end
|
1829
|
-
end
|
1830
|
-
|
1831
|
-
def test_refute_operator
|
1832
|
-
@tc.refute_operator 2, :<, 1
|
1833
|
-
end
|
1834
|
-
|
1835
|
-
def test_refute_operator_bad_object
|
1836
|
-
bad = Object.new
|
1837
|
-
def bad.== _; true end
|
1838
|
-
|
1839
|
-
@tc.refute_operator true, :equal?, bad
|
1840
|
-
end
|
1841
|
-
|
1842
|
-
def test_refute_operator_triggered
|
1843
|
-
assert_triggered "Expected 2 to not be > 1." do
|
1844
|
-
@tc.refute_operator 2, :>, 1
|
1845
|
-
end
|
1846
|
-
end
|
1847
|
-
|
1848
|
-
def test_refute_respond_to
|
1849
|
-
@tc.refute_respond_to "blah", :rawr!
|
1850
|
-
end
|
1851
|
-
|
1852
|
-
def test_refute_respond_to_triggered
|
1853
|
-
assert_triggered 'Expected "blah" to not respond to empty?.' do
|
1854
|
-
@tc.refute_respond_to "blah", :empty?
|
1855
|
-
end
|
1856
|
-
end
|
1857
|
-
|
1858
|
-
def test_refute_same
|
1859
|
-
@tc.refute_same 1, 2
|
1860
|
-
end
|
1861
|
-
|
1862
|
-
def test_refute_same_triggered
|
1863
|
-
assert_triggered "Expected 1 (oid=N) to not be the same as 1 (oid=N)." do
|
1864
|
-
@tc.refute_same 1, 1
|
1865
|
-
end
|
1866
|
-
end
|
1867
|
-
|
1868
|
-
def test_skip
|
1869
|
-
@assertion_count = 0
|
1870
|
-
|
1871
|
-
assert_triggered "haha!", Minitest::Skip do
|
1872
|
-
@tc.skip "haha!"
|
1873
|
-
end
|
1874
|
-
end
|
1875
|
-
|
1876
|
-
def test_runnable_methods_random
|
1877
|
-
@assertion_count = 0
|
1878
|
-
|
1879
|
-
sample_test_case = Class.new FakeNamedTest do
|
1880
|
-
def self.test_order; :random; end
|
1881
|
-
def test_test1; assert "does not matter" end
|
1882
|
-
def test_test2; assert "does not matter" end
|
1883
|
-
def test_test3; assert "does not matter" end
|
1884
|
-
end
|
1885
|
-
|
1886
|
-
srand 42
|
1887
|
-
expected = case
|
1888
|
-
when maglev? then
|
1889
|
-
%w[test_test2 test_test3 test_test1]
|
1890
|
-
else
|
1891
|
-
%w[test_test2 test_test1 test_test3]
|
1892
|
-
end
|
1893
|
-
assert_equal expected, sample_test_case.runnable_methods
|
1894
|
-
end
|
1895
|
-
|
1896
|
-
def test_runnable_methods_sorted
|
1897
|
-
@assertion_count = 0
|
1898
|
-
|
1899
|
-
sample_test_case = Class.new FakeNamedTest do
|
1900
|
-
def self.test_order; :sorted end
|
1901
|
-
def test_test3; assert "does not matter" end
|
1902
|
-
def test_test2; assert "does not matter" end
|
1903
|
-
def test_test1; assert "does not matter" end
|
1904
|
-
end
|
1905
|
-
|
1906
|
-
expected = %w[test_test1 test_test2 test_test3]
|
1907
|
-
assert_equal expected, sample_test_case.runnable_methods
|
1908
|
-
end
|
1909
|
-
|
1910
|
-
def test_i_suck_and_my_tests_are_order_dependent_bang_sets_test_order_alpha
|
1911
|
-
@assertion_count = 0
|
1912
|
-
|
1913
|
-
shitty_test_case = Class.new FakeNamedTest
|
1914
|
-
|
1915
|
-
shitty_test_case.i_suck_and_my_tests_are_order_dependent!
|
1916
|
-
|
1917
|
-
assert_equal :alpha, shitty_test_case.test_order
|
1918
|
-
end
|
1919
|
-
|
1920
|
-
def test_i_suck_and_my_tests_are_order_dependent_bang_does_not_warn
|
1921
|
-
@assertion_count = 0
|
1922
|
-
|
1923
|
-
shitty_test_case = Class.new FakeNamedTest
|
1924
|
-
|
1925
|
-
def shitty_test_case.test_order; :lol end
|
1926
|
-
|
1927
|
-
assert_silent do
|
1928
|
-
shitty_test_case.i_suck_and_my_tests_are_order_dependent!
|
1929
|
-
end
|
1930
|
-
end
|
1931
|
-
|
1932
|
-
def assert_triggered expected, klass = Minitest::Assertion
|
1933
|
-
e = assert_raises klass do
|
1934
|
-
yield
|
1935
|
-
end
|
1936
|
-
|
1937
|
-
msg = e.message.sub(/(---Backtrace---).*/m, '\1')
|
1938
|
-
msg.gsub!(/\(oid=[-0-9]+\)/, "(oid=N)")
|
1939
|
-
msg.gsub!(/(\d\.\d{6})\d+/, '\1xxx') # normalize: ruby version, impl, platform
|
1940
|
-
|
1941
|
-
assert_msg = Regexp === expected ? :assert_match : :assert_equal
|
1942
|
-
self.send assert_msg, expected, msg
|
1943
|
-
end
|
1944
|
-
|
1945
|
-
def util_msg exp, act, msg = nil
|
1946
|
-
s = "Expected: #{exp.inspect}\n Actual: #{act.inspect}"
|
1947
|
-
s = "#{msg}.\n#{s}" if msg
|
1948
|
-
s
|
1949
|
-
end
|
1950
|
-
|
1951
|
-
def without_diff
|
1952
|
-
old_diff = Minitest::Assertions.diff
|
1953
|
-
Minitest::Assertions.diff = nil
|
1954
|
-
|
1955
|
-
yield
|
1956
|
-
ensure
|
1957
|
-
Minitest::Assertions.diff = old_diff
|
1958
|
-
end
|
1959
|
-
end
|
1960
|
-
|
1961
|
-
class TestMinitestGuard < Minitest::Test
|
1962
|
-
parallelize_me!
|
1963
|
-
|
1964
|
-
def test_mri_eh
|
1965
|
-
assert self.class.mri? "ruby blah"
|
1966
|
-
assert self.mri? "ruby blah"
|
1967
|
-
end
|
1968
|
-
|
1969
|
-
def test_jruby_eh
|
1970
|
-
assert self.class.jruby? "java"
|
1971
|
-
assert self.jruby? "java"
|
1972
|
-
end
|
1973
|
-
|
1974
|
-
def test_rubinius_eh
|
1975
|
-
assert self.class.rubinius? "rbx"
|
1976
|
-
assert self.rubinius? "rbx"
|
1136
|
+
def test_osx_eh
|
1137
|
+
assert self.class.osx? "darwin"
|
1138
|
+
assert self.osx? "darwin"
|
1977
1139
|
end
|
1978
1140
|
|
1979
1141
|
def test_windows_eh
|
@@ -2087,12 +1249,12 @@ class TestMinitestUnitRecording < MetaMetaMetaTestCase
|
|
2087
1249
|
|
2088
1250
|
exp = clean "
|
2089
1251
|
Error:
|
2090
|
-
|
1252
|
+
FakeNamedTestXX#test_method:
|
2091
1253
|
AnError: AnError
|
2092
1254
|
FILE:LINE:in `test_method'
|
2093
1255
|
|
2094
1256
|
Error:
|
2095
|
-
|
1257
|
+
FakeNamedTestXX#test_method:
|
2096
1258
|
RuntimeError: unhandled exception
|
2097
1259
|
FILE:LINE:in `teardown'
|
2098
1260
|
"
|