AdamNiederer / cov

An emacs extension for displaying coverage data on your code
GNU General Public License v3.0
76 stars 16 forks source link

One coverage file per source file model prevents many uses #36

Closed dabrahams closed 2 years ago

dabrahams commented 3 years ago

For example, I'm working on a Swift project, which creates either one .json or one .lcov file for the entire run (the same would go for any language in Apple's toolchain). I've been unable to get cov to recognize the output files for whatever reason. It's a shame that I can't even seem to get started with this package; I've had to use coverlay instead, which has some weaknesses I'd hoped cov would fix, but until it's more flexible about the contents and location of the coverage file, I'm afraid I'll never know.

snogge commented 3 years ago

Cov.el does have a data model that supports multiple source files with one coverage file. Please provide more detail about the file system layout and the settings you have done.

dabrahams commented 3 years ago

Sorry, I'm not sure what detail you need, but I'll try. When I run, I get a single .lcov file; I have control over what path it gets generated to; I'm currently generating the .lcov to ./.build/coverage.lcov w.r.t. the root of the project. If this arrangement is supported by Cov.el, it's not obvious from the instructions, which seem to be directed at finding a file with the same base name as a source file.

Thanks!

On Sat, May 15, 2021 at 12:49 PM Ola Nilsson @.***> wrote:

Cov.el does have a data model that supports multiple source files with one coverage file. Please provide more detail about the file system layout and the settings you have done.

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub https://github.com/AdamNiederer/cov/issues/36#issuecomment-841715195, or unsubscribe https://github.com/notifications/unsubscribe-auth/AAAKYIKIE5Z3U3XIYF3Y533TN3F4LANCNFSM44POZJVA .

-- -Dave

snogge commented 3 years ago

Sorry, even if the README states that lcov is supported it really isn't. I was hoping that this was something that could be solved by tweaking the coverage-file-finder. Does the json file also contain coverage data? If so, do you know what format it is?

dabrahams commented 3 years ago

Yes, it does, but I'm not sure about the format. I think it's almost certainly what's shown here: https://keith.github.io/xcode-man-pages/xccov.1.html

On Mon, May 17, 2021 at 2:28 PM Ola Nilsson @.***> wrote:

Sorry, even if the README states that lcov is supported it really isn't. I was hoping that this was something that could be solved by tweaking the coverage-file-finder. Does the json file also contain coverage data? If so, do you know what format it is?

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub https://github.com/AdamNiederer/cov/issues/36#issuecomment-842653160, or unsubscribe https://github.com/notifications/unsubscribe-auth/AAAKYILLPCAALVPJFTQA4P3TOGC7XANCNFSM44POZJVA .

-- -Dave

snogge commented 3 years ago

As far as I can tell from that man page, the JSON file does not contain enough information to display coverage for each line. It's more of a summary on a function level. It seems xccov can output line coverage, but it is not included in the JSON report. I could be wrong, I have no access to the tools so I cannot check an actual file.

dabrahams commented 3 years ago

Thanks for responding… there has to be line-by-line coverage information. Digging deeper, the format appears to be what's discussed here: https://stackoverflow.com/questions/56013927/how-to-read-llvm-cov-json-format Does that help?

On Tue, May 18, 2021 at 12:26 AM Ola Nilsson @.***> wrote:

As far as I can tell from that man page, the JSON file does not contain enough information to display coverage for each line. It's more of a summary on a function level. It seems xccov can output line coverage, but it is not included in the JSON report. I could be wrong, I have no access to the tools so I cannot check an actual file.

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub https://github.com/AdamNiederer/cov/issues/36#issuecomment-842925793, or unsubscribe https://github.com/notifications/unsubscribe-auth/AAAKYIPB4Z3DK7VG3E7LWBLTOIJAZANCNFSM44POZJVA .

-- -Dave

snogge commented 3 years ago

I decided it was probably easier to implement a lcov parser so I did that. I'm still working on the finder function, but it should be ready in a day or so. Any input on how you would find the relevant .info file from the source file would be helpful.

dabrahams commented 3 years ago

Regarding, "how you would find the relevant .info file from the source file", I don't understand. There's just one lcov file generated for all the source files in my project. Where it is located is arbitrary; my build setup happens to put it in .build/coverage.lcov in my project's root directory, but that could easily be changed. I could set up a directory-local variable if that helps cov…

On Thu, May 20, 2021 at 1:00 AM Ola Nilsson @.***> wrote:

I decided it was probably easier to implement a lcov parser so I did that. I'm still working on the finder function, but it should be ready in a day or so. Any input on how you would find the relevant .info file from the source file would be helpful.

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub https://github.com/AdamNiederer/cov/issues/36#issuecomment-844833726, or unsubscribe https://github.com/notifications/unsubscribe-auth/AAAKYIINIFPQXTQSMF2AZWTTOS6QPANCNFSM44POZJVA .

-- -Dave

snogge commented 3 years ago

Each time you enable cov-mode in a buffer, it will search for the coverage file using a number of registered methods. The first matcher looks for a matching gcov file in the same directory, and then there is a number of matchers for other coverage formats like clover and cobertura. The first matcher that finds a file "wins" and determines the coverage format. As you say, the location of the info file depends on the project.
So what would be the most useful way for you to make cov-mode automatically figure out that there is an lcov info file available? I have designed a method that uses both a variable that you can set locally as well as a list of info-file-matchers that can be set up to match your usual project setups. I think that will work for most users.

dabrahams commented 3 years ago

That seems like a good solution. I might put the variable setting in my project's .dir-locals.el

dabrahams commented 3 years ago

FYI: Time is growing short for me to make use of this in a lasting way; I have to leave my current project behind and I'd like to be able to pass it on to future users with the ability to use cov. No pressure ;-)

snogge commented 3 years ago

Sorry for the radio silence. Deadlines...

I ran into some problems with #23 that needed further work before I could get lcov to work properly. It's still not completely done, but I have pushed a branch that works for me to https://github.com/snogge/cov/tree/lcov-wip for now.

I have only verified that it works to set a path to the lcov file with a local variable like this:

/* Local Variables: */
/* cov-lcov-file-name: "path/to/lcov.info" */
/* End: */

I hope you'll have some use for it. I will probably finish this up properly some day....