Browse Source

Merge pull request #262 from herby/uiless-testrunner

Test running separate from its presentation.
Nicolas Petton 12 years ago
parent
commit
b2e8304930
9 changed files with 474 additions and 94 deletions
  1. 16 11
      js/IDE.deploy.js
  2. 19 14
      js/IDE.js
  3. 116 0
      js/SUnit.deploy.js
  4. 161 0
      js/SUnit.js
  5. 11 11
      st/IDE.st
  6. 61 0
      st/SUnit.st
  7. 35 22
      test/Test.deploy.js
  8. 39 26
      test/Test.js
  9. 16 10
      test/Test.st

+ 16 - 11
js/IDE.deploy.js

@@ -4201,17 +4201,22 @@ smalltalk.addMethod(
 "_run_",
 smalltalk.method({
 selector: "run:",
-fn: function (aCollection) {
-    var self = this;
-    var $1;
-    self['@result'] = smalltalk.send(smalltalk.TestResult || TestResult, "_new", []);
-    smalltalk.send(self, "_updateStatusDiv", []);
-    $1 = smalltalk.send(self, "_updateMethodsList", []);
-    smalltalk.send(smalltalk.send(self, "_progressBar", []), "_updatePercent_", [0]);
-    smalltalk.send(self['@result'], "_total_", [smalltalk.send(aCollection, "_size", [])]);
-    smalltalk.send(aCollection, "_do_", [function (each) {return smalltalk.send(function () {smalltalk.send(each, "_runCaseFor_", [self['@result']]);smalltalk.send(smalltalk.send(self, "_progressBar", []), "_updatePercent_", [smalltalk.send(smalltalk.send(smalltalk.send(self['@result'], "_runs", []), "__slash", [smalltalk.send(self['@result'], "_total", [])]), "__star", [100])]);smalltalk.send(self, "_updateStatusDiv", []);return smalltalk.send(self, "_updateMethodsList", []);}, "_valueWithTimeout_", [100]);}]);
-    return self;
-}
+fn: function (aCollection){
+var self=this;
+var $1;
+var worker;
+worker=smalltalk.send((smalltalk.TestSuiteRunner || TestSuiteRunner),"_on_",[aCollection]);
+self["@result"]=smalltalk.send(worker,"_result",[]);
+smalltalk.send(smalltalk.send(worker,"_announcer",[]),"_on_do_",[(smalltalk.ResultAnnouncement || ResultAnnouncement),(function(ann){
+$1=smalltalk.send(smalltalk.send(ann,"_result",[]),"__eq_eq",[self["@result"]]);
+if(smalltalk.assert($1)){
+smalltalk.send(smalltalk.send(self,"_progressBar",[]),"_updatePercent_",[smalltalk.send(smalltalk.send(smalltalk.send(self["@result"],"_runs",[]),"__slash",[smalltalk.send(self["@result"],"_total",[])]),"__star",[(100)])]);
+smalltalk.send(self,"_updateStatusDiv",[]);
+return smalltalk.send(self,"_updateMethodsList",[]);
+};
+})]);
+smalltalk.send(worker,"_run",[]);
+return self}
 }),
 smalltalk.TestRunner);
 

+ 19 - 14
js/IDE.js

