diff options
-rw-r--r-- | ChangeLog | 4 | ||||
-rw-r--r-- | lib/minitest/unit.rb | 39 | ||||
-rw-r--r-- | lib/test/unit.rb | 1 | ||||
-rw-r--r-- | test/minitest/test_minitest_unit.rb | 19 |
4 files changed, 42 insertions, 21 deletions
@@ -27,9 +27,7 @@ Wed Jun 1 15:40:46 2011 Nobuyoshi Nakada <nobu@ruby-lang.org> Wed Jun 1 14:07:57 2011 Ryan Davis <ryand-ruby@zenspider.com> - * lib/minitest/*: MOSTLY Imported minitest 2.2.1 (r6277)... One - feature wouldn't run and I don't know how to fix it. I need - sora_h's help to get it running happy with test/unit. + * lib/minitest/*: Imported minitest 2.2.2 (r6281) * test/minitest/*: ditto Wed Jun 1 12:35:50 2011 Ryan Davis <ryand-ruby@zenspider.com> diff --git a/lib/minitest/unit.rb b/lib/minitest/unit.rb index 41f127a208..199360e644 100644 --- a/lib/minitest/unit.rb +++ b/lib/minitest/unit.rb @@ -121,10 +121,11 @@ module MiniTest Tempfile.open("expect") do |a| a.puts expect - a.rewind + a.flush + Tempfile.open("butwas") do |b| b.puts butwas - b.rewind + b.flush result = `#{MiniTest::Assertions.diff} #{a.path} #{b.path}` result.sub!(/^\-\-\- .+/, "--- expected") @@ -216,7 +217,7 @@ module MiniTest # See also: MiniTest::Assertions.diff def assert_equal exp, act, msg = nil - msg = message(msg) { diff exp, act } + msg = message(msg, "") { diff exp, act } assert(exp == act, msg) end @@ -464,10 +465,10 @@ module MiniTest ## # Returns a proc that will output +msg+ along with the default message. - def message msg = nil, &default + def message msg = nil, ending = ".", &default proc { custom_message = "#{msg}.\n" unless msg.nil? or msg.to_s.empty? - "#{custom_message}#{default.call}." + "#{custom_message}#{default.call}#{ending}" } end @@ -619,7 +620,7 @@ module MiniTest end class Unit - VERSION = "2.2.1" # :nodoc: + VERSION = "2.2.2" # :nodoc: attr_accessor :report, :failures, :errors, :skips # :nodoc: attr_accessor :test_count, :assertion_count # :nodoc: @@ -691,6 +692,23 @@ module MiniTest end ## + # Tells MiniTest::Unit to delegate to +runner+, an instance of a + # MiniTest::Unit subclass, when MiniTest::Unit#run is called. + + def self.runner= runner + @@runner = runner + end + + ## + # Returns the MiniTest::Unit subclass instance that will be used + # to run the tests. A MiniTest::Unit instance is the default + # runner. + + def self.runner + @@runner ||= self.new + end + + ## # Return all plugins' run methods (methods that start with "run_"). def self.plugins @@ -860,9 +878,16 @@ module MiniTest end ## - # Top level driver, controls all output and filtering. + # Begins the full test run. Delegates to +runner+'s #_run method. def run args = [] + self.class.runner._run(args) + end + + ## + # Top level driver, controls all output and filtering. + + def _run args = [] self.options = process_args args puts "Run options: #{help}" diff --git a/lib/test/unit.rb b/lib/test/unit.rb index 6061e3b4bd..620d48f61f 100644 --- a/lib/test/unit.rb +++ b/lib/test/unit.rb @@ -595,6 +595,7 @@ module Test yield self if block_given? files end + Runner.runner = @runner @options = @runner.option_parser @argv = argv end diff --git a/test/minitest/test_minitest_unit.rb b/test/minitest/test_minitest_unit.rb index bc4ffac7b7..b56fb0dc18 100644 --- a/test/minitest/test_minitest_unit.rb +++ b/test/minitest/test_minitest_unit.rb @@ -51,7 +51,7 @@ Finished tests in 0.00 def teardown MiniTest::Unit.output = $stdout - # HACK for ruby-trunk: MiniTest::Unit.runner = nil + MiniTest::Unit.runner = nil Object.send :remove_const, :ATestCase if defined? ATestCase end @@ -392,13 +392,10 @@ not yet end def test_default_runner_is_minitest_unit - skip "ruby-trunk won't run with runner code :(" - assert_instance_of MiniTest::Unit, MiniTest::Unit.runner end def test_run_with_other_runner - skip "ruby-trunk won't run with runner code :(" runner = Class.new(MiniTest::Unit) do # Run once before each suite @@ -542,7 +539,7 @@ class TestMiniTestUnitTestCase < MiniTest::Unit::TestCase @@ -1 +1 @@ -#<#<Class:0xXXXXXX>:0xXXXXXX @name=\"a\"> +#<#<Class:0xXXXXXX>:0xXXXXXX @name=\"b\"> - .".gsub(/^ +/, "") + ".gsub(/^ +/, "") util_assert_triggered msg do @tc.assert_equal o1, o2 @@ -555,7 +552,7 @@ class TestMiniTestUnitTestCase < MiniTest::Unit::TestCase msg = "No visible difference. You should look at your implementation of Object#==. - #<Object:0xXXXXXX>.".gsub(/^ +/, "") + #<Object:0xXXXXXX>".gsub(/^ +/, "") util_assert_triggered msg do @tc.assert_equal o1, o2 @@ -568,7 +565,7 @@ class TestMiniTestUnitTestCase < MiniTest::Unit::TestCase @@ -1 +1 @@ -\"hahahahahahahahahahahahahahahahahahahaha\" +\"blahblahblahblahblahblahblahblahblahblah\" - .".gsub(/^ +/, "") + ".gsub(/^ +/, "") util_assert_triggered msg do o1 = "haha" * 10 @@ -581,7 +578,7 @@ class TestMiniTestUnitTestCase < MiniTest::Unit::TestCase def test_assert_equal_different_long_invisible msg = "No visible difference. You should look at your implementation of String#==. - \"blahblahblahblahblahblahblahblahblahblah\".".gsub(/^ +/, "") + \"blahblahblahblahblahblahblahblahblahblah\"".gsub(/^ +/, "") util_assert_triggered msg do o1 = "blah" * 10 @@ -600,7 +597,7 @@ class TestMiniTestUnitTestCase < MiniTest::Unit::TestCase @@ -1 +1 @@ -\"hahahahahahahahahahahahahahahahahahahaha\" +\"blahblahblahblahblahblahblahblahblahblah\" - .".gsub(/^ +/, "") + ".gsub(/^ +/, "") util_assert_triggered msg do o1 = "haha" * 10 @@ -622,7 +619,7 @@ class TestMiniTestUnitTestCase < MiniTest::Unit::TestCase end def test_assert_equal_different_short_multiline - msg = "--- expected\n+++ actual\n@@ -1,2 +1,2 @@\n \"a\n-b\"\n+c\"\n." + msg = "--- expected\n+++ actual\n@@ -1,2 +1,2 @@\n \"a\n-b\"\n+c\"\n" util_assert_triggered msg do @tc.assert_equal "a\nb", "a\nc" end @@ -1292,7 +1289,7 @@ FILE:LINE:in `test_assert_raises_triggered_subclass' end def util_msg exp, act, msg = nil - s = "Expected: #{exp.inspect}\n Actual: #{act.inspect}." + s = "Expected: #{exp.inspect}\n Actual: #{act.inspect}" s = "#{msg}.\n#{s}" if msg s end |