-
-
Notifications
You must be signed in to change notification settings - Fork 6.5k
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
Refactor -o & --coverage implementation | Fixes #6859 #7611
Conversation
Thank you for your pull request and welcome to our community. We require contributors to sign our Contributor License Agreement, and we don't seem to have you on file. In order for us to review and merge your code, please sign up at https://code.facebook.com/cla. If you are contributing on behalf of someone else (eg your employer), the individual CLA may not be sufficient and your employer may need the corporate CLA signed. If you have received this in error or have any questions, please contact us at [email protected]. Thanks! |
Thank you for signing our Contributor License Agreement. We can now accept your code for this (and any) Facebook open source project. Thanks! |
Codecov Report
@@ Coverage Diff @@
## master #7611 +/- ##
==========================================
- Coverage 68.26% 68.04% -0.22%
==========================================
Files 249 249
Lines 9623 9538 -85
Branches 6 6
==========================================
- Hits 6569 6490 -79
+ Misses 3052 3046 -6
Partials 2 2
Continue to review full report at Codecov.
|
Thank you so much! A failing test is the best sort of bug report ❤️ |
…encies to calculate collectCoverageFrom, fixes #6859
Looks like the Windows job had a blue screen :( |
That's awesome @MarcoScabbiolo, thanks! I added a changelog entry to this. However, I'm not entirely sure this is the correct fix. For instance, if I add this diff the the integration test, it fails again: diff --git i/e2e/__tests__/onlyChanged.test.js w/e2e/__tests__/onlyChanged.test.js
index 8f85d0dd9..9aa64f785 100644
--- i/e2e/__tests__/onlyChanged.test.js
+++ w/e2e/__tests__/onlyChanged.test.js
@@ -151,7 +151,7 @@ test('do not pickup non-tested files when reporting coverage on only changed fil
run(`${GIT} commit --no-gpg-sign -m "first"`, DIR);
writeFiles(DIR, {
- 'b.test.js': 'it("passes", () => {})',
+ 'b.test.js': 'require("./package.json");\nit("passes", () => {})',
'package.json': JSON.stringify({name: 'new name'}),
});
That will not fail if we remove
Ignore it, see #7760 |
@SimenB What you point out is correct, coverage collection behaves differently when using There are some candidates to these "default coverage filter" we're looking for. I think the main issue right now is that the way to filter the coverage for only changed files is to set
let collectCoverageFrom = [];
...
if (matches.collectCoverageFrom) {
collectCoverageFrom = ...
}
...
if (collectCoverageFrom.length) {
const newConfig: GlobalConfig = {...globalConfig, collectCoverageFrom};
globalConfig = Object.freeze(newConfig);
} Maybe using a different option to filter coverage for only changed files would fix the problem and differentiate between user and internal filters. |
Indeed:
if (
globalConfig.collectCoverageFrom &&
globalConfig.collectCoverageFrom.length
) {
context.hasteFS
.matchFilesWithGlob(globalConfig.collectCoverageFrom, config.rootDir)
.forEach(filePath =>
files.push({
config,
path: filePath,
}),
);
} |
I'm sorry that I've not checked up on this until now, given that it's 20 days since I said I would look into it… But I'm really happy to see a bug report turned into a first time PR! 🎉
I ran into this as well, it was one of the most tricky parts of implementing this to begin with 🤔 |
I finally got it, most of the previous code was deleted as it was unnecessary, I added I've deleted the |
I'm really excited about the direction you took, it feels more correct than the current implementation! Only real feedback I have is that using |
@SimenB I thought it wasn't a nice thing to do to add it to the globalConfig but since that was being done in the previous implementation I figured it would be ok, but you're right the value should be passed through. I'll try to find some time to properly finish it. I was using path.resolve to make sure filenames are normalized to absolute ones. I'll try removing all the resolutions and see how it works, the paths may already be absolute or compatible between each other. |
That was done mostly since
That seems fine, but they should resolve from something, e.g. |
I've refactored the |
…ion of TestRunner
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is really starting to shape up, thanks! I'd like to us pass changedFiles
inside of an object to reporters and runners - other than that this is awesome!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks, I think this part really needed some cleaning up to avoid obscure behavior 👍 left some additional comments
Will this fix #7153? |
Yes @SimenB, that PR aims to tackle the same underlying issue |
Thank you so much! |
This pull request has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs. |
Summary
Added
DependencyResolver#resolveInverseModuleMap
that exposes all the module map (the files and their dependencies).resolveInverse
was kept in its original form for compatibility.The changed files are no longer attached to
collectCoverageFrom
. Now they're passed through runners, schedulers and workers toRuntime.shouldInstrument
, the proper method to exclude files from coverage.Includes e2e regression tests.
Fixes #6859, fixes #7101, closes #7153