From 8fdb40c58bf49f81787d89f04c0a4c19e134cfb3 Mon Sep 17 00:00:00 2001 From: Avital Oliver Date: Mon, 11 Feb 2013 23:46:59 -0800 Subject: [PATCH] tools/run-all-tests.sh now also tests a fake installed version of meteor --- lib/warehouse.js | 4 ++++ tools/cli-test.sh | 18 ++++++++++++++---- tools/run-all-tests.sh | 39 +++++++++++++++++++++++++++++++-------- 3 files changed, 49 insertions(+), 12 deletions(-) diff --git a/lib/warehouse.js b/lib/warehouse.js index 383fb0b27c..57c05dd96e 100644 --- a/lib/warehouse.js +++ b/lib/warehouse.js @@ -31,6 +31,10 @@ var warehouse = module.exports = { // $HOME/.meteor. If we're running a checkout, found at // $CHECKOUT/.meteor. getWarehouseDir: function () { + // a hook for tests + if (process.env.TEST_WAREHOUSE_DIR) + return process.env.TEST_WAREHOUSE_DIR; + if (files.in_checkout()) return path.join(files.get_core_dir(), '.meteor'); else diff --git a/tools/cli-test.sh b/tools/cli-test.sh index cfa99b3fb5..cfefc417f8 100755 --- a/tools/cli-test.sh +++ b/tools/cli-test.sh @@ -1,10 +1,15 @@ #!/bin/bash -# NOTE: by default this tests the working copy, not the installed meteor. -# To test the installed meteor, pass in --global +# NOTE: by default this tests the working copy, not the installed +# meteor. To test the installed meteor, pass in --global. To test a +# version of meteor installed in a specific directory, set the +# METEOR_DIR environment variable. cd `dirname $0` -METEOR_DIR=`pwd`/.. + +if [ -z "$METEOR_DIR" ]; then + METEOR_DIR=`pwd`/.. +fi METEOR=$METEOR_DIR/meteor if [ -z "$NODE" ]; then @@ -135,7 +140,12 @@ sleep 2 # need to make sure these kills take effect echo "... test-packages" -$METEOR test-packages -p $PORT >> $OUTPUT 2>&1 & +if [ ! $TEST_INSTALLED_METEOR ]; then + $METEOR test-packages -p $PORT >> $OUTPUT 2>&1 & +else + $METEOR test-packages --release=0.0.1 -p $PORT >> $OUTPUT 2>&1 & +fi + METEOR_PID=$! sleep 2 # XXX XXX lame diff --git a/tools/run-all-tests.sh b/tools/run-all-tests.sh index 8094d6a35a..73672f913f 100755 --- a/tools/run-all-tests.sh +++ b/tools/run-all-tests.sh @@ -1,22 +1,45 @@ #!/bin/bash +## Setup METEOR_DIR=`pwd`/.. - +# Die with message on failure, print commands being executed trap 'echo FAILED' EXIT - -# Die on failure, print commands being executed set -e -x -# Test the Meteor CLI + +## Test the Meteor CLI from a checkout ./cli-test.sh -# Run bundler unit tests + +## Test the Meteor CLI from an installed engine (tests loading packages +## into the warehouse) +TMPDIR=$(mktemp -d -t meteor-installed-cli-tests) +export ENGINE_DIR=$TMPDIR/engine-tree +TARGET_DIR=$ENGINE_DIR admin/build-engine-tree.sh + +export TEST_INSTALLED_METEOR=1 # to use the --release option on `meteor test-packages` +export TEST_WAREHOUSE_DIR=$(mktemp -d -t meteor-installed-cli-tests-warehouse) # run with empty warehouse +METEOR_DIR=$ENGINE_DIR/bin ./cli-test.sh + + +## Run bundler unit tests ./bundler-test.sh -# Test all packages, adding 'kill-server-on-test-completion' -(sleep 1; open http://localhost:3000) & -PACKAGE_DIRS=$METEOR_DIR/tools/cli-test-packages/ $METEOR_DIR/meteor test-packages --once +## Test all packages on installed version, adding 'kill-server-on-test-completion' +export TEST_WAREHOUSE_DIR=$(mktemp -d -t meteor-installed-cli-tests-warehouse) # run with empty warehouse + +# We sleep for 30 seconds since we fetch packages on the first run, +# and only then do we listen on port 3000. In a fully installed +# version, we will have run 'meteor update' after installing the +# engine so this wouldn't happen. XXX should we test the full +# installer? +(sleep 30; open http://localhost:3000) & + +PACKAGE_DIRS=$METEOR_DIR/tools/cli-test-packages/ $METEOR_DIR/meteor test-packages --once --release=0.0.1 + + +## Done trap - EXIT echo PASSED