Permalink
Browse files

Simple util module to track tests. Adds a process.exit hook to print …

…the undone tests. Patched the default reporter.
  • Loading branch information...
1 parent 437cdb0 commit 95ae1b701ec5fc6768ea1e2c366254d39c3d189e @luebken luebken committed Jan 7, 2011
Showing with 31 additions and 0 deletions.
  1. +6 −0 lib/reporters/default.js
  2. +25 −0 lib/track.js
@@ -12,6 +12,7 @@ var nodeunit = require('../nodeunit'),
utils = require('../utils'),
fs = require('fs'),
sys = require('sys'),
+ track = require('../track').track,
path = require('path');
AssertionError = require('../assert').AssertionError;
@@ -62,6 +63,8 @@ exports.run = function (files, options) {
sys.puts('\n' + bold(name));
},
testDone: function (name, assertions) {
+ track.remove(name);
+
if (!assertions.failures()) {
sys.puts('' + name);
}
@@ -105,6 +108,9 @@ exports.run = function (files, options) {
setTimeout(function () {
process.reallyExit(assertions.failures());
}, 10);
+ },
+ testStart: function(name) {
+ track.put(name);
}
});
};
View
@@ -0,0 +1,25 @@
+/*!
+ * Simple util module to track tests. Adds a process.exit hook to print the undone tests.
+ */
+var sys = require('sys');
+var track = {
+ names : {},
+ put : function (testname) {
+ this.names[testname] = testname;
+ },
+ remove : function (testname) {
+ delete this.names[testname];
+ },
+ printnames : function () {
+ for(i in this.names) {
+ sys.puts(i)
+ }
+ }
+};
+
+process.on('exit', function() {
+ sys.puts('Undone tests (or their setups/teardowns): ');
+ track.printnames();
+});
+
+exports.track = track;

0 comments on commit 95ae1b7

Please sign in to comment.