mirror of
https://github.com/ruby/ruby.git
synced 2022-11-09 12:17:21 -05:00
Add spec for Coverage.supported?
and start(eval: true)
. (#6499)
* Don't emit coverage for eval when eval coverage is disabled.
This commit is contained in:
parent
1e6cdc76e4
commit
24f3e397e9
Notes:
git
2022-10-07 20:34:13 +09:00
Merged-By: ioquatix <samuel@codeotaku.com>
2 changed files with 29 additions and 6 deletions
|
@ -106,15 +106,35 @@ describe 'Coverage.result' do
|
||||||
end
|
end
|
||||||
|
|
||||||
ruby_version_is '3.2' do
|
ruby_version_is '3.2' do
|
||||||
it 'returns the correct results when eval is used' do
|
it 'indicates support for different features' do
|
||||||
Coverage.start
|
Coverage.supported?(:lines).should == true
|
||||||
|
end
|
||||||
|
|
||||||
|
it 'returns the correct results when eval coverage is enabled' do
|
||||||
|
Coverage.supported?(:eval).should == true
|
||||||
|
|
||||||
|
Coverage.start(lines: true, eval: true)
|
||||||
require @eval_code_file.chomp('.rb')
|
require @eval_code_file.chomp('.rb')
|
||||||
result = Coverage.result
|
result = Coverage.result
|
||||||
|
|
||||||
result.should == {
|
result.should == {
|
||||||
@eval_code_file => [
|
@eval_code_file => {
|
||||||
1, nil, 1, nil, 1, 1, nil, nil, nil, nil, 1
|
lines: [1, nil, 1, nil, 1, 1, nil, nil, nil, nil, 1]
|
||||||
]
|
}
|
||||||
|
}
|
||||||
|
end
|
||||||
|
|
||||||
|
it 'returns the correct results when eval coverage is enabled' do
|
||||||
|
Coverage.supported?(:eval).should == true
|
||||||
|
|
||||||
|
Coverage.start(lines: true, eval: false)
|
||||||
|
require @eval_code_file.chomp('.rb')
|
||||||
|
result = Coverage.result
|
||||||
|
|
||||||
|
result.should == {
|
||||||
|
@eval_code_file => {
|
||||||
|
lines: [1, nil, 1, nil, 1, nil, nil, nil, nil, nil, 1]
|
||||||
|
}
|
||||||
}
|
}
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
|
@ -11,6 +11,7 @@
|
||||||
|
|
||||||
**********************************************************************/
|
**********************************************************************/
|
||||||
|
|
||||||
|
#include "internal/thread.h"
|
||||||
struct local_var_list {
|
struct local_var_list {
|
||||||
VALUE tbl;
|
VALUE tbl;
|
||||||
};
|
};
|
||||||
|
@ -1672,7 +1673,9 @@ eval_make_iseq(VALUE src, VALUE fname, int line, const rb_binding_t *bind,
|
||||||
rb_iseq_t *iseq = NULL;
|
rb_iseq_t *iseq = NULL;
|
||||||
rb_ast_t *ast;
|
rb_ast_t *ast;
|
||||||
int isolated_depth = 0;
|
int isolated_depth = 0;
|
||||||
int coverage_enabled = Qtrue;
|
|
||||||
|
// Conditionally enable coverage depending on the current mode:
|
||||||
|
VALUE coverage_enabled = RBOOL(rb_get_coverage_mode() & COVERAGE_TARGET_EVAL);
|
||||||
|
|
||||||
{
|
{
|
||||||
int depth = 1;
|
int depth = 1;
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue