Forráskód Böngészése

[SauceLabs] change how the test runner communicate with RunSauceLabs.js

Andy Li 10 éve
szülő
commit
d485e38a65
2 módosított fájl, 23 hozzáadás és 19 törlés
  1. 17 19
      tests/unit/src/RunSauceLabs.hx
  2. 6 0
      tests/unit/src/unit/Test.hx

+ 17 - 19
tests/unit/src/RunSauceLabs.hx

@@ -24,7 +24,7 @@ private typedef Promise = {
 		-connect-port <port>		Port number of remote testing server. Default: 4445 (using Sauce Connect)
 		-browsers <browsers>		A list of browsers to test with in JSON format. Default: refer to source code
 
-	Tests should log "SUCCESS: true" or "SUCCESS: false" to the console when it is done.
+	When a test finishes, it should set `window.success` to a boolean.
 */
 class RunSauceLabs {
 	static function successMsg(msg:String):Void {
@@ -228,31 +228,29 @@ class RunSauceLabs {
 								.then(function() {
 									console.log("[debug] waiting for test to exit");
 									return 
-										until("return (typeof unit != 'undefined') && unit.Test && (typeof unit.Test.success === 'boolean')")
+										until("return (typeof window.success === 'boolean');")
 										.timeout(timeout);
 								})
 								.then(function() {
 									console.log("[debug] test exited");
 									return browser.text("body");
 								})
-								.then(function(resultText:String) {
-									//check if test is successful or not
-									var success = false;
-									for (line in resultText.split("\n")) {
-										infoMsg(line);
-										if (line.indexOf("SUCCESS: ") >= 0) {
-											success = line.indexOf("SUCCESS: true") >= 0;
-											break;
-										}
-									}
-									browserSuccess = browserSuccess && success;
-									allSuccess = allSuccess && browserSuccess;
+								.then(function(text:String) {
+									text.split("\n").iter(infoMsg);
+								})
+								.then(function() {
+									return browser
+										.execute("return window.success;")
+										.then(function(success) {
+											browserSuccess = browserSuccess && success;
+											allSuccess = allSuccess && browserSuccess;
 
-									if (success) {
-										successMsg('$url in ${caps.browserName} ${caps.version} on ${caps.platform}: SUCCESS');
-									} else {
-										failMsg('$url in ${caps.browserName} ${caps.version} on ${caps.platform}: FAIL');
-									}
+											if (success) {
+												successMsg('$url in ${caps.browserName} ${caps.version} on ${caps.platform}: SUCCESS');
+											} else {
+												failMsg('$url in ${caps.browserName} ${caps.version} on ${caps.platform}: FAIL');
+											}
+										});
 								})
 								.timeout(60000 * 5); //5 min
 						});

+ 6 - 0
tests/unit/src/unit/Test.hx

@@ -352,6 +352,12 @@ class Test #if swf_mark implements mt.Protect #end {
 
 		trace("SUCCESS: " + success);
 
+		#if js
+		if (js.Browser.supported) {
+			untyped js.Browser.window.success = success;
+		}
+		#end
+
 		#if sys
 		Sys.exit(success ? 0 : 1);
 		#end