1
0

NodeTestRunner.js 9.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237
  1. define(["amber/boot", "require", "amber_core/Kernel-Objects"], function($boot,requirejs){"use strict";
  2. var $core=$boot.api,nil=$boot.nilAsValue,$nil=$boot.nilAsReceiver,$recv=$boot.asReceiver,$globals=$boot.globals;
  3. var $pkg = $core.addPackage("NodeTestRunner");
  4. $pkg.innerEval = function (expr) { return eval(expr); };
  5. $pkg.transport = {"type":"amd","amdNamespace":"amber_devkit"};
  6. $core.addClass("NodeTestRunner", $globals.Object, [], "NodeTestRunner");
  7. $core.addMethod(
  8. $core.method({
  9. selector: "main",
  10. protocol: "not yet classified",
  11. fn: function (){
  12. var self=this,$self=this;
  13. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  14. return $core.withContext(function($ctx1) {
  15. //>>excludeEnd("ctx");
  16. $self._runTestSuite();
  17. return self;
  18. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  19. }, function($ctx1) {$ctx1.fill(self,"main",{},$globals.NodeTestRunner.a$cls)});
  20. //>>excludeEnd("ctx");
  21. },
  22. //>>excludeStart("ide", pragmas.excludeIdeData);
  23. args: [],
  24. source: "main\x0a\x09self runTestSuite",
  25. referencedClasses: [],
  26. //>>excludeEnd("ide");
  27. messageSends: ["runTestSuite"]
  28. }),
  29. $globals.NodeTestRunner.a$cls);
  30. $core.addMethod(
  31. $core.method({
  32. selector: "runTestSuite",
  33. protocol: "not yet classified",
  34. fn: function (){
  35. var self=this,$self=this;
  36. var suite,worker;
  37. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  38. return $core.withContext(function($ctx1) {
  39. //>>excludeEnd("ctx");
  40. var $2,$1,$3,$9,$8,$12,$11,$10,$7,$6,$15,$14,$13,$5,$4,$17,$16,$19,$18,$26,$25,$24,$23,$22,$28,$27,$21,$20,$30,$29,$32,$31,$39,$38,$37,$36,$35,$34,$33;
  41. suite=$recv($globals.OrderedCollection)._new();
  42. $recv($recv($recv($globals.TestCase)._allSubclasses())._select_((function(each){
  43. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  44. return $core.withContext(function($ctx2) {
  45. //>>excludeEnd("ctx");
  46. return $recv($recv(each)._isAbstract())._not();
  47. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  48. }, function($ctx2) {$ctx2.fillBlock({each:each},$ctx1,1)});
  49. //>>excludeEnd("ctx");
  50. })))._do_((function(each){
  51. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  52. return $core.withContext(function($ctx2) {
  53. //>>excludeEnd("ctx");
  54. return $recv(suite)._addAll_($recv(each)._buildSuite());
  55. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  56. }, function($ctx2) {$ctx2.fillBlock({each:each},$ctx1,2)});
  57. //>>excludeEnd("ctx");
  58. }));
  59. worker=$recv($globals.TestSuiteRunner)._on_(suite);
  60. $recv($recv(worker)._announcer())._on_do_($globals.ResultAnnouncement,(function(ann){
  61. var result;
  62. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  63. return $core.withContext(function($ctx2) {
  64. //>>excludeEnd("ctx");
  65. result=$recv(ann)._result();
  66. $2=$recv(result)._runs();
  67. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  68. $ctx2.sendIdx["runs"]=1;
  69. //>>excludeEnd("ctx");
  70. $1=$recv($2).__eq($recv(result)._total());
  71. if($core.assert($1)){
  72. $3=console;
  73. $9=$recv($recv(result)._runs())._asString();
  74. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  75. $ctx2.sendIdx["asString"]=1;
  76. //>>excludeEnd("ctx");
  77. $8=$recv($9).__comma(" tests run, ");
  78. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  79. $ctx2.sendIdx[","]=5;
  80. //>>excludeEnd("ctx");
  81. $12=$recv(result)._failures();
  82. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  83. $ctx2.sendIdx["failures"]=1;
  84. //>>excludeEnd("ctx");
  85. $11=$recv($12)._size();
  86. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  87. $ctx2.sendIdx["size"]=1;
  88. //>>excludeEnd("ctx");
  89. $10=$recv($11)._asString();
  90. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  91. $ctx2.sendIdx["asString"]=2;
  92. //>>excludeEnd("ctx");
  93. $7=$recv($8).__comma($10);
  94. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  95. $ctx2.sendIdx[","]=4;
  96. //>>excludeEnd("ctx");
  97. $6=$recv($7).__comma(" failures, ");
  98. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  99. $ctx2.sendIdx[","]=3;
  100. //>>excludeEnd("ctx");
  101. $15=$recv(result)._errors();
  102. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  103. $ctx2.sendIdx["errors"]=1;
  104. //>>excludeEnd("ctx");
  105. $14=$recv($15)._size();
  106. $13=$recv($14)._asString();
  107. $5=$recv($6).__comma($13);
  108. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  109. $ctx2.sendIdx[","]=2;
  110. //>>excludeEnd("ctx");
  111. $4=$recv($5).__comma(" errors.");
  112. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  113. $ctx2.sendIdx[","]=1;
  114. //>>excludeEnd("ctx");
  115. $recv($3)._log_($4);
  116. $17=$recv(result)._failures();
  117. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  118. $ctx2.sendIdx["failures"]=2;
  119. //>>excludeEnd("ctx");
  120. $16=$recv($17)._isEmpty();
  121. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  122. $ctx2.sendIdx["isEmpty"]=1;
  123. //>>excludeEnd("ctx");
  124. if(!$core.assert($16)){
  125. $19=$recv(result)._failures();
  126. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  127. $ctx2.sendIdx["failures"]=3;
  128. //>>excludeEnd("ctx");
  129. $18=$recv($19)._first();
  130. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  131. $ctx2.sendIdx["first"]=1;
  132. //>>excludeEnd("ctx");
  133. $recv($18)._runCase();
  134. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  135. $ctx2.sendIdx["runCase"]=1;
  136. //>>excludeEnd("ctx");
  137. $26=$recv(result)._failures();
  138. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  139. $ctx2.sendIdx["failures"]=4;
  140. //>>excludeEnd("ctx");
  141. $25=$recv($26)._first();
  142. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  143. $ctx2.sendIdx["first"]=2;
  144. //>>excludeEnd("ctx");
  145. $24=$recv($25)._class();
  146. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  147. $ctx2.sendIdx["class"]=1;
  148. //>>excludeEnd("ctx");
  149. $23=$recv($24)._name();
  150. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  151. $ctx2.sendIdx["name"]=1;
  152. //>>excludeEnd("ctx");
  153. $22=$recv($23).__comma(" >> ");
  154. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  155. $ctx2.sendIdx[","]=8;
  156. //>>excludeEnd("ctx");
  157. $28=$recv($recv(result)._failures())._first();
  158. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  159. $ctx2.sendIdx["first"]=3;
  160. //>>excludeEnd("ctx");
  161. $27=$recv($28)._selector();
  162. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  163. $ctx2.sendIdx["selector"]=1;
  164. //>>excludeEnd("ctx");
  165. $21=$recv($22).__comma($27);
  166. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  167. $ctx2.sendIdx[","]=7;
  168. //>>excludeEnd("ctx");
  169. $20=$recv($21).__comma(" is failing!");
  170. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  171. $ctx2.sendIdx[","]=6;
  172. //>>excludeEnd("ctx");
  173. $self._throw_($20);
  174. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  175. $ctx2.sendIdx["throw:"]=1;
  176. //>>excludeEnd("ctx");
  177. }
  178. $30=$recv(result)._errors();
  179. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  180. $ctx2.sendIdx["errors"]=2;
  181. //>>excludeEnd("ctx");
  182. $29=$recv($30)._isEmpty();
  183. if(!$core.assert($29)){
  184. $32=$recv(result)._errors();
  185. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  186. $ctx2.sendIdx["errors"]=3;
  187. //>>excludeEnd("ctx");
  188. $31=$recv($32)._first();
  189. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  190. $ctx2.sendIdx["first"]=4;
  191. //>>excludeEnd("ctx");
  192. $recv($31)._runCase();
  193. $39=$recv(result)._errors();
  194. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  195. $ctx2.sendIdx["errors"]=4;
  196. //>>excludeEnd("ctx");
  197. $38=$recv($39)._first();
  198. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  199. $ctx2.sendIdx["first"]=5;
  200. //>>excludeEnd("ctx");
  201. $37=$recv($38)._class();
  202. $36=$recv($37)._name();
  203. $35=$recv($36).__comma(" >> ");
  204. $34=$recv($35).__comma($recv($recv($recv(result)._errors())._first())._selector());
  205. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  206. $ctx2.sendIdx[","]=10;
  207. //>>excludeEnd("ctx");
  208. $33=$recv($34).__comma(" has errors!");
  209. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  210. $ctx2.sendIdx[","]=9;
  211. //>>excludeEnd("ctx");
  212. return $self._throw_($33);
  213. }
  214. }
  215. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  216. }, function($ctx2) {$ctx2.fillBlock({ann:ann,result:result},$ctx1,3)});
  217. //>>excludeEnd("ctx");
  218. }));
  219. $recv(worker)._run();
  220. return self;
  221. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  222. }, function($ctx1) {$ctx1.fill(self,"runTestSuite",{suite:suite,worker:worker},$globals.NodeTestRunner.a$cls)});
  223. //>>excludeEnd("ctx");
  224. },
  225. //>>excludeStart("ide", pragmas.excludeIdeData);
  226. args: [],
  227. source: "runTestSuite\x0a\x09| suite worker |\x0a\x0a\x09suite := OrderedCollection new.\x0a (TestCase allSubclasses select: [ :each | each isAbstract not ])\x0a\x09do: [ :each | suite addAll: each buildSuite ].\x0a\x0a\x09worker := TestSuiteRunner on: suite.\x0a\x09worker announcer on: ResultAnnouncement do:\x0a\x09[ :ann | | result |\x0a \x09result := ann result.\x0a result runs = result total ifTrue: [\x0a\x09 console log: result runs asString, ' tests run, ', result failures size asString, ' failures, ', result errors size asString, ' errors.'.\x0a\x0a result failures isEmpty ifFalse: [\x0a result failures first runCase.\x0a \x22the line above should throw, normally, but just in case I leave the line below\x22\x0a self throw: result failures first class name, ' >> ', result failures first selector, ' is failing!' ].\x0a result errors isEmpty ifFalse: [\x0a result errors first runCase.\x0a \x22the line above should throw, normally, but just in case I leave the line below\x22\x0a self throw: result errors first class name, ' >> ', result errors first selector, ' has errors!' ].\x0a ]].\x0a worker run",
  228. referencedClasses: ["OrderedCollection", "TestCase", "TestSuiteRunner", "ResultAnnouncement"],
  229. //>>excludeEnd("ide");
  230. messageSends: ["new", "do:", "select:", "allSubclasses", "not", "isAbstract", "addAll:", "buildSuite", "on:", "on:do:", "announcer", "result", "ifTrue:", "=", "runs", "total", "log:", ",", "asString", "size", "failures", "errors", "ifFalse:", "isEmpty", "runCase", "first", "throw:", "name", "class", "selector", "run"]
  231. }),
  232. $globals.NodeTestRunner.a$cls);
  233. });