From: michael@... Date: 2016-06-23T22:36:40+00:00 Subject: [ruby-core:76122] [Ruby trunk Bug#12480] Restarting Coverage does not capture additional coverage for already loaded files Issue #12480 has been updated by Michael Grosser. Solved this by using Coverage.peek_result in the before-fork part of my code to capture the current state and then merged it after the fork is done :D Feel free to close this now! ---------------------------------------- Bug #12480: Restarting Coverage does not capture additional coverage for already loaded files https://bugs.ruby-lang.org/issues/12480#change-59326 * Author: Michael Grosser * Status: Feedback * Priority: Normal * Assignee: Yusuke Endoh * ruby -v: 2.3.1 * Backport: 2.1: UNKNOWN, 2.2: UNKNOWN, 2.3: UNKNOWN ---------------------------------------- I'm trying to combine coverage from before fork and after fork to make coverage reporting work in a forking test runner. The problem I ran into is 2-fold: - A: when forking, previous coverage is lost - B: when restarting coverage, old files do not get added to I could work around issue A by storing the old result and then merging it with the new result post fork, but issue B makes that impossible. Please fix either A or B ... Reproduction steps for A: ~~~ # reproduce.rb require 'coverage' Coverage.start require_relative 'test' a fork do b new = Coverage.result puts "NEW: #{new}" end # test.rb def a 1 end def b 1 end ~~~ NEW: {"/Users/mgrosser/Code/tools/forking_test_runner/test.rb"=>[0, 0, nil, nil, 0, 1, nil]} -> missing coverage information for method `a` Reproduction steps for B: ~~~ # reproduce.rb require 'coverage' Coverage.start require_relative 'test' a old = Coverage.result Coverage.start b new = Coverage.result puts "OLD: #{old} -- NEW: #{new}" # test.rb def a 1 end def b 1 end ~~~ OLD: {"test.rb"=>[1, 1, nil, nil, 1, 0, nil]} -- NEW: {"test.rb"=>[]} -> missing coverage information for method `b` -- https://bugs.ruby-lang.org/ Unsubscribe: