AdamNiederer / cov

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

cov--lcov-parse error #47

Closed kmerfeld closed 2 years ago

kmerfeld commented 2 years ago

in cov--lcov-parse I need to add the following to get this working

diff --git a/cov.el b/cov.el
index c73082a..2af6d69 100644
--- a/cov.el
+++ b/cov.el
@@ -397,7 +397,7 @@ Return a list `((FILE . ((LINE-NUM EXEC-COUNT) ...)) ...)'."
                         (setq sourcefile (file-truename
                                           (expand-file-name
                                            (buffer-substring (point) (line-end-position))
-                                           (file-name-directory cov-coverage-file))))
+                                           (replace-regexp-in-string "/.coverage/$" "" (file-name-directory cov-coverage-file)))))
                         (setq filelines
                               (or (gethash sourcefile data)
                                   (puthash sourcefile (make-hash-table :test 'eql) data)))))

my lcov.info file is in $projectroot/.coverage/lcov.info each path in cov-coverages was getting /.coverage/ in it

I don't really understand why this is happening, do you have any insight?

Thanks for your work on this project!

snogge commented 2 years ago

What tool are you using to generate that lcov.info file? The lines starting with SF in the lcov.info file are supposed to be absolute paths to the originating souce file. Is this not the case for you?

kmerfeld commented 2 years ago

I'm using nyc/babel-plugin-istanbul

In the lcov.info file it doesn't have the /.coverage/ path SF:src/app.js

snogge commented 2 years ago

OK, that is not an absolute path which I assumed when I wrote the parser. According to the istanbul docs here https://istanbul.js.org/docs/advanced/alternative-reporters/#lcovonly , the lcov.info file should have the SF lines like SF:$PROJECT_PATH/src/bar/index.ts So is this a configuration problem on your end?

I don't do any JS coding, so I wont be able to set up any test projects. I also do not know the ecosystem, but maybe you know which project could answer why the paths are not absolute?

I have an idea that might work, but I would like to know how you find the lcov.info file from your source files.

kmerfeld commented 2 years ago

your right, this is nyc doing something weird https://github.com/istanbuljs/nyc/issues/1277

Thanks for helping me find this!

snogge commented 2 years ago

Just so I do not forget: My idea was, that if I from /some/project/containing/source.js find /some/project/unrelated/lcov.info and the SF entries in that file are relative it should be possible to find SF entries that match the end of the source file path; containing/source.js in this case. It is then possible to determine that the "project root" for lcov.info should be /some/project. Each source file referenced by lcov.info then has to be prefixed by this path in the cov data structures.

But it should be noted that the lcov docs clearly states that the SF entries should be absolute paths.