1
0

NodeTestRunner.js 9.4 KB

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