source_gen icon indicating copy to clipboard operation
source_gen copied to clipboard

Coverage ignore option

Open jtdLab opened this issue 3 years ago • 3 comments

Hi,

is it possible to add an option to combining_builder which leads to the line //coverage:ignore-file beeing added on top of generated files. Or is there already an existing solution?

Something like:

targets:
  $default:
    builders:
      source_gen:combining_builder:
        options:
          coverage-ignore-file: true

jtdLab avatar Sep 24 '22 22:09 jtdLab

It could be added (would work similar to ignore_for_file).

Note though that this would take effect for all source_gen builder outputs that are combined into that file, which might be fine, but is worth keeping in mind.

I would probably try and lean towards something a bit more general though than a coverage-specific thing. Not sure why ingore_for_file was implemented that way as a general approach would also have solved this use case :).

jakemac53 avatar Sep 26 '22 15:09 jakemac53

Yep i agree a general approach would be the preferable solution.

jtdLab avatar Sep 26 '22 23:09 jtdLab

I spoke a bit with @kevmoo and it sounds like we agree this is a sensible feature to have - but I don't think either of us have the time to implement it at this time. We would accept a PR though, either with a specific option to ignore coverage (maybe ignore_coverage: true?) or a general preamble option which accepts any text and inserts it at the top of the file. If we did the more general approach we would want to ensure the text ends with a newline.

jakemac53 avatar Sep 27 '22 19:09 jakemac53

See https://github.com/dart-lang/source_gen/pull/636#issuecomment-1384683749

kevmoo avatar Jan 17 '23 02:01 kevmoo

er, preamble

kevmoo avatar Jan 17 '23 02:01 kevmoo