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

Empty file when merging lcov.files #55

Open
migheorghe opened this issue Feb 3, 2023 · 8 comments
Open

Empty file when merging lcov.files #55

migheorghe opened this issue Feb 3, 2023 · 8 comments

Comments

@migheorghe
Copy link

For some reasone version 4 does not output anything when run like bellow:
V4.0.0 - npx lcov-result-merger "C:\temp\CodeCoverage**\lcov.info" "C:\Temp\CodeCoverage\lcov.info"

version 3.3.0 works as expected
npx [email protected] "C:\temp\CodeCoverage**\lcov.info" "C:\Temp\CodeCoverage\lcov.info"

@yuriy-yarosh
Copy link

yuriy-yarosh commented May 20, 2023

@migheorghe It's overwriting the original files, prepending the path over and over with the --prepend-source-files arg.

I'm using it as a yarn bin instead of a yarn script, and it's the only way it works, for some reason.

yarn coverage && yarn lcov-result-merger **/coverage/lcov.info lcov.info --prepend-source-files

There should be some kind of pwd bug, when it can't switch to the root folder of a monorepo.

I migh refactor this project a bit, and provide a bit more decent replacement, in the future.

@mweibel
Copy link
Owner

mweibel commented May 22, 2023

@mdeanjones any idea here?

@mdeanjones
Copy link
Collaborator

Nothing at present @mweibel. I'll be closing out some other work in the next couple of weeks, and plan on digging into this.

@yuriy-yarosh refactors are welcome! There's a lot that I've been eyeing too.

@mdeanjones
Copy link
Collaborator

Following up on this @migheorghe. v5.0.0-rc.0 has just been released which may contain a fix for the problem that you are experiencing. Prior versions were creating a temp file named lcov.info in the working directory that might be clobbering things for you.

OLD

lcov-result-merger/index.js

Lines 104 to 107 in 5aa886d

fs.writeFileSync('lcov.info', Buffer.from(report.toString()), {
encoding: 'utf-8',
flag: 'w+',
});

With this release, that temp file is being created in the OS' temp space, so it should never collide.

NEW

const tmpFile = await config.getTempFilePath();
await writeFile(tmpFile, Buffer.from(report.toString()), {
encoding: 'utf-8',
flag: 'w+',
});

I think that we can move even further and eliminate using temp files altogether... more refactors incoming.

@carboni-rob
Copy link

I seem to be still experiencing this on 5.0.0.

@carboni-rob
Copy link

Tbh, I don't seem to be able to make any combination of versions/commands/options work.
The files are picked up, but lines, functions and branches are all 0/0.

@mdeanjones
Copy link
Collaborator

mdeanjones commented Dec 22, 2023

@carboni-rob, would you be able to create a minimal reproduction of your issue, or furnish a sample file that is failing to be read?

Initial thoughts:

  1. Line breaks aren't being handled correctly when parsing files.
  2. Something that is somehow tied into [5.0.0] Issues with host system temp directory for transient lcov.info file #58

Happy holidays!

@Farenheith
Copy link

I was having the same issue, actually was about to post it here, when I realized my problem was that the file pattern informed to lcov-result-merger was wrong.

@mdeanjones maybe you could output some feedback when no source lcovs are found, which can give a clue for the user if he got the parameters wrong.

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

6 participants