Skip to content
This repository has been archived by the owner on Oct 8, 2021. It is now read-only.

Commit

Permalink
Grunt: Add testswarm task, for now with a small subset of somewhat st…
Browse files Browse the repository at this point in the history
…able testsuites, as a starting point
  • Loading branch information
jzaefferer committed Jun 30, 2012
1 parent e3c173e commit 788e3b2
Show file tree
Hide file tree
Showing 2 changed files with 63 additions and 1 deletion.
61 changes: 61 additions & 0 deletions 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 #<a href="https://github.com/jquery/jquery-mobile/commit/' + commit + '">' + commit.substr( 0, 10 ) + '</a>',
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() );
});

};
3 changes: 2 additions & 1 deletion package.json
Expand Up @@ -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"
Expand Down

0 comments on commit 788e3b2

Please sign in to comment.