Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

cov--lcov-parse error #47

Closed
kmerfeld opened this issue Jul 22, 2022 · 5 comments
Closed

cov--lcov-parse error #47

kmerfeld opened this issue Jul 22, 2022 · 5 comments

Comments

@kmerfeld
Copy link

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
Copy link
Contributor

snogge commented Jul 22, 2022

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
Copy link
Author

I'm using nyc/babel-plugin-istanbul

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

@snogge
Copy link
Contributor

snogge commented Jul 25, 2022

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
Copy link
Author

kmerfeld commented Aug 5, 2022

your right, this is nyc doing something weird istanbuljs/nyc#1277

Thanks for helping me find this!

@kmerfeld kmerfeld closed this as completed Aug 5, 2022
@snogge
Copy link
Contributor

snogge commented Aug 5, 2022

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants