Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Remove coverage workaround #479

Merged
merged 1 commit into from
Mar 5, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 0 additions & 10 deletions ext/bootsnap/bootsnap.c
Original file line number Diff line number Diff line change
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
Original file line number Diff line number Diff line change
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
Original file line number Diff line number Diff line change
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
Loading