summaryrefslogtreecommitdiff
path: root/test
diff options
context:
space:
mode:
authortenderlove <tenderlove@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2015-02-13 15:53:47 +0000
committertenderlove <tenderlove@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2015-02-13 15:53:47 +0000
commita86eacf552c0f3a7862d6891cf174007d96f656a (patch)
tree9e2bd8acbd7907eb7816acf63c55d4d11b09a71a /test
parentecccd9f42ce9b75d5a3fc742e81f1dc79bf03abd (diff)
* 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
Diffstat (limited to 'test')
-rw-r--r--test/coverage/test_coverage.rb26
1 files changed, 26 insertions, 0 deletions
diff --git a/test/coverage/test_coverage.rb b/test/coverage/test_coverage.rb
index f4f192a..bade668 100644
--- a/test/coverage/test_coverage.rb
+++ b/test/coverage/test_coverage.rb
@@ -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