Sha256: a180fc36794472295e2ad0811834a686476065a7efb0341251fa720815b0ddef

Contents?: true

Size: 1.27 KB

Versions: 74

Compression:

Stored size: 1.27 KB

Contents

#!/usr/bin/env ruby

# This is a small script to illustrate how previous results get wiped out by forking
# this has implications of forking processes like Resque...
# this in the end would cause coverage.array_diff
# with previous results to add NEGATIVE code hits to the stored Coverage
# which in turn causes all sorts of crazy issues.
#
# ruby test/benchmarks/coverage_fork.rb
# in parent before fork
# {"/Users/danmayer/projects/coverband/test/dog.rb"=>[nil, nil, 1, 1, 2, nil, nil]}
# in child after fork
# {"/Users/danmayer/projects/coverband/test/dog.rb"=>[nil, nil, 0, 0, 0, nil, nil]}
# now triggering hits
# {"/Users/danmayer/projects/coverband/test/dog.rb"=>[nil, nil, 0, 0, 3, nil, nil]}
#
# I believe this might be related to CoW and GC... not sure
# http://patshaughnessy.net/2012/3/23/why-you-should-be-excited-about-garbage-collection-in-ruby-2-0
#
# NOTE: That the child now has 0 hits where previously method definitions had 1
# this causes all sorts of bad things to happen.
require 'coverage'
Coverage.start
load './test/dog.rb'
Dog.new.bark
Dog.new.bark
puts 'in parent before fork'
puts Coverage.peek_result
fork do
  puts 'in child after fork'
  puts Coverage.peek_result
  puts 'now triggering hits'
  Dog.new.bark
  Dog.new.bark
  Dog.new.bark
  puts Coverage.peek_result
end

Version data entries

74 entries across 74 versions & 1 rubygems

Version Path
coverband-4.2.3.rc.2 test/benchmarks/coverage_fork.sh
coverband-4.2.3.rc.1 test/benchmarks/coverage_fork.sh
coverband-4.2.2 test/benchmarks/coverage_fork.sh
coverband-4.2.2.rc.1 test/benchmarks/coverage_fork.sh
coverband-4.2.1 test/benchmarks/coverage_fork.sh
coverband-4.2.1.rc4 test/benchmarks/coverage_fork.sh
coverband-4.2.1.rc3 test/benchmarks/coverage_fork.sh
coverband-4.2.1.rc2 test/benchmarks/coverage_fork.sh
coverband-4.2.1.rc1 test/benchmarks/coverage_fork.sh
coverband-4.2.0 test/benchmarks/coverage_fork.sh
coverband-4.2.0.rc3 test/benchmarks/coverage_fork.sh
coverband-4.2.0.rc2 test/benchmarks/coverage_fork.sh
coverband-4.1.1 test/benchmarks/coverage_fork.sh
coverband-4.2.0.rc1 test/benchmarks/coverage_fork.sh