Skip to content

Commit

Permalink
fix how different node versions are run for test262
Browse files Browse the repository at this point in the history
  • Loading branch information
arshaw committed Apr 3, 2024
1 parent 0fa7fb9 commit 2771a2c
Show file tree
Hide file tree
Showing 4 changed files with 11 additions and 14 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -49,4 +49,4 @@ jobs:
run: pnpm run build

- name: Test
run: pnpm run test --node-version=${{ matrix.node }}
run: TEST262_NODE_VERSION=${{ matrix.node }} pnpm run test
2 changes: 1 addition & 1 deletion .npmrc
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,4 @@ prefer-workspace-packages = true
engine-strict = true

# NOTE: keep synced with ci.yml
use-node-version = ${NODE_VERSION:-18.19.0}
use-node-version = ${PNPM_NODE_VERSION:-18.19.0}
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
"ci": "pnpm run clean && pnpm run lint && pnpm run build && pnpm run test",
"lint": "pnpm -r run lint",
"build": "pnpm -r run build",
"test": "pnpm -r --filter=!@js-temporal/temporal-test262-runner run test",
"test": "pnpm -r --stream --filter=!@js-temporal/temporal-test262-runner run test",
"clean": "pnpm -r run clean"
},
"devDependencies": {
Expand Down
19 changes: 8 additions & 11 deletions packages/temporal-polyfill/scripts/test262.js
Original file line number Diff line number Diff line change
Expand Up @@ -49,29 +49,26 @@ yargs(hideBin(process.argv))
default: false,
type: 'boolean',
description: 'Whether to test the minified bundle',
})
.option('node-version', {
requiresArg: true,
type: 'string',
description: 'Force a specific version of Node',
}),
async (options) => {
const currentNodeVersion = process.versions.node
const currentNodeMajorVersion = parseInt(currentNodeVersion.split('.')[0])
const requestedNodeVersion = process.env.TEST262_NODE_VERSION

// If different version of Node requested, spawn a new process
if (
options.nodeVersion &&
options.nodeVersion !== currentNodeVersion &&
!process.env.NODE_VERSION // not already executing a forced-version call
) {
if (requestedNodeVersion && requestedNodeVersion !== currentNodeVersion) {
return await execLive(
['pnpm', 'exec', 'node', ...process.argv.slice(1)],
{
cwd: process.cwd(),
env: {
...filterEnv(process.env),
NODE_VERSION: options.nodeVersion, // forces PNPM to use specific version (see .npmrc)

// Forces PNPM to use specific version (see .npmrc)
PNPM_NODE_VERSION: requestedNodeVersion,

// Clear requestedNodeVersion for spawned process
TEST262_NODE_VERSION: '',
},
},
)
Expand Down

0 comments on commit 2771a2c

Please sign in to comment.