Issue #4796 has been updated by Yusuke Endoh.

Status changed from Closed to Open
Assignee deleted (Yusuke Endoh)
Priority changed from Normal to Low
Target version changed from 1.9.3 to 1.9.x

Unfortunately this patch seems to cause SEGV on os x. [#4927]
I cannot fix it because I have no os x.  So I can't help but
revert it.

Anyone who wants this feature, please fix it by yourself or
please give me a Mac :-)

-- 
Yusuke Endoh <mame / tsg.ne.jp>
----------------------------------------
Feature #4796: Coverage should be restartable
http://redmine.ruby-lang.org/issues/4796

Author: Xavier Shay
Status: Open
Priority: Low
Assignee: 
Category: lib
Target version: 1.9.x


I would like a way to be able to make the following test past:

    require "test/unit"
    require "coverage"
    require 'tmpdir'

    class TestCoverage < Test::Unit::TestCase
      def test_restarting_coverage
        Dir.mktmpdir {|tmp|
          Dir.chdir(tmp) {
            File.open("test.rb", "w") do |f|
              f.puts <<-EOS
                def coverage_test_method
                  puts :ok
                end
              EOS
            end

            Coverage.start
            require tmp + '/test.rb'
            Coverage.result
            Coverage.start
            coverage_test_method
            assert_equal 1, Coverage.result.size
          }
        }
      end
    end

The problem is that `Coverage.start` doesn't track any files loaded before it is called. This is probably desired behaviour so that stdlib files are not tracked, but it limits the usefulness of Coverage. Specifically, I am trying to collate coverage reports from workers in multiple processes. Also I want to associate coverages with specific tests (this test executed this code, etc...). This is very difficult without being able to restart.

What would be involved in doing this? If you point me in the right direction I can perhaps have a go.



-- 
http://redmine.ruby-lang.org