2012-11-01 23:17:31 +01:00
|
|
|
var srcFolder = "../../../src/node_modules/";
|
|
|
|
var log4js = require(srcFolder + "log4js");
|
|
|
|
var wd = require(srcFolder + "wd");
|
|
|
|
|
|
|
|
var config = {
|
|
|
|
host: "ondemand.saucelabs.com"
|
|
|
|
, port: 80
|
|
|
|
, username: process.env.SAUCE_USER
|
|
|
|
, accessKey: process.env.SAUCE_KEY
|
|
|
|
}
|
|
|
|
|
|
|
|
var browser = wd.remote(config.host, config.port, config.username, config.accessKey);
|
|
|
|
var browserChain = browser.chain();
|
|
|
|
|
|
|
|
var enviroment = {
|
|
|
|
'platform' : 'Linux'
|
|
|
|
, 'browserName' : 'firefox'
|
|
|
|
, 'version' : ''
|
|
|
|
, 'name' : 'Halloween test'
|
|
|
|
}
|
|
|
|
|
|
|
|
browserChain.init(enviroment).get("http://localhost:9001/tests/frontend/", function(){
|
2012-11-02 00:21:10 +01:00
|
|
|
var stopSauce = function(success){
|
|
|
|
getStatusInterval && clearInterval(getStatusInterval);
|
|
|
|
clearTimeout(timeout);
|
|
|
|
|
2012-11-01 23:17:31 +01:00
|
|
|
browserChain.quit();
|
|
|
|
setTimeout(function(){
|
2012-11-02 00:21:10 +01:00
|
|
|
process.exit(success ? 0 : 1);
|
2012-11-01 23:17:31 +01:00
|
|
|
}, 1000);
|
2012-11-02 00:21:10 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
var timeout = setTimeout(function(){
|
|
|
|
stopSauce(false);
|
|
|
|
}, 60000 * 10);
|
|
|
|
|
|
|
|
var knownConsoleText = "";
|
|
|
|
var getStatusInterval = setInterval(function(){
|
|
|
|
browserChain.eval("$('#console').text()", function(err, consoleText){
|
|
|
|
if(!consoleText || err){
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
var newText = consoleText.substr(knownConsoleText.length);
|
2012-11-03 14:20:44 +01:00
|
|
|
newText = newText.replace(/\[red\]/g,'\x1B[31m').replace(/\[yellow\]/g,'\x1B[33m')
|
|
|
|
.replace(/\[green\]/g,'\x1B[32m').replace(/\[clear\]/g, '\x1B[39m');
|
|
|
|
|
|
|
|
if(newText.length > 0){
|
|
|
|
console.log(newText.replace(/\n$/, ""))
|
|
|
|
}
|
2012-11-02 00:21:10 +01:00
|
|
|
knownConsoleText = consoleText;
|
|
|
|
|
|
|
|
if(knownConsoleText.indexOf("FINISHED") > 0){
|
|
|
|
var success = knownConsoleText.indexOf("FAILED") === -1;
|
|
|
|
stopSauce(success);
|
|
|
|
}
|
|
|
|
});
|
|
|
|
}, 5000);
|
2012-11-01 23:17:31 +01:00
|
|
|
});
|