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

gitdiff should strip a/ b/ prefixes from --- +++ lines #317

Closed
zackw opened this issue Sep 4, 2024 · 7 comments
Closed

gitdiff should strip a/ b/ prefixes from --- +++ lines #317

zackw opened this issue Sep 4, 2024 · 7 comments

Comments

@zackw
Copy link

zackw commented Sep 4, 2024

I am getting errors like

genhtml: WARNING: source file '/.../project/sourcefile.py'
  (in both baseline and current .info files)
  has same basename as 'diff' entry '/.../project/b/sourcefile.py' -
  but a different path.  Possible pathname mismatch?
genhtml: ERROR: possible path inconsistency in baseline/current/udiff data
	(use "genhtml --ignore-errors path ..." to bypass this error)

The error goes away if I run the diff file through sed 's@^\([-+]* \)[ab]/@\1@'. However, I generated the diff using gitdiff - shouldn't it handle this for me?

@henry2cox
Copy link
Collaborator

Yes. I believe is should.
Which version of lcov are you using? does your copy of gitdiff look substantially similar to the one here?

@henry2cox
Copy link
Collaborator

Ah - I noticed a bug in gitdiff. Will push a fix after some testing.

Can you confirm that .../project/sourcefile.py is unmodified in your sandbox (diff for that file should be empty).

@zackw
Copy link
Author

zackw commented Sep 5, 2024

Which version of lcov are you using?

"LCOV version 2.0-1" according to lcov --version. I see that this is outdated and I will update to at least 2.1 before filing any more bug reports.

does your copy of gitdiff look substantially similar to the one here?

Hm, no, and in particular

--- /usr/share/lcov/support-scripts/gitdiff	2024-09-04 09:43:26.000000000 -0400
+++ gitdiff.HEAD	2024-09-05 10:52:05.899340859 -0400
...
@@ -85,7 +92,12 @@
     s/\r//g;
     my $line = $_;

-    if ($line =~ /diff --git a\/(\S+) b\/(\S+)/) {
+    if ($line =~ /(^diff|\+\+\+|---) /) {
+        # remove the a/b leader from the
+        $line =~ s# [ab]/# $prefix#g;
+    }
+
+    if ($line =~ /^diff --git (\S+) (\S+)/) {

And the newer gitdiff does indeed remove the a/ b/ prefixes from the --- and +++ lines.

Can you confirm that .../project/sourcefile.py is unmodified in your sandbox (diff for that file should be empty).

No, the genhtml error happens on the first file that is modified. Both versions of gitdiff produce output like this for unmodified files:

diff --git a/pyproject.toml b/pyproject.toml
=== pyproject.toml
diff --git a/setup.py b/setup.py
=== setup.py

but genhtml doesn't seem to care about the a/ b/ prefixes on the "diff --git" lines.

@henry2cox
Copy link
Collaborator

For curiousity: I just noticed that the source file in question appears to be python...but I think I added the py2lcov translator to lcov after the 2.0 release.
So now I'm curious where you got the input data that genhtml was complaining about.
If you were using the lcov 2.0 release, I don't think you had the translator - which means that there must be another one out there...so I'm wondering if that one is better than this one (...so I can get rid of a component or possibly fix what is missing).
Thanks
Henry

@zackw
Copy link
Author

zackw commented Sep 6, 2024

coverage.py can generate LCOV-format reports since version 6.3, but it's got some bugs (e.g. nedbat/coveragepy#1846) and it doesn't emit function coverage records. If you like, I can give py2lcov a try and see if it does a better job on my project.

@henry2cox
Copy link
Collaborator

Sure...give it a try - perhaps, after your other issues are resolved.

py2lcov does generate function records :-)
Probably still some bugs or misfeatures, though.

@henry2cox
Copy link
Collaborator

I'm going to close this one because I think it was addressed (due to out-of-date version).
If there is still a problem, please either reopen this issue or file a new one.
Please include a testcase that exhibits the problem, if at all possible.

@henry2cox henry2cox closed this as not planned Won't fix, can't repro, duplicate, stale Sep 11, 2024
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