@@ -5502,21 +5502,26 @@ smalltalk.addMethod(
 smalltalk.method({
 selector: "run:",
 category: 'actions',
-fn: function (aCollection) {
-    var self = this;
-    var $1;
-    self['@result'] = smalltalk.send(smalltalk.TestResult || TestResult, "_new", []);
-    smalltalk.send(self, "_updateStatusDiv", []);
-    $1 = smalltalk.send(self, "_updateMethodsList", []);
-    smalltalk.send(smalltalk.send(self, "_progressBar", []), "_updatePercent_", [0]);
-    smalltalk.send(self['@result'], "_total_", [smalltalk.send(aCollection, "_size", [])]);
-    smalltalk.send(aCollection, "_do_", [function (each) {return smalltalk.send(function () {smalltalk.send(each, "_runCaseFor_", [self['@result']]);smalltalk.send(smalltalk.send(self, "_progressBar", []), "_updatePercent_", [smalltalk.send(smalltalk.send(smalltalk.send(self['@result'], "_runs", []), "__slash", [smalltalk.send(self['@result'], "_total", [])]), "__star", [100])]);smalltalk.send(self, "_updateStatusDiv", []);return smalltalk.send(self, "_updateMethodsList", []);}, "_valueWithTimeout_", [100]);}]);
-    return self;
-},
+fn: function (aCollection){
+var self=this;
+var $1;
+var worker;
+worker=smalltalk.send((smalltalk.TestSuiteRunner || TestSuiteRunner),"_on_",[aCollection]);
+self["@result"]=smalltalk.send(worker,"_result",[]);
+smalltalk.send(smalltalk.send(worker,"_announcer",[]),"_on_do_",[(smalltalk.ResultAnnouncement || ResultAnnouncement),(function(ann){
+$1=smalltalk.send(smalltalk.send(ann,"_result",[]),"__eq_eq",[self["@result"]]);
+if(smalltalk.assert($1)){
+smalltalk.send(smalltalk.send(self,"_progressBar",[]),"_updatePercent_",[smalltalk.send(smalltalk.send(smalltalk.send(self["@result"],"_runs",[]),"__slash",[smalltalk.send(self["@result"],"_total",[])]),"__star",[(100)])]);
+smalltalk.send(self,"_updateStatusDiv",[]);
+return smalltalk.send(self,"_updateMethodsList",[]);
+};
+})]);
+smalltalk.send(worker,"_run",[]);
+return self},
 args: ["aCollection"],
-source: "run: aCollection\x0a\x09result := TestResult new.\x0a\x09self \x0a\x09\x09updateStatusDiv;\x0a\x09\x09updateMethodsList.\x0a\x09self progressBar updatePercent: 0.\x0a\x09result total: aCollection size.\x0a\x09aCollection do: [:each | \x0a\x09\x09[each runCaseFor: result.\x0a\x09\x09self progressBar updatePercent: result runs / result total * 100.\x0a\x09\x09self updateStatusDiv.\x0a\x09\x09self updateMethodsList] valueWithTimeout: 100].",
-messageSends: ["new", "updateStatusDiv", "updateMethodsList", "updatePercent:", "progressBar", "total:", "size", "do:", "valueWithTimeout:", "runCaseFor:", "*", "/", "total", "runs"],
-referencedClasses: ["TestResult"]
+source: "run: aCollection\x0a| worker |\x0a\x09worker := TestSuiteRunner on: aCollection.\x0a\x09result := worker result.\x0a    worker announcer on: ResultAnnouncement do: [:ann |\x0a    \x09ann result == result ifTrue: [\x0a\x09\x09\x09self progressBar updatePercent: result runs / result total * 100.\x0a\x09\x09\x09self updateStatusDiv.\x0a\x09\x09\x09self updateMethodsList\x0a  \x09\x09]\x0a\x09].\x0a\x09worker run",
+messageSends: ["on:", "result", "on:do:", "ifTrue:", "updatePercent:", "*", "/", "total", "runs", "progressBar", "updateStatusDiv", "updateMethodsList", "==", "announcer", "run"],
+referencedClasses: ["TestSuiteRunner", "ResultAnnouncement"]
 }),
 smalltalk.TestRunner);
 

+ 116 - 0
js/SUnit.deploy.js

@@ -1,4 +1,29 @@
 smalltalk.addPackage('SUnit', {});
+smalltalk.addClass('ResultAnnouncement', smalltalk.Object, ['result'], 'SUnit');
+smalltalk.addMethod(
+"_result",
+smalltalk.method({
+selector: "result",
+fn: function (){
+var self=this;
+return self["@result"];
+}
+}),
+smalltalk.ResultAnnouncement);
+
+smalltalk.addMethod(
+"_result_",
+smalltalk.method({
+selector: "result:",
+fn: function (aTestResult){
+var self=this;
+self["@result"]=aTestResult;
+return self}
+}),
+smalltalk.ResultAnnouncement);
+
+
+
 smalltalk.addClass('TestCase', smalltalk.Object, ['testSelector'], 'SUnit');
 smalltalk.addMethod(
 "_assert_",
@@ -422,3 +447,94 @@ smalltalk.TestResult);
 
 
 
