From 47b8b48ee7f650156086cfb530c360b99aecc875 Mon Sep 17 00:00:00 2001 From: Igor Minar Date: Wed, 13 May 2015 22:21:04 -0700 Subject: [PATCH] build(gulp): log test errors but suppress error handling within gulp while in watch mode if any tasks executed by gulp results in an error, gulp will try hard to show errors. these are usually irelevant in the watch mode. this is why it's ok to supress them except when running in the ci test mode, in which case failing tasks and logging exceptions is helpful. Closes #1881 --- gulpfile.js | 47 +++++++++++++++++++++++++++-------------------- 1 file changed, 27 insertions(+), 20 deletions(-) diff --git a/gulpfile.js b/gulpfile.js index 1970b67468..adad2ab8f9 100644 --- a/gulpfile.js +++ b/gulpfile.js @@ -79,7 +79,22 @@ var angularBuilder = { console.warn(Array(80).join('!')); } }); -}()) +}()); + + +var treatTestErrorsAsFatal = true; + +function runJasmineTests(globs, done) { + fork('./tools/traceur-jasmine', globs, { + stdio: 'inherit' + }).on('close', function jasmineCloseHandler(exitCode) { + if (exitCode && treatTestErrorsAsFatal) { + done(new Error('Jasmine tests failed')); + } else { + done(); + } + }); +} // Note: when DART_SDK is not found, all gulp tasks ending with `.dart` will be skipped. var DART_SDK = require('./tools/build/dartdetect')(gulp); @@ -306,11 +321,7 @@ function createDocsTasks(publicBuild) { }); gulp.task(taskPrefix + '/test', function (done) { - fork('./tools/traceur-jasmine', ['docs/**/*.spec.js'], { - stdio: 'inherit' - }).on('close', function (exitCode) { - done(exitCode); - }); + runJasmineTests(['docs/**/*.spec.js'], done); }); gulp.task(taskPrefix + '/serve', function() { @@ -437,15 +448,14 @@ gulp.task('test.unit.dart/ci', function (done) { gulp.task('test.unit.cjs/ci', function(done) { - fork('./tools/traceur-jasmine', ['dist/js/cjs/angular2/test/**/*_spec.js'], { - stdio: 'inherit' - }).on('close', function (exitCode) { - done(exitCode); - }); + runJasmineTests(['dist/js/cjs/angular2/test/**/*_spec.js'], done); }); -gulp.task('test.unit.cjs', ['build/clean.js', 'build.tools'], function (done) { +gulp.task('test.unit.cjs', ['build/clean.js', 'build.tools'], function (neverDone) { + + treatTestErrorsAsFatal = false; + var buildAndTest = [ '!build.js.cjs', 'test.unit.cjs/ci' @@ -456,13 +466,14 @@ gulp.task('test.unit.cjs', ['build/clean.js', 'build.tools'], function (done) { gulp.task('test.unit.tools/ci', function(done) { - fork('./tools/traceur-jasmine', ['dist/tools/**/*.spec.js'], { - stdio: 'inherit' - }).on('close', done.bind(null, null)); + runJasmineTests(['dist/tools/**/*.spec.js'], done); }); gulp.task('test.unit.tools', ['build/clean.tools'], function(done) { + + treatTestErrorsAsFatal = false; + var buildAndTest = [ '!build.tools', 'test.unit.tools/ci' @@ -483,11 +494,7 @@ gulp.task('test.server.dart', runServerDartTests(gulp, gulpPlugins, { // ----------------- // test builders gulp.task('test.transpiler.unittest', function(done) { - fork('./tools/traceur-jasmine', ['tools/transpiler/unittest/**/*.js'], { - stdio: 'inherit' - }).on('close', function (exitCode) { - done(exitCode); - }); + runJasmineTests(['tools/transpiler/unittest/**/*.js'], done); }); // -----------------