зеркало из https://github.com/github/ruby.git
Ensure main file has default coverage if required. (#7169)
* Extract common code for coverage setup.
This commit is contained in:
Родитель
3e7fdf2953
Коммит
2c93c55401
13
iseq.c
13
iseq.c
|
@ -835,13 +835,20 @@ iseq_setup_coverage(VALUE coverages, VALUE path, const rb_ast_body_t *ast, int l
|
||||||
return Qnil;
|
return Qnil;
|
||||||
}
|
}
|
||||||
|
|
||||||
rb_iseq_t *
|
static inline void
|
||||||
rb_iseq_new_top(const rb_ast_body_t *ast, VALUE name, VALUE path, VALUE realpath, const rb_iseq_t *parent)
|
iseq_new_setup_coverage(VALUE path, const rb_ast_body_t *ast, int line_offset)
|
||||||
{
|
{
|
||||||
VALUE coverages = rb_get_coverages();
|
VALUE coverages = rb_get_coverages();
|
||||||
|
|
||||||
if (RTEST(coverages)) {
|
if (RTEST(coverages)) {
|
||||||
iseq_setup_coverage(coverages, path, ast, 0);
|
iseq_setup_coverage(coverages, path, ast, 0);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
rb_iseq_t *
|
||||||
|
rb_iseq_new_top(const rb_ast_body_t *ast, VALUE name, VALUE path, VALUE realpath, const rb_iseq_t *parent)
|
||||||
|
{
|
||||||
|
iseq_new_setup_coverage(path, ast, 0);
|
||||||
|
|
||||||
return rb_iseq_new_with_opt(ast, name, path, realpath, 0, parent, 0,
|
return rb_iseq_new_with_opt(ast, name, path, realpath, 0, parent, 0,
|
||||||
ISEQ_TYPE_TOP, &COMPILE_OPTION_DEFAULT);
|
ISEQ_TYPE_TOP, &COMPILE_OPTION_DEFAULT);
|
||||||
|
@ -850,6 +857,8 @@ rb_iseq_new_top(const rb_ast_body_t *ast, VALUE name, VALUE path, VALUE realpath
|
||||||
rb_iseq_t *
|
rb_iseq_t *
|
||||||
rb_iseq_new_main(const rb_ast_body_t *ast, VALUE path, VALUE realpath, const rb_iseq_t *parent, int opt)
|
rb_iseq_new_main(const rb_ast_body_t *ast, VALUE path, VALUE realpath, const rb_iseq_t *parent, int opt)
|
||||||
{
|
{
|
||||||
|
iseq_new_setup_coverage(path, ast, 0);
|
||||||
|
|
||||||
return rb_iseq_new_with_opt(ast, rb_fstring_lit("<main>"),
|
return rb_iseq_new_with_opt(ast, rb_fstring_lit("<main>"),
|
||||||
path, realpath, 0,
|
path, realpath, 0,
|
||||||
parent, 0, ISEQ_TYPE_MAIN, opt ? &COMPILE_OPTION_DEFAULT : &COMPILE_OPTION_FALSE);
|
parent, 0, ISEQ_TYPE_MAIN, opt ? &COMPILE_OPTION_DEFAULT : &COMPILE_OPTION_FALSE);
|
||||||
|
|
Загрузка…
Ссылка в новой задаче