1
0

NodeTestRunner.js 9.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230
  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. suite=$recv($globals.OrderedCollection)._new();
  48. $recv($recv($recv($globals.TestCase)._allSubclasses())._select_((function(each){
  49. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  50. return $core.withContext(function($ctx2) {
  51. //>>excludeEnd("ctx");
  52. return $recv($recv(each)._isAbstract())._not();
  53. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  54. }, function($ctx2) {$ctx2.fillBlock({each:each},$ctx1,1)});
  55. //>>excludeEnd("ctx");
  56. })))._do_((function(each){
  57. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  58. return $core.withContext(function($ctx2) {
  59. //>>excludeEnd("ctx");
  60. return $recv(suite)._addAll_($recv(each)._buildSuite());
  61. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  62. }, function($ctx2) {$ctx2.fillBlock({each:each},$ctx1,2)});
  63. //>>excludeEnd("ctx");
  64. }));
  65. worker=$recv($globals.TestSuiteRunner)._on_(suite);
  66. $recv($recv(worker)._announcer())._on_do_($globals.ResultAnnouncement,(function(ann){
  67. var result;
  68. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  69. return $core.withContext(function($ctx2) {
  70. //>>excludeEnd("ctx");
  71. result=$recv(ann)._result();
  72. if($core.assert($recv([$recv(result)._runs()
  73. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  74. ,$ctx2.sendIdx["runs"]=1
  75. //>>excludeEnd("ctx");
  76. ][0]).__eq($recv(result)._total()))){
  77. $recv(console)._log_([$recv([$recv([$recv([$recv([$recv([$recv($recv(result)._runs())._asString()
  78. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  79. ,$ctx2.sendIdx["asString"]=1
  80. //>>excludeEnd("ctx");
  81. ][0]).__comma(" tests run, ")
  82. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  83. ,$ctx2.sendIdx[","]=5
  84. //>>excludeEnd("ctx");
  85. ][0]).__comma([$recv([$recv([$recv(result)._failures()
  86. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  87. ,$ctx2.sendIdx["failures"]=1
  88. //>>excludeEnd("ctx");
  89. ][0])._size()
  90. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  91. ,$ctx2.sendIdx["size"]=1
  92. //>>excludeEnd("ctx");
  93. ][0])._asString()
  94. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  95. ,$ctx2.sendIdx["asString"]=2
  96. //>>excludeEnd("ctx");
  97. ][0])
  98. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  99. ,$ctx2.sendIdx[","]=4
  100. //>>excludeEnd("ctx");
  101. ][0]).__comma(" failures, ")
  102. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  103. ,$ctx2.sendIdx[","]=3
  104. //>>excludeEnd("ctx");
  105. ][0]).__comma($recv($recv([$recv(result)._errors()
  106. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  107. ,$ctx2.sendIdx["errors"]=1
  108. //>>excludeEnd("ctx");
  109. ][0])._size())._asString())
  110. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  111. ,$ctx2.sendIdx[","]=2
  112. //>>excludeEnd("ctx");
  113. ][0]).__comma(" errors.")
  114. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  115. ,$ctx2.sendIdx[","]=1
  116. //>>excludeEnd("ctx");
  117. ][0]);
  118. if(!$core.assert([$recv([$recv(result)._failures()
  119. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  120. ,$ctx2.sendIdx["failures"]=2
  121. //>>excludeEnd("ctx");
  122. ][0])._isEmpty()
  123. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  124. ,$ctx2.sendIdx["isEmpty"]=1
  125. //>>excludeEnd("ctx");
  126. ][0])){
  127. [$recv([$recv([$recv(result)._failures()
  128. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  129. ,$ctx2.sendIdx["failures"]=3
  130. //>>excludeEnd("ctx");
  131. ][0])._first()
  132. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  133. ,$ctx2.sendIdx["first"]=1
  134. //>>excludeEnd("ctx");
  135. ][0])._runCase()
  136. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  137. ,$ctx2.sendIdx["runCase"]=1
  138. //>>excludeEnd("ctx");
  139. ][0];
  140. [$self._throw_([$recv([$recv([$recv([$recv([$recv([$recv([$recv(result)._failures()
  141. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  142. ,$ctx2.sendIdx["failures"]=4
  143. //>>excludeEnd("ctx");
  144. ][0])._first()
  145. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  146. ,$ctx2.sendIdx["first"]=2
  147. //>>excludeEnd("ctx");
  148. ][0])._class()
  149. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  150. ,$ctx2.sendIdx["class"]=1
  151. //>>excludeEnd("ctx");
  152. ][0])._name()
  153. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  154. ,$ctx2.sendIdx["name"]=1
  155. //>>excludeEnd("ctx");
  156. ][0]).__comma(" >> ")
  157. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  158. ,$ctx2.sendIdx[","]=8
  159. //>>excludeEnd("ctx");
  160. ][0]).__comma([$recv([$recv($recv(result)._failures())._first()
  161. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  162. ,$ctx2.sendIdx["first"]=3
  163. //>>excludeEnd("ctx");
  164. ][0])._selector()
  165. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  166. ,$ctx2.sendIdx["selector"]=1
  167. //>>excludeEnd("ctx");
  168. ][0])
  169. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  170. ,$ctx2.sendIdx[","]=7
  171. //>>excludeEnd("ctx");
  172. ][0]).__comma(" is failing!")
  173. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  174. ,$ctx2.sendIdx[","]=6
  175. //>>excludeEnd("ctx");
  176. ][0])
  177. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  178. ,$ctx2.sendIdx["throw:"]=1
  179. //>>excludeEnd("ctx");
  180. ][0];
  181. }
  182. if(!$core.assert($recv([$recv(result)._errors()
  183. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  184. ,$ctx2.sendIdx["errors"]=2
  185. //>>excludeEnd("ctx");
  186. ][0])._isEmpty())){
  187. $recv([$recv([$recv(result)._errors()
  188. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  189. ,$ctx2.sendIdx["errors"]=3
  190. //>>excludeEnd("ctx");
  191. ][0])._first()
  192. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  193. ,$ctx2.sendIdx["first"]=4
  194. //>>excludeEnd("ctx");
  195. ][0])._runCase();
  196. return $self._throw_([$recv([$recv($recv($recv($recv([$recv([$recv(result)._errors()
  197. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  198. ,$ctx2.sendIdx["errors"]=4
  199. //>>excludeEnd("ctx");
  200. ][0])._first()
  201. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  202. ,$ctx2.sendIdx["first"]=5
  203. //>>excludeEnd("ctx");
  204. ][0])._class())._name()).__comma(" >> ")).__comma($recv($recv($recv(result)._errors())._first())._selector())
  205. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  206. ,$ctx2.sendIdx[","]=10
  207. //>>excludeEnd("ctx");
  208. ][0]).__comma(" has errors!")
  209. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  210. ,$ctx2.sendIdx[","]=9
  211. //>>excludeEnd("ctx");
  212. ][0]);
  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})});
  223. //>>excludeEnd("ctx");
  224. }; }),
  225. $globals.NodeTestRunner.a$cls);
  226. });