Socket
Socket
Sign inDemoInstall

tap

Package Overview
Dependencies
Maintainers
1
Versions
418
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

tap - npm Package Compare versions

Comparing version 0.2.0 to 0.2.1

lib/harness.js

16

lib/tap-assert.js
// 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")

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc