mirror of
https://github.com/ruby/ruby.git
synced 2022-11-09 12:17:21 -05:00
* ext/coverage/coverage.c: revert r32071. The commit caused SEGV on
some minor nonfree OS. I have no means of debugging the bug. My personal opinion is that such OS should be unsupported unless there is an active maintainer. [ruby-core:37352] * test/coverage/test_coverage.rb: ditto. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@32401 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
parent
276033220d
commit
74454f5796
3 changed files with 18 additions and 42 deletions
|
@ -1,3 +1,12 @@
|
||||||
|
Mon Jul 4 20:42:31 2011 Yusuke Endoh <mame@tsg.ne.jp>
|
||||||
|
|
||||||
|
* ext/coverage/coverage.c: revert r32071. The commit caused SEGV on
|
||||||
|
some minor nonfree OS. I have no means of debugging the bug. My
|
||||||
|
personal opinion is that such OS should be unsupported unless there
|
||||||
|
is an active maintainer. [ruby-core:37352]
|
||||||
|
|
||||||
|
* test/coverage/test_coverage.rb: ditto.
|
||||||
|
|
||||||
Mon Jul 4 07:14:12 2011 NARUSE, Yui <naruse@ruby-lang.org>
|
Mon Jul 4 07:14:12 2011 NARUSE, Yui <naruse@ruby-lang.org>
|
||||||
|
|
||||||
* thread_pthread.c (get_stack): the return address of get_stack
|
* thread_pthread.c (get_stack): the return address of get_stack
|
||||||
|
|
|
@ -11,8 +11,6 @@
|
||||||
#include "ruby.h"
|
#include "ruby.h"
|
||||||
#include "vm_core.h"
|
#include "vm_core.h"
|
||||||
|
|
||||||
static VALUE rb_coverages = Qundef;
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* call-seq:
|
* call-seq:
|
||||||
* Coverage.start => nil
|
* Coverage.start => nil
|
||||||
|
@ -23,25 +21,19 @@ static VALUE
|
||||||
rb_coverage_start(VALUE klass)
|
rb_coverage_start(VALUE klass)
|
||||||
{
|
{
|
||||||
if (!RTEST(rb_get_coverages())) {
|
if (!RTEST(rb_get_coverages())) {
|
||||||
if (rb_coverages == Qundef) {
|
VALUE coverages = rb_hash_new();
|
||||||
rb_coverages = rb_hash_new();
|
RBASIC(coverages)->klass = 0;
|
||||||
RBASIC(rb_coverages)->klass = 0;
|
rb_set_coverages(coverages);
|
||||||
}
|
|
||||||
rb_set_coverages(rb_coverages);
|
|
||||||
}
|
}
|
||||||
return Qnil;
|
return Qnil;
|
||||||
}
|
}
|
||||||
|
|
||||||
static int
|
static int
|
||||||
coverage_result_i(st_data_t key, st_data_t val, st_data_t h)
|
coverage_result_i(st_data_t key, st_data_t val, st_data_t dummy)
|
||||||
{
|
{
|
||||||
VALUE path = (VALUE)key;
|
|
||||||
VALUE coverage = (VALUE)val;
|
VALUE coverage = (VALUE)val;
|
||||||
VALUE coverages = (VALUE)h;
|
RBASIC(coverage)->klass = rb_cArray;
|
||||||
coverage = rb_ary_dup(coverage);
|
|
||||||
rb_ary_clear((VALUE)val);
|
|
||||||
rb_ary_freeze(coverage);
|
rb_ary_freeze(coverage);
|
||||||
rb_hash_aset(coverages, path, coverage);
|
|
||||||
return ST_CONTINUE;
|
return ST_CONTINUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -56,14 +48,14 @@ static VALUE
|
||||||
rb_coverage_result(VALUE klass)
|
rb_coverage_result(VALUE klass)
|
||||||
{
|
{
|
||||||
VALUE coverages = rb_get_coverages();
|
VALUE coverages = rb_get_coverages();
|
||||||
VALUE ncoverages = rb_hash_new();
|
|
||||||
if (!RTEST(coverages)) {
|
if (!RTEST(coverages)) {
|
||||||
rb_raise(rb_eRuntimeError, "coverage measurement is not enabled");
|
rb_raise(rb_eRuntimeError, "coverage measurement is not enabled");
|
||||||
}
|
}
|
||||||
st_foreach(RHASH_TBL(coverages), coverage_result_i, ncoverages);
|
RBASIC(coverages)->klass = rb_cHash;
|
||||||
rb_hash_freeze(ncoverages);
|
st_foreach(RHASH_TBL(coverages), coverage_result_i, 0);
|
||||||
|
rb_hash_freeze(coverages);
|
||||||
rb_reset_coverages();
|
rb_reset_coverages();
|
||||||
return ncoverages;
|
return coverages;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Coverage provides coverage measurement feature for Ruby.
|
/* Coverage provides coverage measurement feature for Ruby.
|
||||||
|
|
|
@ -15,29 +15,4 @@ class TestCoverage < Test::Unit::TestCase
|
||||||
assert_kind_of(Array, val)
|
assert_kind_of(Array, val)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
def test_restarting_coverage
|
|
||||||
loaded_features = $".dup
|
|
||||||
|
|
||||||
Dir.mktmpdir {|tmp|
|
|
||||||
Dir.chdir(tmp) {
|
|
||||||
File.open("test.rb", "w") do |f|
|
|
||||||
f.puts <<-EOS
|
|
||||||
def coverage_test_method
|
|
||||||
:ok
|
|
||||||
end
|
|
||||||
EOS
|
|
||||||
end
|
|
||||||
|
|
||||||
Coverage.start
|
|
||||||
require tmp + '/test.rb'
|
|
||||||
Coverage.result
|
|
||||||
Coverage.start
|
|
||||||
coverage_test_method
|
|
||||||
assert_equal 1, Coverage.result.size
|
|
||||||
}
|
|
||||||
}
|
|
||||||
ensure
|
|
||||||
$".replace loaded_features
|
|
||||||
end
|
|
||||||
end
|
end
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue