Socket
Socket
Sign inDemoInstall

tap-arc

Package Overview
Dependencies
Maintainers
3
Versions
34
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

tap-arc - npm Package Compare versions

Comparing version 1.0.0-RC.0 to 1.0.0-RC.1

2

index.js

@@ -10,2 +10,3 @@ #!/usr/bin/env node

verbose: [ 'v', 'verbose' ],
debug: [ 'd', 'debug' ],
}

@@ -17,2 +18,3 @@ const options = {

verbose: false,
debug: false,
...minimist(process.argv.slice(2), { alias }),

@@ -19,0 +21,0 @@ }

31

package.json

@@ -5,3 +5,3 @@ {

"author": "tbeseda",
"version": "1.0.0-RC.0",
"version": "1.0.0-RC.1",
"license": "Apache-2.0",

@@ -34,22 +34,23 @@ "type": "module",

"lint": "eslint .",
"lint:fix": "eslint --fix .",
"tap-arc.diff:-v": "npm run --silent tape.diff | tap-arc -v",
"tap-arc.diff": "npm run --silent tape.diff | tap-arc",
"tap-arc.empty": "npm run --silent tape.empty | tap-arc",
"tap-arc.mixed": "npm run --silent tape.mixed | tap-arc",
"tap-arc.upstream-error": "npm run --silent tape.upstream-error | tap-arc",
"tap-arc.passing": "npm run --silent tape.passing | tap-arc",
"tap-arc.simple.-p": "npm run --silent tape.simple | tap-arc -p",
"tap-arc.simple.-v": "npm run --silent tape.simple | tap-arc -v",
"tap-arc.simple": "npm run --silent tape.simple | tap-arc",
"tap-arc.throws": "npm run --silent tape.throws | tap-arc",
"lint.fix": "eslint --fix .",
"tap-arc": "node index.js",
"tap-arc.diff.-v": "npm run --silent tape.diff | node index.js -v",
"tap-arc.diff": "npm run --silent tape.diff | node index.js",
"tap-arc.empty": "npm run --silent tape.empty | node index.js",
"tap-arc.mixed": "npm run --silent tape.mixed | node index.js",
"tap-arc.passing": "npm run --silent tape.passing | node index.js",
"tap-arc.simple.-p": "npm run --silent tape.simple | node index.js -p",
"tap-arc.simple.-v": "npm run --silent tape.simple | node index.js -v",
"tap-arc.simple": "npm run --silent tape.simple | node index.js",
"tap-arc.throws": "npm run --silent tape.throws | node index.js",
"tap-arc.upstream-error": "npm run --silent tape.upstream-error | node index.js",
"tape.diff": "tape test/create-diff-tap.cjs",
"tape.empty": "tape test/create-empty-tap.cjs",
"tape.mixed": "tape test/create-mixed-tap.cjs",
"tape.upstream-error": "tape test/create-upstream-error-tap.cjs",
"tape.passing": "tape test/create-passing-tap.cjs",
"tape.simple": "tape test/create-simple-tap.cjs",
"tape.throws": "tape test/create-throws-tap.cjs",
"tape": "tape test/index.js | tap-arc",
"test": "npm link && npm run lint && npm run tape"
"tape.upstream-error": "tape test/create-upstream-error-tap.cjs",
"tape": "tape test/index.js | node index.js",
"test": "npm run lint && npm run tape"
},

