Project

General

Profile

Feature #13667 ยป 0001-Add-Coverage.enabled-to-quickly-check-if-coverage-is.patch

burke (Burke Libbey), 06/19/2017 07:28 PM

View differences:

ext/coverage/coverage.c
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.
*
......
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);
}
test/coverage/test_coverage.rb
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
    (1-1/1)