Repository navigation
test: missing expected exception in parallel/test-require-deps-deprecation.js #17148
Description
Activity
- addedmoduleIssues and PRs related to the module subsystem.Issues and PRs related to the module subsystem.testIssues and PRs related to Node.js core tests and test infrastructure.Issues and PRs related to Node.js core tests and test infrastructure.
on Nov 20, 2017 @Tiriel What's the output if you run this?:
./node test/parallel/test-require-deps-deprecation.js
@Tiriel Also, what's the output of each of these two commands?:
./node -e "require('acorn/dist/acorn')"./node -e "require('acorn/dist/walk')"Hey @Trott , Thanks!
- test only :
$ ./node test/parallel/test-require-deps-deprecation.js assert.js:42 throw new errors.AssertionError({ ^ AssertionError [ERR_ASSERTION]: Missing expected exception. at innerThrows (assert.js:186:7) at Function.throws (assert.js:205:3) at Object.<anonymous> (/home/benjamin/Dev/javascript/NodeFoundation/node/test/parallel/test-require-deps-deprecation.js:43:10) at Module._compile (module.js:644:30) at Object.Module._extensions..js (module.js:655:10) at Module.load (module.js:563:32) at tryModuleLoad (module.js:506:12) at Function.Module._load (module.js:498:3) at Function.Module.runMain (module.js:685:10) at startup (bootstrap_node.js:192:16)- require('acorn/dist/acorn') :
no output - require('acorn/dist/walk') :
no output - Just to be sure, require('acorn/dist/foo') :
module.js:547 throw err; ^ Error: Cannot find module 'acorn/dist/foo' at Function.Module._resolveFilename (module.js:545:15) at Function.Module._load (module.js:475:25) at Module.require (module.js:588:17) at require (internal/module.js:11:18) at [eval]:1:1 at ContextifyScript.Script.runInThisContext (vm.js:50:33) at Object.runInThisContext (vm.js:152:38) at Object.<anonymous> ([eval]-wrapper:6:22) at Module._compile (module.js:644:30) at evalScript (bootstrap_node.js:471:27)require('acorn/dist/acorn)andrequire('acorn/dist/walk')should throw likerequire('acorn/dist/foo')does. Maybe you haveacorntucked away somewhere thatrequire()is finding it? You don't haveNODE_PATHenvironment variable set by any chance, do you?Damn, you got it. Sorry I missed this.
NODE_PATHis indeed defined, though I don't know how to solve this simply. Anyway, not a global issue then, I'll close this.Thanks!
@Tiriel It's conceivable that a sensible solution is to PR in a change to
Makefile/vcbuild.batortest.pythat unsetsNODE_PATH. I'm not 100% sure about that--perhaps there's something in CI that needsNODE_PATHbut I don't think so.@Trott But it would then need to be re set afterwards right? I'm not really good at sysadmin, but can it be unset temporarily?
@Trott But it would then need to be re set afterwards right? I'm not really good at sysadmin, but can it be unset temporarily?
You can unset it for the subprocess only. It won't affect the invoking shell.
$ NODE_PATH='foo' ./node -e 'console.log(process.env.NODE_PATH)' foo $ echo $NODE_PATH $
@Trott Awesome, thanks! And sorry for being such a weight ^^'
I'll just reopen this since it seems there may be a solution and a fix that would solve the problem for people potentially having it like me.
Right now I'm investigatin the problem, but prefixing the commands in the Makefile hasn't improved the situation yet. I think because the Python is launching the tests by executing commands, and so the temporary assignment is lost. 4ill try and dig inside
test.pyjust to be sure. Also tried addingprocess.env.NODE_PATH = '';at the top of the js test, but no joy.If anyone as another idea, they're deeply welcome to share!
@Tiriel There's already code in
test.pyto removeNODE_PATHfrom the environment before exectuing tests:# Remove NODE_PATH if "NODE_PATH" in env_copy: del env_copy["NODE_PATH"]Perhaps the root cause of the problem is something else. Maybe check for the other things listed in https://nodejs.org/api/modules.html#modules_loading_from_the_global_folders that confound module loading:
1: $HOME/.node_modules 2: $HOME/.node_libraries 3: $PREFIX/lib/node(I think
$PREFIXwill be the value ofprefix_nodeinconfig.gypi.)Reacted by Benjamin Zaslavsky2 remaining items
Okay, this was a long time ago, but I finally had the time to put some more tests to it.
Simply checked
require.resolve('acorn/dist/acorn'))intest-require-deps-deprecation.js. It appears it's loaded from$HOME/node_modules(without the dot).
To be a bit more specific,require.resolve.paths('/acorn/dist/acorn')indicates that it finds acorn simply by iterating up through my folder structure, searching for anode_modulefolder at every depth until it finds one. Which is precisely it's usual workflow if I'm not mistaken.But I must admit I'm note sure which path to follow from now on. I'm searching for a way to limit the upward iterating to a certain number of levels, at least locally in this test file, but it seems weird.
Any intake, or should I just drop it and ignore this test failing when building Node?
@Tiriel I propose this: Change the
require()in the test to berequire.resolve(). If it throws, the test passes. If it returns a string other thanacorn/dist/acorn, then it passes. If it returns exactlyacorn/dist/acorn, then it fails.I'm happy to put that together as a PR, but would be even happier to see you do it. Let me know. :-D
@Trott awesome thanks !
I’ll open a PR later today !
- added 2 commits that reference this issue
on Jan 10, 2018 - added a commit that references this issue
on Feb 20, 2018 - added a commit that references this issue
on Jul 27, 2026
Hey there!
Got this error when running tests on master:
If I'm corect this was added some three days ago in this commit 7ce6d23 but I have no idea why that doesn't throws, when the patch was specifically designed to make this kind of
requirethrow.Is it only me?
For the record, I thought I had done some breaking changes without wanting it, so I erase my copy and re cloned it, fetched the last updates and then ran
./configureandmake. Build is as fresh as it can get.