Permalink
Browse files

Rename a few event callback functions

onSuiteDone     -> onSuiteCompleted
onError         -> onSuiteError
onPrematureExit -> onSuiteExit

This make it more obvious that each of these events ends the suite and
that only one of them is called per suite.
  • Loading branch information...
1 parent bd2dff7 commit df7a9abd3bef7636cabeedd1be7551d8936bb25b Benjamin Thomas committed Oct 27, 2010
Showing with 18 additions and 24 deletions.
  1. +6 −9 lib/child.js
  2. +3 −3 lib/console-runner.js
  3. +9 −12 lib/testing.js
View
@@ -7,9 +7,6 @@ var opts =
{ name: JSON.parse(process.ARGV[3])
, parallel: JSON.parse(process.ARGV[4])
, testName: JSON.parse(process.ARGV[5])
- , onSuiteStart: function suiteStart() {
- postMessage('onSuiteStart');
- }
, onTestStart: function testStart(name) {
postMessage('onTestStart', name);
}
@@ -20,14 +17,14 @@ var opts =
postMessage('onTestDone', result);
}
- , onSuiteDone: function suiteDone(results) {
- postMessage('onSuiteDone', results);
+ , onSuiteCompleted: function suiteDone(results) {
+ postMessage('onSuiteCompleted', results);
}
- , onError: function error(err, tests) {
- postMessage('onError', makeErrorJsonable(err), tests);
+ , onSuiteError: function error(err, tests) {
+ postMessage('onSuiteError', makeErrorJsonable(err), tests);
}
- , onExit: function exit(tests) {
- postMessage('onExit', tests);
+ , onSuiteExit: function exit(tests) {
+ postMessage('onSuiteExit', tests);
}
};
View
@@ -131,13 +131,13 @@ exports.run = function(list, options, callback) {
, onTestDone: function(result) {
testFinished(suite, result);
}
- , onSuiteDone: function(results) {
+ , onSuiteCompleted: function(results) {
suiteFinished(suite, 'suiteCompleted', Array.prototype.slice.call(arguments));
}
- , onError: function(error, tests) {
+ , onSuiteError: function(error, tests) {
suiteFinished(suite, 'suiteErrored', Array.prototype.slice.call(arguments));
}
- , onPrematureExit: function(tests) {
+ , onSuiteExit: function(tests) {
suiteFinished(suite, 'suiteExited', Array.prototype.slice.call(arguments));
}
}
View
@@ -18,12 +18,11 @@ var assert = require('assert')
* Plus, there are options for the following events. These should be functions.
* See API.md for a description of these events.
*
- * + onSuiteStart
- * + onSuiteDone
* + onTestStart
* + onTestDone
- * + onError
- * + onPrematureExit
+ * + onSuiteCompleted
+ * + onSuiteError
+ * + onSuiteExit
*/
exports.runSuite = function(obj, options) {
// make sure options exists
@@ -38,8 +37,6 @@ exports.runSuite = function(obj, options) {
if (suite.todo.length < 1) { return suiteFinished(); }
- if (options.onSuiteStart) { options.onSuiteStart(options.name); }
-
process.on('uncaughtException', errorHandler);
process.on('exit', exitHandler);
@@ -212,12 +209,12 @@ exports.runSuite = function(obj, options) {
process.removeListener('uncaughtException', errorHandler);
process.removeListener('exit', exitHandler);
- if (options.onError) {
+ if (options.onSuiteError) {
var tests = test ? [test] : suite.started;
if (tests.length < 1) {
tests = suite.results;
}
- options.onError(err, tests.map(function(t) { return t.name; }));
+ options.onSuiteError(err, tests.map(function(t) { return t.name; }));
process.exit(1);
}
else {
@@ -227,8 +224,8 @@ exports.runSuite = function(obj, options) {
function exitHandler() {
if (suite.started.length > 0) {
- if (options.onPrematureExit) {
- options.onPrematureExit(suite.started.map(function(t) { return t.name; }));
+ if (options.onSuiteExit) {
+ options.onSuiteExit(suite.started.map(function(t) { return t.name; }));
}
}
}
@@ -242,7 +239,7 @@ exports.runSuite = function(obj, options) {
process.removeListener('uncaughtException', errorHandler);
process.removeListener('exit', exitHandler);
- if (options.onSuiteDone) {
+ if (options.onSuiteCompleted) {
var result =
{ name: options.name
, tests: suite.results
@@ -255,7 +252,7 @@ exports.runSuite = function(obj, options) {
result[r.failure ? 'numFailures' : 'numSuccesses']++;
});
- options.onSuiteDone(result);
+ options.onSuiteCompleted(result);
}
}
}

0 comments on commit df7a9ab

Please sign in to comment.