Actions
Bug #20167
openCode execution isn't recorded in Ractor
    Bug #20167:
    Code execution isn't recorded in Ractor
  
Description
reproduction code¶
# frozen-string-literal: true
require "coverage"
Coverage.start
require_relative "./some_lib"
# # some_lib.rb
# class C
#   def hoge(i)
#     i
#   end
# end
r = Ractor.new do
  loop do
    v = Ractor.receive
    ret_v = C.new.hoge(v)
    Ractor.yield ret_v
  end
end
2.times do |i|
  r << i
  r.take
end
Coverage.result.each do |file, lines|
  if file.include?("some_ractor_lib")
    if lines == [1, 1, 2, nil, nil]
      puts "OK"
    else
      puts "expected: [1, 1, 2, nil, nil]"
      puts "actual: #{lines.inspect}"
    end
  end
end
Target ruby version¶
3.2.0+ affected
        
          
          Updated by mame (Yusuke Endoh) almost 2 years ago
          
          
        
        
      
      At this time, the coverage library should be able to only measure coverage for Ractor that invoked Coverage.start. (I have not tried but invoking Coverage.start in multiple Ractors may cause fatal problems.)
To improve this situation, probabily we need the following big modification.
- 
Covearge.startregisters hooks to all existing Ractors. - The hook measures coverage data per Ractor, not globally.
 - 
Coverage.resultaggregates all coverage data from every Ractor. 
        
          
          Updated by jeremyevans0 (Jeremy Evans) almost 2 years ago
          
          
        
        
      
      - Is duplicate of Bug #20158: Ractor affects Coverage results added
 
        
          
          Updated by jhawthorn (John Hawthorn) 6 months ago
          
          
        
        
      
      - Assignee set to ractor
 
        
          
          Updated by hsbt (Hiroshi SHIBATA) 6 months ago
          
          
        
        
      
      - Status changed from Open to Assigned
 
Actions