@@ -56,0 +57,0 @@ "dependencies": {

import { Chalk } from 'chalk'
const RIGHT = '▸'
const RIGHT = '↦'
const CHECK = '✓'

@@ -13,2 +13,4 @@ const CROSS = '✗'

export default function (options, output) {
const { color, debug, verbose } = options
const d = debug || verbose
const {

@@ -24,6 +26,4 @@ blue,

yellow,
} = new Chalk({ level: options.color ? 3 : 0 })
} = new Chalk({ level: color ? 3 : 0 })
const good = green
const bad = red
const expected = yellow

@@ -34,4 +34,7 @@ const actual = blue

const skipMark = RIGHT
const pad = (n = 1, c = ' ') => dim(c).repeat(n)
function pad (n = 1, c = ' ') {
return dim(c).repeat(n)
}
return {

@@ -41,29 +44,36 @@ end (start) {

},
print (s, p = 0) {
output.write(`${pad(p)}${s}\n`)
print (str, p = 0, n = 1) {
output.write(`${pad(p)}${str}${'\n'.repeat(n)}`)
},
pass (s) {
return `${passMark} ${dim(s)}`
pass (test) {
const { id, name } = test
return `${passMark}${d ? ` [${id}]` : ''} ${dim(name)}`
},
fail (s, id) {
return `${failMark} ${id}) ${red(s)}`
fail (test) {
const { id, name, tapError } = test
return tapError
? `${failMark} ${red(tapError)}`
: `${failMark} [${id}] ${red(name)}`
},
skip (s) {
return cyan(`${skipMark} ${s}`)
skip (test) {
const { id, name } = test
return cyan(`${skipMark}${d ? ` [${id}]` : ''} ${name}`)
},
todo (s, pass = true) {
todo (test) {
const { id, name, ok: pass } = test
const method = pass ? dim : red
return method(`${skipMark} ${s}`)
return method(`${skipMark}${d ? ` [${id}]` : ''} ${name}`)
},
diffOptions: { actual, expected, dim: italic.dim },
pad,
good,
bad,
actual,
bad: red,
bail: bold.underline.red,
dim,
bail: bold.underline.red,
expected,
good: green,
highlight: magenta,
strong: bold,
title: bold.underline,
expected,
actual,
}
}
import { PassThrough } from 'stream'
import { Parser } from 'tap-parser'
import duplexer from 'duplexer3' // TODO: handwrite a simpelr duplexer
import duplexer from 'duplexer3' // TODO: write a custom, simpler duplexer
import stripAnsi from 'strip-ansi'

@@ -8,7 +8,8 @@ import createMakeDiff from './_make-diff.js'

const reservedCommentPrefixes = [ 'tests ', 'pass ', 'skip', 'todo', 'fail ', 'failed ', 'ok' ]
const reservedCommentPrefixes = [ 'tests ', 'pass ', 'skip', 'todo', 'fail ', 'failed ', 'ok', 'test count' ]
export default function createParser (options) {
const { debug, pessimistic, verbose } = options
const output = new PassThrough()
const parser = new Parser({ bail: options.pessimistic })
const parser = new Parser({ bail: pessimistic })
const stream = duplexer(parser, output)

@@ -23,14 +24,16 @@

parser.on('pass', (test) => {
P(_.pass(test.name), 2)
})
const counter = {
pass: 0,
skip: 0,
todo: 0,
fail: 0,
}
parser.on('skip', (test) => {
P(_.skip(test.name), 2)
parser.on('comment', (comment) => {
if (!reservedCommentPrefixes.some((c) => comment.startsWith(c, 2))) {
// "comment" is generally a test group name
P(`\n${_.title(comment.trimEnd().replace(/^(# )/, ''))}`)
}
})
parser.on('todo', (test) => {
P(_.todo(test.name, test.ok), 2)
})
parser.on('extra', (extra) => {

@@ -40,14 +43,23 @@ // typically `console.log` output from the test or program it tests

const justAnsi = stripped.length === 0 && extra.length > 0
if (!justAnsi) P(extra.trim())
if (!justAnsi) P(extra, 0, 0)
})
parser.on('comment', (comment) => {
if (!reservedCommentPrefixes.some((c) => comment.startsWith(c, 2))) {
// "comment" is a test group title
P(`\n${_.title(comment.trimEnd().replace(/^(# )/, ''))}`)
}
parser.on('pass', (test) => {
counter.pass++
P(_.pass(test), 2)
})
parser.on('skip', (test) => {
counter.skip++
P(_.skip(test), 2)
})
parser.on('todo', (test) => {
counter.todo++
P(_.todo(test), 2)
})
parser.on('fail', (test) => {
P(_.fail(test.name, test.id), 2)
counter.fail++
P(_.fail(test), 2)

@@ -151,3 +163,3 @@ if (test.diag) {

if (options.verbose && stack) {
if (verbose && stack) {
stack.split('\n').forEach((s) => {

@@ -170,3 +182,3 @@ P(_.dim(s.trim().replace(cwd, '')), I)

for (const test of result.failures) P(_.fail(test.name, test.id), 2)
for (const test of result.failures) P(_.fail(test), 2)
}

@@ -181,6 +193,29 @@

if (debug) {
P('tap-parser result:')
P(JSON.stringify(result, null, 2))
P('tap-arc internal counters:')
P(JSON.stringify(counter, null, 2))
}
_.end(start)
})
if (verbose) {
parser.on('version', (version) => {
P(`${_.strong('TAP version:')} ${version}`)
})
parser.on('plan', (plan) => {
const { start, end, comment } = plan
P(`${_.strong('Plan:')} start=${start} end=${end} ${comment ? `"${comment}"` : ''}`)
})
}
if (debug) {
parser.on('line', (line) => {
P(line.trim())
})
}
return stream
}
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