+smalltalk.addClass('TestSuiteRunner', smalltalk.Object, ['suite', 'result', 'announcer'], 'SUnit');
+smalltalk.addMethod(
+"_announcer",
+smalltalk.method({
+selector: "announcer",
+fn: function (){
+var self=this;
+return self["@announcer"];
+}
+}),
+smalltalk.TestSuiteRunner);
+
+smalltalk.addMethod(
+"_initialize",
+smalltalk.method({
+selector: "initialize",
+fn: function (){
+var self=this;
+smalltalk.send(self,"_initialize",[],smalltalk.Object);
+self["@announcer"]=smalltalk.send((smalltalk.Announcer || Announcer),"_new",[]);
+self["@result"]=smalltalk.send((smalltalk.TestResult || TestResult),"_new",[]);
+return self}
+}),
+smalltalk.TestSuiteRunner);
+
+smalltalk.addMethod(
+"_result",
+smalltalk.method({
+selector: "result",
+fn: function (){
+var self=this;
+return self["@result"];
+}
+}),
+smalltalk.TestSuiteRunner);
+
+smalltalk.addMethod(
+"_run",
+smalltalk.method({
+selector: "run",
+fn: function (){
+var self=this;
+smalltalk.send(self["@result"],"_total_",[smalltalk.send(self["@suite"],"_size",[])]);
+smalltalk.send(self["@announcer"],"_announce_",[smalltalk.send(smalltalk.send((smalltalk.ResultAnnouncement || ResultAnnouncement),"_new",[]),"_result_",[self["@result"]])]);
+smalltalk.send(self["@suite"],"_do_",[(function(each){
+return smalltalk.send((function(){
+smalltalk.send(each,"_runCaseFor_",[self["@result"]]);
+return smalltalk.send(self["@announcer"],"_announce_",[smalltalk.send(smalltalk.send((smalltalk.ResultAnnouncement || ResultAnnouncement),"_new",[]),"_result_",[self["@result"]])]);
+}),"_valueWithTimeout_",[(100)]);
+})]);
+return self}
+}),
+smalltalk.TestSuiteRunner);
+
+smalltalk.addMethod(
+"_suite_",
+smalltalk.method({
+selector: "suite:",
+fn: function (aCollection){
+var self=this;
+self["@suite"]=aCollection;
+return self}
+}),
+smalltalk.TestSuiteRunner);
+
+
+smalltalk.addMethod(
+"_new",
+smalltalk.method({
+selector: "new",
+fn: function (){
+var self=this;
+smalltalk.send(self,"_shouldNotImplement",[]);
+return self}
+}),
+smalltalk.TestSuiteRunner.klass);
+
+smalltalk.addMethod(
+"_on_",
+smalltalk.method({
+selector: "on:",
+fn: function (aCollection){
+var self=this;
+var $1;
+$1=smalltalk.send(smalltalk.send(self,"_new",[],smalltalk.Object.klass),"_suite_",[aCollection]);
+return $1;
+}
+}),
+smalltalk.TestSuiteRunner.klass);
+
+

+ 161 - 0
js/SUnit.js

@@ -1,4 +1,39 @@
 smalltalk.addPackage('SUnit', {});
+smalltalk.addClass('ResultAnnouncement', smalltalk.Object, ['result'], 'SUnit');
+smalltalk.addMethod(
+"_result",
+smalltalk.method({
+selector: "result",
+category: 'accessing',
+fn: function (){
+var self=this;
+return self["@result"];
+},
+args: [],
+source: "result\x0a\x09^result",
+messageSends: [],
+referencedClasses: []
+}),
+smalltalk.ResultAnnouncement);
+
+smalltalk.addMethod(
+"_result_",
+smalltalk.method({
+selector: "result:",
+category: 'accessing',
+fn: function (aTestResult){
+var self=this;
+self["@result"]=aTestResult;
+return self},
+args: ["aTestResult"],
+source: "result: aTestResult\x0a\x09result := aTestResult",
+messageSends: [],
+referencedClasses: []
+}),
+smalltalk.ResultAnnouncement);
+
+
+
 smalltalk.addClass('TestCase', smalltalk.Object, ['testSelector'], 'SUnit');
 smalltalk.addMethod(
 "_assert_",
@@ -582,3 +617,129 @@ smalltalk.TestResult);
 
 
 
+smalltalk.addClass('TestSuiteRunner', smalltalk.Object, ['suite', 'result', 'announcer'], 'SUnit');
+smalltalk.addMethod(
+"_announcer",
+smalltalk.method({
+selector: "announcer",
+category: 'accessing',
+fn: function (){
+var self=this;
+return self["@announcer"];
+},
+args: [],
+source: "announcer\x0a\x09^announcer",
+messageSends: [],
+referencedClasses: []
+}),
+smalltalk.TestSuiteRunner);
+
+smalltalk.addMethod(
+"_initialize",
+smalltalk.method({
+selector: "initialize",
+category: 'initialization',
+fn: function (){
+var self=this;
+smalltalk.send(self,"_initialize",[],smalltalk.Object);
+self["@announcer"]=smalltalk.send((smalltalk.Announcer || Announcer),"_new",[]);
+self["@result"]=smalltalk.send((smalltalk.TestResult || TestResult),"_new",[]);
+return self},
+args: [],
+source: "initialize\x0a\x09super initialize.\x0a\x09announcer := Announcer new.\x0a    result := TestResult new",
+messageSends: ["initialize", "new"],
+referencedClasses: ["Announcer", "TestResult"]
+}),
+smalltalk.TestSuiteRunner);
+
+smalltalk.addMethod(
+"_result",
+smalltalk.method({
+selector: "result",
+category: 'accessing',
+fn: function (){
+var self=this;
+return self["@result"];
+},
+args: [],
+source: "result\x0a\x09^result",
+messageSends: [],
+referencedClasses: []
+}),
+smalltalk.TestSuiteRunner);
+
+smalltalk.addMethod(
+"_run",
+smalltalk.method({
+selector: "run",
+category: 'actions',
+fn: function (){
+var self=this;
+smalltalk.send(self["@result"],"_total_",[smalltalk.send(self["@suite"],"_size",[])]);
+smalltalk.send(self["@announcer"],"_announce_",[smalltalk.send(smalltalk.send((smalltalk.ResultAnnouncement || ResultAnnouncement),"_new",[]),"_result_",[self["@result"]])]);
+smalltalk.send(self["@suite"],"_do_",[(function(each){
+return smalltalk.send((function(){
+smalltalk.send(each,"_runCaseFor_",[self["@result"]]);
+return smalltalk.send(self["@announcer"],"_announce_",[smalltalk.send(smalltalk.send((smalltalk.ResultAnnouncement || ResultAnnouncement),"_new",[]),"_result_",[self["@result"]])]);
+}),"_valueWithTimeout_",[(100)]);
+})]);
+return self},
+args: [],
+source: "run\x0a\x09result total: suite size.\x0a    announcer announce: (ResultAnnouncement new result: result).\x0a\x09suite do: [:each | [\x0a      \x09each runCaseFor: result.\x0a\x09    announcer announce: (ResultAnnouncement new result: result)\x0a\x09] valueWithTimeout: 100]\x0a",
+messageSends: ["total:", "size", "announce:", "result:", "new", "do:", "valueWithTimeout:", "runCaseFor:"],
+referencedClasses: ["ResultAnnouncement"]
+}),
+smalltalk.TestSuiteRunner);
+
+smalltalk.addMethod(
+"_suite_",
+smalltalk.method({
+selector: "suite:",
+category: 'accessing',
+fn: function (aCollection){
+var self=this;
+self["@suite"]=aCollection;
+return self},
+args: ["aCollection"],
+source: "suite: aCollection\x0a\x09suite := aCollection",
+messageSends: [],
+referencedClasses: []
+}),
+smalltalk.TestSuiteRunner);
+
+
+smalltalk.addMethod(
+"_new",
+smalltalk.method({
+selector: "new",
+category: 'instance creation',
+fn: function (){
+var self=this;
+smalltalk.send(self,"_shouldNotImplement",[]);
+return self},
+args: [],
+source: "new\x0a\x09self shouldNotImplement",
+messageSends: ["shouldNotImplement"],
+referencedClasses: []
+}),
+smalltalk.TestSuiteRunner.klass);
+
+smalltalk.addMethod(
+"_on_",
+smalltalk.method({
+selector: "on:",
+category: 'instance creation',
+fn: function (aCollection){
+var self=this;
+var $1;
+$1=smalltalk.send(smalltalk.send(self,"_new",[],smalltalk.Object.klass),"_suite_",[aCollection]);
+return $1;
+},
+args: ["aCollection"],
+source: "on: aCollection\x0a\x09^super new suite: aCollection",
+messageSends: ["suite:", "new"],
+referencedClasses: []
+}),
+smalltalk.TestSuiteRunner.klass);
+
+

+ 11 - 11
st/IDE.st

@@ -2059,17 +2059,17 @@ performFailure: aTestCase
 !
 
 run: aCollection
-	result := TestResult new.
-	self 
-		updateStatusDiv;
-		updateMethodsList.
-	self progressBar updatePercent: 0.
-	result total: aCollection size.
-	aCollection do: [:each | 
-		[each runCaseFor: result.
-		self progressBar updatePercent: result runs / result total * 100.
-		self updateStatusDiv.
-		self updateMethodsList] valueWithTimeout: 100].
+| worker |
+	worker := TestSuiteRunner on: aCollection.
+	result := worker result.
+    worker announcer on: ResultAnnouncement do: [:ann |
+    	ann result == result ifTrue: [
+			self progressBar updatePercent: result runs / result total * 100.
+			self updateStatusDiv.
+			self updateMethodsList
+  		]
+	].
+	worker run
 !
 
 selectAllCategories

