Skip to content

Handle multiple coverage files#483

Merged
ryanluker merged 6 commits into
ryanluker:masterfrom
mattseddon:fix-481
Aug 10, 2025
Merged

Handle multiple coverage files#483
ryanluker merged 6 commits into
ryanluker:masterfrom
mattseddon:fix-481

Conversation

@mattseddon

@mattseddon mattseddon commented Jun 11, 2025

Copy link
Copy Markdown
Collaborator

Closes #481

cc @ryanluker - I'm leaving this one as draft as I'm not too sure how you've setup the data structures here. Please let me know if there are downstream consequences that I've missed. I couldn't see any.

This PR gives the extension the ability to handle multiple coverage files.

I have left some comments inline.

testFiles.set("/file/123", "datastringhere");
testFiles.set("/file/111", "datastring111");
testFiles.set("/file/222", "datastring222");
testFiles.set("/file/123", "samestringhere");

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

As this is a map it only ever has 3 entries, making the test meaningless :(

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

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

Whoops hah! Darn Ryan from many ages ago 😅.

@mattseddon mattseddon self-assigned this Jun 11, 2025
@ryanluker ryanluker added this to the 2.14.0 milestone Jul 13, 2025

@ryanluker ryanluker left a comment

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

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

I'm leaving this one as draft as I'm not too sure how you've setup the data structures here. Please let me know if there are downstream consequences that I've missed. I couldn't see any.

This is looking good to me so far, downstream wise I don't think they account for duplicate coverage lines and more just focus on parsing test out into a single file format.

I did leave one question in the coverageparser though and how we might decide between different conflicts.

testFiles.set("/file/123", "datastringhere");
testFiles.set("/file/111", "datastring111");
testFiles.set("/file/222", "datastring222");
testFiles.set("/file/123", "samestringhere");

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

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

Whoops hah! Darn Ryan from many ages ago 😅.

Comment thread src/files/coverageparser.ts Outdated
Comment thread src/files/coverageparser.ts Outdated
const sections = new Map<string, Section>();
const addToSectionsMap = async (section: Section) => {
sections.set(section.title + "::" + section.file, section);
sections.set([coverageFilename, section.title, section.file].join("::"), section);

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

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

I am curious how this will decide between two conflicting coverage files / lines? Do we just need to assume the "best case" scenario and pick the coverage line that is more positive?

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

The answer is: this breaks at least one thing downstream (Displayed coverage %).

@ryanluker ryanluker removed this from the 2.14.0 milestone Jul 13, 2025
@ryanluker ryanluker changed the title use coverage filename in cache keys Use coverage filename in cache keys Jul 13, 2025
Comment thread example/node/lcov.info
@@ -1,10058 +0,0 @@
TN:

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

@ryanluker er.... why was this file so long?

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

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

It was to test out "large coverage" files / big code repositories.

I ended up just copy and pasting a bunch of jiggerish to make it big enough to detecting performance regressions.

switch (coverageFile.type) {
case CoverageType.CLOVER:
coverage = await this.xmlExtractClover(fileName, fileContent);
await this.xmlExtractClover(

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

[F] Each of these extract methods now mutate the original coverages Map.

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

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

Gotcha that makes sense to allow for the multiple coverage files scenario.

return;
}

const mergedSection = this.mergeSections(existingSection, section);

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

[F] If we already have a section with the current title and file, then we merge the line and branch information as they are used downstream.

});
}

private mergeSections(existingSection: Section, section: Section): Section {

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

[F] If you look at 66df5d7 you can see how I initially worked this out by updating the node example project.

FNDA:1,test
DA:1,1
DA:2,1
DA:3,1

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

Line 3 is only covered by the integration test in this example.

@mattseddon mattseddon changed the title Use coverage filename in cache keys Handle multiple coverage files Jul 25, 2025
@mattseddon mattseddon requested a review from ryanluker July 25, 2025 10:05
@mattseddon mattseddon marked this pull request as ready for review July 25, 2025 10:06
import { OutputChannel } from "vscode";

import {CoverageFile, CoverageType} from "./coveragefile";
import { CoverageFile, CoverageType } from "./coveragefile";

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

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

Yeahhh this file hasn't been touched in a while, didn't even have the latest lintings 😓.

};
}

private mergeLineCoverage(

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

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

This merging logic looks correct to me, nice work 🦾.

@ryanluker ryanluker left a comment

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

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

Very nice work! I will add this against the 2.14.0 release.

@ryanluker ryanluker merged commit 481f515 into ryanluker:master Aug 10, 2025
5 checks passed
@ryanluker ryanluker added this to the 2.14.0 milestone Aug 10, 2025
@mattseddon mattseddon deleted the fix-481 branch August 10, 2025 20:58
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.

Not handling multiple lcov files correctly

2 participants