summaryrefslogtreecommitdiff
path: root/test/coverage/test_coverage.rb
diff options
context:
space:
mode:
authorYusuke Endoh <mame@ruby-lang.org>2019-12-04 10:33:35 +0900
committerYusuke Endoh <mame@ruby-lang.org>2019-12-04 10:40:54 +0900
commitf9e5c74cd24025a5aa19e318e8fecabf207f1b7b (patch)
treeec8826ff9768c25b0e3a88761aec5fdc83b272ec /test/coverage/test_coverage.rb
parent5a404efd29d255402e30f4f23a09d4e5398600b8 (diff)
compile.c: stop wrong peephole optimization when covearge is enabled
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`.
Diffstat (limited to 'test/coverage/test_coverage.rb')
-rw-r--r--test/coverage/test_coverage.rb12
1 files changed, 12 insertions, 0 deletions
diff --git a/test/coverage/test_coverage.rb b/test/coverage/test_coverage.rb
index f88e97e..1de39bf 100644
--- a/test/coverage/test_coverage.rb
+++ b/test/coverage/test_coverage.rb
@@ -728,4 +728,16 @@ class TestCoverage < Test::Unit::TestCase
}
}
end
+
+ def test_stop_wrong_peephole_optimization
+ result = {
+ :lines => [1, 1, 1, nil]
+ }
+ assert_coverage(<<~"end;", { lines: true }, result)
+ raise if 1 == 2
+ while true
+ break
+ end
+ end;
+ end
end