-
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: preloading common module in tests #2836
Conversation
Oh, that's nice! I assume you need to add the Line 9 in de05175
|
Also, I'm curious if this has a visible effect on the test suite runtime. |
@silverwind It just preloads, so I am not sure about the impact on the run time :( |
Pretty much zero impact here: master:
This PR:
|
It seems a bit suspicious thought that the run time is the same. Are we sure the leak check is happening when the module is just preloaded instead of required? |
@silverwind Ya, I am sure it is happening. Additional changes in thefourtheye@8e191cb are because the build was failing because of the leakage. So I had to explicitly fix them. |
@@ -1,7 +0,0 @@ | |||
'use strict'; |
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 removed this test, as it doesn't make much sense to keep it.
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.
What was the issue with it?
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.
@silverwind Actually, I learnt something new when I was debugging this. When we add something to Object.prototype
, it is getting added to the global
as well.
> process.versions
{ http_parser: '2.5.0',
node: '5.0.0-pre',
v8: '4.5.103.30',
uv: '1.7.3',
zlib: '1.2.8',
ares: '1.10.1-DEV',
modules: '46',
openssl: '1.0.2d' }
> Object.prototype.silverwind = 1;
1
> global.silverwind
1
So, the property xadsadsdasasdxx
is leaked to global. But, this doesn't have any reference to why this is necessary. So I thought that it may not be necessary to keep it around.
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.
It looks to be ancient and related to c-ares: cc9d5ab
I'm think fine with removing it.
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.
Also, that's quite interesting, I didn't expect the global object to inherit from Object.prototype
.
Unrelated LGTM, maybe @Fishrock123 can also sign this off. |
LGTM if it works I suppose. Is there some way to test that this is working? cc @nodejs/build since this alters our testing a bit. |
@Fishrock123 You mean something like this?
|
Hmm, yeah. Maybe spawn a child process with that and assert that it throws? |
215bc0a
to
91a5d7b
Compare
@silverwind
|
Preloading `common` module will make sure that we don't have to explicitly import it in the tests unless necessary. This module has few stuff, like global variables leakage checking, clearing common PIPEs etc, which are necessary for most of the tests.
As the test-runner preloads `common` module, importing it in the test is not necessary unless its properties are used. This commit removes all such unnecessary imports.
91a5d7b
to
1151652
Compare
Okay, switched to normal functions and force-pushed. @Fishrock123 I included a test in I thought it would be better to have another CI run, so started one. https://ci.nodejs.org/job/node-test-pull-request/286/ |
Add |
ummmm .. +0, I guess this means we enforce common.js preloading which should be a good thing |
-100. It's singularly annoying that you have to pass |
@bnoordhuis All are valid points. I didn't think of any of them. Thanks for pointing out :-) |
common.js contains code that checks for variables leaking into the global namespace. Load common.js in all tests that do not intentionally leak variables. PR-URL: #3095 Reviewed-By: Jeremiah Senkpiel <fishrock123@rocketmail.com> Reviewed-By: Sakthipriyan Vairamani <thechargingvolcano@gmail.com>
1st commit:
Preloading
common
module will make sure that we don't have toexplicitly import it in the tests unless necessary. This module
has few stuff, like global variables leakage checking, clearing
common PIPEs etc, which are necessary for most of the tests.
2nd commit:
As the test-runner preloads
common
module, importing it in the testis not necessary unless its properties are used. This commit removes
all such unnecessary imports.
Related: #2828
cc: @silverwind