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