-
Notifications
You must be signed in to change notification settings - Fork 29.6k
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
tools: use local or specified $NODE for test-npm #1984
Conversation
@@ -136,7 +136,7 @@ test-debugger: all | |||
$(PYTHON) tools/test.py debugger | |||
|
|||
test-npm: $(NODE_EXE) |
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.
These are still correct, right? I'm not too sure how makefile uses this part.
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.
Yeah, NODE_EXE is mostly used as build target.
../$NODE_EXE cli.js install --ignore-scripts | ||
../$NODE_EXE cli.js run-script test-all | ||
../$NODE cli.js install --ignore-scripts | ||
../$NODE cli.js run-script test-all |
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.
Aren't we changing directory a few lines up? Thinking this should just be $NODE
. Guess it depends on how you pass the binary path.
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.
It's not ./node
because at this point we are inside the test-npm
directory. :)
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.
Yeah, you're right
@jbergstroem is this lgty? |
I haven't tried it but the change LGTM. |
496cac6
to
e487c35
Compare
Rebased and updated, tested, can confirm it still works. Unfortunately npm's tests still require a global node for now. ...unless that can be passed via env variable? |
|
||
../$NODE cli.js install --ignore-scripts | ||
../$NODE cli.js run-script test-legacy | ||
../$NODE cli.js run-script test |
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.
Actually on second thought this always used the local node to run cli.js anyways because these are relative links.
Still, I think this PR is better practice given our makefile setup.
e487c35
to
3967162
Compare
@@ -3,11 +3,11 @@ | |||
set -e | |||
|
|||
# always change the working directory to the project's root directory | |||
cd $(dirname $0)/.. | |||
cd $(dirname ${BASH_SOURCE[0]})/.. |
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.
see: http://stackoverflow.com/a/9107028/1279026 (related comment linked below in the "get absolute path" part).
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.
Seems zsh doesn't sport this variable unfortunately. There is an alternative, but I'd rather avoid using shell-specific things, if possible.
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.
Ok, Will revert to using $0
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.
Hmm, what issue were you trying to solve here exactly? Maybe there's an alternative way.
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.
Nothing really, I just saw it was suggested in the stackoverflow, going to revert to using $0
Updated, PTAL. It now creates a local Will also test on my assigned linux machine. |
|
||
## a hopefully temporary hack to use the local $NODE binary when calling node(1) | ||
# make a link to $NODE as test-npm/node | ||
ln -f $NODE test-npm/node |
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 may be an issue cross-platform.
My OS X ln
cannot do relative symlinks (-r
), but linux does not appear to like hard links.
I wonder if we have other bash-specific things in those test-npm scripts. Could be an explanation for the weird issues I was having with test-npm on zsh. |
3967162
to
1bbc4ed
Compare
PTAL: Updated to remove this bit, which I'll PR separately: EDIT: on second thought it is kind of useless without the hack, so I'm re-adding it again. |
05516f5
to
1959fd0
Compare
popd > /dev/null | ||
# export that link as preferred in the $PATH | ||
export PATH=$PWD:$PATH | ||
## |
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.
Ok I can confirm this works on both OS X and Linux (Ubuntu 15), it just means we have an extra thing to clean up in the project root, as seen at the bottom of this file.
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.
Looks like this fails on a more recent npm with these errors:
test/tap/lifecycle-path.js ............................ 2/4
make sure the path is correct
not ok exit code
+++ found
--- wanted
-0
+1
compare: ===
at:
file: test/tap/lifecycle-path.js
line: 55
column: 7
stack: |
test/tap/lifecycle-path.js:55:7
f (node_modules/once/once.js:17:25)
ChildProcess.<anonymous> (test/common-tap.js:56:5)
maybeClose (internal/child_process.js:764:16)
Socket.<anonymous> (internal/child_process.js:319:11)
Pipe._onclose (net.js:467:12)
make sure the path is correct
not ok should be equivalent
+++ found
--- wanted
[
- "{{ROOT}}/bin/node-gyp-bin"
- "{{ROOT}}/test/tap/lifecycle-path/node_modules/.bin"
- "/bin"
- "/usr/bin"
+ "> ./node-bin/node print-path.js"
]
at:
file: test/tap/lifecycle-path.js
line: 74
column: 7
stack: |
test/tap/lifecycle-path.js:74:7
f (node_modules/once/once.js:17:25)
ChildProcess.<anonymous> (test/common-tap.js:56:5)
maybeClose (internal/child_process.js:764:16)
Socket.<anonymous> (internal/child_process.js:319:11)
Pipe._onclose (net.js:467:12)
From this test: https://github.com/npm/npm/blob/master/test/tap/lifecycle-path.js
@othiym23 is this worth the effort to hack this in before npm's tests work without a global node? It seems like this test is relying on the location of the node binary, is that something that can / should be fixed?
@silverwind / @jbergstroem ptal again. :) |
1959fd0
to
d6dc006
Compare
Anyone able to review? :D |
Hmm, getting some failures...not sure if it is related to the most recent changes you made or not though... |
@evanlucas what OS? Those look like npm failures. If my script is broken on your system the tests will almost certainly fail to run. :P |
Yosemite. Haven't tried running them standalone yet though |
Uh oh, the same two tests are failing for me now when rebased on master, but only with this patch? How is that possible... I'll have to investigate. Edit: must have something to do with setting the |
PWD=`pwd -P` | ||
popd > /dev/null | ||
# export that link as preferred in the $PATH | ||
export PATH=$PWD:$PATH |
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.
I think the original PATH should be restored after the test run? (Maybe through saving it to a temp var)
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.
@silverwind you mean after the legacy tests? I could try that.
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.
I mean having PATH=$PWD:$PATH
will prepend the directory on each run of test-npm.sh, resulting in PATH getting longer and longer.
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.
Hmmm, nope. It appears the tests themselves depend on a global node
(from the tap module, I think?)
Since running the test requires it, and causes it to fail, that's not a possibility.
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.
Not sure you understand what I mean. My issue is with the global shell's PATH being in an modified state after this script finishes executing (global node now pointing to the built one), and I think we should restore PATH after this script is done.
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 just removing the export
is sufficient so all child scripts get the correct binary and we avoid touching the global PATH.
d6dc006
to
d566029
Compare
d566029
to
4303372
Compare
Updated to remove the |
Looks pretty straightforward now. LGTM |
LGTM |
PR-URL: nodejs#1984 Reviewed-By: Johan Bergström <bugs@bergstroem.nu> Reviewed-By: Roman Reiss <me@silverwind.io>
4303372
to
68b06e9
Compare
See: #1955 (comment)
cc @nodejs/build