diff --git a/ChangeLog b/ChangeLog index 1268ea7484..3598eb3688 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,8 @@ +Tue Jun 14 01:10:38 2011 Yusuke Endoh + + * test/coverage/test_coverage.rb: add a test for restart. a patch + from Xavier Shay. [ruby-core:36745] + Tue Jun 14 01:05:10 2011 Yusuke Endoh * ext/coverage/coverage.c: make it restartable. [ruby-core:36539] diff --git a/test/coverage/test_coverage.rb b/test/coverage/test_coverage.rb index ace49d3282..56966b1f0e 100644 --- a/test/coverage/test_coverage.rb +++ b/test/coverage/test_coverage.rb @@ -1,5 +1,6 @@ require "test/unit" require "coverage" +require "tmpdir" class TestCoverage < Test::Unit::TestCase def test_result_without_start @@ -14,4 +15,29 @@ class TestCoverage < Test::Unit::TestCase assert_kind_of(Array, val) end end + + def test_restarting_coverage + loaded_features = $".dup + + Dir.mktmpdir {|tmp| + Dir.chdir(tmp) { + File.open("test.rb", "w") do |f| + f.puts <<-EOS + def coverage_test_method + :ok + end + EOS + end + + Coverage.start + require tmp + '/test.rb' + Coverage.result + Coverage.start + coverage_test_method + assert_equal 1, Coverage.result.size + } + } + ensure + $".replace loaded_features + end end