+ 61 - 0
st/SUnit.st

@@ -1,4 +1,18 @@
 Smalltalk current createPackage: 'SUnit' properties: #{}!
+Object subclass: #ResultAnnouncement
+	instanceVariableNames: 'result'
+	package: 'SUnit'!
+
+!ResultAnnouncement methodsFor: 'accessing'!
+
+result
+	^result
+!
+
+result: aTestResult
+	result := aTestResult
+! !
+
 Object subclass: #TestCase
 	instanceVariableNames: 'testSelector'
 	package: 'SUnit'!
@@ -180,3 +194,50 @@ initialize
 	total := 0
 ! !
 
+Object subclass: #TestSuiteRunner
+	instanceVariableNames: 'suite result announcer'
+	package: 'SUnit'!
+
+!TestSuiteRunner methodsFor: 'accessing'!
+
+announcer
+	^announcer
+!
+
+result
+	^result
+!
+
+suite: aCollection
+	suite := aCollection
+! !
+
+!TestSuiteRunner methodsFor: 'actions'!
+
+run
+	result total: suite size.
+    announcer announce: (ResultAnnouncement new result: result).
+	suite do: [:each | [
+      	each runCaseFor: result.
+	    announcer announce: (ResultAnnouncement new result: result)
+	] valueWithTimeout: 100]
+! !
+
+!TestSuiteRunner methodsFor: 'initialization'!
+
+initialize
+	super initialize.
+	announcer := Announcer new.
+    result := TestResult new
+! !
+
+!TestSuiteRunner class methodsFor: 'instance creation'!
+
+new
+	self shouldNotImplement
+!
+
+on: aCollection
+	^super new suite: aCollection
+! !
+

+ 35 - 22
test/Test.deploy.js

@@ -5,11 +5,10 @@ smalltalk.addMethod(
 "_initialize",
 smalltalk.method({
 selector: "initialize",
-fn: function () {
-    var self = this;
-    smalltalk.send(self, "_runTestSuite", []);
-    return self;
-}
+fn: function (){
+var self=this;
+smalltalk.send(self, "_runTestSuite", []);
+return self;}
 }),
 smalltalk.NodeTestRunner.klass);
 
