From 5d8a21da57a466541aef5b16b032a21e46bbf15b Mon Sep 17 00:00:00 2001 From: Brian Hann Date: Fri, 20 Dec 2013 17:22:03 -0600 Subject: [PATCH] fix(travis): use SauceLabs for e2e tests on travis --- .travis.yml | 2 +- Gruntfile.js | 13 +++++++++++++ lib/grunt/plugins.js | 4 ++++ lib/grunt/utils.js | 20 ++++++++++++++++++++ travis_build.sh | 2 +- 5 files changed, 39 insertions(+), 2 deletions(-) diff --git a/.travis.yml b/.travis.yml index 6f1d85e526..32896a083c 100644 --- a/.travis.yml +++ b/.travis.yml @@ -39,7 +39,7 @@ before_script: - ./lib/sauce/sauce_connect_block.sh script: - - ./scripts/travis/travis_build.sh + - ./travis_build.sh after_success: - grunt release diff --git a/Gruntfile.js b/Gruntfile.js index a7449be3bf..02c740be35 100644 --- a/Gruntfile.js +++ b/Gruntfile.js @@ -147,6 +147,18 @@ module.exports = function(grunt) { } } }, + ci: { + keepAlive: false, + options: { + args: { + seleniumPort: 4444, + baseUrl: 'http://localhost:9999', + specs: ['.tmp/doc-scenarios/**/*.spec.js', 'test/e2e/**/*.spec.js'], + sauceUser: process.env.SAUCE_USERNAME, + sauceKey: process.env.SAUCE_ACCESS_KEY + } + } + } auto: { keepAlive: true, options: { @@ -415,6 +427,7 @@ module.exports = function(grunt) { grunt.registerTask('test:ci', ['clean', 'jshint', 'ngtemplates', 'serialsauce']); grunt.registerTask('test:docs', ['connect:testserver', 'protractor:docs']); grunt.registerTask('test:e2e', ['connect:testserver', 'protractor:singlerun']); + grunt.registerTask('test:e2e:ci', ['connect:testserver', 'protractor:ci']); // Test grunt.registerTask('test', 'Run tests on singleRun karma server', function() { diff --git a/lib/grunt/plugins.js b/lib/grunt/plugins.js index f3ff13b8c3..44f4ad6415 100644 --- a/lib/grunt/plugins.js +++ b/lib/grunt/plugins.js @@ -16,6 +16,10 @@ module.exports = function(grunt) { * */ + grunt.registerMultiTask('tests', '**Use `grunt test` instead**', function(){ + util.startKarma.call(util, this.data, true, this.async()); + }); + // Run tests on multiple versions of angular grunt.registerTask('karmangular', 'Run tests against multiple versions of angular', function() { // Start karma servers diff --git a/lib/grunt/utils.js b/lib/grunt/utils.js index 743a186d29..d0110ecac9 100644 --- a/lib/grunt/utils.js +++ b/lib/grunt/utils.js @@ -31,6 +31,26 @@ var util = module.exports = { return retFiles; }, + startKarma: function(config, singleRun, done){ + var browsers = grunt.option('browsers'); + var reporters = grunt.option('reporters'); + var noColor = grunt.option('no-colors'); + var port = grunt.option('port'); + var p = spawn('node', ['node_modules/karma/bin/karma', 'start', config, + singleRun ? '--single-run=true' : '', + reporters ? '--reporters=' + reporters : '', + browsers ? '--browsers=' + browsers : '', + noColor ? '--no-colors' : '', + port ? '--port=' + port : '' + ]); + p.stdout.pipe(process.stdout); + p.stderr.pipe(process.stderr); + p.on('exit', function(code){ + if(code !== 0) grunt.fail.warn("Karma test(s) failed. Exit code: " + code); + done(); + }); + }, + customLaunchers: function() { return { 'SL_Chrome': { diff --git a/travis_build.sh b/travis_build.sh index 6f2ee45e37..a98b2a7cba 100644 --- a/travis_build.sh +++ b/travis_build.sh @@ -8,7 +8,7 @@ if [ $JOB = "unit" ]; then elif [ $JOB = "e2e" ]; then # grunt clean build test:e2e --browsers=SL_Chrome grunt - grunt test:e2e + grunt test:e2e:ci else echo "Unknown job type. Please set JOB=unit or JOB=e2e." fi