From 465cf8d80b719a3507c188e9c6bc2fe2932138c6 Mon Sep 17 00:00:00 2001 From: Kevin Newton Date: Wed, 21 Aug 2024 15:24:06 -0400 Subject: [PATCH] [PRISM] Potentially enable coverage on the main script --- ruby.c | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/ruby.c b/ruby.c index 31ab81a6d8..b401d90e02 100644 --- a/ruby.c +++ b/ruby.c @@ -2186,6 +2186,12 @@ prism_script(ruby_cmdline_options_t *opt, pm_parse_result_t *result) error = pm_parse_file(result, opt->script_name); } + // Check if (after requiring all of the files through -r flags) we have + // coverage enabled and need to enable coverage on the main script. + if (RTEST(rb_get_coverages())) { + result->node.coverage_enabled = 1; + } + // If we found an __END__ marker, then we're going to define a global // DATA constant that is a file object that can be read to read the // contents after the marker.