From: contact@... Date: 2016-04-06T00:57:02+00:00 Subject: [ruby-core:74825] [Ruby trunk Bug#12220] Why does Coverage keep previously-loaded files as empty arrays? Issue #12220 has been updated by Xavier Shay. Hello, I filed #4796. It was a long time ago, and I don't remember what I was trying to do. Likely something around a "coverage per test" feature. > Right, there is a compatibility concern, and I would like to check simplecov about it. > it does prevent to make accurate tests without additional efforts (filtering out the empty arrays). I don't feel making it "easier to write specs" is sufficient reason to change this, but if simplecov test suite passes with it (pretty sure it doesn't rely on restartable coverage) then I don't have a strong objection. ---------------------------------------- Bug #12220: Why does Coverage keep previously-loaded files as empty arrays? https://bugs.ruby-lang.org/issues/12220#change-57951 * Author: Benoit Daloze * Status: Open * Priority: Normal * Assignee: Yusuke Endoh * ruby -v: ruby 2.2.2p95 (2015-04-13 revision 50295) [x86_64-linux] * Backport: 2.1: UNKNOWN, 2.2: UNKNOWN, 2.3: UNKNOWN ---------------------------------------- For instance, ruby -e 'require "coverage"; Coverage.start; require "set"; Coverage.result; Coverage.start; require "tmpdir"; p Coverage.result' {".../lib/ruby/2.2.0/set.rb"=>[], ".../lib/ruby/2.2.0/tmpdir.rb"=>[nil, nil, nil, nil, nil, nil, 1, 1, ...]} So Coverage.result stops coverage but also does some cleaning up. I think the most intuitive would be that the coverage Hash would be reset to be empty, but instead it's filled with empty arrays. As an example, this makes it fairly awkward to test and it enforces irreversible global state (https://github.com/ruby/spec/pull/219). I also do not see how this would be useful for coverage libraries. Is there a reason for this behavior? If not, would it be OK to clear the Hash when calling #result? ---Files-------------------------------- 0001-ext-coverage-coverage.c-Fully-reset-coverage-to-not-.patch (5.14 KB) -- https://bugs.ruby-lang.org/ Unsubscribe: