1
0

NodeTestRunner.js 9.1 KB

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