diff --git a/gulpfile.js b/gulpfile.js index 38eb2513a3a6..3e335d804e6f 100644 --- a/gulpfile.js +++ b/gulpfile.js @@ -132,7 +132,8 @@ var CONFIG = { dev: {es6: 'dist/js/dev/es6', es5: 'dist/js/dev/es5'}, prod: {es6: 'dist/js/prod/es6', es5: 'dist/js/prod/es5'}, cjs: 'dist/js/cjs', - dart2js: 'dist/js/dart2js' + dart2js: 'dist/js/dart2js', + dart_dev_compiler: 'dist/js/ddc' }, dart: 'dist/dart', docs: 'dist/docs', @@ -369,6 +370,10 @@ function jsServeDartJs() { return jsserve(gulp, gulpPlugins, {path: CONFIG.dest.js.dart2js, port: 8002})(); } +function jsServeDartDevCompiler() { + return jsserve(gulp, gulpPlugins, {path: CONFIG.dest.js.dart_dev_compiler, port: 8003})(); +} + function proxyServeDart() { return jsserve(gulp, gulpPlugins, { port: 8002, @@ -407,6 +412,8 @@ gulp.task('serve.e2e.prod', ['build.js.prod', 'build.js.cjs'], function(neverDon gulp.task('serve.js.dart2js', jsServeDartJs); +gulp.task('serve.js.ddc', jsServeDartDevCompiler); + gulp.task('!proxyServeDart', proxyServeDart); gulp.task('serve.dart', function(done) { diff --git a/protractor-ddc.conf.js b/protractor-ddc.conf.js new file mode 100644 index 000000000000..cb0413456e97 --- /dev/null +++ b/protractor-ddc.conf.js @@ -0,0 +1,3 @@ +var data = module.exports = require('./protractor-shared.js'); +var config = data.config; +config.baseUrl = 'http://localhost:8003/'; diff --git a/scripts/ci/build_dart_ddc.sh b/scripts/ci/build_dart_ddc.sh index b94f9a4c7c3e..c277cde3f7be 100755 --- a/scripts/ci/build_dart_ddc.sh +++ b/scripts/ci/build_dart_ddc.sh @@ -7,8 +7,9 @@ echo =========================================================================== # go to project dir SCRIPT_DIR=$(dirname $0) +REPO_ROOT_DIR=`cd ${SCRIPT_DIR}/../..; pwd` source $SCRIPT_DIR/env_dart.sh -cd $SCRIPT_DIR/../.. +cd $REPO_ROOT_DIR # Variables DDC_TOTAL_WARNING_CAP="210" @@ -25,15 +26,28 @@ git clone https://github.com/dart-lang/dev_compiler.git tmp/dev_compiler $PUB get) # Convert TypeScript to Dart +./node_modules/.bin/gulp build.js.cjs ./node_modules/.bin/gulp build/packages.dart ./node_modules/.bin/gulp build/pubspec.dart node ./scripts/ci/dart_ddc/pubspec_for_ddc.js \ --pubspec-file=dist/dart/playground/pubspec.yaml - -# Compile playground cd dist/dart/playground $PUB build --mode=debug cd build/web + +# TODO: temporarily remove references to dart.js as ddc doesn't do it +# automatically yet (https://github.com/dart-lang/dev_compiler/issues/437) +echo `pwd` +for htmlFile in `find ./src -name '*.html'`; do + tmpFile=$REPO_ROOT_DIR/tmp/scriptless_html.tmp + cat $htmlFile | grep -vE '$tmpFile + mv $tmpFile $htmlFile +done + +############################################################################## +# Analyze code +############################################################################## + LOG_FILE="analyzer.log" set +e $DART_SDK/bin/dart $DDC_DIR/bin/dartdevc.dart \ @@ -91,5 +105,66 @@ else echo "Warning count ok" fi + +############################################################################## +# Run e2e tests +############################################################################## + +DIST_DIR="${REPO_ROOT_DIR}/dist/js/ddc" + +# Build the apps (again) +# TODO: ddc does not yet support compiling multiple html files. Ideally we +# could build everything during analysis above. +# See: https://github.com/dart-lang/dev_compiler/issues/430 + +ln -s `pwd`/packages src/hello_world/packages + +set +e +OUT_DIR="${DIST_DIR}/playground/src/hello_world" +mkdir -p $OUT_DIR +$DART_SDK/bin/dart $DDC_DIR/bin/dartdevc.dart \ + --force-compile \ + --dart-sdk=$DART_SDK_LIB_SEARCH_PATH -o $OUT_DIR \ + src/hello_world/index.html +EXIT_CODE=`echo $?` +set -e + +if [[ "$EXIT_CODE" -ne "0" && "$EXIT_CODE" -ne "1" ]] +then + echo "DDC compiler crashed with exit code $EXIT_CODE" + exit 1 +fi + + +# Run e2e tests +cd $REPO_ROOT_DIR + +./node_modules/.bin/webdriver-manager update + +function killServer () { + kill $serverPid +} + +./node_modules/.bin/gulp serve.js.ddc& +serverPid=$! + +echo CHROM_BIN=$CHROME_BIN +echo CHROM_BIN_VERSION=`$CHROME_BIN --version` + +trap killServer EXIT + +# wait for server to come up +sleep 10 + +function runSpec { + SPEC=$1 + ./node_modules/.bin/protractor protractor-ddc.conf.js \ + --browsers=${E2E_BROWSERS:-ChromeDesktop} \ + --spec=$SPEC +} + +# TODO: add more e2e tests +runSpec hello_world/hello_world_spec.js + echo 'Dart DDC build finished' exit $EXIT_CODE diff --git a/scripts/ci/install_chromium.sh b/scripts/ci/install_chromium.sh index 206c6b5f4b34..21553a14c3c8 100755 --- a/scripts/ci/install_chromium.sh +++ b/scripts/ci/install_chromium.sh @@ -9,7 +9,24 @@ set -e -x #Build version read from the OmahaProxy CSV Viewer at https://www.chromium.org/developers/calendar #Let's use the following version of Chromium, and inform about availability of newer build from https://omahaproxy.appspot.com/all -CHROMIUM_VERSION=359700 +CHROMIUM_VERSION=369907 + +PLATFORM="$(uname -s)" +case "$PLATFORM" in + (Darwin) + ARCHITECTURE=Mac + DIST_FILE=chrome-mac.zip + ;; + (Linux) + ARCHITECTURE=Linux_x64 + DIST_FILE=chrome-linux.zip + ;; + (*) + echo Unsupported platform $PLATFORM. Exiting ... >&2 + exit 3 + ;; +esac + TMP=$(curl -s "https://omahaproxy.appspot.com/all") || true oldIFS="$IFS" IFS=' @@ -47,7 +64,7 @@ if [[ "$EXISTING_VERSION" != "$CHROMIUM_VERSION" ]]; then while [[ $STATUS == 404 && $NEXT -ge 0 ]] do echo Fetch Chromium version: ${NEXT} - STATUS=$(curl "https://storage.googleapis.com/chromium-browser-snapshots/Linux_x64/${NEXT}/chrome-linux.zip" -s -w %{http_code} --create-dirs -o $FILE) || true + STATUS=$(curl "https://storage.googleapis.com/chromium-browser-snapshots/${ARCHITECTURE}/${NEXT}/${DIST_FILE}" -s -w %{http_code} --create-dirs -o $FILE) || true NEXT=$[$NEXT-1] done