summaryrefslogtreecommitdiff
path: root/test/coverage/test_coverage.rb
AgeCommit message (Collapse)Author
8 days[PRISM] Modify test_coverage to take prism into accountKevin Newton
2023-10-16Fix method coverage comparisonsNobuyoshi Nakada
Although Ruby's hashes preserve the insertion order, the ordering of method coverage results is inherently nondeterministic, because they are collected using `ObjectSpace`.
2023-09-04Revert "Don't reset line coverage for evaled code. (#8330)"Yusuke Endoh
This reverts commit 7e0f5df2f99693267d61636d23da47f79924e9d5. https://bugs.ruby-lang.org/issues/19857#note-7
2023-09-04Don't reset line coverage for evaled code. (#8330)Samuel Williams
* Add failing test. Notes: Merged-By: ioquatix <samuel@codeotaku.com>
2023-01-22More coverage tests & specs. (#7171)Samuel Williams
* Add spec for eval and line coverage. * Add test for main file coverage. Notes: Merged-By: ioquatix <samuel@codeotaku.com>
2023-01-19Test some missing coverage too. (#7041)Samuel Williams
Notes: Merged-By: ioquatix <samuel@codeotaku.com>
2022-12-29Coverage.supported? recognizes oneshot_lines mode (#7040)Kevin Murphy
This adds oneshot_lines as a mode of coverage that is supported. Notes: Merged-By: ioquatix <samuel@codeotaku.com>
2022-11-08Fix false LocalJumpError when branch coverage is enabledYusuke Endoh
`throw TAG_BREAK` instruction makes a jump only if the continuation of catch of TAG_BREAK exactly matches the instruction immediately following the "send" instruction that is currently being executed. Otherwise, it seems to determine break from proc-closure. Branch coverage may insert some recording instructions after "send" instruction, which broke the conditions for TAG_BREAK to work properly. This change forces to set the continuation of catch of TAG_BREAK immediately after "send" (or "invokesuper") instruction. [Bug #18991] Notes: Merged: https://github.com/ruby/ruby/pull/6688
2022-10-17Change a tab to spacesyui-knk
Notes: Merged: https://github.com/ruby/ruby/pull/6570
2022-09-29Add `Coverage.supported?` to detect what modes are supported.Samuel Williams
2022-09-29Add `eval: true/false` flag to `Coverage.setup`.Samuel Williams
2022-09-22Enable coverage for eval.Samuel Williams
Notes: Merged: https://github.com/ruby/ruby/pull/6396
2022-07-11Fix a regression of b2e58b02aec73f9c350bf109c021c180fc699cccYusuke Endoh
At that commit, I fixed a wrong conditional expression that was always true. However, that seemed to have caused a regression. [Bug #18906] This change removes the condition to make the code always enabled. It had been enabled until that commit, albeit unintentionally, and even if it is enabled it only consumes a tiny bit of memory, so I believe it is harmless. [Bug #18906] Notes: Merged: https://github.com/ruby/ruby/pull/6112
2021-10-25Make Coverage suspendable (#4856)Yusuke Endoh
* Make Coverage suspendable Add `Coverage.suspend`, `Coverage.resume` and some methods. [Feature #18176] [ruby-core:105321] Notes: Merged-By: mame <mame@ruby-lang.org>
2021-06-23Check type of instruction - can be INSN or ADJUSTeileencodes
If the type is ADJUST we don't want to treat it like an INSN so we have to check the type before reading from `insn_info.events`. [Bug #18001] [ruby-core:104371] Co-authored-by: Aaron Patterson <tenderlove@ruby-lang.org> Notes: Merged: https://github.com/ruby/ruby/pull/4601
2020-06-20test/coverage/test_coverage.rb: Add a test for [Bug #16967]Yusuke Endoh
Notes: Merged: https://github.com/ruby/ruby/pull/3240
2019-12-04compile.c: stop wrong peephole optimization when covearge is enabledYusuke Endoh
jump-jump optimization ignores the event flags of the jump instruction being skipped, which leads to overlook of line events. This changeset stops the wrong optimization when coverage measurement is neabled and when the jump instruction has any event flag. Note that this issue is not only for coverage but also for TracePoint, and this change does not fix TracePoint. However, fixing it fundamentally is tough (which requires revamp of the compiler). This issue is critical in terms of coverage measurement, but minor for TracePoint (ko1 said), so we here choose a stopgap measurement. [Bug #15980] [Bug #16397] Note for backporters: this changeset can be viewed by `git diff -w`.
2019-04-17Introduce pattern matching [EXPERIMENTAL]ktsj
[ruby-core:87945] [Feature #14912] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@67586 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2019-02-01Revert r63383, r63248 "compile.c: copy a short insn with leave"nobu
When copying `leave` insn, TRACE also should be copied if it is present, but this optimization is trivial and not worth the complexity. [ruby-core:91366] [Bug #15578] 4cae5353c03009beb1e0a1619422072773580609 5afd479de63b6609ddcd1510da94d2c1ac384f7f git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@66977 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2019-01-01compile.c (iseq_set_sequence): fix branch coverage tablemame
Not only TRACE_ELEMENT but also INSN_ELEMENT may have events. The old pc2branchindex was created using only events of TRACE_ELEMENTs. This change uses events of INSN_ELEMENTs too for pc2branchindex table. [Bug #15476] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@66676 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2019-01-01compile.c: support branch coverage for `a&.foo = 1`mame
[Bug #15475] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@66674 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2019-01-01Revert r66670 because of wrong ticket numbermame
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@66672 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2019-01-01compile.c: support branch coverage for `a&.foo = 1`mame
[Bug #15476] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@66670 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2018-12-20ext/coverage/lib/coverage.rb (Coverage.line_stub): use only line eventsmame
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-10-20ext/coverage/: add the oneshot modemame
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-08-22compile.c: remove tracecoverage instruction for line coveragemame
Line coverage was based on special instruction "tracecoverage". Now, instead, it uses the mechanism of trace hook [Feature #14104]. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@64509 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2018-08-22parse.y: remove coverage-related code fragmentsmame
The code fragments that initializes coverage data were scattered into both parse.y and compile.c. parse.y allocated a coverage data, and compile.c initialize the data. To remove this cross-cutting concern, this change moves the allocation from "coverage" function of parse.y to "rb_iseq_new_top" of iseq.c. For the sake, parse.y just counts the line number of the original source code, and the number is passed via rb_ast_body_t. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@64508 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2017-12-20test/coverage/test_coverage.rb: make the expected value the same as 2.4mame
A follow up of r61350 git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@61352 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2017-12-18iseq.c (finish_iseq_build): fix coverage leakage [Bug #14191]mame
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
2017-12-12ext/coverage/coverage.c: Add test casesyui-knk
* 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
2017-12-12ext/coverage/coverage.c: remove COVERAGE_EXPERIMENTAL_MODEmame
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-05ext/coverage/coverage.c: method coverage has column info. of method def.mame
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-05Revamp method coverage to support define_methodmame
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-11-16Add a last location to branch coverageyui-knk
* 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-10-23Add test cases for branch coverageyui-knk
* 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-22Add test cases for branch coverageyui-knk
* 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-22Add test cases for branch coverageyui-knk
* 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-22Add test cases for branch coverageyui-knk
* 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-22test/coverage/test_coverage.rb: Use `<<~` to ease to calculate column of ↵yui-knk
target codes git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@60363 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2017-10-22Add column numbers to branch coverageyui-knk
* 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-09-23test/coverage/test_coverage.rb: Refactor coverage tests.mame
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-23Enable to take branch coverages for safe method invocationsyui-knk
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@59990 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2017-09-14Introduce NODE_UNLESS for branch coveragemame
`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-14Add method coveragemame
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@59888 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2017-09-14Fix the lineno of case statement that has no expressionmame
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@59886 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2017-09-14Add branch coverage for case-when statementmame
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@59885 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2017-09-14Add branch coverage for while and until statementsmame
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@59877 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2017-09-14Add branch coverage for if statementmame
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@59876 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2017-09-10compile.c: pop coverage tracenobu
* 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-03test_coverage.rb: suppress warningsnobu
* 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