Skip to content

Commit 0730b75

Browse files
yjbanovmhevery
authored andcommitted
chore(ddc): add e2e test infra + first test
1 parent cad693d commit 0730b75

File tree

3 files changed

+85
-4
lines changed

3 files changed

+85
-4
lines changed

gulpfile.js

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -132,7 +132,8 @@ var CONFIG = {
132132
dev: {es6: 'dist/js/dev/es6', es5: 'dist/js/dev/es5'},
133133
prod: {es6: 'dist/js/prod/es6', es5: 'dist/js/prod/es5'},
134134
cjs: 'dist/js/cjs',
135-
dart2js: 'dist/js/dart2js'
135+
dart2js: 'dist/js/dart2js',
136+
dart_dev_compiler: 'dist/js/ddc'
136137
},
137138
dart: 'dist/dart',
138139
docs: 'dist/docs',
@@ -369,6 +370,10 @@ function jsServeDartJs() {
369370
return jsserve(gulp, gulpPlugins, {path: CONFIG.dest.js.dart2js, port: 8002})();
370371
}
371372

373+
function jsServeDartDevCompiler() {
374+
return jsserve(gulp, gulpPlugins, {path: CONFIG.dest.js.dart_dev_compiler, port: 8003})();
375+
}
376+
372377
function proxyServeDart() {
373378
return jsserve(gulp, gulpPlugins, {
374379
port: 8002,
@@ -407,6 +412,8 @@ gulp.task('serve.e2e.prod', ['build.js.prod', 'build.js.cjs'], function(neverDon
407412

408413
gulp.task('serve.js.dart2js', jsServeDartJs);
409414

415+
gulp.task('serve.js.ddc', jsServeDartDevCompiler);
416+
410417
gulp.task('!proxyServeDart', proxyServeDart);
411418

412419
gulp.task('serve.dart', function(done) {

protractor-ddc.conf.js

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
var data = module.exports = require('./protractor-shared.js');
2+
var config = data.config;
3+
config.baseUrl = 'http://localhost:8003/';

scripts/ci/build_dart_ddc.sh

Lines changed: 74 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,9 @@ echo ===========================================================================
77

88
# go to project dir
99
SCRIPT_DIR=$(dirname $0)
10+
REPO_ROOT_DIR=`cd ${SCRIPT_DIR}/../..; pwd`
1011
source $SCRIPT_DIR/env_dart.sh
11-
cd $SCRIPT_DIR/../..
12+
cd $REPO_ROOT_DIR
1213

1314
# Variables
1415
DDC_TOTAL_WARNING_CAP="210"
@@ -29,11 +30,23 @@ git clone https://github.com/dart-lang/dev_compiler.git tmp/dev_compiler
2930
./node_modules/.bin/gulp build/pubspec.dart
3031
node ./scripts/ci/dart_ddc/pubspec_for_ddc.js \
3132
--pubspec-file=dist/dart/playground/pubspec.yaml
32-
33-
# Compile playground
3433
cd dist/dart/playground
3534
$PUB build --mode=debug
3635
cd build/web
36+
37+
# TODO: temporarily remove references to dart.js as ddc doesn't do it
38+
# automatically yet (https://github.com/dart-lang/dev_compiler/issues/437)
39+
echo `pwd`
40+
for htmlFile in `find ./src -name '*.html'`; do
41+
tmpFile=$REPO_ROOT_DIR/tmp/scriptless_html.tmp
42+
cat $htmlFile | grep -vE '<script.*dart\.js' >$tmpFile
43+
mv $tmpFile $htmlFile
44+
done
45+
46+
##############################################################################
47+
# Analyze code
48+
##############################################################################
49+
3750
LOG_FILE="analyzer.log"
3851
set +e
3952
$DART_SDK/bin/dart $DDC_DIR/bin/dartdevc.dart \
@@ -91,5 +104,63 @@ else
91104
echo "Warning count ok"
92105
fi
93106

107+
108+
##############################################################################
109+
# Run e2e tests
110+
##############################################################################
111+
112+
DIST_DIR="${REPO_ROOT_DIR}/dist/js/ddc"
113+
114+
# Build the apps (again)
115+
# TODO: ddc does not yet support compiling multiple html files. Ideally we
116+
# could build everything during analysis above.
117+
# See: https://github.com/dart-lang/dev_compiler/issues/430
118+
119+
ln -s `pwd`/packages src/hello_world/packages
120+
121+
set +e
122+
OUT_DIR="${DIST_DIR}/playground/src/hello_world"
123+
mkdir -p $OUT_DIR
124+
$DART_SDK/bin/dart $DDC_DIR/bin/dartdevc.dart \
125+
--force-compile \
126+
--dart-sdk=$DART_SDK_LIB_SEARCH_PATH -o $OUT_DIR \
127+
src/hello_world/index.html
128+
EXIT_CODE=`echo $?`
129+
set -e
130+
131+
if [[ "$EXIT_CODE" -ne "0" && "$EXIT_CODE" -ne "1" ]]
132+
then
133+
echo "DDC compiler crashed with exit code $EXIT_CODE"
134+
exit 1
135+
fi
136+
137+
138+
# Run e2e tests
139+
cd $REPO_ROOT_DIR
140+
141+
./node_modules/.bin/webdriver-manager update
142+
143+
function killServer () {
144+
kill $serverPid
145+
}
146+
147+
./node_modules/.bin/gulp serve.js.ddc&
148+
serverPid=$!
149+
150+
trap killServer EXIT
151+
152+
# wait for server to come up
153+
sleep 10
154+
155+
function runSpec {
156+
SPEC=$1
157+
./node_modules/.bin/protractor protractor-ddc.conf.js \
158+
--browsers=${E2E_BROWSERS:-Dartium} \
159+
--spec=$SPEC
160+
}
161+
162+
# TODO: add more e2e tests
163+
runSpec hello_world/hello_world_spec.js
164+
94165
echo 'Dart DDC build finished'
95166
exit $EXIT_CODE

0 commit comments

Comments
 (0)