pad.pub0.org/tests/frontend/travis/remote_runner.js

116 lines
3.4 KiB
JavaScript
Raw Normal View History

var srcFolder = "../../../src/node_modules/";
var wd = require(srcFolder + "wd");
2012-11-03 15:55:14 +00:00
var async = require(srcFolder + "async");
var config = {
host: "ondemand.saucelabs.com"
, port: 80
, username: process.env.SAUCE_USER
2013-06-06 16:58:06 +00:00
, accessKey: process.env.SAUCE_ACCESS_KEY
}
2012-11-03 15:55:14 +00:00
var allTestsPassed = true;
2012-11-03 15:55:14 +00:00
var sauceTestWorker = async.queue(function (testSettings, callback) {
var browser = wd.promiseChainRemote(config.host, config.port, config.username, config.accessKey);
2012-11-03 15:55:14 +00:00
var name = process.env.GIT_HASH + " - " + testSettings.browserName + " " + testSettings.version + ", " + testSettings.platform;
testSettings.name = name;
2012-11-03 17:46:02 +00:00
testSettings["public"] = true;
testSettings["build"] = process.env.GIT_HASH;
2012-11-03 15:55:14 +00:00
// we wait 10 seconds here with the hope it was enough time for the minified files to be built etc.
setTimeout(function(){
browser.init(testSettings).get("http://localhost:9001/tests/frontend/", function(){
var url = "https://saucelabs.com/jobs/" + browser.sessionID;
console.log("Remote sauce test '" + name + "' started! " + url);
2012-11-03 15:55:14 +00:00
//tear down the test excecution
var stopSauce = function(success){
getStatusInterval && clearInterval(getStatusInterval);
clearTimeout(timeout);
2012-11-03 15:55:14 +00:00
browser.quit();
2012-11-03 15:55:14 +00:00
if(!success){
allTestsPassed = false;
}
var testResult = knownConsoleText.replace(/\[red\]/g,'\x1B[31m').replace(/\[yellow\]/g,'\x1B[33m')
.replace(/\[green\]/g,'\x1B[32m').replace(/\[clear\]/g, '\x1B[39m');
testResult = testResult.split("\\n").map(function(line){
return "[" + testSettings.browserName + (testSettings.version === "" ? '' : (" " + testSettings.version)) + "] " + line;
}).join("\n");
2012-11-03 15:55:14 +00:00
console.log(testResult);
console.log("Remote sauce test '" + name + "' finished! " + url);
2012-11-03 15:55:14 +00:00
callback();
}
2012-11-03 15:55:14 +00:00
//timeout for the case the test hangs
var timeout = setTimeout(function(){
stopSauce(false);
}, 60000 * 10);
var knownConsoleText = "";
var getStatusInterval = setInterval(function(){
browser.eval("$('#console').text()", function(err, consoleText){
if(!consoleText || err){
return;
}
knownConsoleText = consoleText;
if(knownConsoleText.indexOf("FINISHED") > 0){
var success = knownConsoleText.indexOf("FAILED") === -1;
stopSauce(success);
}
});
}, 5000);
});
}, 10000);
2012-11-03 15:55:14 +00:00
}, 1); //run 1 test in parrallel
2012-11-03 15:55:14 +00:00
// 1) Firefox on Linux
2012-11-03 15:55:14 +00:00
sauceTestWorker.push({
'platform' : 'Linux'
, 'browserName' : 'firefox'
, 'version' : 'latest'
2012-11-03 15:55:14 +00:00
});
2020-05-29 16:52:00 +00:00
// 2) Chrome on Linux
2012-11-03 15:55:14 +00:00
sauceTestWorker.push({
'platform' : 'Linux'
, 'browserName' : 'googlechrome'
, 'version' : 'latest'
2012-11-03 15:55:14 +00:00
});
2020-05-29 16:52:00 +00:00
// 3) Safari on OSX 10.15
2012-11-03 15:55:14 +00:00
sauceTestWorker.push({
'platform' : 'OS X 10.15'
, 'browserName' : 'safari'
, 'version' : 'latest'
2012-11-03 15:55:14 +00:00
});
// IE 10 doesn't appear to be working anyway
/*
// 4) IE 10 on Win 8
2012-11-03 15:55:14 +00:00
sauceTestWorker.push({
'platform' : 'Windows 8'
2012-11-03 15:55:14 +00:00
, 'browserName' : 'iexplore'
, 'version' : '10.0'
2012-11-03 15:55:14 +00:00
});
*/
// 5) Edge on Win 10
2012-11-03 15:55:14 +00:00
sauceTestWorker.push({
'platform' : 'Windows 10'
, 'browserName' : 'microsoftedge'
, 'version' : 'latest'
2012-11-03 15:55:14 +00:00
});
2012-11-03 15:55:14 +00:00
sauceTestWorker.drain = function() {
setTimeout(function(){
process.exit(allTestsPassed ? 0 : 1);
}, 3000);
}