@@ -17,23 +16,37 @@ smalltalk.addMethod(
 "_runTestSuite",
 smalltalk.method({
 selector: "runTestSuite",
-fn: function () {
-    var self = this;
-    var $1, $2;
-    var result;
-    result = smalltalk.send(smalltalk.TestResult || TestResult, "_new", []);
-    smalltalk.send(smalltalk.send(smalltalk.send(smalltalk.TestCase || TestCase, "_allSubclasses", []), "_select_", [function (each) {return smalltalk.send(smalltalk.send(each, "_isAbstract", []), "_not", []);}]), "_do_", [function (each) {return smalltalk.send(smalltalk.send(each, "_buildSuite", []), "_do_", [function (suite) {return smalltalk.send(suite, "_runCaseFor_", [result]);}]);}]);
-    smalltalk.send(console, "_log_", [smalltalk.send(smalltalk.send(smalltalk.send(smalltalk.send(smalltalk.send(smalltalk.send(smalltalk.send(result, "_runs", []), "_asString", []), "__comma", [" tests run, "]), "__comma", [smalltalk.send(smalltalk.send(smalltalk.send(result, "_failures", []), "_size", []), "_asString", [])]), "__comma", [" failures, "]), "__comma", [smalltalk.send(smalltalk.send(smalltalk.send(result, "_errors", []), "_size", []), "_asString", [])]), "__comma", [" errors."])]);
-    $1 = smalltalk.send(smalltalk.send(result, "_failures", []), "_isEmpty", []);
-    if (!smalltalk.assert($1)) {
-        smalltalk.send(self, "_throw_", [smalltalk.send(smalltalk.send(smalltalk.send(smalltalk.send(smalltalk.send(smalltalk.send(smalltalk.send(result, "_failures", []), "_first", []), "_class", []), "_name", []), "__comma", [" >> "]), "__comma", [smalltalk.send(smalltalk.send(smalltalk.send(result, "_failures", []), "_first", []), "_selector", [])]), "__comma", [" is failing!"])]);
-    }
-    $2 = smalltalk.send(smalltalk.send(result, "_errors", []), "_isEmpty", []);
-    if (!smalltalk.assert($2)) {
-        smalltalk.send(self, "_throw_", [smalltalk.send(smalltalk.send(smalltalk.send(smalltalk.send(smalltalk.send(smalltalk.send(smalltalk.send(result, "_errors", []), "_first", []), "_class", []), "_name", []), "__comma", [" >> "]), "__comma", [smalltalk.send(smalltalk.send(smalltalk.send(result, "_errors", []), "_first", []), "_selector", [])]), "__comma", [" has errors!"])]);
-    }
-    return self;
-}
+fn: function (){
+var self=this;
+var $1,$2,$3;
+var suite;
+var worker;
+suite=smalltalk.send((smalltalk.OrderedCollection || OrderedCollection),"_new",[]);
+smalltalk.send(smalltalk.send(smalltalk.send((smalltalk.TestCase || TestCase),"_allSubclasses",[]),"_select_",[(function(each){
+return smalltalk.send(smalltalk.send(each,"_isAbstract",[]),"_not",[]);
+})]),"_do_",[(function(each){
+return smalltalk.send(suite,"_addAll_",[smalltalk.send(each,"_buildSuite",[])]);
+})]);
+worker=smalltalk.send((smalltalk.TestSuiteRunner || TestSuiteRunner),"_on_",[suite]);
+smalltalk.send(smalltalk.send(worker,"_announcer",[]),"_on_do_",[(smalltalk.ResultAnnouncement || ResultAnnouncement),(function(ann){
+var result;
+result=smalltalk.send(ann,"_result",[]);
+result;
+$1=smalltalk.send(smalltalk.send(result,"_runs",[]),"__eq",[smalltalk.send(result,"_total",[])]);
+if(smalltalk.assert($1)){
+smalltalk.send(console,"_log_",[smalltalk.send(smalltalk.send(smalltalk.send(smalltalk.send(smalltalk.send(smalltalk.send(smalltalk.send(result,"_runs",[]),"_asString",[]),"__comma",[" tests run, "]),"__comma",[smalltalk.send(smalltalk.send(smalltalk.send(result,"_failures",[]),"_size",[]),"_asString",[])]),"__comma",[" failures, "]),"__comma",[smalltalk.send(smalltalk.send(smalltalk.send(result,"_errors",[]),"_size",[]),"_asString",[])]),"__comma",[" errors."])]);
+$2=smalltalk.send(smalltalk.send(result,"_failures",[]),"_isEmpty",[]);
+if(! smalltalk.assert($2)){
+smalltalk.send(self,"_throw_",[smalltalk.send(smalltalk.send(smalltalk.send(smalltalk.send(smalltalk.send(smalltalk.send(smalltalk.send(result,"_failures",[]),"_first",[]),"_class",[]),"_name",[]),"__comma",[" >> "]),"__comma",[smalltalk.send(smalltalk.send(smalltalk.send(result,"_failures",[]),"_first",[]),"_selector",[])]),"__comma",[" is failing!"])]);
+};
+$3=smalltalk.send(smalltalk.send(result,"_errors",[]),"_isEmpty",[]);
+if(! smalltalk.assert($3)){
+return smalltalk.send(self,"_throw_",[smalltalk.send(smalltalk.send(smalltalk.send(smalltalk.send(smalltalk.send(smalltalk.send(smalltalk.send(result,"_errors",[]),"_first",[]),"_class",[]),"_name",[]),"__comma",[" >> "]),"__comma",[smalltalk.send(smalltalk.send(smalltalk.send(result,"_errors",[]),"_first",[]),"_selector",[])]),"__comma",[" has errors!"])]);
+};
+};
+})]);
+smalltalk.send(worker,"_run",[]);
+return self}
 }),
 smalltalk.NodeTestRunner.klass);
 

+ 39 - 26
test/Test.js

