Skip to content

Commit

Permalink
[SauceLabs] colorise important logs for readability
Browse files Browse the repository at this point in the history
  • Loading branch information
andyli committed Oct 15, 2014
1 parent 8c0300f commit 20861c5
Showing 1 changed file with 18 additions and 4 deletions.
22 changes: 18 additions & 4 deletions tests/unit/src/RunSauceLabs.hx
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,16 @@ import js.Node.*;
using Reflect;

class RunSauceLabs {
static function successMsg(msg:String):Void {
console.log('\x1b[32m' + msg + '\x1b[0m');
}
static function failMsg(msg:String):Void {
console.log('\x1b[31m' + msg + '\x1b[0m');
}
static function infoMsg(msg:String):Void {
console.log('\x1b[36m' + msg + '\x1b[0m');
}

static function main():Void {
var success = true;
var webdriver:Dynamic = require("wd");
Expand Down Expand Up @@ -122,20 +132,24 @@ class RunSauceLabs {
browser.waitForConditionInBrowser("try { typeof unit.Test.success === 'boolean'; } catch(e) { false; }", 15000); //15s timeout
console.log("[debug] test exited");

browser.text("body", function(err, re) {
browser.text("body", function(err, re:String) {
if (!handleError(err)) return;
console.log(re);

//check if test is successful or not
var test = false;
for (line in re.split("\n")) {
infoMsg(line);
if (line.indexOf("SUCCESS: ") >= 0) {
test = line.indexOf("SUCCESS: true") >= 0;
break;
}
}
success = success && test;
console.log("[debug] all SauceLabs tests success: " + success);

if (test) {
successMsg('${caps.browserName} ${caps.version} on ${caps.platform}: SUCCESS');
} else {
failMsg('${caps.browserName} ${caps.version} on ${caps.platform}: FAIL');
}

//let saucelabs knows the result
browser.sauceJobUpdate({ passed: test }, function(err) {
Expand Down

0 comments on commit 20861c5

Please sign in to comment.