This provides summary results such as the following:

% conkeror -q -batch -l tests/simple
...
Totals: 78 run, 0 failed in 18 suites
---

Requires the quit_hook patch.

But the summary does not appear when the above command is run in an
existing conkeror (or at least not until that conkeror exits).  Maybe
an explicit all-simple-tests.js file that loads the directory full of
test and displays the summary would be better.
---
 modules/walnut.js |   22 +++++++++++++++++++++-
 1 files changed, 21 insertions(+), 1 deletions(-)

diff --git a/modules/walnut.js b/modules/walnut.js
index 8cb3048..58b2423 100644
--- a/modules/walnut.js
+++ b/modules/walnut.js
@@ -57,7 +57,26 @@ function assert_objects_equal (got, expect) {
 function walnut_results () {
     this.run = 0;
     this.failed = 0;
+    this.suites = 0;
 }
+walnut_results.prototype = {
+    show : function (title) {
+        dumpln((title ? title + ": " : "") +
+               this.run +" run, " + this.failed + " failed" +
+               (this.suites > 1 ? " in " + this.suites + " suites" : ""));
+    },
+    accumulate : function (results) {
+        this.run += results.run;
+        this.failed += results.failed;
+        this.suites += results.suites ? results.suites : 1;
+    }
+}
+
+var walnut_totals = new walnut_results();
+add_hook("quit_hook", function () {
+    if (walnut_totals.suites > 1)
+        walnut_totals.show("Totals");
+});
 
 function walnut_run (suite) {
     var results = new walnut_results();
@@ -83,7 +102,8 @@ function walnut_run (suite) {
     }
     if (suite.suite_teardown)
         suite.suite_teardown();
-    dumpln(results.run+" run, "+results.failed+" failed");
+    results.show();
+    walnut_totals.accumulate(results);
     return results;
 }
 
-- 
1.6.5

_______________________________________________
Conkeror mailing list
[email protected]
https://www.mozdev.org/mailman/listinfo/conkeror

Reply via email to