8000 Allow running tests in child processes by liuxingbaoyu · Pull Request #17486 · babel/babel · GitHub
[go: up one dir, main page]

Skip to content

Conversation

@liuxingbaoyu
Copy link
Member
Q                       A
Fixed Issues? Fixes #1, Fixes #2
Patch: Bug Fix?
Major: Breaking Change?
Minor: New Feature?
Tests Added + Pass? Yes
Documentation PR Link
Any Dependency Changes?
License MIT

This is in preparation for Babel 8.
After we clean up our Babel 7 code, we still want to test compatibility with older Node.js versions.
This also makes it easier for local development, as we can now quickly test compatibility with older versions.

Usage: cross-env EXEC_TESTS_NODE=16 yarn jest

@babel-bot
Copy link
Collaborator
babel-bot commented Aug 21, 2025

Build successful! You can test your changes in the REPL here: https://babeljs.io/repl/build/60721

< 8000 /circle>

@pkg-pr-new
Copy link
pkg-pr-new bot commented Aug 21, 2025

Open in StackBlitz

commit: 5e482bf

@liuxingbaoyu liuxingbaoyu force-pushed the exec-worker branch 6 times, most recently from f7a8c25 to 0630f73 Compare September 17, 2025 22:48
Copy link
Member
@nicolo-ribaudo nicolo-ribaudo left a comment

Choose a reason for hiding this comment

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

Nice!

@liuxingbaoyu liuxingbaoyu force-pushed the exec-worker branch 2 times, most recently from 09eb690 to 0f6d4ed Compare September 18, 2025 18:10
return new Promise((resolve, reject) => {
if (!(globalThis as any).worker) {
const workerFile = path.join(dirname, "worker.js");
const worker = ((globalThis as any).worker = spawn("fnm", [
Copy link
Contributor

Choose a reason for hiding this comment

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

I am on the fence with the introduction of a new node version manager for the test purpose, if the fnm website is down the whole CI pipeline will be blocked, too. And it is not very efficient that every babel-8-exec test pipeline has to install a version manager.

Would it be possible to make EXEC_TESTS_NODE independent of the node version manager? For example let EXEC_TESTS_NODE_BIN be the path to the exec test node binary, then we can directly pass it to spawn. Doing so should reduce the runtime overhead of the version manager since we have thousands of exec tests.

The path to the node binary should be easily obtained from any node version manager. With this approach, we may just use the node 6 installed from the setup-node action, it is likely provided in the CI runner toolchain, too.

Copy link
Member Author

Choose a reason for hiding this comment

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

Doing so should reduce the runtime overhead of the version manager since we have thousands of exec tests.

We only initialize one worker for each child process, and the total number of workers in CI should be 2 or 4. :)

Whether EXEC_TESTS_NODE_BIN is supported depends on whether setup-node caches compressed, which is a bit more complicated if they are compressed.

Copy link
Member Author

Choose a reason for hiding this comment

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

There seems to be no good way to get the path to other versions of setup-node.

Initially, I also didn't want to rely on a package manager, but unfortunately, tools like esvu don't provide NodeJS support.

Copy link
Member

Choose a reason for hiding this comment

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

What if we used n, which can be installed through npm?

Copy link
Contributor
@JLHwung JLHwung Sep 19, 2025

Choose a reason for hiding this comment

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

There seems to be no good way to get the path to other versions of setup-node.

After we checked out the legacy node version via setup-node, could we write the result of whic 8000 h node to the github output? Then we can enable the latest node version and pass that output to the test step.

Copy link
Member Author

Choose a reason for hiding this comment

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

What if we used n, which can be installed through npm?

Unfortunately it doesn't support Windows.

@liuxingbaoyu liuxingbaoyu force-pushed the exec-worker branch 3 times, most recently from 6095b2b to 3c40069 Compare September 19, 2025 16:07
@liuxingbaoyu
Copy link
Member Author

One issue I've noticed is that this PR contains breaking changes (using transform in tests is no longer supported, and runCodeInTestContext no longer includes Babel helpers).
I'm a bit concerned about people relying on this package.

@liuxingbaoyu liuxingbaoyu force-pushed the exec-worker branch 2 times, most recently from 6685301 to ea73f0c Compare January 27, 2026 21:53
Comment on lines 192 to +195
uses: codecov/codecov-action@v5
with:
token: ${{ secrets.CODECOV_TOKEN }}
name: babel-7
name: babel-8
Copy link
Member Author

Choose a reason for hiding this comment

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

We should probably do this.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants

0