From 788e3b27165c4f0abe6c50329625ca85704e523c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=B6rn=20Zaefferer?= Date: Sat, 30 Jun 2012 13:22:15 -0700 Subject: [PATCH] Grunt: Add testswarm task, for now with a small subset of somewhat stable testsuites, as a starting point --- build/tasks/testswarm.js | 61 ++++++++++++++++++++++++++++++++++++++++ package.json | 3 +- 2 files changed, 63 insertions(+), 1 deletion(-) create mode 100644 build/tasks/testswarm.js diff --git a/build/tasks/testswarm.js b/build/tasks/testswarm.js new file mode 100644 index 00000000000..96aa1058541 --- /dev/null +++ b/build/tasks/testswarm.js @@ -0,0 +1,61 @@ +/*jshint node: true */ +module.exports = function( grunt ) { + +/* +To test these tasks locally, create a testswarm-local.json file like this, replacing the token and urls: + +{ + "jquerymobile": { + "authUsername": "jquerymobile", + "authToken": "1489f0baccc7af70b15d4bee6b0498f66b1ef611", + "swarmUrl": "http://swarm.local/", + "testUrl": "http://localhost/", + "runMax": 1 + } +} + +Then call: + + grunt config:test:pages testswarm:jquery-mobile/:testswarm-local.json + +Adapt the second flag, the 'commit', to match files along with the testUrl property. + */ + +function submit( commit, tests, configFile, done ) { + var test, + testswarm = require( "testswarm" ), + config = grunt.file.readJSON( configFile ).jquerymobile, + testBase = config.testUrl + commit, + testUrls = []; + for ( test in tests ) { + testUrls.push( testBase + tests[ test ] ); + } + testswarm({ + url: config.swarmUrl, + pollInterval: 10000, + timeout: 1000 * 60 * 30, + done: done + }, { + authUsername: config.authUsername, + authToken: config.authToken, + jobName: 'jQuery Mobile commit #' + commit.substr( 0, 10 ) + '', + runMax: config.runMax, + "runNames[]": Object.keys(tests), + "runUrls[]": testUrls, + "browserSets[]": ["mobile"] + }); +} + +grunt.registerTask( "testswarm", function( commit, configFile ) { + // TODO currently using only the first five somewhat stable testsuites + // need to expand this + var tests = grunt.config.get('global').test_paths.slice( 0, 5 ); + var test, + latestTests = {}; + for ( var i = 0; i < tests.length; i++ ) { + latestTests[ tests[ i ].replace(/^tests\/unit\//, "") ] = tests[ i ]; + } + submit( commit, latestTests, configFile, this.async() ); +}); + +}; diff --git a/package.json b/package.json index 8e5e22f1cbe..9373fc4ed1e 100644 --- a/package.json +++ b/package.json @@ -16,7 +16,8 @@ "grunt-junit": "0.1.4", "requirejs": "1.0.8", "glob-whatev": "~0.1.4", - "rimraf": "2.0.1" + "rimraf": "2.0.1", + "testswarm": "0.2.3" }, "engine": { "node": ">=6.0"