2
0

Js.hx 3.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121
  1. package runci.targets;
  2. import sys.FileSystem;
  3. import runci.System.*;
  4. import runci.Config.*;
  5. import haxe.io.Path;
  6. import sys.io.Process;
  7. using StringTools;
  8. class Js {
  9. static final miscJsDir = miscDir + 'js/';
  10. static public function getJSDependencies() {
  11. switch [ci, systemName] {
  12. case [_, "Linux"]:
  13. if (commandSucceed("node", ["-v"])) {
  14. infoMsg('node has already been installed.');
  15. } else {
  16. Linux.requireAptPackages(["nodejs"]);
  17. }
  18. case _:
  19. //pass
  20. }
  21. runCommand("node", ["-v"]);
  22. }
  23. static public function run(args:Array<String>) {
  24. getJSDependencies();
  25. var jsOutputs = [
  26. for (es_ver in [[], ["-D", "js-es=3"], ["-D", "js-es=6"]])
  27. for (unflatten in [[], ["-D", "js-unflatten"]])
  28. for (classic in [[], ["-D", "js-classic"]])
  29. for (enums_as_objects in [[], ["-D", "js-enums-as-arrays"]])
  30. {
  31. var extras = args.concat(es_ver).concat(unflatten).concat(classic).concat(enums_as_objects);
  32. runCommand("haxe", ["compile-js.hxml"].concat(extras));
  33. var output = if (extras.length > 0) {
  34. "bin/js/" + extras.join("") + "/unit.js";
  35. } else {
  36. "bin/js/default/unit.js";
  37. }
  38. var outputDir = Path.directory(output);
  39. if (!FileSystem.exists(outputDir)) {
  40. FileSystem.createDirectory(outputDir);
  41. }
  42. FileSystem.rename("bin/unit.js", output);
  43. FileSystem.rename("bin/unit.js.map", output + ".map");
  44. runCommand("node", ["-e", "require('./" + output + "').unit.TestMain.main();"]);
  45. output;
  46. }
  47. ];
  48. infoMsg("Test ES6:");
  49. changeDirectory(miscDir + "es6");
  50. runCommand("haxe", ["run.hxml"]);
  51. haxelibInstallGit("HaxeFoundation", "hxnodejs");
  52. var env = Sys.environment();
  53. if (
  54. env.exists("SAUCE") &&
  55. env.exists("SAUCE_USERNAME") &&
  56. env.exists("SAUCE_ACCESS_KEY")
  57. ) {
  58. var sc = switch (ci) {
  59. // TODO: figure out SauceConnect for GitHub Actions
  60. // case AzurePipelines:
  61. // var scVersion = "sc-4.5.3-linux";
  62. // runCommand("wget", ["-q", 'https://saucelabs.com/downloads/${scVersion}.tar.gz'], true);
  63. // runCommand("tar", ["-xf", '${scVersion}.tar.gz']);
  64. // //start sauce-connect
  65. // var scReadyFile = "sauce-connect-ready-" + Std.random(100);
  66. // var p = new Process('${scVersion}/bin/sc', [
  67. // "-i", Sys.getEnv("SAUCE_TUNNEL_ID"),
  68. // "-f", scReadyFile
  69. // ]);
  70. // while(!FileSystem.exists(scReadyFile)) {
  71. // Sys.sleep(0.5);
  72. // }
  73. // p;
  74. case _:
  75. // sauce-connect should have been started
  76. null;
  77. }
  78. changeDirectory(unitDir);
  79. runCommand("npm", ["install", "wd", "q"], true);
  80. runCommand("haxe", ["compile-saucelabs-runner.hxml"]);
  81. var server = new Process("nekotools", ["server"]);
  82. runCommand("node", ["bin/RunSauceLabs.js"].concat([for (js in jsOutputs) "unit-js.html?js=" + js.urlEncode()]));
  83. server.close();
  84. if (sc != null)
  85. sc.close();
  86. }
  87. infoMsg("Test optimization:");
  88. changeDirectory(optDir);
  89. runCommand("haxe", ["run.hxml"]);
  90. runci.targets.Java.getJavaDependencies(); // this is awkward
  91. haxelibInstallGit("Simn", "haxeserver");
  92. changeDirectory(serverDir);
  93. runCommand("haxe", ["build.hxml"]);
  94. runCommand("node", ["test.js"]);
  95. changeDirectory(sysDir);
  96. runCommand("npm", ["install", "deasync"], true);
  97. runCommand("haxe", ["compile-js.hxml"].concat(args));
  98. runSysTest("node", ["bin/js/sys.js"]);
  99. changeDirectory(miscJsDir);
  100. runCommand("haxe", ["run.hxml"]);
  101. }
  102. }