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

Support relative filenames in lcov.info #59

Open
vlnn opened this issue Jun 17, 2024 · 6 comments
Open

Support relative filenames in lcov.info #59

vlnn opened this issue Jun 17, 2024 · 6 comments

Comments

@vlnn
Copy link

vlnn commented Jun 17, 2024

The cov.el expects the lcov.info with absolute file paths in SF field:

cov/cov.el

Line 402 in 42bf07c

;; SF always hold an absolute path

At least one tool (https://github.com/cloverage/cloverage) generates lcov files with file names relative to the project path, which makes it impossible to match with cov.el workflow. I've made quick POC to enable this flow: vlnn@9d1836a . This is, of course, very limited to my needs only, without configuration and relying on specific clojure mode to find the project's root.

Is there a possibility to enable proper configuration/functionality for relative filenames in lcov.info?

@snogge
Copy link
Contributor

snogge commented Jun 18, 2024

Relative filenames are supported - as I read the code, despite the comment - , but they are assumed to be relative to the lcov.info file.
I'm not sure how project roots should be handled in a generic way.
The lcov specification (such as it is; man geninfo) specifies that SF should be absolute. Maybe file an issue with https://github.com/cloverage/cloverage instead?

Update:

The man page on my system (debian bookworm) says that SF should be absolute, but the current man page in the lcov repo only says file path
https://github.com/linux-test-project/lcov/blob/master/man/geninfo.1#L1194
without explaining how relative paths should be interpreted.

cloverage already has an issue about this: cloverage/cloverage#323

Would it be possible for you to post (part of) an lcov.info file here? Please try to make it minimal but complete.

@vlnn
Copy link
Author

vlnn commented Jun 18, 2024

Sure! Here it is for the smallest file:

TN:
SF:src/call_martian/config/core.clj
DA:1,1
DA:5,1
DA:6,5
DA:8,1
DA:9,7
DA:11,1
DA:12,7
DA:14,1
DA:15,4
DA:17,1
DA:18,4
DA:20,1
DA:21,4
LF:13
LH:13
end_of_record

@snogge
Copy link
Contributor

snogge commented Jun 19, 2024

There is really nothing in there to help us find the starting point of the relative paths.
How do you find the lcov.info file from your source file when you start cov-mode?

@vlnn
Copy link
Author

vlnn commented Jun 19, 2024

How do you find the lcov.info file from your source file when you start cov-mode?

As I'm using lcov.info generated over Clojure project, I run lein cloverage —lcov from the root of the project (the directory with project.clj), and then the results are in the ./target/coverage/lcov.info. The full path from each source file to lcov.info can vary, as Clojure ./src/ can hold *.clj files in complex tree of directories.

@snogge
Copy link
Contributor

snogge commented Jun 27, 2024

Maybe my question was not clear enough - or I'm not awake enough to understand the answer.
When you activate cov-mode in one of your source files, what do you need to do for cov-mode to find the lcov.infofile? Do you have any directory local variables, for instance cov-lcov-patterns. Otherwise cov-mode would only look in the same directory as the source file.

@vlnn
Copy link
Author

vlnn commented Jun 29, 2024

Maybe my question was not clear enough - or I'm not awake enough to understand the answer. When you activate cov-mode in one of your source files, what do you need to do for cov-mode to find the lcov.infofile? Do you have any directory local variables, for instance cov-lcov-patterns. Otherwise cov-mode would only look in the same directory as the source file.

All I'm using to configure cov-mode so it can find lcov.info is exactly one line in use-package! as it seems to be in same place for every project I've been testing:
(setq cov-lcov-file-name (concat (clojure-project-dir) "target/coverage/lcov.info"))

Full configuration in my doom-emacs style is:

(use-package! cov
  :demand t
  :defer t
  :init
  (setq cov-coverage-mode t)
  (setq cov-fringe-symbol 'empty-line)
  (custom-set-faces
   '(cov-coverage-not-run-face ((t (:foreground "#900000"))))
   '(cov-coverage-run-face ((t (:foreground "#00BE00"))))
   '(cov-none-face ((t (:foreground "#0000F0")))))

  :config
  (setq cov-lcov-file-name (concat (clojure-project-dir) "target/coverage/lcov.info"))
  :hook
  (cider-mode . cov-mode))

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