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

Fix lcov 2.0 source file handling #315

Merged
merged 1 commit into from Aug 9, 2023

Conversation

warmwaffles
Copy link
Contributor

Prior to 2.0 being released, genhtml was much better about handling source files from the following paths:

  • test/support/some_helper.ex
  • lib/foo/bar.ex

But after 2.0 was released, when rendering with genhtml the paths would be mangled and look like the following:

  • test/support/test/support/some_helper.ex
  • lib/foo/lib/foo/bar.ex

I have tried in vain with many permutations of --prefix when running genhtml but the ultimate fix that made all of this go away was using the absolute path for the source file (SF).

Prior to 2.0 being released, `genhtml` was much better about handling
source files from the following paths:

* `test/support/some_helper.ex`
* `lib/foo/bar.ex`

But after 2.0 was released, when rendering with `genhtml` the paths
would be mangled and look like the following:

* `test/support/test/support/some_helper.ex`
* `lib/foo/lib/foo/bar.ex`

I have tried in vain with many permutations of `--prefix` when running
`genhtml` but the ultimate fix that made all of this go away was using
the absolute path for the source file (`SF`).
@warmwaffles warmwaffles force-pushed the fix-lcov-2.0-pathing-problems branch from 3633ecf to c6b4bd4 Compare July 24, 2023 21:20
@@ -53,18 +53,18 @@ defmodule ExCoveralls.LcovTest do
Lcov.execute(@source_info)
end) =~ @stats_result

assert(File.read!(report) =~ ~s(TN:\nSF:test/fixtures/test.ex\nDA:1,0\nDA:2,1\nLF:2\nLH:1\nend_of_record\n))
%{size: size} = File.stat! report
assert(size == @file_size)
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I had to remove the file size assertion because with the absolute path being used, it would cause the file size to be different.

We already test the file size via the File.read! and matching it against the string.

@warmwaffles
Copy link
Contributor Author

Hopefully @parroty this is okay to merge upstream as it would be nice for me to stop having to manually shim in a find replace for SF: files in my lcov info file.

@parroty parroty merged commit b475ec9 into parroty:master Aug 9, 2023
4 checks passed
@parroty
Copy link
Owner

parroty commented Aug 9, 2023

Thanks!

@warmwaffles warmwaffles deleted the fix-lcov-2.0-pathing-problems branch August 9, 2023 04:20
@warmwaffles
Copy link
Contributor Author

I think the issue resides somewhere in the lcov perl based upstream when they updated to 2.0, but I really don't know or have the time to go figure that bit out.

standback

@parroty
Copy link
Owner

parroty commented Aug 9, 2023

Thanks for the comment 🙇 . (Before releasing the new version) I just wanted to confirm if it works on lcov 1.x too, as it's about the path expansion, correct?

@warmwaffles
Copy link
Contributor Author

warmwaffles commented Aug 9, 2023

Correct, it's the path expansion/truncation being messed up. I have not checked this with lcov 1.0 as my distro and others have all bumped and upgraded as well.

@warmwaffles
Copy link
Contributor Author

warmwaffles commented Aug 9, 2023

This is what it looks like on LCOV 2.0 before this patch

20230808-233818

And after the patch is applied

20230808-234028

Generated with

MIX_ENV=test mix coveralls.lcov


genhtml \
    --output-directory cover \
    --show-navigation \
    --no-function-coverage \
    --no-branch-coverage \
    --flat \
    --quiet \
    ./cover/lcov.info

@warmwaffles
Copy link
Contributor Author

warmwaffles commented Aug 9, 2023

20230808-234429

Here's the patch with lcov 1.16

pardon my crappy coverage here... you can see why I need this 😄

@parroty
Copy link
Owner

parroty commented Aug 9, 2023

Thanks for the detailed information 🙇 . I try to release the package later today.

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

Successfully merging this pull request may close these issues.

None yet

2 participants