Before this change, coverage.so had failed to measure some multiple-line
code fragments. This is because removing trace instructions (#14104)
changed TracePoint's lineno (new lineno), and coverage counter array was
based on old lineno.
This change initializes coverage counter array based on new lineno.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@61313 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* ext/coverage/coverage.c (test_method_coverage_for_define_method):
Add test cases for method coverages which test do-end block
define_method.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@61165 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This change makes method coverage result have not only first lineno of
method defintion, but also code range (i.e. first lineno, first column,
last lineno, and last column).
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@61026 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Traditionally, method coverage measurement was implemented by inserting
`trace2` instruction to the head of method iseq. So, it just measured
methods defined by `def` keyword.
This commit drastically changes the measuring mechanism of method
coverage; at `RUBY_EVENT_CALL`, it keeps a hash from rb_method_entry_t*
to runs (i.e., it counts the runs per method entry), and at
`Coverage.result`, it creates the result hash by enumerating all
`rb_method_entry_t*` objects (by `ObjectSpace.each_object`).
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@61023 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* compile.c (DECL_BRANCH_BASE, ADD_TRACE_BRANCH_COVERAGE): Add
a last location to arguments.
* compile.c (compile_if, compile_case, compile_case2, compile_loop, iseq_compile_each0):
Pass a last location to macros.
* ext/coverage/coverage.c (branch_coverage): Add a last location to
a return value.
* test/coverage/test_coverage.rb: Follow-up these changes.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@60785 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* test/coverage/test_coverage.rb (test_branch_coverage_for_if_statement):
Add a test case for ternary operator.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@60366 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* test/coverage/test_coverage.rb (test_branch_coverage_for_if_statement):
Add test cases for if/unless without else clauses.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@60364 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Add `assert_coverage` to invoke Ruby script under coverage measurement
and to compare the result with an expected value.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@60003 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
`unless` statement was a syntactic sugar for `if` statement,
which made the result of branch coverage hard to understand.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@59889 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* compile.c (iseq_compile_each0): pop trace for coverage only and
clear its corresponding line. [ruby-core:82726] [Bug #13886]
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@59828 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* test/coverage/test_coverage.rb (test_restarting_coverage): use
real directory path for the case $TMPDIR contains symlinks. on
macOS, it is defaulted to a path under /var which is a symlink
to /private/var.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@59725 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
The tests had been disabled under coverage measurement (during
`ENV['COVERAGE']`), since they call `Coverage.result` which stops
coverage measurement.
So, we couldn't measure both C-level and Ruby-level coverage of Ruby
simultaneously.
In short, `./configure --enable-gcov && make exam COVERAGE=true`
misses some coverages.
Now, the test runs in another process. They does not stop coverage
measurement, so we can now enable the tests under coverage measurement.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@59724 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* ext/coverage/coverage.c (rb_coverage_running): add to quickly
check if coverage is enabled. patched by Burke Libbey <burke AT
libbey.me> in [ruby-core:81726]. [Feature #13667]
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@59716 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
There is an invariant that ISEQ_COVERAGE(iseq) must be Qnil if and only
if option->coverage_enabled is false. This invariant was broken by
NODE_PRELUDE which updates option->coverage_enabled but not
ISEQ_COVERAGE(iseq).
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@57971 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* compile.c (ADD_TRACE): ignore trace instruction on non-positive
line.
* parse.y (coverage): get rid of ArgumentError when the starting
line number is not positive. [ruby-core:76141] [Bug #12517]
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@55509 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
It was returning old file coverages as empty arrays to the user.
[ruby-core:74596] [Bug #12220]
* ext/coverage/coverage.c (rb_coverages): remove unused static state.
* thread.c: Moved and renamed coverage_clear_result_i to reset_coverage_i.
* test/coverage/test_coverage.rb: improve precision of tests.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@54504 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
When you change this to true, you may need to add more tests.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@53141 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
capture coverage information without stopping the coverage tool.
[ruby-core:67940] [Feature #10816]
* test/coverage/test_coverage.rb: test for change.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@49589 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
instead of `p' to get rid of a side effect.
Kernel#p without any argument seems to do nothing, but flushes stdout.
and, if stdout is redirected to file, fsync() will be called on
Windows. so, when running test-all on Windows with redirection, such
as CI environment, this test took a lot of time.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@42439 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
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
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