Skip to content

armgit / mocha

Public Imported from GitHub
0

☕️ Classic, reliable, trusted test framework for Node.js and the browser

1.16.1

Travis Jeffery40913c3a192f
diff --git a/History.md b/History.md
index bf9d34d3..198e4d39 100644
--- a/History.md
+++ b/History.md
@@ -1,3 +1,9 @@
+1.16.1 / 2013-12-19
+==================
+
+ * fix: recompiled for missed changes from the last release
+
+
1.16.0 / 2013-12-19
==================
diff --git a/bower.json b/bower.json
index 17c04727..472ca8c8 100644
--- a/bower.json
+++ b/bower.json
@@ -1,6 +1,6 @@
{
"name": "mocha",
- "version": "1.16.0",
+ "version": "1.16.1",
"main": "mocha.js",
"ignore": [
"bin",
diff --git a/component.json b/component.json
index 7090f6c1..02e40792 100644
--- a/component.json
+++ b/component.json
@@ -1,6 +1,6 @@
{
"name": "mocha",
- "version": "1.16.0",
+ "version": "1.16.1",
"repo": "visionmedia/mocha",
"description": "simple, flexible, fun test framework",
"keywords": [
diff --git a/mocha.js b/mocha.js
index 587bdb57..bd2bc9a9 100644
--- a/mocha.js
+++ b/mocha.js
@@ -3813,10 +3813,6 @@ function Spec(runner) {
if (1 == indents) console.log();
});
- runner.on('test', function(test){
- process.stdout.write(indent() + color('pass', ' ◦ ' + test.title + ': '));
- });
-
runner.on('pending', function(test){
var fmt = indent() + color('pending', ' - %s');
console.log(fmt, test.title);
@@ -3988,7 +3984,7 @@ function XUnit(runner) {
});
runner.on('end', function(){
- console.log(tag('testsuite', {
+ process.stdout.write(tag('testsuite', {
name: 'Mocha Tests'
, tests: stats.tests
, failures: stats.failures
@@ -3999,7 +3995,7 @@ function XUnit(runner) {
}, false));
tests.forEach(test);
- console.log('</testsuite>');
+ process.stdout.write('</testsuite>');
});
}
@@ -4021,17 +4017,17 @@ function test(test) {
var attrs = {
classname: test.parent.fullTitle()
, name: test.title
- , time: test.duration / 1000
+ , time: (test.duration / 1000) || 0
};
if ('failed' == test.state) {
var err = test.err;
attrs.message = escape(err.message);
- console.log(tag('testcase', attrs, false, tag('failure', attrs, false, cdata(err.stack))));
+ process.stdout.write(tag('testcase', attrs, false, tag('failure', attrs, false, cdata(err.stack))));
} else if (test.pending) {
- console.log(tag('testcase', attrs, false, tag('skipped', {}, true)));
+ process.stdout.write(tag('testcase', attrs, false, tag('skipped', {}, true)));
} else {
- console.log(tag('testcase', attrs, true) );
+ process.stdout.write(tag('testcase', attrs, true) );
}
}
@@ -4211,6 +4207,16 @@ Runnable.prototype.resetTimeout = function(){
}, ms);
};
+/**
+ * Whitelist these globals for this test run
+ *
+ * @api private
+ */
+Runnable.prototype.globals = function(arr){
+ var self = this;
+ this._allowedGlobals = arr;
+};
+
/**
* Run the test and invoke `fn(err)`.
*
@@ -4342,6 +4348,7 @@ module.exports = Runner;
function Runner(suite) {
var self = this;
this._globals = [];
+ this._abort = false;
this.suite = suite;
this.total = suite.total();
this.failures = 0;
@@ -4453,10 +4460,15 @@ Runner.prototype.globals = function(arr){
Runner.prototype.checkGlobals = function(test){
if (this.ignoreLeaks) return;
var ok = this._globals;
+
var globals = this.globalProps();
var isNode = process.kill;
var leaks;
+ if (test) {
+ ok = ok.concat(test._allowedGlobals || []);
+ }
+
// check length - 2 ('errno' and 'location' globals)
if (isNode && 1 == ok.length - globals.length) return;
else if (2 == ok.length - globals.length) return;
@@ -4500,12 +4512,12 @@ Runner.prototype.fail = function(test, err){
* - If bail, then exit
* - Failed `before` hook skips all tests in a suite and subsuites,
* but jumps to corresponding `after` hook
- * - Failed `before each` hook skips remaining tests in a
+ * - Failed `before each` hook skips remaining tests in a
* suite and jumps to corresponding `after each` hook,
* which is run only once
* - Failed `after` hook does not alter
* execution order
- * - Failed `after each` hook skips remaining tests in a
+ * - Failed `after each` hook skips remaining tests in a
* suite and subsuites, but executes other `after each`
* hooks
*
@@ -4554,7 +4566,7 @@ Runner.prototype.hook = function(name, fn){
var testError = hook.error();
if (testError) self.fail(self.test, testError);
if (err) {
- self.failHook(hook, err);
+ self.failHook(hook, err);
// stop executing hooks, notify callee of hook err
return fn(err);
@@ -4692,7 +4704,7 @@ Runner.prototype.runTests = function(suite, fn){
// for failed 'after each' hook start from errSuite parent,
// otherwise start from errSuite itself
self.suite = after ? errSuite.parent : errSuite;
-
+
if (self.suite) {
// call hookUp afterEach
self.hookUp('afterEach', function(err2, errSuite2) {
@@ -4703,7 +4715,7 @@ Runner.prototype.runTests = function(suite, fn){
fn(errSuite);
});
} else {
- // there is no need calling other 'after each' hooks
+ // there is no need calling other 'after each' hooks
self.suite = orig;
fn(errSuite);
}
@@ -4713,6 +4725,8 @@ Runner.prototype.runTests = function(suite, fn){
// if we bail after first err
if (self.failures && suite._bail) return fn();
+ if (self._abort) return fn();
+
if (err) return hookErr(err, errSuite, true);
// next test
@@ -4795,6 +4809,8 @@ Runner.prototype.runSuite = function(suite, fn){
}
}
+ if (self._abort) return done();
+
var curr = suite.suites[i++];
if (!curr) return done();
self.runSuite(curr, next);
@@ -4879,6 +4895,17 @@ Runner.prototype.run = function(fn){
return this;
};
+/**
+ * Cleanly abort execution
+ *
+ * @return {Runner} for chaining
+ * @api public
+ */
+Runner.prototype.abort = function(){
+ debug('aborting');
+ this._abort = true;
+}
+
/**
* Filter leaks with the given globals flagged as `ok`.
*
@@ -5454,11 +5481,13 @@ exports.slug = function(str){
exports.clean = function(str) {
str = str
+ .replace(/\r\n?|[\n\u2028\u2029]/g, "\n").replace(/^\uFEFF/, '')
.replace(/^function *\(.*\) *{/, '')
.replace(/\s+\}$/, '');
- var whitespace = str.match(/^\n?(\s*)/)[1]
- , re = new RegExp('^' + whitespace, 'gm');
+ var spaces = str.match(/^\n?( *)/)[1].length
+ , tabs = str.match(/^\n?(\t*)/)[1].length
+ , re = new RegExp('^\n?' + (tabs ? '\t' : ' ') + '{' + (tabs ? tabs : spaces) + '}', 'gm');
str = str.replace(re, '');
@@ -5578,9 +5607,8 @@ var uncaughtExceptionHandlers = [];
process.removeListener = function(e, fn){
if ('uncaughtException' == e) {
global.onerror = function() {};
-
- var indexOfFn = uncaughtExceptionHandlers.indexOf(fn);
- if (indexOfFn != -1) { uncaughtExceptionHandlers.splice(indexOfFn, 1); }
+ var i = uncaughtExceptionHandlers.indexOf(fn);
+ if (i != -1) { uncaughtExceptionHandlers.splice(i, 1); }
}
};
@@ -5592,6 +5620,7 @@ process.on = function(e, fn){
if ('uncaughtException' == e) {
global.onerror = function(err, url, line){
fn(new Error(err + ' (' + url + ':' + line + ')'));
+ return true;
};
uncaughtExceptionHandlers.push(fn);
}
@@ -5604,6 +5633,11 @@ process.on = function(e, fn){
var Mocha = global.Mocha = require('mocha'),
mocha = global.mocha = new Mocha({ reporter: 'html' });
+// The BDD UI is registered by default, but no UI will be functional in the
+// browser without an explicit call to the overridden `mocha.ui` (see below).
+// Ensure that this default UI does not expose its methods to the global scope.
+mocha.suite.removeAllListeners('pre-require');
+
var immediateQueue = []
, immediateTimeout;
@@ -5637,7 +5671,7 @@ Mocha.Runner.immediately = function(callback) {
*/
mocha.throwError = function(err) {
uncaughtExceptionHandlers.forEach(function (fn) {
- fn(err);
+ fn(err) ;
});
throw err;
};
diff --git a/package.json b/package.json
index 3043700d..ed6cf700 100644
--- a/package.json
+++ b/package.json
@@ -1,6 +1,6 @@
{
"name": "mocha",
- "version": "1.16.0",
+ "version": "1.16.1",
"description": "simple, flexible, fun test framework",
"keywords": [
"mocha",