Comparing version 0.2.0 to 0.2.1
// an assert module that returns tappable data for each assertion. | ||
var difflet = require('difflet') | ||
@@ -225,2 +226,6 @@ module.exports = assert | ||
message = message || "should be similar" | ||
var isObj = assert(a, message, extra); | ||
if(!isObj.ok) | ||
return isObj; | ||
return equivalent(selectFields(a, b), b, message, extra) | ||
@@ -239,3 +244,4 @@ } | ||
message = message || "should be dissimilar" | ||
return inequivalent(selectFields(a, b), b, message, extra) | ||
a = a && selectFields(a, b); // Always send selectFields() usable params. | ||
return inequivalent(a, b, message, extra) | ||
} | ||
@@ -363,9 +369,3 @@ assert.dissimilar = dissimilar | ||
function diffObject (f, w) { | ||
var f = stringify(f) | ||
, w = stringify(w) | ||
, l = w.length | ||
if (f === w) return null | ||
var p = 0 | ||
while (p < l && f.charAt(p) === w.charAt(p)) p ++ | ||
return diff(f, w, p) | ||
return difflet({ indent : 2, comment : true }).compare(f, w) | ||
} | ||
@@ -372,0 +372,0 @@ |
@@ -121,6 +121,8 @@ module.exports = TapConsumer | ||
if (line.match(/^bail out!/i)) { | ||
var bo | ||
if (bo = line.match(/^bail out!\s*(.*)$/i)) { | ||
this.bailedOut = true | ||
// this.emit("error", new Error(line)) | ||
this.emit("bailout", line) | ||
this.emit("bailout", bo[1]) | ||
return | ||
} | ||
@@ -127,0 +129,0 @@ |
@@ -18,2 +18,3 @@ // this is just a harness that pipes to stdout. | ||
} | ||
globalHarness = global.TAP_Global_Harness = this | ||
@@ -20,0 +21,0 @@ GlobalHarness.super.call(this, Test) |
@@ -174,2 +174,3 @@ // a thing that runs tests. | ||
var t = new this._Test(this, name, conf) | ||
var self = this | ||
if (cb) { | ||
@@ -180,3 +181,8 @@ //console.error("attaching cb to ready event") | ||
var timer = setTimeout(this.timeout.bind(this), conf.timeout) | ||
this.on("end", clearTimeout.bind(null, timer)) | ||
var clear = clearTimeout.bind(null, timer) | ||
t.on("end", clear) | ||
t.on("bailout", function (message) { | ||
self.bailout(message) | ||
clear() | ||
}) | ||
} | ||
@@ -195,7 +201,10 @@ }) | ||
Harness.prototype.bailout = function (message) { | ||
// console.error("Harness bailout", this.constructor.name) | ||
message = message || "" | ||
//console.error("adding bailout message result") | ||
this.results.add({bailout: message}) | ||
// console.error(">>> results after bailout" , this.results) | ||
this._bailedOut = true | ||
this.emit("bailout", message) | ||
this.output.end({bailout: message}) | ||
} | ||
@@ -202,0 +211,0 @@ |
@@ -41,3 +41,10 @@ module.exports = TapProducer | ||
if (res.bailout) { | ||
var bo = "bail out!" | ||
if (typeof res.bailout === "string") bo += " " + res.bailout | ||
this.emit("data", bo) | ||
return | ||
} | ||
this.results.add(res, false) | ||
this.count ++ | ||
@@ -48,2 +55,3 @@ } | ||
if (res) this.write(res) | ||
// console.error("TapProducer end", res, this.results) | ||
this.emit("data", "\n1.."+this.results.testsTotal+"\n") | ||
@@ -80,2 +88,3 @@ if (this.trailer && typeof this.trailer !== "string") { | ||
function encodeResult (res, count, diag) { | ||
// console.error(res, count, diag) | ||
if (typeof res === "string") { | ||
@@ -90,2 +99,5 @@ res = res.split(/\r?\n/).map(function (l) { | ||
if (res.bailout) return "" | ||
if (!!process.env.TAP_NODIAG) diag = false | ||
@@ -98,8 +110,8 @@ else if (!!process.env.TAP_DIAG) diag = true | ||
output += ( !res.ok ? "not " : "") + "ok " + count | ||
+ ( !res.name ? "" | ||
: " " + res.name.replace(/[\r\n]/, " ") ) | ||
+ ( res.skip ? " # SKIP" | ||
: res.todo ? " # TODO" | ||
: "" ) | ||
+ "\n" | ||
+ ( !res.name ? "" | ||
: " " + res.name.replace(/[\r\n]/g, " ") ) | ||
+ ( res.skip ? " # SKIP" | ||
: res.todo ? " # TODO" | ||
: "" ) | ||
+ "\n" | ||
@@ -106,0 +118,0 @@ if (!diag) return output |
@@ -61,3 +61,6 @@ // A class for counting up results in a test harness. | ||
if (r.bailout || typeof r.bailout === "string") this.bailedOut = true | ||
if (r.bailout || typeof r.bailout === "string") { | ||
// console.error("Bailing out in result") | ||
this.bailedOut = true | ||
} | ||
this.ok = !!(this.ok && r.ok) | ||
@@ -64,0 +67,0 @@ |
@@ -130,2 +130,3 @@ var fs = require("fs") | ||
return function (cb) { | ||
if (self._bailedOut) return | ||
var relDir = dir || path.dirname(f) | ||
@@ -190,2 +191,12 @@ , fileName = relDir === "." ? f : f.substr(relDir.length + 1) | ||
tc.on("bailout", function (message) { | ||
clearTimeout(timeout) | ||
console.log("# " + f.substr(process.cwd().length + 1)) | ||
process.stderr.write(err) | ||
process.stdout.write(out + "\n") | ||
self._bailedOut = true | ||
cp._ended = true | ||
cp.kill() | ||
}) | ||
cp.stdout.pipe(tc) | ||
@@ -199,2 +210,3 @@ cp.stdout.on("data", function (c) { out += c }) | ||
cp.on("exit", function (code) { | ||
if (cp._ended) return | ||
cp._ended = true | ||
@@ -426,3 +438,1 @@ var ok = !cp._timedOut && !code | ||
} | ||
{ "name" : "yamlish" | ||
, "description" : "Parser/encoder for the yamlish format" | ||
, "repository":"https://github.com/isaacs/yamlish" | ||
, "version" : "0.0.2" | ||
, "version" : "0.0.4" | ||
, "main" : "yamlish.js" | ||
@@ -6,0 +6,0 @@ , "keywords" : [ "yaml", "yamlish", "test", "anything", "protocol", "tap"] |
@@ -25,3 +25,5 @@ exports.encode = encode | ||
return "|\n" + indent + obj.split(/\r?\n/).join("\n"+indent) | ||
} else return obj | ||
} else { | ||
return JSON.stringify(obj) | ||
} | ||
@@ -45,10 +47,12 @@ case "number": | ||
Object.prototype.toString.call(obj) === "[object Date]") { | ||
return "[Date " + obj.toISOString() + "]" | ||
return JSON.stringify("[Date " + obj.toISOString() + "]") | ||
} | ||
if (obj instanceof RegExp || | ||
Object.prototype.toString.call(obj) === "[object RegExp]" || | ||
obj instanceof Boolean || | ||
Object.prototype.toString.call(obj) === "[object Boolean]" | ||
) { | ||
Object.prototype.toString.call(obj) === "[object RegExp]") { | ||
return JSON.stringify(obj.toString()) | ||
} | ||
if (obj instanceof Boolean || | ||
Object.prototype.toString.call(obj) === "[object Boolean]") { | ||
return obj.toString() | ||
@@ -116,9 +120,22 @@ } | ||
, d | ||
, dateRe = /^\[Date ([0-9]{4}-[0-9]{2}-[0-9]{2}T[0-9]{2}:[0-9]{2}(?::[0-9]{2})?(?:\.[0-9]{3})?(?:[A-Z]+)?)\]$/ | ||
if (v === "~") return null | ||
if (v.match(/^[0-9]{4}-[0-9]{2}-[0-9]{2}T[0-9]{2}:[0-9]{2}/) | ||
&& (d = Date.parse(v))) { | ||
try { | ||
var jp = JSON.parse(str) | ||
} catch (e) { | ||
var jp = "" | ||
} | ||
if (jp && | ||
typeof jp === "string" && | ||
(d = jp.match(dateRe)) && | ||
(d = Date.parse(d[1]))) { | ||
return new Date(d) | ||
} | ||
if (v === "true" || v === "false") return JSON.parse(v) | ||
if (typeof jp === "boolean") return jp | ||
if (v && !isNaN(v)) return parseInt(v, 10) | ||
// something interesting. | ||
@@ -221,3 +238,3 @@ var lines = str.split(/\r?\n/) | ||
// XXX Turn this into proper tests. | ||
if (require.main === module) { | ||
@@ -234,2 +251,3 @@ var obj = [{"bigstring":new Error().stack} | ||
} | ||
var enc = encode(obj) | ||
@@ -236,0 +254,0 @@ , dec = decode(enc) |
{ | ||
"name": "tap", | ||
"version": "0.2.0", | ||
"version": "0.2.1", | ||
"author": "Isaac Z. Schlueter <i@izs.me> (http://blog.izs.me)", | ||
@@ -14,3 +14,4 @@ "description": "A Test-Anything-Protocol library", | ||
"nopt": "~1.0.10", | ||
"mkdirp": "~0.2.2" | ||
"mkdirp": "~0.2.2", | ||
"difflet" : "0.2.0" | ||
}, | ||
@@ -17,0 +18,0 @@ "bundledDependencies": [ |
@@ -25,2 +25,5 @@ var tap = require("../") | ||
t.doesNotThrow(noop, "noop does not throw"); | ||
t.similar({foo:"bar", bar:"foo"}, {foo:"bar"}, "similar objects are ok"); | ||
t.dissimilar({}, {mandatory:"value"}, "dissimilar objects are ok"); | ||
t.dissimilar(null, {}, "null is dissimilar from an object, even with no keys"); | ||
@@ -32,3 +35,6 @@ // a few failures. | ||
t.notOk(true, "true is not not ok") | ||
t.similar(null, {}, "Null is not similar to an object, even with no keys"); | ||
t.throws(noop, "noop does not throw"); | ||
t.throws(noop, new Error("Whoops!"), "noop does not throw an Error"); | ||
t.throws(noop, {name:"MyError", message:"Whoops!"}, "noop does not throw a MyError"); | ||
t.doesNotThrow(thr0w, "thrower does throw"); | ||
@@ -42,5 +48,5 @@ t.end() | ||
t.notOk(results.ok, "not ok") | ||
t.equal(results.tests, 20, "total test count") | ||
t.equal(results.passTotal, 14, "tests passed") | ||
t.equal(results.fail, 6, "tests failed") | ||
t.equal(results.tests, 26, "total test count") | ||
t.equal(results.passTotal, 17, "tests passed") | ||
t.equal(results.fail, 9, "tests failed") | ||
t.type(results.ok, "boolean", "ok is boolean") | ||
@@ -47,0 +53,0 @@ t.type(results.skip, "number", "skip is number") |
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
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
97538
51
2786
7
+ Addeddifflet@0.2.0
+ Addedarray-buffer-byte-length@1.0.1(transitive)
+ Addedarraybuffer.prototype.slice@1.0.3(transitive)
+ Addedavailable-typed-arrays@1.0.7(transitive)
+ Addedcall-bind@1.0.7(transitive)
+ Addedcharm@0.0.8(transitive)
+ Addeddata-view-buffer@1.0.1(transitive)
+ Addeddata-view-byte-length@1.0.1(transitive)
+ Addeddata-view-byte-offset@1.0.0(transitive)
+ Addeddeep-equal@0.0.0(transitive)
+ Addeddefine-data-property@1.1.4(transitive)
+ Addeddefine-properties@1.2.1(transitive)
+ Addeddifflet@0.2.0(transitive)
+ Addedes-abstract@1.23.3(transitive)
+ Addedes-define-property@1.0.0(transitive)
+ Addedes-errors@1.3.0(transitive)
+ Addedes-object-atoms@1.0.0(transitive)
+ Addedes-set-tostringtag@2.0.3(transitive)
+ Addedes-to-primitive@1.2.1(transitive)
+ Addedfor-each@0.3.3(transitive)
+ Addedfunction-bind@1.1.2(transitive)
+ Addedfunction.prototype.name@1.1.6(transitive)
+ Addedfunctions-have-names@1.2.3(transitive)
+ Addedget-intrinsic@1.2.4(transitive)
+ Addedget-symbol-description@1.0.2(transitive)
+ Addedglobalthis@1.0.4(transitive)
+ Addedgopd@1.0.1(transitive)
+ Addedhas-bigints@1.0.2(transitive)
+ Addedhas-property-descriptors@1.0.2(transitive)
+ Addedhas-proto@1.0.3(transitive)
+ Addedhas-symbols@1.0.3(transitive)
+ Addedhas-tostringtag@1.0.2(transitive)
+ Addedhasown@2.0.2(transitive)
+ Addedinternal-slot@1.0.7(transitive)
+ Addedis-array-buffer@3.0.4(transitive)
+ Addedis-bigint@1.0.4(transitive)
+ Addedis-boolean-object@1.1.2(transitive)
+ Addedis-callable@1.2.7(transitive)
+ Addedis-data-view@1.0.1(transitive)
+ Addedis-date-object@1.0.5(transitive)
+ Addedis-negative-zero@2.0.3(transitive)
+ Addedis-number-object@1.0.7(transitive)
+ Addedis-regex@1.1.4(transitive)
+ Addedis-shared-array-buffer@1.0.3(transitive)
+ Addedis-string@1.0.7(transitive)
+ Addedis-symbol@1.0.4(transitive)
+ Addedis-typed-array@1.1.13(transitive)
+ Addedis-weakref@1.0.2(transitive)
+ Addedisarray@2.0.5(transitive)
+ Addedobject-inspect@1.13.2(transitive)
+ Addedobject-keys@1.1.1(transitive)
+ Addedobject.assign@4.1.5(transitive)
+ Addedpossible-typed-array-names@1.0.0(transitive)
+ Addedregexp.prototype.flags@1.5.2(transitive)
+ Addedsafe-array-concat@1.1.2(transitive)
+ Addedsafe-regex-test@1.0.3(transitive)
+ Addedset-function-length@1.2.2(transitive)
+ Addedset-function-name@2.0.2(transitive)
+ Addedside-channel@1.0.6(transitive)
+ Addedstring.prototype.trim@1.2.9(transitive)
+ Addedstring.prototype.trimend@1.0.8(transitive)
+ Addedstring.prototype.trimstart@1.0.8(transitive)
+ Addedtraverse@0.6.10(transitive)
+ Addedtyped-array-buffer@1.0.2(transitive)
+ Addedtyped-array-byte-length@1.0.1(transitive)
+ Addedtyped-array-byte-offset@1.0.2(transitive)
+ Addedtyped-array-length@1.0.6(transitive)
+ Addedtypedarray.prototype.slice@1.0.3(transitive)
+ Addedunbox-primitive@1.0.2(transitive)
+ Addedwhich-boxed-primitive@1.0.2(transitive)
+ Addedwhich-typed-array@1.1.15(transitive)