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

53 Коммитов

Автор SHA1 Сообщение Дата
nobu 3d1c86a26f Removed moving toplevel header since r12501
Moving public headers was 12-years ago, no depend files would
expect ruby.h in the top source directory now.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@67033 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2019-02-08 02:46:22 +00:00
mame ab2da43ce4 ext/coverage/lib/coverage.rb (Coverage.line_stub): use only line events
It wrongly used all linenos of ISeq#trace_points which includes not only
line events but also call, return, and other events.  So, the result
included some linenos that can not be covered at all by line coverage.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@66468 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2018-12-20 10:17:37 +00:00
svn 8076601976 * expand tabs.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@65196 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2018-10-20 05:33:13 +00:00
mame 47ea999b46 ext/coverage/: add the oneshot mode
This patch introduces "oneshot_lines" mode for `Coverage.start`, which
checks "whether each line was executed at least once or not", instead of
"how many times each line was executed".  A hook for each line is fired
at most once, and after it is fired, the hook flag was removed; it runs
with zero overhead.

See [Feature #15022] in detail.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@65195 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2018-10-20 05:33:04 +00:00
nobu aaa18bae72 update dependencies
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@61715 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2018-01-09 06:55:55 +00:00
mame 9b1d8ab7d0 ext/coverage/coverage.c: remove COVERAGE_EXPERIMENTAL_MODE
A NEWS entry is also added.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@61129 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2017-12-12 00:20:58 +00:00
mame f6556c5c39 ext/coverage/coverage.c: method coverage has column info. of method def.
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
2017-12-05 08:56:51 +00:00
mame a5e02f249d vm_core.h (rb_iseq_locatoin_t): add a field `code_range`
This change makes each ISeq keep NODE's code range.  This information is
needed for method coverage.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@61025 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2017-12-05 08:56:50 +00:00
mame 0a6816ecd7 Revamp method coverage to support define_method
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
2017-12-05 07:16:42 +00:00
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 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
yui-knk c7fa2bf568 ext/coverage/coverage.c (rb_coverage_start): Ensure `opt` is a hash
Ensure `opt` is a hash before using `rb_hash_lookup` to `opt`.
This will prevent SEGV when an inappropriate object (i.e. an array)
is passed to `opt`.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@59915 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2017-09-15 00:40:38 +00:00
mame b324a64946 ext/coverage/coverage.c: use long instead of int for coverage site id
Coverage generates unique ID numbers for each branch and each method.
Use long instead of int for the IDs.  I don't want to see 2^32 branches
and methods in one file, but just in case...

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@59894 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2017-09-14 10:45:04 +00:00
mame db9f36f3fa ext/coverage/coverage.c (method_coverage): `id` was used uninitialized
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@59891 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2017-09-14 07:45:17 +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
hsbt c4a64b734c Removed needless operator.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@59878 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2017-09-14 03:57:22 +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
mame c171ca1efd ext/coverage/coverage.c: Fix the condition for non-experimental mode
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@59875 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2017-09-14 02:53:54 +00:00
mame 68394b27ba [EXPERIMENTAL] Extend the API of `Coverage.start` and `result`
The old API:

    Coverage.start
    load "foo.rb"
    p Coverage.result #=> {"foo.rb" => [1, 2, nil]}

The new API:

    ENV["COVERAGE_EXPERIMENTAL_MODE"] = "true"
    Coverage.start(lines: true)
    load "foo.rb"
    p Coverage.result #=> {"foo.rb" => {:lines => [1, 2, nil]}}

This new API allows us to add other measuring target types.

Notes:

* To keep compatibility, the old interface is still remained; passing no
  optional argument makes `Coverage.result` return the old format.
* This feature is still experimental.  So, to enable the new API, the
  environment variable `COVERAGE_EXPERIMENTAL_MODE` must be set.  I plan
  to activate this feature by Ruby 2.5.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@59874 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2017-09-14 02:36:26 +00:00
mame cd6df5fb3c Refactor the internal data format for coverage measurement
To prepare new measuring targets: branch and method coverages.
So far, iseq->coverage was an array of counts executed for line coverage.
Now, it is a three-element array for each measuring target,
whose first element is an array for line coverage.
The second element is planned for branch coverage, and the third will be
for method coverage.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@59738 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2017-09-03 14:26:06 +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
shyouhei 20c72dc89d ruby tool/update-deps --fix
Onigumo 6 (r57045) introduced new onigumo.h header file, which is
required from quite much everywhere.  This commit adds necessary
dependencies.

Note: ruby/oniguruma.h now includes onigumo.h,
      ruby/io.h includes oniguruma.h,
      ruby/encoding.h also includes oniguruma.h,
      and internal.h includes encoding.h.


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@58054 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2017-03-22 06:00:18 +00:00
akr 9d8ef4ea20 Update dependencies.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@54544 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2016-04-11 11:50:00 +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
eregon 8dd2435877 * thread.c (update_coverage): Do not track coverage in loaded files
after Coverage.result. Avoids out-of-bounds access. [Bug #12237]
* ext/coverage/coverage.c (coverage_clear_result_i): document.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@54465 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2016-03-31 16:14:52 +00:00
nobu 4a01021002 vm_core.h: use RUBY_ASSERT
* vm_core.h (VM_ASSERT): use RUBY_ASSERT instead of rb_bug.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@53616 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2016-01-22 08:37:36 +00:00
naruse c4fdfabcc8 handle ext/ as r53141
g -L frozen_string_literal ext/**/*.rb|xargs ruby -Ka -e'ARGV.each{|fn|puts
fn;open(fn,"r+"){|f|s=f.read.sub(/\A(#!.*\n)?(#.*coding.*\n)?/,"\\&#
frozen_string_literal: false\n");f.rewind;f.write s}}'

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@53143 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2015-12-16 05:31:54 +00:00
hsbt f662d31b6b * ext/coverage/coverage.c: Remove extension from require argument.
[ci skip][fix GH-870] Patch by @yui-knk

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@50256 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2015-04-12 04:52:23 +00:00
nobu 68c2c522fd coverage.c: suppress a warning
* ext/coverage/coverage.c (coverage_clear_result_i): use local
  variable coverage.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@49591 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2015-02-13 23:26:26 +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
akr ecedd3b224 Update dependencies.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@48898 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2014-12-19 13:34:54 +00:00
akr 6ca202fcee Update dependency.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@48526 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2014-11-21 03:04:44 +00:00
akr 20fe728a24 Dependencies updated.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@48483 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2014-11-18 15:28:08 +00:00
akr 7cd76ab0c5 * internal.h: Include ruby.h and ruby/encoding.h to be
includable without prior inclusion.



git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@48447 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2014-11-15 11:49:06 +00:00
akr dd547e1b22 Mark auogenerated part.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@48441 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2014-11-15 11:14:08 +00:00
akr 57682b05e1 * common.mk: Remove comments in Dependency lines.
Notified by usa.

* enc/depend: Ditto.

* ext/**/depend: Ditto.



git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@48434 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2014-11-15 10:28:25 +00:00
akr 8727eb77be * tool/update-deps: Extend to fix dependencies.
* common.mk: Dependencies updated by tool/update-deps.

* enc/depend: Ditto.

* ext/**/depend: Ditto.



git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@48431 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2014-11-15 05:15:49 +00:00
ko1 7093a2cb5b * ext/openssl/depend: remove dependency from internal headers.
[Feature #9612]
* ext/openssl/ossl.c (ossl_fips_mode_set): ditto.
* ext/coverage/depend: ditto.
* include/ruby/thread_native.h: added.
  This header file only provides wrapper functions to control
  native threads. These wrapper functions are used by MRI
  implementation.
* vm_core.h: use include/ruby/thread_native.h.
* thread.c: ditto.
* thread_pthread.h: ditto.
* thread_win32.h: ditto.
* thread_native.h: removed.



git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@45944 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2014-05-14 10:55:38 +00:00
akr 674f14a0bc * common.mk, ext/objspace/depend, ext/coverage/depend,
ext/-test-/debug/depend, ext/date/depend: Update dependencies.


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@43445 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-10-28 03:43:17 +00:00
ko1 83aba04862 * include/ruby/ruby.h: constify RBasic::klass and add
RBASIC_CLASS(obj) macro which returns a class of `obj'.
  This change is a part of RGENGC branch [ruby-trunk - Feature #8339].
* object.c: add new function rb_obj_reveal().
  This function reveal interal (hidden) object by rb_obj_hide().
  Note that do not change class before and after hiding.
  Only permitted example is:
  klass = RBASIC_CLASS(obj);
  rb_obj_hide(obj);
  ....
  rb_obj_reveal(obj, klass);
  TODO: API design. rb_obj_reveal() should be replaced with others.
  TODO: modify constified variables using cast may be harmful for
  compiler's analysis and optimizaton.
  Any idea to prohibt inserting RBasic::klass directly?
  If rename RBasic::klass and force to use RBASIC_CLASS(obj),
  then all codes such as `RBASIC(obj)->klass' will be
  compilation error. Is it acceptable? (We have similar
  experience at Ruby 1.9,
  for example "RARRAY(ary)->ptr" to "RARRAY_PTR(ary)".
* internal.h: add some macros.
* RBASIC_CLEAR_CLASS(obj) clear RBasic::klass to make it internal
  object.
* RBASIC_SET_CLASS(obj, cls) set RBasic::klass.
* RBASIC_SET_CLASS_RAW(obj, cls) same as RBASIC_SET_CLASS
  without write barrier (planned).
* RCLASS_SET_SUPER(a, b) set super class of a.
* array.c, class.c, compile.c, encoding.c, enum.c, error.c, eval.c,
  file.c, gc.c, hash.c, io.c, iseq.c, marshal.c, object.c,
  parse.y, proc.c, process.c, random.c, ruby.c, sprintf.c,
  string.c, thread.c, transcode.c, vm.c, vm_eval.c, win32/file.c:
  Use above macros and functions to access RBasic::klass.
* ext/coverage/coverage.c, ext/readline/readline.c,
  ext/socket/ancdata.c, ext/socket/init.c,
* ext/zlib/zlib.c: ditto.



git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@40691 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-05-13 10:49:11 +00:00
naruse e4f6efcc4a * ext/coverage/depend: fix id.h place as r40283.
* ext/coverage/extconf.rb: add topdir and topsrcdir to VPATH.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@40302 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-04-15 01:24:37 +00:00
akr 788b45da3e * ext/-test-/debug/depend: New file.
* ext/-test-/exception/depend: Ditto.

* ext/-test-/printf/depend: Ditto.

* ext/-test-/string/depend: Ditto.

* ext/coverage/depend: Ditto.

* ext/io/console/depend: Ditto.

* ext/io/nonblock/depend: Ditto.

* ext/io/wait/depend: Ditto.

* ext/openssl/depend: Ditto.

* ext/pathname/depend: Ditto.

* ext/psych/depend: Ditto.

* ext/zlib/depend: Ditto.



git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@40287 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-04-14 10:48:08 +00:00
drbrain ccec5b49ca * ext/coverage/coverage.c (Init_coverage): Change list format and
describe Coverage.result output.  Patch by Sylvain Daubert.
  [Ruby 1.9 - Bug #5428]


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@33449 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2011-10-10 21:06:39 +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 7023a64d80 * ext/coverage/coverage.c: make it restartable. [ruby-core:36539]
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@32071 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2011-06-13 16:06:26 +00:00
nobu 9f41782ec8 * ext/{coverage,objspace}/extconf.rb ($INCFLAGS): explicitly add
topdir and top_srcdir.  [ruby-dev:42031]

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@28987 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2010-08-14 10:12:13 +00:00
nobu a33fdc4ec0 * vm_core.h (rb_{get,set,reset}_coverages): used in coverage.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@28978 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2010-08-14 05:58:19 +00:00
nobu bb239558b8 * ext/coverage/coverage.c (rb_mCoverage): removed unneeded static variable.
* ext/socket/socket.c (unix_recv_io): ditto.

* ext/socket/socket.c (mConst): ditto.


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@18977 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2008-08-31 04:48:02 +00:00
nobu 04969c4a86 * ext/coverage/coverage.c (rb_coverage_start): return nil.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@17991 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2008-07-10 05:09:08 +00:00