-
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: compute list of expected globals from ESLint config file #42056
base: main
Are you sure you want to change the base?
Conversation
test/common/index.js
Outdated
atob, | ||
btoa | ||
} = require('buffer'); | ||
const parseEslintConfigForGlobals = require('./parseEslintConfigForGlobals'); |
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.
Does this need to be a separate file? Should it be inlined so that people don't think it's something they can/should include themselves in their own 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.
We need to synchronously read and parse lib/.eslintrc.yaml
line-by-line for this to work correctly.
b3964c2
to
d6e4f2d
Compare
d6e4f2d
to
96115e9
Compare
96115e9
to
9a5ec5f
Compare
Makefile
Outdated
.PHONY: jstest | ||
jstest: build-addons build-js-native-api-tests build-node-api-tests ## Runs addon tests and JS tests | ||
jstest: build-addons build-js-native-api-tests build-node-api-tests test/common/knownGlobals.json ## Runs addon tests and JS 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.
Makefile
Outdated
@@ -1140,7 +1140,7 @@ pkg-upload: pkg | |||
scp -p $(TARNAME).pkg $(STAGINGSERVER):nodejs/$(DISTTYPEDIR)/$(FULLVERSION)/$(TARNAME).pkg | |||
ssh $(STAGINGSERVER) "touch nodejs/$(DISTTYPEDIR)/$(FULLVERSION)/$(TARNAME).pkg.done" | |||
|
|||
$(TARBALL): release-only doc-only | |||
$(TARBALL): release-only doc-only test/common/knownGlobals.json |
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 target will also probably need to copy in the generated test/common/knownGlobals.json
as the tarball is prepared in $(TARNAME)/
from a fresh git checkout-index
.
Blocked on nodejs/build#2879 |
What's the reason for using Python to generate the file? |
Because the tarball action doesn't have any available |
Don't GitHub runners all have |
Maybe it was too old to work? I don't exactly remember tbh. Using Python as also the upside of being already integrated in the test suite. Is there a reason not to use Python? |
I hope that one day, Python won't be required anymore to work on node, so adding things that rely on it doesn't help. |
OK gotcha! Hopefully this won't be too much of a burden to port this to whatever replacement we find – it could be a sed script if it wasn't for Windows support. |
@@ -15,6 +15,8 @@ common.skipIfDumbTerminal(); | |||
const tmpdir = require('../common/tmpdir'); | |||
tmpdir.refresh(); | |||
|
|||
common.allowGlobals('require', '_', '_error', ...require('module').builtinModules); |
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.
Maybe add common.allowReplGlobals()
or similar to avoid repetition?
I'm ok with the bullet points in your OP, and the changes to |
If we avoid Python and generate the JSON in JS, it would be convenient to do it without creating any additional files which would address #42056 (comment) but I don't know how much time it would add overall when we run all the tests. |
We don't want to rely on mutable globals for core modules. Instead of
maintaining a separate list of known globals in our test files, parse
the ESLint config to ensure all globals are restricted in the
lib/
directory.
fetch
). It also solves the case where there are two global variables referencing the same object (e.g.global
andglobalThis
).@targos This may have consequences for V8 updates (if the new V8 version ships with new globals).
/cc @benjamingr
Blocked on
#42049nodejs/build#2879.