From: "jeremyevans0 (Jeremy Evans)" Date: 2022-09-22T21:13:38+00:00 Subject: [ruby-core:110004] [Ruby master Feature#19008] Introduce coverage support for `eval`. Issue #19008 has been updated by jeremyevans0 (Jeremy Evans). Considering the issues, could we make `eval` coverage optional, maybe by a keyword to `Coverage.start`? I'd prefer it be opt-in, but at the minimum I think we need an option to disable it if it is enabled by default. mame (Yusuke Endoh) wrote in #note-5: > I propose three possible solutions: > > * 1. Do not record an eval coverage when a file coverage already exists. (And if a file is required after eval, overwrite an eval coverage with a file coverage) > * 2. Accumulate the two data (It is inaccurate, but it is maybe better than current) > * 3. Record the data for eval as another key (This will break some coverage tools because it changes the type of keys) I would prefer 3. It should always be possible to inspect the coverage data to determine whether the coverage is for `eval` or `load`/`require`. I think a unique coverage key should be generated for each eval. With this example: ```ruby 3.times do |i| eval <<-END, binding, __FILE__, __LINE__+1 case i when 0 p "a" when 1 p "2" else p "b" end END end ``` You should have 3 separate coverage entries, one for each `eval`, each showing some branches/lines covered and others not. ---------------------------------------- Feature #19008: Introduce coverage support for `eval`. https://bugs.ruby-lang.org/issues/19008#change-99255 * Author: ioquatix (Samuel Williams) * Status: Open * Priority: Normal ---------------------------------------- I'd like to introduce coverage support for `eval`. I mostly only care about the case where an explicit path is given, and I'd even be okay to only handle the case where the line number is the default (0). https://github.com/ruby/ruby/pull/6396 This is an incredibly useful feature for computing coverage of ERB templates and other similar things. -- https://bugs.ruby-lang.org/ Unsubscribe: