From 705d3aacff4005483f8ecbff5fc2d484b3e38cf5 Mon Sep 17 00:00:00 2001 From: Igor Minar Date: Wed, 6 May 2015 08:45:28 -0700 Subject: [PATCH] build(gulp): fix concurrency and caching issues in test.unit.js and test.unit.dart tasks previously there was a chance of race conditions that could sporadically fail the build. additionally runing a task via gulp.start or runSequence always reruns its dependencies, which meant that we were blowing away the build.tools build and rebuilding everything from scratch even during the interactive/watch mode. This meant that the build pipeline cache was destroyed on every change and we never got the benefit of incremental compilation --- gulpfile.js | 79 +++++++++++++++++++++++++++++++++++++++-------------- 1 file changed, 58 insertions(+), 21 deletions(-) diff --git a/gulpfile.js b/gulpfile.js index 74f4e6edfa..04e9e088a0 100644 --- a/gulpfile.js +++ b/gulpfile.js @@ -102,10 +102,16 @@ gulp.task('build/clean.docs', clean(gulp, gulpPlugins, { // ------------ // transpile -gulp.task('build/tree.dart', ['build.tools'], function() { +gulp.task('build/tree.dart', ['build/clean.dart', 'build.tools'], function(done) { + runSequence('!build/tree.dart', done); +}); + + +gulp.task('!build/tree.dart', function() { return angularBuilder.rebuildDartTree(); }); + // ------------ // pubspec @@ -322,40 +328,67 @@ function getBrowsersFromCLI() { return [args.browsers?args.browsers:'DartiumWithWebPlatform'] } -gulp.task('test.unit.js', ['build/clean.js', 'broccoli.js.dev'], function (neverDone) { - function buildAndTest() { +gulp.task('test.unit.js', ['build.js.dev'], function (neverDone) { + + runSequence( + '!test.unit.js/karma-server', + '!test.unit.js/karma-run', + 'check-format' + ); + + gulp.watch('modules/**', function() { runSequence( - 'broccoli.js.dev', - 'test.unit.js/karma-run' + '!broccoli.js.dev', + '!test.unit.js/karma-run', + 'check-format' ); - } + }); +}); + +gulp.task('!test.unit.js/karma-server', function() { karma.server.start({configFile: __dirname + '/karma-js.conf.js'}); - - gulp.watch('modules/**', buildAndTest); }); -gulp.task('test.unit.js/karma-run', function (done) { - karma.runner.run({configFile: __dirname + '/karma-js.conf.js'}, done); + +gulp.task('!test.unit.js/karma-run', function(done) { + karma.runner.run({configFile: __dirname + '/karma-js.conf.js'}, function(exitCode) { + // ignore exitCode, we don't want to fail the build in the interactive (non-ci) mode + // karma will print all test failures + done(); + }); }); + gulp.task('test.unit.dart', ['build/tree.dart'], function (done) { - function buildAndTest() { + + runSequence( + '!test.unit.dart/karma-server', + '!test.unit.dart/karma-run' + ); + + gulp.watch('modules/angular2/**', function() { runSequence( - 'build/tree.dart', - 'test.unit.dart/karma-run' + '!build/tree.dart', + '!test.unit.dart/karma-run' ); - } + }); +}); +gulp.task('!test.unit.dart/karma-run', function (done) { + karma.runner.run({configFile: __dirname + '/karma-dart.conf.js'}, function(exitCode) { + // ignore exitCode, we don't want to fail the build in the interactive (non-ci) mode + // karma will print all test failures + done(); + }); +}); + + +gulp.task('!test.unit.dart/karma-server', function() { karma.server.start({configFile: __dirname + '/karma-dart.conf.js'}); - - gulp.watch('modules/angular2/**', buildAndTest); }); -gulp.task('test.unit.dart/karma-run', function (done) { - karma.runner.run({configFile: __dirname + '/karma-dart.conf.js'}, done); -}); gulp.task('test.unit.js/ci', function (done) { karma.server.start({configFile: __dirname + '/karma-js.conf.js', @@ -538,12 +571,16 @@ gulp.task('!build.tools', function() { return mergedStream; }); -gulp.task('broccoli.js.dev', ['build.tools'], function() { +gulp.task('broccoli.js.dev', ['build.tools'], function(done) { + runSequence('!broccoli.js.dev', done); +}); + +gulp.task('!broccoli.js.dev', function() { return angularBuilder.rebuildBrowserDevTree(); }); -gulp.task('build.js.dev', function(done) { +gulp.task('build.js.dev', ['build/clean.js'], function(done) { runSequence( 'broccoli.js.dev', 'build/checkCircularDependencies',