From ee99a5a02b7daf637006fb80d699c3bc0f9e2b61 Mon Sep 17 00:00:00 2001 From: Marc Laval Date: Fri, 7 Nov 2014 18:29:19 +0100 Subject: [PATCH] chore: gulpifying the tests Closes #168 --- README.md | 8 ++++---- gulpfile.js | 27 +++++++++++++++++++++++++++ scripts/ci/test_unit.sh | 7 +------ 3 files changed, 32 insertions(+), 10 deletions(-) diff --git a/README.md b/README.md index a40d0c9f5c..26c1756ec8 100644 --- a/README.md +++ b/README.md @@ -11,7 +11,7 @@ should go to [angular/angular.js](https://github.com/angular/angular.js) If you don't already have `npm`, get it by installing [node.js](http://nodejs.org/). 1. `npm install` -2. `npm install -g gulp karma karma-cli` (you might need to prefix this command with `sudo`) +2. `npm install -g gulp` (you might need to prefix this command with `sudo`) 3. `npm install -g protractor` (you might need to prefix this command with `sudo`) 4. `webdriver-manager update` 5. If you plan to use Dart: @@ -44,8 +44,8 @@ If you don't already have `npm`, get it by installing [node.js](http://nodejs.or ### Unit tests -1. `karma start karma-js.conf.js`: JS tests -2. `karma start karma-dart.conf.js`: Dart tests +1. `gulp test.js`: JS tests +2. `gulp test.dart`: Dart tests Notes for transpiler tests: @@ -98,7 +98,7 @@ Notes: If you need to debug the tests: - add a `debugger;` statement to the test you want to debug (oe the source code), -- execute karma `node_modules/karma/bin/karma start karma-js.conf.js`, +- execute karma `gulp test.js`, - press the top right "DEBUG" button, - open the dev tools and press F5, - the execution halt at the `debugger;` statement diff --git a/gulpfile.js b/gulpfile.js index a041a85dce..b47602204e 100644 --- a/gulpfile.js +++ b/gulpfile.js @@ -13,6 +13,8 @@ var pubbuild = require('./tools/build/pubbuild'); var dartanalyzer = require('./tools/build/dartanalyzer'); var jsserve = require('./tools/build/jsserve'); var pubserve = require('./tools/build/pubserve'); +var karma = require('karma').server; +var minimist = require('minimist'); var DART_SDK = require('./tools/build/dartdetect')(gulp); // ----------------------- @@ -396,6 +398,31 @@ gulp.task('docs/serve', function() { })); }); +// ------------------ +// tests +function getBrowsersFromCLI() { + var args = minimist(process.argv.slice(2)); + return [args.browsers?args.browsers:'DartiumWithWebPlatform'] +} +gulp.task('test.js', function (done) { + karma.start({configFile: __dirname + '/karma-js.conf.js'}, done); +}); +gulp.task('test.dart', function (done) { + karma.start({configFile: __dirname + '/karma-dart.conf.js'}, done); +}); +gulp.task('test.js/ci', function (done) { + karma.start({configFile: __dirname + '/karma-js.conf.js', singleRun: true, reporters: ['dots'], browsers: getBrowsersFromCLI()}, done); +}); +gulp.task('test.dart/ci', function (done) { + karma.start({configFile: __dirname + '/karma-dart.conf.js', singleRun: true, reporters: ['dots'], browsers: getBrowsersFromCLI()}, done); +}); +gulp.task('ci', function(done) { + runSequence( + 'test.js/ci', + 'test.dart/ci' + ); +}); + // ----------------- // orchestrated targets gulp.task('build.dart', function() { diff --git a/scripts/ci/test_unit.sh b/scripts/ci/test_unit.sh index 189b184b09..c49eed7550 100755 --- a/scripts/ci/test_unit.sh +++ b/scripts/ci/test_unit.sh @@ -7,9 +7,4 @@ SCRIPT_DIR=$(dirname $0) source $SCRIPT_DIR/env_dart.sh cd $SCRIPT_DIR/../.. -./node_modules/karma/bin/karma start karma-js.conf \ - --reporters=dots \ - --browsers=$KARMA_BROWSERS --single-run -./node_modules/karma/bin/karma start karma-dart.conf \ - --reporters=dots \ - --browsers=$KARMA_BROWSERS --single-run +./node_modules/.bin/gulp ci --browsers=$KARMA_BROWSERS