@@ -6,13 +6,12 @@ smalltalk.addMethod(
 smalltalk.method({
 selector: "initialize",
 category: 'not yet classified',
-fn: function () {
-    var self = this;
-    smalltalk.send(self, "_runTestSuite", []);
-    return self;
-},
+fn: function (){
+var self=this;
+smalltalk.send(self, "_runTestSuite", []);
+return self;},
 args: [],
-source: "initialize\x0a\x09self runTestSuite",
+source: "initialize\x0d\x0a\x09self runTestSuite",
 messageSends: ["runTestSuite"],
 referencedClasses: []
 }),
@@ -23,27 +22,41 @@ smalltalk.addMethod(
 smalltalk.method({
 selector: "runTestSuite",
 category: 'not yet classified',
-fn: function () {
-    var self = this;
-    var $1, $2;
-    var result;
-    result = smalltalk.send(smalltalk.TestResult || TestResult, "_new", []);
-    smalltalk.send(smalltalk.send(smalltalk.send(smalltalk.TestCase || TestCase, "_allSubclasses", []), "_select_", [function (each) {return smalltalk.send(smalltalk.send(each, "_isAbstract", []), "_not", []);}]), "_do_", [function (each) {return smalltalk.send(smalltalk.send(each, "_buildSuite", []), "_do_", [function (suite) {return smalltalk.send(suite, "_runCaseFor_", [result]);}]);}]);
-    smalltalk.send(console, "_log_", [smalltalk.send(smalltalk.send(smalltalk.send(smalltalk.send(smalltalk.send(smalltalk.send(smalltalk.send(result, "_runs", []), "_asString", []), "__comma", [" tests run, "]), "__comma", [smalltalk.send(smalltalk.send(smalltalk.send(result, "_failures", []), "_size", []), "_asString", [])]), "__comma", [" failures, "]), "__comma", [smalltalk.send(smalltalk.send(smalltalk.send(result, "_errors", []), "_size", []), "_asString", [])]), "__comma", [" errors."])]);
-    $1 = smalltalk.send(smalltalk.send(result, "_failures", []), "_isEmpty", []);
-    if (!smalltalk.assert($1)) {
-        smalltalk.send(self, "_throw_", [smalltalk.send(smalltalk.send(smalltalk.send(smalltalk.send(smalltalk.send(smalltalk.send(smalltalk.send(result, "_failures", []), "_first", []), "_class", []), "_name", []), "__comma", [" >> "]), "__comma", [smalltalk.send(smalltalk.send(smalltalk.send(result, "_failures", []), "_first", []), "_selector", [])]), "__comma", [" is failing!"])]);
-    }
-    $2 = smalltalk.send(smalltalk.send(result, "_errors", []), "_isEmpty", []);
-    if (!smalltalk.assert($2)) {
-        smalltalk.send(self, "_throw_", [smalltalk.send(smalltalk.send(smalltalk.send(smalltalk.send(smalltalk.send(smalltalk.send(smalltalk.send(result, "_errors", []), "_first", []), "_class", []), "_name", []), "__comma", [" >> "]), "__comma", [smalltalk.send(smalltalk.send(smalltalk.send(result, "_errors", []), "_first", []), "_selector", [])]), "__comma", [" has errors!"])]);
-    }
-    return self;
-},
+fn: function (){
+var self=this;
+var $1,$2,$3;
+var suite;
+var worker;
+suite=smalltalk.send((smalltalk.OrderedCollection || OrderedCollection),"_new",[]);
+smalltalk.send(smalltalk.send(smalltalk.send((smalltalk.TestCase || TestCase),"_allSubclasses",[]),"_select_",[(function(each){
+return smalltalk.send(smalltalk.send(each,"_isAbstract",[]),"_not",[]);
+})]),"_do_",[(function(each){
+return smalltalk.send(suite,"_addAll_",[smalltalk.send(each,"_buildSuite",[])]);
+})]);
+worker=smalltalk.send((smalltalk.TestSuiteRunner || TestSuiteRunner),"_on_",[suite]);
+smalltalk.send(smalltalk.send(worker,"_announcer",[]),"_on_do_",[(smalltalk.ResultAnnouncement || ResultAnnouncement),(function(ann){
+var result;
+result=smalltalk.send(ann,"_result",[]);
+result;
+$1=smalltalk.send(smalltalk.send(result,"_runs",[]),"__eq",[smalltalk.send(result,"_total",[])]);
+if(smalltalk.assert($1)){
+smalltalk.send(console,"_log_",[smalltalk.send(smalltalk.send(smalltalk.send(smalltalk.send(smalltalk.send(smalltalk.send(smalltalk.send(result,"_runs",[]),"_asString",[]),"__comma",[" tests run, "]),"__comma",[smalltalk.send(smalltalk.send(smalltalk.send(result,"_failures",[]),"_size",[]),"_asString",[])]),"__comma",[" failures, "]),"__comma",[smalltalk.send(smalltalk.send(smalltalk.send(result,"_errors",[]),"_size",[]),"_asString",[])]),"__comma",[" errors."])]);
+$2=smalltalk.send(smalltalk.send(result,"_failures",[]),"_isEmpty",[]);
+if(! smalltalk.assert($2)){
+smalltalk.send(self,"_throw_",[smalltalk.send(smalltalk.send(smalltalk.send(smalltalk.send(smalltalk.send(smalltalk.send(smalltalk.send(result,"_failures",[]),"_first",[]),"_class",[]),"_name",[]),"__comma",[" >> "]),"__comma",[smalltalk.send(smalltalk.send(smalltalk.send(result,"_failures",[]),"_first",[]),"_selector",[])]),"__comma",[" is failing!"])]);
+};
+$3=smalltalk.send(smalltalk.send(result,"_errors",[]),"_isEmpty",[]);
+if(! smalltalk.assert($3)){
+return smalltalk.send(self,"_throw_",[smalltalk.send(smalltalk.send(smalltalk.send(smalltalk.send(smalltalk.send(smalltalk.send(smalltalk.send(result,"_errors",[]),"_first",[]),"_class",[]),"_name",[]),"__comma",[" >> "]),"__comma",[smalltalk.send(smalltalk.send(smalltalk.send(result,"_errors",[]),"_first",[]),"_selector",[])]),"__comma",[" has errors!"])]);
+};
+};
+})]);
+smalltalk.send(worker,"_run",[]);
+return self},
 args: [],
-source: "runTestSuite\x0a\x09| result |\x0a\x09result := TestResult new.\x0a\x0a\x09((TestCase allSubclasses\x0a\x09\x09select: [ :each | each isAbstract not ])\x0a\x09\x09do: [ :each | each buildSuite do: [ :suite | suite runCaseFor: result ] ]).\x0a\x0a\x09console log: result runs asString, ' tests run, ', result failures size asString, ' failures, ', result errors size asString, ' errors.'.\x0a\x0a\x09result failures isEmpty ifFalse: [ \x0a\x09\x09self throw: result failures first class name, ' >> ', result failures first selector, ' is failing!' ].\x0a\x09result errors isEmpty ifFalse: [\x0a\x09\x09self throw: result errors first class name, ' >> ', result errors first selector, ' has errors!' ].",
-messageSends: ["new", "do:", "runCaseFor:", "buildSuite", "select:", "not", "isAbstract", "allSubclasses", "log:", ",", "asString", "size", "errors", "failures", "runs", "ifFalse:", "throw:", "selector", "first", "name", "class", "isEmpty"],
-referencedClasses: ["TestResult", "TestCase"]
+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                self throw: result failures first class name, ' >> ', result failures first selector, ' is failing!' ].\x0a            result errors isEmpty ifFalse: [\x0a                self throw: result errors first class name, ' >> ', result errors first selector, ' has errors!' ].\x0a    ]].\x0a    worker run",
+messageSends: ["new", "do:", "addAll:", "buildSuite", "select:", "not", "isAbstract", "allSubclasses", "on:", "on:do:", "result", "ifTrue:", "log:", ",", "asString", "size", "errors", "failures", "runs", "ifFalse:", "throw:", "selector", "first", "name", "class", "isEmpty", "=", "total", "announcer", "run"],
+referencedClasses: ["OrderedCollection", "TestCase", "TestSuiteRunner", "ResultAnnouncement"]
 }),
 smalltalk.NodeTestRunner.klass);
 

