oneshot coverage does not allow counting code lines without coverage
I'm using https://github.com/grosser/single_cov to alert when uncovered lines where added to the codebase after each test run.
I'd love to use oneshot coverage for that to make it faster, but noticed that this does not work since there is no way to find out which lines of a given files are uncovered.
My naive implementation failed https://github.com/grosser/single_cov/pull/17 since to know what uncovered lines are I need to know which lines ruby considers code,
otherwise I'd be alerting on comments etc that are uncovered.
Example: loading this file would result in oneshot coverage of , loading an executing would result on [2,3]
but since I don't have a way of knowing that line 3 is code and supposed to be covered, I cannot show it as uncovered code.
# Foo <- not code and not covered = OK def a <- code and covered = OK 1 <- code and not covered = FAIL end <- not code and not covered = OK
- oneshot could be implemented as true/false/nil array for covered, uncovered, no-code (maybe oneshot_lines: :full)
- oneshot could resturn the same hash as regular coverage, but with only 1/0 (maybe oneshot_lines: :hash)
oneshot_linesenabled at the same time and make lines stop counting at 1
Updated by mame (Yusuke Endoh) about 2 months ago
Thank you for playing with oneshot coverage. You may want to use
$ cat t.rb # Foo def a 1 end
$ ruby -rcoverage -e 'p Coverage.line_stub("t.rb")' [nil, 0, 0, nil]
nil means that the corresponding line is uncoverable.
0 means that the corresponding line is coverable (lines ruby considers code).