Browse Source

test js-es5 and js-unflatten on SauceLabs

Andy Li 10 years ago
parent
commit
4da3cc5fc8
2 changed files with 28 additions and 8 deletions
  1. 16 6
      tests/RunCi.hx
  2. 12 2
      tests/unit/unit-js.html

+ 16 - 6
tests/RunCi.hx

@@ -626,12 +626,22 @@ class RunCi {
 				case Js:
 					getJSDependencies();
 
-					for (es5 in [true, false]) {
-						for (flatten in [true, false]) {
-							runCommand("haxe", ["compile-js.hxml"].concat(flatten ? [] : ["-D", "js-unflatten"]).concat(es5 ? ["-D", "js-es5"] : []));
-							runCommand("node", ["-e", "var unit = require('./bin/unit.js').unit; unit.Test.main(); process.exit(unit.Test.success ? 0 : 1);"]);
+					var jsOutputs = [
+						for (es5 in [[], ["-D", "js-es5"]])
+						for (unflatten in [[], ["-D", "js-unflatten"]])
+						{
+							var extras = [].concat(es5).concat(unflatten);
+
+							runCommand("haxe", ["compile-js.hxml"].concat(extras));
+
+							var output = "bin/unit" + extras.join("") + ".js";
+							if (extras.length > 0) {
+								File.copy("bin/unit.js", output);
+							}
+							runCommand("node", ["-e", "var unit = require('./" + output + "').unit; unit.Test.main(); process.exit(unit.Test.success ? 0 : 1);"]);
+							output;
 						}
-					}
+					];
 
 					if (Sys.getEnv("TRAVIS_SECURE_ENV_VARS") == "true" && systemName == "Linux") {
 						var scVersion = "sc-4.3-linux";
@@ -652,7 +662,7 @@ class RunCi {
 						haxelibInstallGit("dionjwa", "nodejs-std", "master", null, true, "nodejs");
 						runCommand("haxe", ["compile-saucelabs-runner.hxml"]);
 						var server = new Process("nekotools", ["server"]);
-						runCommand("node", ["bin/RunSauceLabs.js", "unit-js.html"]);
+						runCommand("node", ["bin/RunSauceLabs.js"].concat([for (js in jsOutputs) "unit-js.html?js=" + js.urlEncode()]));
 
 						server.close();
 						sc.close();

+ 12 - 2
tests/unit/unit-js.html

@@ -7,7 +7,17 @@
         <meta name="viewport" content="width=device-width, initial-scale=1">
     </head>
     <body id="haxe:trace">
-        <script src="bin/unit.js"></script>
-        <script>unit.Test.main();</script>
+        <script type="text/javascript" src="//code.jquery.com/jquery-1.11.3.min.js"></script>
+        <script type="text/javascript">
+            // http://stackoverflow.com/questions/11582512/how-to-get-url-parameters-with-javascript
+            function getURLParameter(name) {
+                return decodeURIComponent((new RegExp('[?|&]' + name + '=' + '([^&;]+?)(&|#|;|$)').exec(location.search)||[,""])[1].replace(/\+/g, '%20'))||null
+            }
+
+            var js = getURLParameter("js") || "bin/unit.js";
+            $.getScript(js, function() {
+                unit.Test.main();
+            });
+        </script>
     </body>
 </html>