From 56a5b02d047c4f490f2c2fc50af35b78ee30c0e2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mis=CC=8Cko=20Hevery?= Date: Wed, 16 Aug 2017 13:00:00 -0700 Subject: [PATCH] test: add cli integration test (#18738) This adds cli integration test which creates a hello-world and tests it. PR Close #18738 --- integration/.gitignore | 5 ++- integration/ng-cli-create.sh | 70 ++++++++++++++++++++++++++++++++++++ integration/run_tests.sh | 11 ++++++ 3 files changed, 85 insertions(+), 1 deletion(-) create mode 100755 integration/ng-cli-create.sh diff --git a/integration/.gitignore b/integration/.gitignore index 297cd21083..f91b475b7e 100644 --- a/integration/.gitignore +++ b/integration/.gitignore @@ -1,10 +1,13 @@ built/ dist/ vendor/ +yarn.lock +.ng-cli/ +cli-*/** */src/*.d.ts */src/*.js **/*.ngfactory.ts **/*.ngsummary.json **/*.ngsummary.ts */yarn* -*/.yarn_local_cache* +**/.yarn_local_cache* diff --git a/integration/ng-cli-create.sh b/integration/ng-cli-create.sh new file mode 100755 index 0000000000..a7d1ce2a79 --- /dev/null +++ b/integration/ng-cli-create.sh @@ -0,0 +1,70 @@ +#!/usr/bin/env bash + +set -e -o pipefail + +if [ $# -eq 0 ] + then + echo "Angular cli integration create project" + echo + echo "./ng-cli-create.sh [project-name]" + echo +else + TEMP=`dirname $0` + INTEGRATION_DIR=`(cd $TEMP; pwd)` + PROJECT=$1 + PROJECT_DIR=$INTEGRATION_DIR/$PROJECT + NG=$INTEGRATION_DIR/.ng-cli/node_modules/.bin/ng + ( + echo "===================" + echo Creating $PROJECT... + echo "===================" + cd $INTEGRATION_DIR + rm -rf $PROJECT + $NG set --global packageManager=yarn + $NG new $PROJECT --skip-install + echo "===================" + echo $PROJECT created + echo "===================" + ) + + + # By default `ng new` creates a package.json which uses @angular/* from NPM. + # Instead we want to use them from the current build so we overwrite theme here. + ( + echo "===================" + echo Updating $PROJECT bundles + echo "===================" + cd $PROJECT_DIR + + sed -i -E 's/ng build/ng build --prod --build-optimizer/g' package.json + sed -i -E 's/ng test/ng test --single-run/g' package.json + # workaround for https://github.com/angular/angular-cli/issues/7401 + sed -i -E 's/"@angular\/cli\"\: \".*\"/"@angular\/cli": "https:\/\/github.com\/angular\/cli-builds"/g' package.json + + yarn add \ + file:../../dist/packages-dist/compiler-cli \ + file:../../dist/packages-dist/language-service \ + --save-dev --skip-integrity-check --emoji + + yarn add \ + file:../../dist/packages-dist/core \ + file:../../dist/packages-dist/common \ + file:../../dist/packages-dist/forms \ + file:../../dist/packages-dist/http \ + --save --skip-integrity-check --emoji + + # yarn bug: can not install all of them in a single command and it has to be broken into separate invocations. + yarn add \ + file:../../dist/packages-dist/animations \ + file:../../dist/packages-dist/compiler \ + file:../../dist/packages-dist/platform-browser \ + file:../../dist/packages-dist/platform-browser-dynamic \ + --save --skip-integrity-check --emoji + + yarn install --emoji + + echo "===================" + echo $PROJECT created succesfully + echo "===================" + ) +fi diff --git a/integration/run_tests.sh b/integration/run_tests.sh index 53a64ad566..74315b87fe 100755 --- a/integration/run_tests.sh +++ b/integration/run_tests.sh @@ -14,6 +14,17 @@ rm_cache mkdir $cache trap rm_cache EXIT +# We need to install `ng` but don't want to do it globally so we plate it into `.ng-cli` folder. +# This check prevents constant re-installing. +if [ ! -d ".ng-cli" ]; then + ( + mkdir -p .ng-cli + cd .ng-cli + yarn add https://github.com/angular/cli-builds --cache-folder ../$cache + ) +fi +./ng-cli-create.sh cli-hello-world + for testDir in $(ls | grep -v node_modules) ; do [[ -d "$testDir" ]] || continue echo "#################################"