Skip to content

Commit 3416e93

Browse files
committed
tools: refactor make test-npm into test-npm.sh
Extracts test-npm from Makefile and puts it in tools/test-npm.sh Also improves test-npm to use a separate copy of deps/npm for testing. PR-URL: nodejs#1662 Reviewed-By: Johan Bergström <bugs@bergstroem.nu> Reviewed-By: Evan Lucas <evanlucas@me.com>
1 parent 69bc061 commit 3416e93

File tree

2 files changed

+38
-13
lines changed

2 files changed

+38
-13
lines changed

Makefile

+1-13
Original file line numberDiff line numberDiff line change
@@ -138,19 +138,7 @@ test-debugger: all
138138
$(PYTHON) tools/test.py debugger
139139

140140
test-npm: $(NODE_EXE)
141-
rm -rf npm-cache npm-tmp npm-prefix
142-
mkdir npm-cache npm-tmp npm-prefix
143-
cd deps/npm ; npm_config_cache="$(shell pwd)/npm-cache" \
144-
npm_config_prefix="$(shell pwd)/npm-prefix" \
145-
npm_config_tmp="$(shell pwd)/npm-tmp" \
146-
../../$(NODE_EXE) cli.js install --ignore-scripts
147-
cd deps/npm ; npm_config_cache="$(shell pwd)/npm-cache" \
148-
npm_config_prefix="$(shell pwd)/npm-prefix" \
149-
npm_config_tmp="$(shell pwd)/npm-tmp" \
150-
../../$(NODE_EXE) cli.js run-script test-all && \
151-
../../$(NODE_EXE) cli.js prune --prod && \
152-
cd ../.. && \
153-
rm -rf npm-cache npm-tmp npm-prefix
141+
NODE_EXE=$(NODE_EXE) tools/test-npm.sh
154142

155143
test-npm-publish: $(NODE_EXE)
156144
npm_package_config_publishtest=true ./$(NODE_EXE) deps/npm/test/run.js

tools/test-npm.sh

+37
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
#!/bin/bash
2+
3+
set -e
4+
5+
# always change the working directory to the project's root directory
6+
cd $(dirname $0)/..
7+
8+
# pass NODE_EXE from something like Makefile
9+
# it should point to either {./}node or {./}node.exe, depending on the platform
10+
if [ -z $NODE_EXE ]; then
11+
echo "No node executable provided. Bailing." >&2
12+
exit 0
13+
fi
14+
15+
rm -rf test-npm
16+
mkdir test-npm
17+
18+
# make a copy of deps/npm to run the tests on
19+
cp -r deps/npm/ test-npm/
20+
21+
cd test-npm
22+
23+
# do a rm first just in case deps/npm contained these
24+
rm -rf npm-cache npm-tmp npm-prefix
25+
mkdir npm-cache npm-tmp npm-prefix
26+
27+
# set some npm env varibles to point to our new temporary folders
28+
export npm_config_cache="npm-cache"
29+
export npm_config_prefix="npm-prefix"
30+
export npm_config_tmp="npm-tmp"
31+
32+
# install npm devDependencies and run npm's tests
33+
../$NODE_EXE cli.js install --ignore-scripts
34+
../$NODE_EXE cli.js run-script test-all
35+
36+
# clean up everything one single shot
37+
cd .. && rm -rf test-npm

0 commit comments

Comments
 (0)