Skip to content

test: isolate configure-nodedir from npm_config_nodedir - #3389

Open
gengjiawen wants to merge 1 commit into
nodejs:mainfrom
gengjiawen:test/configure-nodedir-env
Open

gengjiawen wants to merge 1 commit into
nodejs:mainfrom
gengjiawen:test/configure-nodedir-env

Conversation

@gengjiawen

Copy link
Copy Markdown
Member
Checklist
  • npm install && npm run lint && npm test passes
  • tests are included
  • commit message follows commit guidelines
Description of change

Fixes the remaining node-gyp failure in Jenkins citgm-smoker reported in nodejs/citgm#1202, where configure-nodedir › configure nodedir with node-gyp command line times out after 30s.

The Jenkins citgm-smoker job runs export npm_config_nodedir="$WORKSPACE/node" and passes --nodedir to citgm, and citgm puts npm_config_nodedir in the module's test environment. parseArgv lets npm_config_* override command line options, so the test's --nodedir=/usr is replaced. The generated common.gypi path then doesn't match, and the spawn stub calls assert.fail().

That assertion never shows up because the test calls configure(prog, [], assert.fail). configure() is async, so the third argument is ignored, the rejection goes unhandled, done is never called, and mocha reports a timeout. A plain citgm node-gyp run (e.g. in Docker) doesn't set nodedir, which is why it passes there.

Repro on main:

npm_config_nodedir=/anything npx mocha test/test-configure-nodedir.js
# Error: Timeout of 30000ms exceeded

This PR only changes the test:

  • clear npm_config_nodedir and npm_package_config_node_gyp_nodedir for the suite (they are restored afterwards)
  • use .catch(done) at all four configure() call sites, so any future mismatch fails right away with the real assertion instead of a timeout

The env-over-CLI precedence for nodedir itself is unchanged.

parseArgv lets npm_config_* environment variables override command line
options, so when the test harness exports npm_config_nodedir (as the
Jenkins citgm-smoker job does) the --nodedir=/usr passed by the test is
replaced and the spawn stub's assert.fail() throws.

Because configure() is async and the test passed assert.fail as an
ignored third argument, that rejection was never handled and the test
timed out after 30s instead of reporting the assertion.

Clear the nodedir environment variables for the suite and route
configure() rejections to done().

Refs: nodejs/citgm#1202
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.

1 participant