1- require 'stringio'
21require 'pathname'
3- require 'minitest/autorun '
2+ require 'test/metametameta '
43
54module MyModule ; end
65class AnError < StandardError ; include MyModule ; end
76class ImmutableString < String ; def inspect ; super . freeze ; end ; end
87
9- class TestMiniTestUnit < MiniTest :: Unit :: TestCase
8+ class TestMiniTestUnit < MetaMetaMetaTestCase
109 pwd = Pathname . new ( File . expand_path ( Dir . pwd ) )
1110 basedir = Pathname . new ( File . expand_path ( "lib/minitest" ) ) + 'mini'
1211 basedir = basedir . relative_path_from ( pwd ) . to_s
@@ -16,38 +15,6 @@ class TestMiniTestUnit < MiniTest::Unit::TestCase
1615 "#{ MINITEST_BASE_DIR } /test.rb:139:in `run'" ,
1716 "#{ MINITEST_BASE_DIR } /test.rb:106:in `run'" ]
1817
19- def assert_report expected = nil
20- expected ||= "Run options: --seed 42
21-
22- # Running tests:
23-
24- .
25-
26- Finished tests in 0.00
27-
28- 1 tests, 1 assertions, 0 failures, 0 errors, 0 skips
29- "
30- output = @output . string . sub ( /Finished tests in .*/ , "Finished tests in 0.00" )
31- output . sub! ( /Loaded suite .*/ , 'Loaded suite blah' )
32- output . sub! ( /^(\s +)(?:#{ Regexp . union ( __FILE__ , File . expand_path ( __FILE__ ) ) } ):\d +:/o , '\1FILE:LINE:' )
33- output . sub! ( /\[ (?:#{ Regexp . union ( __FILE__ , File . expand_path ( __FILE__ ) ) } ):\d +\] /o , '[FILE:LINE]' )
34- assert_equal ( expected , output )
35- end
36-
37- def setup
38- srand 42
39- MiniTest ::Unit ::TestCase . reset
40- @tu = MiniTest ::Unit . new
41- @output = StringIO . new ( "" )
42- MiniTest ::Unit . runner = nil # protect the outer runner from the inner tests
43- MiniTest ::Unit . output = @output
44- end
45-
46- def teardown
47- MiniTest ::Unit . output = $stdout
48- Object . send :remove_const , :ATestCase if defined? ATestCase
49- end
50-
5118 def test_class_puke_with_assertion_failed
5219 exception = MiniTest ::Assertion . new "Oh no!"
5320 exception . set_backtrace [ "unhappy" ]
@@ -229,21 +196,23 @@ def test_error
229196
230197 @tu . run %w[ --seed 42 ]
231198
232- expected = "Run options: --seed 42
199+ expected = <<-EOM . gsub ( /^ {6}/ , '' )
200+ Run options: --seed 42
233201
234- # Running tests:
202+ # Running tests:
235203
236- E.
204+ E.
237205
238- Finished tests in 0.00
206+ Finished tests in 0.00
239207
240- 1) Error:
241- test_error(ATestCase):
242- RuntimeError: unhandled exception
243- FILE:LINE:in `test_error'
208+ 1) Error:
209+ test_error(ATestCase):
210+ RuntimeError: unhandled exception
211+ FILE:LINE:in `test_error'
212+
213+ 2 tests, 1 assertions, 0 failures, 1 errors, 0 skips
214+ EOM
244215
245- 2 tests, 1 assertions, 0 failures, 1 errors, 0 skips
246- "
247216 assert_report expected
248217 end
249218
@@ -621,6 +590,8 @@ def util_expand_bt bt
621590
622591class TestMiniTestUnitTestCase < MiniTest ::Unit ::TestCase
623592 def setup
593+ super
594+
624595 MiniTest ::Unit ::TestCase . reset
625596
626597 @tc = MiniTest ::Unit ::TestCase . new 'fake tc'
0 commit comments