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: vm.script code coverage had been tampered (#10645) #10657

Closed
wants to merge 3 commits into from

Conversation

jyunhan
Copy link

@jyunhan jyunhan commented Oct 20, 2020

Summary

The currently v8-code-coverage would be tampered thru the condition.
To keep all test process works and have new request,
the easiest way to fix it is to remove the one of the culprits at:
https://github.com/facebook/jest/blob/master/packages/jest-runtime/src/index.ts#L830

And do some tricks in currently test.
In the end, the test still goes well and the vm.script() coverage is correct now.

See issue #10645

Test plan

I extend v8Coverage.test and compare if the code coverage report goes 100% in each columns as expection.

A new dependent issue

@SimenB
One of trait of VM.script() is able to assign variable from VM.runInNewContext().
However, there has contradiction between the rule of code-smell and that trait.
Maybe we should have another discussion about how we can process that situation.

@facebook-github-bot
Copy link
Contributor

Hi @jyunhan!

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 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 to sign the corporate CLA.

If you have received this in error or have any questions, please contact us at [email protected]. Thanks!

@facebook-github-bot
Copy link
Contributor

Thank you for signing our Contributor License Agreement. We can now accept your code for this (and any) Facebook open source project. Thanks!

Copy link
Member

@SimenB SimenB left a comment

Choose a reason for hiding this comment

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

Thanks, this looks good to me! Could you add a changelog entry as well?

e2e/vmscript-coverage/package/vmscript.js Outdated Show resolved Hide resolved
e2e/__tests__/v8Coverage.test.ts Outdated Show resolved Hide resolved
e2e/v8-coverage/no-sourcemap/package.json Outdated Show resolved Hide resolved
e2e/vmscript-coverage/package/vmscript.js Show resolved Hide resolved
e2e/__tests__/v8Coverage.test.ts Outdated Show resolved Hide resolved
e2e/__tests__/v8Coverage.test.ts Outdated Show resolved Hide resolved
@@ -0,0 +1,15 @@
function addOne(inputNumber) {
Copy link
Member

Choose a reason for hiding this comment

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

add some code to this file that's not covered? Just to ensure that works as well

Copy link
Author

Choose a reason for hiding this comment

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

IMHO, this function covered by the tail call from line #14 in the same file.
Do you expect to have a new test case for this function individually?

@facebook-github-bot
Copy link
Contributor

Thank you for signing our Contributor License Agreement. We can now accept your code for this (and any) Facebook open source project. Thanks!

@jyunhan jyunhan force-pushed the @fix/vmscript_coverage branch 3 times, most recently from 1f8f721 to 6e6a99d Compare October 21, 2020 04:39
@jyunhan
Copy link
Author

jyunhan commented Oct 21, 2020

Not sure if I need help, there are 2 places weird.

Why the original test case has different code coverage in the execution environment?
The snapshot I pushed is generated by Nodev12.x on macOS-latest, but the outcome is different from the CI?
Can anyone share knowledge of the previous test case and the environment difference?

@SimenB
Copy link
Member

SimenB commented Feb 23, 2022

Hey @jyunhan! Sorry, I completely lost track of this. Can you rebase so we can see what CI says now?

@SimenB
Copy link
Member

SimenB commented May 5, 2022

I merged in main now. but the changes here makes an existent test fail since we now pick up a file used by test transform (i.e. not in a test) which we shouldn't I think. Might be wrong, tho

@SimenB
Copy link
Member

SimenB commented Mar 6, 2023

@github-actions
Copy link

github-actions bot commented Apr 6, 2023

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.
Please note this issue tracker is not a help forum. We recommend using StackOverflow or our discord channel for questions.

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Apr 6, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants