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 the issue with coverage inside of a TypeApply #18420

Merged
merged 1 commit into from
Aug 25, 2023

Conversation

javax-swing
Copy link

@javax-swing javax-swing commented Aug 18, 2023

Based on looking into the issues that: #17239 was trying to solve.

It was discovered that TypeApply was throwing away parts of the expression tree, which meant that the coverage file contained references to things that could never be invoked.

Note that i'm not too familiar with opening pull requests in github, so my apologies if this is not correct

@javax-swing javax-swing changed the title Fix the issue with coverage that was caused by information being lost… Fix the issue with coverage inside of a TypeApply Aug 19, 2023
Copy link
Member

@mbovel mbovel left a comment

Choose a reason for hiding this comment

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

Thanks for your PR, looks good to me.
Could you please 1. add a test in tests/coverage/pos demonstrating the fix, and 2. rebase your commits into a single one?

@javax-swing
Copy link
Author

@mbovel I've made the changes you suggested.

It seems that it was a bit more involved than adding a test into tests/coverage/pos as my changes didn't result in a change in the scoverage.coverage file, but rather in a runtime change.

So i've added the ability for any of the tests/coverage/run tests to include a $filename.measurement.check file. When present the CoverageTests suite will verify that the generated measurement file matches the check file (similar to the scoverage.check file)

This is optional behaviour for now.

@@ -61,6 +61,26 @@ class CoverageTests:
val instructions = FileDiff.diffMessage(expectFile.toString, targetFile.toString)
fail(s"Coverage report differs from expected data.\n$instructions")

// measurement files only exist in the "run" category
Copy link
Author

Choose a reason for hiding this comment

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

This verifies the measurement file against the check file (if a measurement check file exists).

Mainly so that none of the other tests need tweaking

Copy link
Member

@KacperFKorban KacperFKorban left a comment

Choose a reason for hiding this comment

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

The change looks good to me.
Added one small nitpick.

… with a TypeApply

Add the ability to verify measured coverage invocations in CoverageTests
Copy link
Member

@KacperFKorban KacperFKorban left a comment

Choose a reason for hiding this comment

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

LGTM

@javax-swing
Copy link
Author

Thanks for your PR, looks good to me. Could you please 1. add a test in tests/coverage/pos demonstrating the fix, and 2. rebase your commits into a single one?

done

Copy link
Member

@mbovel mbovel left a comment

Choose a reason for hiding this comment

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

LGTM!

@sjrd sjrd merged commit 2616c8b into scala:main Aug 25, 2023
17 checks passed
@javax-swing javax-swing deleted the adjust-coverage branch August 25, 2023 12:37
@TheElectronWill
Copy link
Contributor

thanks for the fix!

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.

7 participants