-
Notifications
You must be signed in to change notification settings - Fork 30k
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
test: switch to native v8 coverage #25157
Conversation
@mhdawson I note that |
@mhdawson @schuay I've finally been able to test our work on v8, here are some findings:
Things are working well enough that I'd vote:
@nodejs/build 👆 |
The throw case should be handled just like a return as last statement. |
Lets get a CI job running which uses the new approach to validate and then plan the steps to land the PRs to enable in core. @bcoe let's try to catch up on Monday to work on the CI job, |
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.
@mhdawson 👍 I think this is pretty much ready to go, I've been playing a bit of whack a mole with a few edge-case tests, but the vast majority run effectively under test.
src/node_env_var.cc
Outdated
@@ -69,6 +69,7 @@ static void EnvSetter(Local<Name> property, | |||
Environment* env = Environment::GetCurrent(info); | |||
if (env->options()->pending_deprecation && env->EmitProcessEnvWarning() && | |||
!value->IsString() && !value->IsNumber() && !value->IsBoolean()) { | |||
env->SetEmitProcessEnvWarning(true); |
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.
EmitProcessEnvWarning
has the side effect of setting emit_env_nonstring_warning_ = false;
which I believe shouldn't be set unless a warning has actually been emitted?
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.
Why would this be necessary? Does c8 use the the process.env
setter in the deprecated way?
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.
@joyeecheung I'll dig a bit further, I don't believe that coverage.js
is setting process.env
incorrectly (c8 doesn't come into play until the reporting step). It just seemed like setting the environment variable in internal/process/coverage.js
was suppressing the warning message generated by the unit test.
@bcoe working on a job here to test it out: https://ci.nodejs.org/view/All/job/node-test-commit-linux-coverage-new |
@bcoe Nice! I think this is ready for merging? |
@@ -12,5 +12,9 @@ common.expectWarning( | |||
'DEP0104' | |||
); | |||
|
|||
// Make sure setting a valid environment variable doesn't | |||
// result in warning being suppressed, see: |
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.
@joyeecheung confirmed that this failure wasn't coverage related, setting an environment variable correctly would suppress future warnings; easy fix is simply calling env->EmitProcessEnvWarning()
last.
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.
Is this change relevant to this PR (making a switch in coverage)?
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.
Turning on coverage surfaced this bug, and made this test not run if coverage was enabled. I figured it was an innocent enough change that it was worth patching; If you'd like me to break it out into another patch I can.
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.
BTW: After this PR will the test suite in make coverage
pass (RE: #25543 (comment))
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.
@refack not quite, there are a couple addon
tests that fail; I think related to the inspector session creating resources that break a few assertions.
I would be happy to help isolate these, and maybe we could use TEST_TO_SKIP_FOR_COVERAGE
to remove them, then maybe we could get to the point where @mhdawson and I can abort on failure for coverage tests?
Would folks be okay with keeping this patch in, if @mhdawson and I work on making this pull request run coverage without ignoring errors?
39c3179
to
5730abd
Compare
Latest CI run (new job to test out) ran ok, and generated coverage results and artifacts. I do see that some of the end brackets are not covered (already mentioned by @bcoe ). A few other things I've noticed so far:
|
Also noticed it does not show coverage as missing in:
It shows these 2 paths as being covered, where as the existing report does not.
|
BUILDING.md
Outdated
Alternatively, for the JavaScript test suite, it's faster to run: | ||
|
||
```text | ||
$ CI_JS_SUITES=fs-mkdir CI_NATIVE_SUITES= make jscov |
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.
Nit: A note about unsetting CI_NATIVE_SUITES
would help the readers.
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.
Perhaps:
Note: CI_NATIVE_SUITES
is unset, ensuring that the fs-mkdir
tests are the only tests executed, otherwise the default suite of native tests will also be run.
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.
Yup, that makes it crystal clear 🙂
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.
I'm not sure we should recommend the use of CI_*
variables to the public. AFAICT they are meant for internal use by our CI systems, and should be considered "private".
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.
@refack we reference this variable earlier in the document already:
CI_JS_SUITES=child-process CI_NATIVE_SUITES= make coverage
and it's a nice way to kick off a partial suite of tests with coverage, which is somewhat involved:
- you need to set the
NODE_V8_COVERAGE
variable to the appropriate path. - you need to know to run
make js-coverage-report
.
Long story short I'd like to expose something like this behavior to users, open to alternate suggestions for implementation.
Makefile
Outdated
coverage-build-js: | ||
mkdir -p node_modules | ||
if [ ! -d node_modules/c8 ]; then \ | ||
$(NODE) ./deps/npm install c8@next --no-save --no-package-lock; fi |
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.
Nit: Can we have fi
in a new line?
src/node_env_var.cc
Outdated
@@ -72,8 +72,9 @@ static void EnvSetter(Local<Name> property, | |||
Local<Value> value, | |||
const PropertyCallbackInfo<Value>& info) { | |||
Environment* env = Environment::GetCurrent(info); | |||
if (env->options()->pending_deprecation && env->EmitProcessEnvWarning() && | |||
!value->IsString() && !value->IsNumber() && !value->IsBoolean()) { | |||
if (env->options()->pending_deprecation && !value->IsString() && |
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.
A comment indicating EmitProcessEnvWarning
should be called at the end would help future readers and refactorings.
Makefile
Outdated
$(MAKE) coverage-build-js | ||
-NODE_V8_COVERAGE=out/$(BUILDTYPE)/.coverage \ | ||
CI_SKIP_TESTS=core_line_numbers.js,testFinalizer.js,test_function/test.js \ | ||
$(MAKE) jstest |
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.
Nit: This could be aligned with the previous line, right?
-NODE_V8_COVERAGE=out/$(BUILDTYPE)/.coverage \ | ||
CI_SKIP_TESTS=core_line_numbers.js,testFinalizer.js,test_function/test.js \ | ||
$(MAKE) jstest | ||
$(MAKE) coverage-report-js |
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.
Just trying to understand this better. Even if the previous command fails, does it make sense to run this command?
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.
@mhdawson and I are having a discussion around this right now -- currently (and I believe historically) there are a small minority of tests that fail when under coverage, and we've simply opted to not fail when running under coverage and still run reports.
If we start failing the coverage test suite on failures, we'll need top explicitly exclude a few tests, and be more diligent about not introducing new tests that fail under coverage going forward.
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.
@thefourtheye I think I've addressed your review.
@mhdawson I've rebased this with the back ported v8 changes, and am quite happy with how things are looking; you should be able to run your coverage tests against this pull now.
Coverage tests failing should no longer break coverage report outputting -- going forward, I can certainly get onboard with the argument that we should fail tests, maybe instead of reporting on failure, we should identify the specific tests that fail and add them to an ignore list?
-NODE_V8_COVERAGE=out/$(BUILDTYPE)/.coverage \ | ||
CI_SKIP_TESTS=core_line_numbers.js,testFinalizer.js,test_function/test.js \ | ||
$(MAKE) jstest | ||
$(MAKE) coverage-report-js |
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.
@mhdawson and I are having a discussion around this right now -- currently (and I believe historically) there are a small minority of tests that fail when under coverage, and we've simply opted to not fail when running under coverage and still run reports.
If we start failing the coverage test suite on failures, we'll need top explicitly exclude a few tests, and be more diligent about not introducing new tests that fail under coverage going forward.
@@ -12,5 +12,9 @@ common.expectWarning( | |||
'DEP0104' | |||
); | |||
|
|||
// Make sure setting a valid environment variable doesn't | |||
// result in warning being suppressed, see: |
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.
Turning on coverage surfaced this bug, and made this test not run if coverage was enabled. I figured it was an innocent enough change that it was worth patching; If you'd like me to break it out into another patch I can.
Could it be possible that a file with a lot of tests in it fail during the coverage? If so, we can work towards breaking them down to multiple smaller tests. |
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.
Left some naming and semantic comments
@@ -12,5 +12,9 @@ common.expectWarning( | |||
'DEP0104' | |||
); | |||
|
|||
// Make sure setting a valid environment variable doesn't | |||
// result in warning being suppressed, see: |
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.
BTW: After this PR will the test suite in make coverage
pass (RE: #25543 (comment))
Makefile
Outdated
$(RM) -r out/$(BUILDTYPE)/.coverage | ||
$(MAKE) coverage-build-js | ||
-NODE_V8_COVERAGE=out/$(BUILDTYPE)/.coverage \ | ||
CI_SKIP_TESTS=core_line_numbers.js,testFinalizer.js,test_function/test.js \ |
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.
Could the list of tests be refactored to a new var (TEST_TO_SKIP_FOR_COVERAGE
)? and D.R.Y. L307?
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.
I wonder if we could use TEST_TO_SKIP_FOR_COVERAGE
to isolate the tests that fail under coverage (@mhdawson?) and stop using -
to suppress erros.
BUILDING.md
Outdated
Alternatively, for the JavaScript test suite, it's faster to run: | ||
|
||
```text | ||
$ CI_JS_SUITES=fs-mkdir CI_NATIVE_SUITES= make jscov |
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.
I'm not sure we should recommend the use of CI_*
variables to the public. AFAICT they are meant for internal use by our CI systems, and should be considered "private".
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.
Makefile
Outdated
$(RM) -r out/$(BUILDTYPE)/.coverage | ||
$(MAKE) coverage-build-js | ||
-NODE_V8_COVERAGE=out/$(BUILDTYPE)/.coverage \ | ||
CI_SKIP_TESTS=core_line_numbers.js,testFinalizer.js,test_function/test.js \ |
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.
I wonder if we could use TEST_TO_SKIP_FOR_COVERAGE
to isolate the tests that fail under coverage (@mhdawson?) and stop using -
to suppress erros.
@@ -12,5 +12,9 @@ common.expectWarning( | |||
'DEP0104' | |||
); | |||
|
|||
// Make sure setting a valid environment variable doesn't | |||
// result in warning being suppressed, see: |
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.
@refack not quite, there are a couple addon
tests that fail; I think related to the inspector session creating resources that break a few assertions.
I would be happy to help isolate these, and maybe we could use TEST_TO_SKIP_FOR_COVERAGE
to remove them, then maybe we could get to the point where @mhdawson and I can abort on failure for coverage tests?
Would folks be okay with keeping this patch in, if @mhdawson and I work on making this pull request run coverage without ignoring errors?
We have chosen to allow failing tests when run with coverage. With unlimited resources, we would fix that. I'd be concerned with the ongoing maintenance (for those keeping coverage going) as well as showing things that are covered as not-covered that we'd get from excluding tests. My personal feeling is that allowing failing tests is a reasonable balance between work/benefit but of course I'm open to other thoughts. |
Coverage CI run with all the changes - https://ci.nodejs.org/view/All/job/node-test-commit-linux-coverage-new/9/ |
PR-URL: nodejs#25157 Reviewed-By: Anna Henningsen <anna@addaleax.net> Reviewed-By: Sakthipriyan Vairamani <thechargingvolcano@gmail.com> Reviewed-By: Refael Ackermann <refack@gmail.com>
Landed in d1dee49 |
PR-URL: #25157 Reviewed-By: Anna Henningsen <anna@addaleax.net> Reviewed-By: Sakthipriyan Vairamani <thechargingvolcano@gmail.com> Reviewed-By: Refael Ackermann <refack@gmail.com>
Update the comments for the `coverage` Makefile target. - Source files under `lib` are no longer instrumented since d1dee49 - Fix the name of the related CI job. PR-URL: #39365 Refs: #25157 Reviewed-By: Tobias Nießen <tniessen@tnie.de> Reviewed-By: Luigi Pinca <luigipinca@gmail.com> Reviewed-By: James M Snell <jasnell@gmail.com>
Update the comments for the `coverage` Makefile target. - Source files under `lib` are no longer instrumented since d1dee49 - Fix the name of the related CI job. PR-URL: #39365 Refs: #25157 Reviewed-By: Tobias Nießen <tniessen@tnie.de> Reviewed-By: Luigi Pinca <luigipinca@gmail.com> Reviewed-By: James M Snell <jasnell@gmail.com>
Update the comments for the `coverage` Makefile target. - Source files under `lib` are no longer instrumented since d1dee49 - Fix the name of the related CI job. PR-URL: #39365 Refs: #25157 Reviewed-By: Tobias Nießen <tniessen@tnie.de> Reviewed-By: Luigi Pinca <luigipinca@gmail.com> Reviewed-By: James M Snell <jasnell@gmail.com>
Update the comments for the `coverage` Makefile target. - Source files under `lib` are no longer instrumented since d1dee49 - Fix the name of the related CI job. PR-URL: #39365 Refs: #25157 Reviewed-By: Tobias Nießen <tniessen@tnie.de> Reviewed-By: Luigi Pinca <luigipinca@gmail.com> Reviewed-By: James M Snell <jasnell@gmail.com>
Switches to using v8's built in coverage support.
Note: these results will get better once https://chromium-review.googlesource.com/c/v8/v8/+/1339119 is landed.
CC: @schuay, @hashseed we're almost over the finish line \o/
TODO:
Checklist
make -j4 test
(UNIX), orvcbuild test
(Windows) passes