Skip to content

Commit

Permalink
Merge pull request #479 from Earlopain/remove-coverage-workaround
Browse files Browse the repository at this point in the history
Remove coverage workaround
  • Loading branch information
casperisfine committed Mar 5, 2024
2 parents de109b2 + cf24e98 commit 5d37046
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 14 deletions.
10 changes: 0 additions & 10 deletions ext/bootsnap/bootsnap.c
Expand Up @@ -146,15 +146,6 @@ struct s2o_data;
struct i2o_data;
struct i2s_data;

/* https://bugs.ruby-lang.org/issues/13667 */
extern VALUE rb_get_coverages(void);
static VALUE
bs_rb_coverage_running(VALUE self)
{
VALUE cov = rb_get_coverages();
return RTEST(cov) ? Qtrue : Qfalse;
}

static VALUE
bs_rb_get_path(VALUE self, VALUE fname)
{
Expand Down Expand Up @@ -193,7 +184,6 @@ Init_bootsnap(void)
rb_define_module_function(rb_mBootsnap, "instrumentation_enabled=", bs_instrumentation_enabled_set, 1);
rb_define_module_function(rb_mBootsnap_CompileCache_Native, "readonly=", bs_readonly_set, 1);
rb_define_module_function(rb_mBootsnap_CompileCache_Native, "revalidation=", bs_revalidation_set, 1);
rb_define_module_function(rb_mBootsnap_CompileCache_Native, "coverage_running?", bs_rb_coverage_running, 0);
rb_define_module_function(rb_mBootsnap_CompileCache_Native, "fetch", bs_rb_fetch, 4);
rb_define_module_function(rb_mBootsnap_CompileCache_Native, "precompile", bs_rb_precompile, 3);
rb_define_module_function(rb_mBootsnap_CompileCache_Native, "compile_option_crc32=", bs_compile_option_crc32_set, 1);
Expand Down
2 changes: 1 addition & 1 deletion lib/bootsnap/compile_cache/iseq.rb
Expand Up @@ -84,7 +84,7 @@ def self.input_to_output(_data, _kwargs)
module InstructionSequenceMixin
def load_iseq(path)
# Having coverage enabled prevents iseq dumping/loading.
return nil if defined?(Coverage) && Bootsnap::CompileCache::Native.coverage_running?
return nil if defined?(Coverage) && Coverage.running?

Bootsnap::CompileCache::ISeq.fetch(path.to_s)
rescue RuntimeError => error
Expand Down
7 changes: 4 additions & 3 deletions test/compile_cache_test.rb
Expand Up @@ -21,12 +21,13 @@ def test_compile_option_crc32
end
end

def test_coverage_running?
refute(Bootsnap::CompileCache::Native.coverage_running?)
def test_coverage_running
require "coverage"
Bootsnap::CompileCache::ISeq.expects(:fetch).times(0)
begin
Coverage.start
assert(Bootsnap::CompileCache::Native.coverage_running?)
path = Help.set_file("a.rb", "a = a = 3", 100)
load(path)
ensure
Coverage.result
end
Expand Down

0 comments on commit 5d37046

Please sign in to comment.