+ 16 - 10
test/Test.st

@@ -10,18 +10,24 @@ initialize
 !
 
 runTestSuite
-	| result |
-	result := TestResult new.
+	| suite worker |
 
-	((TestCase allSubclasses
-		select: [ :each | each isAbstract not ])
-		do: [ :each | each buildSuite do: [ :suite | suite runCaseFor: result ] ]).
+	suite := OrderedCollection new.
+    (TestCase allSubclasses select: [ :each | each isAbstract not ])
+	do: [ :each | suite addAll: each buildSuite ].
 
-	console log: result runs asString, ' tests run, ', result failures size asString, ' failures, ', result errors size asString, ' errors.'.
+	worker := TestSuiteRunner on: suite.
+	worker announcer on: ResultAnnouncement do:
+	[ :ann | | result |
+    	result := ann result.
+        result runs = result total ifTrue: [
+	        console log: result runs asString, ' tests run, ', result failures size asString, ' failures, ', result errors size asString, ' errors.'.
 
-	result failures isEmpty ifFalse: [ 
-		self throw: result failures first class name, ' >> ', result failures first selector, ' is failing!!' ].
-	result errors isEmpty ifFalse: [
-		self throw: result errors first class name, ' >> ', result errors first selector, ' has errors!!' ].
+            result failures isEmpty ifFalse: [
+                self throw: result failures first class name, ' >> ', result failures first selector, ' is failing!!' ].
+            result errors isEmpty ifFalse: [
+                self throw: result errors first class name, ' >> ', result errors first selector, ' has errors!!' ].
+    ]].
+    worker run
 ! !