Browse Source

[SauceLabs] colorise important logs for readability

Andy Li 11 years ago
parent
commit
20861c5103
1 changed files with 18 additions and 4 deletions
  1. 18 4
      tests/unit/src/RunSauceLabs.hx

+ 18 - 4
tests/unit/src/RunSauceLabs.hx

@@ -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");
@@ -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) {