From 0b21ab13b7dec92bca216b03f32c8f578c644a4d Mon Sep 17 00:00:00 2001 From: Jeremiah Senkpiel Date: Thu, 7 May 2015 16:48:12 -0400 Subject: [PATCH] tools: refactor `make test-npm` into test-npm.sh MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 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: https://github.com/iojs/io.js/pull/1662 Reviewed-By: Johan Bergström Reviewed-By: Evan Lucas --- Makefile | 14 +------------- tools/test-npm.sh | 37 +++++++++++++++++++++++++++++++++++++ 2 files changed, 38 insertions(+), 13 deletions(-) create mode 100755 tools/test-npm.sh diff --git a/Makefile b/Makefile index c87a8ea7f1cedf..92a7694a0a2897 100644 --- a/Makefile +++ b/Makefile @@ -138,19 +138,7 @@ test-debugger: all $(PYTHON) tools/test.py debugger test-npm: $(NODE_EXE) - rm -rf npm-cache npm-tmp npm-prefix - mkdir npm-cache npm-tmp npm-prefix - cd deps/npm ; npm_config_cache="$(shell pwd)/npm-cache" \ - npm_config_prefix="$(shell pwd)/npm-prefix" \ - npm_config_tmp="$(shell pwd)/npm-tmp" \ - ../../$(NODE_EXE) cli.js install --ignore-scripts - cd deps/npm ; npm_config_cache="$(shell pwd)/npm-cache" \ - npm_config_prefix="$(shell pwd)/npm-prefix" \ - npm_config_tmp="$(shell pwd)/npm-tmp" \ - ../../$(NODE_EXE) cli.js run-script test-all && \ - ../../$(NODE_EXE) cli.js prune --prod && \ - cd ../.. && \ - rm -rf npm-cache npm-tmp npm-prefix + NODE_EXE=$(NODE_EXE) tools/test-npm.sh test-npm-publish: $(NODE_EXE) npm_package_config_publishtest=true ./$(NODE_EXE) deps/npm/test/run.js diff --git a/tools/test-npm.sh b/tools/test-npm.sh new file mode 100755 index 00000000000000..9e7f161e7f5046 --- /dev/null +++ b/tools/test-npm.sh @@ -0,0 +1,37 @@ +#!/bin/bash + +set -e + +# always change the working directory to the project's root directory +cd $(dirname $0)/.. + +# pass NODE_EXE from something like Makefile +# it should point to either {./}node or {./}node.exe, depending on the platform +if [ -z $NODE_EXE ]; then + echo "No node executable provided. Bailing." >&2 + exit 0 +fi + +rm -rf test-npm +mkdir test-npm + +# make a copy of deps/npm to run the tests on +cp -r deps/npm/ test-npm/ + +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 + +# set some npm env varibles to point to our new temporary folders +export npm_config_cache="npm-cache" +export npm_config_prefix="npm-prefix" +export npm_config_tmp="npm-tmp" + +# install npm devDependencies and run npm's tests +../$NODE_EXE cli.js install --ignore-scripts +../$NODE_EXE cli.js run-script test-all + +# clean up everything one single shot +cd .. && rm -rf test-npm