RunCi.hx 2.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108
  1. import haxe.Exception;
  2. import runci.TestTarget;
  3. import runci.System;
  4. import runci.System.*;
  5. import runci.Config.*;
  6. import runci.Deployment.*;
  7. using StringTools;
  8. class RunCi {
  9. static function main():Void {
  10. Sys.putEnv("OCAMLRUNPARAM", "b");
  11. var args = Sys.args();
  12. var tests:Array<TestTarget> = switch (args.length==1 ? args[0] : Sys.getEnv("TEST")) {
  13. case null:
  14. [Macro];
  15. case env:
  16. [for (v in env.split(",")) v.trim().toLowerCase()];
  17. }
  18. infoMsg('Going to test: $tests');
  19. if (isCi()) {
  20. changeDirectory('echoServer');
  21. runCommand('haxe', ['build.hxml']);
  22. changeDirectory(cwd);
  23. }
  24. for (test in tests) {
  25. switch (systemName) {
  26. case "Windows":
  27. // change codepage to UTF-8
  28. runCommand("chcp", ["65001"]);
  29. case _:
  30. //pass
  31. }
  32. //run neko-based http echo server
  33. var echoServer = new sys.io.Process('nekotools', ['server', '-d', 'echoServer/www/', '-p', '20200']);
  34. infoMsg('test $test');
  35. var success = true;
  36. try {
  37. changeDirectory(unitDir);
  38. haxelibInstallGit("haxe-utest", "utest", "master");
  39. var args = switch (ci) {
  40. case null:
  41. [];
  42. case AzurePipelines:
  43. ["-D","azure"];
  44. case GithubActions:
  45. ["-D","github"];
  46. }
  47. args = args.concat(["-D", systemName]);
  48. switch (test) {
  49. case Macro:
  50. runci.targets.Macro.run(args);
  51. case Neko:
  52. runci.targets.Neko.run(args);
  53. case Php:
  54. runci.targets.Php.run(args);
  55. case Python:
  56. runci.targets.Python.run(args);
  57. case Lua:
  58. runci.targets.Lua.run(args);
  59. case Cpp:
  60. runci.targets.Cpp.run(args, true, true);
  61. case Cppia:
  62. runci.targets.Cpp.run(args, false, true);
  63. case Js:
  64. runci.targets.Js.run(args);
  65. case Java:
  66. runci.targets.Java.run(args);
  67. case Jvm:
  68. runci.targets.Jvm.run(args);
  69. case Cs:
  70. runci.targets.Cs.run(args);
  71. case Flash9:
  72. runci.targets.Flash.run(args);
  73. case Hl:
  74. runci.targets.Hl.run(args);
  75. case t:
  76. throw new Exception("unknown target: " + t);
  77. }
  78. } catch(f:Failure) {
  79. success = false;
  80. }
  81. if (success) {
  82. successMsg('test ${test} succeeded');
  83. } else {
  84. failMsg('test ${test} failed');
  85. break;
  86. }
  87. echoServer.kill();
  88. echoServer.close();
  89. }
  90. if (success) {
  91. deploy();
  92. } else {
  93. Sys.exit(1);
  94. }
  95. }
  96. }