Comparing version 0.0.5 to 0.1.0
27
index.js
@@ -9,3 +9,10 @@ var createDefaultStream = require('./lib/default_stream'); | ||
function createHarness () { | ||
var canEmitExit = typeof process !== 'undefined' && process | ||
&& typeof process.on === 'function' | ||
; | ||
var canExit = typeof process !== 'undefined' && process | ||
&& typeof process.exit === 'function' | ||
; | ||
function createHarness (conf_) { | ||
var pending = []; | ||
@@ -19,3 +26,12 @@ var running = false; | ||
var t = new Test(name, conf, cb); | ||
if (!conf || typeof conf !== 'object') conf = conf_ || {}; | ||
if (conf.exit !== false && canEmitExit) { | ||
process.on('exit', function (code) { | ||
t._exit(); | ||
out.close(); | ||
if (code === 0 && !t._ok) process.exit(1); | ||
}); | ||
} | ||
process.nextTick(function () { | ||
@@ -45,3 +61,3 @@ if (!out.piped) out.pipe(createDefaultStream()); | ||
return t | ||
return t; | ||
@@ -62,4 +78,7 @@ function onend () { | ||
process.nextTick(function () { | ||
if (pending.length) pending.shift()() | ||
else out.close() | ||
if (pending.length) return pending.shift()(); | ||
out.close(); | ||
if (conf.exit !== false && canExit && !t._ok) { | ||
process.exit(1); | ||
} | ||
}); | ||
@@ -66,0 +85,0 @@ } |
@@ -84,2 +84,10 @@ var Stream = require('stream'); | ||
} | ||
if (res.operator === 'error' && res.actual && res.actual.stack) { | ||
var lines = String(res.actual.stack).split('\n'); | ||
output += inner + 'stack:\n'; | ||
output += inner + ' ' + lines[0] + '\n'; | ||
for (var i = 1; i < lines.length; i++) { | ||
output += inner + lines[i] + '\n'; | ||
} | ||
} | ||
@@ -86,0 +94,0 @@ output += outer + '...\n'; |
@@ -35,2 +35,3 @@ var EventEmitter = require('events').EventEmitter; | ||
this._progeny = []; | ||
this._ok = true; | ||
} | ||
@@ -40,6 +41,11 @@ | ||
if (this._skip) { | ||
this.end(); | ||
} else { | ||
return this.end(); | ||
} | ||
try { | ||
this._cb(this); | ||
} | ||
catch (err) { | ||
this.error(err); | ||
this.end(); | ||
} | ||
}; | ||
@@ -75,2 +81,17 @@ | ||
Test.prototype._exit = function () { | ||
if (this._plan !== undefined && | ||
!this._planError && this.assertCount !== this._plan) { | ||
this._planError = true; | ||
this.fail('plan != count', { | ||
expected : this._plan, | ||
actual : this.assertCount | ||
}); | ||
} | ||
else if (!this.ended) { | ||
this.fail('test exited without ending'); | ||
} | ||
}; | ||
Test.prototype._assert = function assert (ok, opts) { | ||
@@ -89,2 +110,3 @@ var self = this; | ||
}; | ||
this._ok = Boolean(this._ok && ok); | ||
@@ -169,3 +191,3 @@ if (!ok) { | ||
this._assert(!err, { | ||
message : defined(msg, err.message), | ||
message : defined(msg, String(err)), | ||
operator : 'error', | ||
@@ -172,0 +194,0 @@ actual : err, |
{ | ||
"name" : "tape", | ||
"version" : "0.0.5", | ||
"version" : "0.1.0", | ||
"description" : "tap-producing test harness for node and browsers", | ||
@@ -5,0 +5,0 @@ "main" : "index.js", |
@@ -8,3 +8,3 @@ var falafel = require('falafel'); | ||
var test = tape.createHarness(); | ||
var test = tape.createHarness({ exit : false }); | ||
var tc = tap.createConsumer(); | ||
@@ -11,0 +11,0 @@ |
var test = require('../'); | ||
var harness = test.createHarness(); | ||
var harness = test.createHarness({ exit : false }); | ||
@@ -4,0 +4,0 @@ // minimal write stream mockery |
@@ -8,3 +8,3 @@ var falafel = require('falafel'); | ||
var test = tape.createHarness(); | ||
var test = tape.createHarness({ exit : false }); | ||
var tc = tap.createConsumer(); | ||
@@ -11,0 +11,0 @@ |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
Shell access
Supply chain riskThis module accesses the system shell. Accessing the system shell increases the risk of executing arbitrary code.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
44218
31
1272
14