Js.hx 2.9 KB

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