2015-05-07 22:48:12 +02:00
|
|
|
#!/bin/bash
|
|
|
|
|
|
|
|
set -e
|
|
|
|
|
|
|
|
# always change the working directory to the project's root directory
|
|
|
|
cd $(dirname $0)/..
|
|
|
|
|
2015-06-15 18:10:44 +02:00
|
|
|
# pass a $NODE environment variable from something like Makefile
|
2015-08-13 18:14:34 +02:00
|
|
|
# it should point to either ./node or ./node.exe, depending on the platform
|
2015-06-15 18:10:44 +02:00
|
|
|
if [ -z $NODE ]; then
|
2015-05-07 22:48:12 +02:00
|
|
|
echo "No node executable provided. Bailing." >&2
|
|
|
|
exit 0
|
|
|
|
fi
|
|
|
|
|
|
|
|
rm -rf test-npm
|
|
|
|
|
|
|
|
# make a copy of deps/npm to run the tests on
|
2015-05-31 19:18:18 +02:00
|
|
|
cp -r deps/npm test-npm
|
2015-05-07 22:48:12 +02:00
|
|
|
|
|
|
|
cd test-npm
|
|
|
|
|
|
|
|
# do a rm first just in case deps/npm contained these
|
|
|
|
rm -rf npm-cache npm-tmp npm-prefix
|
|
|
|
mkdir npm-cache npm-tmp npm-prefix
|
|
|
|
|
2015-10-10 02:34:20 +02:00
|
|
|
# set some npm env variables to point to our new temporary folders
|
|
|
|
export npm_config_cache="$(pwd)/npm-cache"
|
|
|
|
export npm_config_prefix="$(pwd)/npm-prefix"
|
|
|
|
export npm_config_tmp="$(pwd)/npm-tmp"
|
2015-05-07 22:48:12 +02:00
|
|
|
|
2015-10-22 19:28:20 +02:00
|
|
|
# ensure npm always uses the local node
|
|
|
|
export PATH="$(../$NODE -p 'require("path").resolve("..")'):$PATH"
|
2015-10-30 00:40:20 +01:00
|
|
|
unset NODE
|
2015-10-22 19:28:20 +02:00
|
|
|
|
2015-10-30 00:40:20 +01:00
|
|
|
# make sure the binaries from the non-dev-deps are available
|
|
|
|
node cli.js rebuild
|
2015-05-07 22:48:12 +02:00
|
|
|
# install npm devDependencies and run npm's tests
|
2015-10-30 00:40:20 +01:00
|
|
|
node cli.js install --ignore-scripts
|
|
|
|
# run the tests
|
|
|
|
node cli.js run-script test-node
|
2015-05-07 22:48:12 +02:00
|
|
|
|
|
|
|
# clean up everything one single shot
|
|
|
|
cd .. && rm -rf test-npm
|