mirror of
https://github.com/ruby/ruby.git
synced 2022-11-09 12:17:21 -05:00
* thread.c (update_coverage): skip coverage count up if the current
line is out of the way. rb_sourceline() is unreliable when source code is big. [ruby-dev:44413] * test/coverage/test_coverage.rb: add a test for above. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@33030 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
parent
a14e13b23b
commit
54163e2b52
3 changed files with 32 additions and 3 deletions
|
@ -1,3 +1,11 @@
|
||||||
|
Wed Aug 24 00:38:22 2011 Yusuke Endoh <mame@tsg.ne.jp>
|
||||||
|
|
||||||
|
* thread.c (update_coverage): skip coverage count up if the current
|
||||||
|
line is out of the way. rb_sourceline() is unreliable when source
|
||||||
|
code is big. [ruby-dev:44413]
|
||||||
|
|
||||||
|
* test/coverage/test_coverage.rb: add a test for above.
|
||||||
|
|
||||||
Tue Aug 23 15:23:56 2011 Eric Hodel <drbrain@segment7.net>
|
Tue Aug 23 15:23:56 2011 Eric Hodel <drbrain@segment7.net>
|
||||||
|
|
||||||
* load.c (rb_f_require): Improve documentation of Kernel#require.
|
* load.c (rb_f_require): Improve documentation of Kernel#require.
|
||||||
|
|
|
@ -31,10 +31,31 @@ class TestCoverage < Test::Unit::TestCase
|
||||||
|
|
||||||
Coverage.start
|
Coverage.start
|
||||||
require tmp + '/test.rb'
|
require tmp + '/test.rb'
|
||||||
Coverage.result
|
assert_equal 3, Coverage.result[tmp + '/test.rb'].size
|
||||||
Coverage.start
|
Coverage.start
|
||||||
coverage_test_method
|
coverage_test_method
|
||||||
assert_equal 1, Coverage.result.size
|
assert_equal 0, Coverage.result[tmp + '/test.rb'].size
|
||||||
|
}
|
||||||
|
}
|
||||||
|
ensure
|
||||||
|
$".replace loaded_features
|
||||||
|
end
|
||||||
|
|
||||||
|
def test_big_code
|
||||||
|
loaded_features = $".dup
|
||||||
|
|
||||||
|
Dir.mktmpdir {|tmp|
|
||||||
|
Dir.chdir(tmp) {
|
||||||
|
File.open("test.rb", "w") do |f|
|
||||||
|
f.puts "p\n" * 10000
|
||||||
|
f.puts "def ignore(x); end"
|
||||||
|
f.puts "ignore([1"
|
||||||
|
f.puts "])"
|
||||||
|
end
|
||||||
|
|
||||||
|
Coverage.start
|
||||||
|
require tmp + '/test.rb'
|
||||||
|
assert_equal 10003, Coverage.result[tmp + '/test.rb'].size
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
ensure
|
ensure
|
||||||
|
|
2
thread.c
2
thread.c
|
@ -4764,7 +4764,7 @@ update_coverage(rb_event_flag_t event, VALUE proc, VALUE self, ID id, VALUE klas
|
||||||
long line = rb_sourceline() - 1;
|
long line = rb_sourceline() - 1;
|
||||||
long count;
|
long count;
|
||||||
if (RARRAY_PTR(coverage)[line] == Qnil) {
|
if (RARRAY_PTR(coverage)[line] == Qnil) {
|
||||||
rb_bug("bug");
|
return;
|
||||||
}
|
}
|
||||||
count = FIX2LONG(RARRAY_PTR(coverage)[line]) + 1;
|
count = FIX2LONG(RARRAY_PTR(coverage)[line]) + 1;
|
||||||
if (POSFIXABLE(count)) {
|
if (POSFIXABLE(count)) {
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue