зеркало из https://github.com/github/ruby.git
* 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:
Родитель
a14e13b23b
Коммит
54163e2b52
|
@ -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>
|
||||
|
||||
* load.c (rb_f_require): Improve documentation of Kernel#require.
|
||||
|
|
|
@ -31,10 +31,31 @@ class TestCoverage < Test::Unit::TestCase
|
|||
|
||||
Coverage.start
|
||||
require tmp + '/test.rb'
|
||||
Coverage.result
|
||||
assert_equal 3, Coverage.result[tmp + '/test.rb'].size
|
||||
Coverage.start
|
||||
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
|
||||
|
|
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 count;
|
||||
if (RARRAY_PTR(coverage)[line] == Qnil) {
|
||||
rb_bug("bug");
|
||||
return;
|
||||
}
|
||||
count = FIX2LONG(RARRAY_PTR(coverage)[line]) + 1;
|
||||
if (POSFIXABLE(count)) {
|
||||
|
|
Загрузка…
Ссылка в новой задаче