Граф коммитов

37 Коммитов

Автор SHA1 Сообщение Дата
yui-knk 7fbab01f77 Add a last location to branch coverage
* 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
2017-11-16 03:36:20 +00:00
yui-knk 8bbdbf9e75 Add test cases for branch coverage
* test/coverage/test_coverage.rb (test_branch_coverage_for_while_statement):
  Add test cases for modifier while/until.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@60382 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2017-10-23 13:25:59 +00:00
yui-knk 588ac3ee1f Add test cases for branch coverage
* 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
2017-10-22 14:13:50 +00:00
yui-knk ef29f8db80 Add test cases for branch coverage
* test/coverage/test_coverage.rb (test_branch_coverage_for_if_statement):
  Add test cases for modifier if/unless.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@60365 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2017-10-22 13:58:55 +00:00
yui-knk ecdac92e50 Add test cases for branch coverage
* 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
2017-10-22 13:49:41 +00:00
yui-knk de482ab143 test/coverage/test_coverage.rb: Use `<<~` to ease to calculate column of target codes
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@60363 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2017-10-22 13:34:24 +00:00
yui-knk 755dd9f461 Add column numbers to branch coverage
* compile.c (DECL_BRANCH_BASE, ADD_TRACE_BRANCH_COVERAGE): Add
  column to arguments.

* compile.c (compile_if, compile_case, compile_when, compile_loop, iseq_compile_each0):
  Pass column numbers to macros.

* ext/coverage/coverage.c (branch_coverage): Add column numbers to
  a return value.

* test/coverage/test_coverage.rb: Follow-up these changes.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@60362 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2017-10-22 13:18:40 +00:00
mame 6975993882 test/coverage/test_coverage.rb: Refactor coverage tests.
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
2017-09-23 23:58:24 +00:00
yui-knk 7da13f05fd Enable to take branch coverages for safe method invocations
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@59990 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2017-09-23 00:17:35 +00:00
mame 3c8c17d30d Introduce NODE_UNLESS for branch coverage
`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
2017-09-14 05:27:02 +00:00
mame 78cf46078e Add method coverage
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@59888 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2017-09-14 05:12:34 +00:00
mame 3155da024c Fix the lineno of case statement that has no expression
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@59886 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2017-09-14 04:42:23 +00:00
mame 1f7abf7283 Add branch coverage for case-when statement
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@59885 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2017-09-14 04:32:58 +00:00
mame 16ab236b88 Add branch coverage for while and until statements
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@59877 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2017-09-14 03:36:05 +00:00
mame ce570370f0 Add branch coverage for if statement
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@59876 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2017-09-14 03:25:36 +00:00
nobu d446f15c97 compile.c: pop coverage trace
* 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
2017-09-10 16:19:40 +00:00
nobu 0cbcb5f580 test_coverage.rb: suppress warnings
* test/coverage/test_coverage.rb (test_nonpositive_linenumber):
  suppress method redefinition warnings.

* test/coverage/test_coverage.rb (test_eval): suppress literal in
  void context warning.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@59727 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2017-09-03 00:13:15 +00:00
nobu 3b55682529 test_coverage.rb: use real path
* 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
2017-09-03 00:02:23 +00:00
mame f34090ca4b test/coverage/test_coverage.rb: run the tests in separated processes
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
2017-09-02 13:55:12 +00:00
mame 95d949d571 ext/coverage/coverage.c: add Coverage.enabled?
* 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
2017-09-01 14:58:52 +00:00
naruse 8a66d13535 suppress_warning
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@58483 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2017-04-25 19:13:26 +00:00
mame 3c96f9c76a Fix a consistency bug of ISEQ_COVERAGE [Bug #13305]
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
2017-03-14 11:39:58 +00:00
nobu f540475134 Coverage on non-positive lines
* 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
2016-06-26 23:56:57 +00:00
nobu ba56de8b06 test_coverage.rb: suppress warnings
* test/coverage/test_coverage.rb (test_coverage_snapshot),
  (test_restarting_coverage): use unique names to suppress method
  redefinition warnings.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@54535 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2016-04-11 05:13:31 +00:00
eregon 4225b29df9 * ext/coverage/coverage.c: Fully reset coverage to not persist global state.
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
2016-04-06 14:29:17 +00:00
hsbt acc472dd24 * test/coverage/test_coverage.rb: ignored test when enabled to coverage.
It lead to crash with `make test-all`.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@53424 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2016-01-04 01:14:45 +00:00
naruse 3e92b635fb Add frozen_string_literal: false for all files
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
2015-12-16 05:07:31 +00:00
hsbt 676c80d203 * test/coverage/test_coverage.rb: Added test-case for Coverage.restart.
[Misc #11732][ruby-dev:49379]

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@52754 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2015-11-26 00:51:03 +00:00
hsbt a4ac506551 * test/coverage/test_coverage.rb: Added test-case for Coverage.peek_result
without Coverage.start. [Misc #11726][ruby-core:71622]

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@52753 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2015-11-26 00:48:56 +00:00
tenderlove a86eacf552 * ext/coverage/coverage.c: Add Coverage.peek_result. Allows you to
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
2015-02-13 15:53:47 +00:00
naruse 4a7afb71ec suppress warning introduced by r42439 [ruby-dev:47040]
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@42453 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-08-08 16:27:08 +00:00
usa f21d6210eb * test/coverage/test_coverage.rb (TestCoverage#test_big_code): use `1'
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
2013-08-08 06:42:05 +00:00
mame 54163e2b52 * 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
2011-08-23 15:44:26 +00:00
nagachika ea8b916307 * ext/coverage/coverage.c: resurrect r32071 + add GC guard for
rb_coverages. [ruby-core:37352] [Bug #4927]
  [ruby-core:36539] [Feature #4796]

* test/coverage/test_coverage.rb resurrect r32071.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@32404 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2011-07-04 15:55:06 +00:00
mame 74454f5796 * 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
2011-07-04 12:21:02 +00:00
mame 1d147fb24c * test/coverage/test_coverage.rb: add a test for restart. a patch
from Xavier Shay.  [ruby-core:36745]

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@32072 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2011-06-13 16:12:52 +00:00
nobu 78b10588bf * test/coverage/test_coverage.rb: added.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@28988 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2010-08-14 11:59:35 +00:00