mirror of
https://github.com/ruby/ruby.git
synced 2022-11-09 12:17:21 -05:00
* ext/coverage/coverage.c: Add Coverage.peek_result. Allows you to
capture coverage information without stopping the coverage tool. [ruby-core:67940] [Feature #10816] * test/coverage/test_coverage.rb: test for change. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@49589 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
parent
ecccd9f42c
commit
a86eacf552
4 changed files with 69 additions and 8 deletions
|
@ -16,6 +16,32 @@ class TestCoverage < Test::Unit::TestCase
|
|||
end
|
||||
end
|
||||
|
||||
def test_coverage_snapshot
|
||||
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'
|
||||
cov = Coverage.peek_result[tmp + '/test.rb']
|
||||
coverage_test_method
|
||||
cov2 = Coverage.peek_result[tmp + '/test.rb']
|
||||
assert_equal cov[1] + 1, cov2[1]
|
||||
assert_equal cov2, Coverage.result[tmp + '/test.rb']
|
||||
}
|
||||
}
|
||||
ensure
|
||||
$".replace loaded_features
|
||||
end
|
||||
|
||||
def test_restarting_coverage
|
||||
loaded_features = $".dup
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue