зеркало из https://github.com/github/ruby.git
ext/coverage/coverage.c: add Coverage.enabled?
* ext/coverage/coverage.c (rb_coverage_running): add to quickly check if coverage is enabled. patched by Burke Libbey <burke AT libbey.me> in [ruby-core:81726]. [Feature #13667] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@59716 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
Родитель
3d46d51c45
Коммит
95d949d571
|
@ -75,6 +75,20 @@ rb_coverage_result(VALUE klass)
|
|||
return ncoverages;
|
||||
}
|
||||
|
||||
/*
|
||||
* call-seq:
|
||||
* Coverage.running? => bool
|
||||
*
|
||||
* Returns true if coverage stats are currently being collected (after
|
||||
* Coverage.start call, but before Coverage.result call)
|
||||
*/
|
||||
static VALUE
|
||||
rb_coverage_running(VALUE klass)
|
||||
{
|
||||
VALUE coverages = rb_get_coverages();
|
||||
return RTEST(coverages) ? Qtrue : Qfalse;
|
||||
}
|
||||
|
||||
/* Coverage provides coverage measurement feature for Ruby.
|
||||
* This feature is experimental, so these APIs may be changed in future.
|
||||
*
|
||||
|
@ -115,4 +129,5 @@ Init_coverage(void)
|
|||
rb_define_module_function(rb_mCoverage, "start", rb_coverage_start, 0);
|
||||
rb_define_module_function(rb_mCoverage, "result", rb_coverage_result, 0);
|
||||
rb_define_module_function(rb_mCoverage, "peek_result", rb_coverage_peek_result, 0);
|
||||
rb_define_module_function(rb_mCoverage, "running?", rb_coverage_running, 0);
|
||||
}
|
||||
|
|
|
@ -23,6 +23,16 @@ class TestCoverage < Test::Unit::TestCase
|
|||
end
|
||||
end
|
||||
|
||||
def test_coverage_running?
|
||||
refute Coverage.running?
|
||||
Coverage.start
|
||||
assert Coverage.running?
|
||||
Coverage.peek_result
|
||||
assert Coverage.running?
|
||||
Coverage.result
|
||||
refute Coverage.running?
|
||||
end
|
||||
|
||||
def test_coverage_snapshot
|
||||
loaded_features = $".dup
|
||||
|
||||
|
|
Загрузка…
Ссылка в новой задаче