From: "mame (Yusuke Endoh)" Date: 2022-09-22T22:26:59+00:00 Subject: [ruby-core:110008] [Ruby master Feature#19008] Introduce coverage support for `eval`. Issue #19008 has been updated by mame (Yusuke Endoh). @jeremyevans0 Thank you for joining the discussion! jeremyevans0 (Jeremy Evans) wrote in #note-7: > 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. Now I am a bit keen to have `Coverage.start(eval: false)` because there may be some issues that we don't know yet. > In the cases where I do care and I want to check coverage of evaled code, it would be best to be able to look at all evals separately. It looks like your current approach is to just override any existing coverage entry for each new eval, which does not allow for that. It is a fair point, but I am afraid that recording per call to eval will bloat the coverage data without limit. How about accumulating all coverage data of eval'ed code? ``` 10000.times do |i| eval <<-END, binding, __FILE__, __LINE__+1 1 END end Coverage.result #=> { __FILE__ => [1, nil, ...], [:eval, __FILE__] => [10000] } ``` I am very afraid if the key `[:eval, __FILE__]` will break some existing coverage tools like simplecov. If we choose this design, we should introduce `Coverage.start(eval: false)` and disable it by default. ---------------------------------------- Feature #19008: Introduce coverage support for `eval`. https://bugs.ruby-lang.org/issues/19008#change-99259 * 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: