Socket
Socket
Sign inDemoInstall

tap-parser

Package Overview
Dependencies
Maintainers
1
Versions
106
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

tap-parser - npm Package Compare versions

Comparing version 0.1.0 to 0.2.0

test/skip_all_nonempty.js

38

index.js

@@ -11,3 +11,3 @@ var Stream = require('stream');

].join('')),
plan: /^(\d+)\.\.(\d+)\b/,
plan: /^(\d+)\.\.(\d+)\b(?:\s+#\s+SKIP\s+(.*)$)?/,
comment: /^#\s*(.+)/,

@@ -54,3 +54,3 @@ version: /^TAP\s+version\s+(\d+)/i,

stream.on('plan', function (plan) {
stream.on('plan', function (plan, skip_reason) {
if (results.plan !== undefined) {

@@ -62,2 +62,14 @@ stream.emit('parseError', {

}
if (plan.start === 1 && plan.end === 0) {
plan.skip_all = true;
plan.skip_reason = skip_reason; // could be undefined
} else if (skip_reason !== undefined) {
stream.emit('parseError', {
message: 'plan is not empty, but has a SKIP reason',
skip_reason: skip_reason,
});
plan.skip_all = false;
plan.skip_reason = skip_reason;
// continue to use the plan
}
results.plan = plan;

@@ -101,15 +113,20 @@ checkAssertionStart();

if (results.asserts.length === 0) {
if (results.plan === undefined) {
stream.emit('parseError', {
message: 'no assertions found'
message: 'no plan found'
});
}
if (results.ok === undefined) results.ok = true;
if (results.plan === undefined) {
var skip_all = (results.plan && results.plan.skip_all);
if (results.asserts.length === 0 && ! skip_all) {
stream.emit('parseError', {
message: 'no plan found'
message: 'no assertions found'
});
} else if (skip_all && results.asserts.length !== 0) {
stream.emit('parseError', {
message: 'assertion found after skip_all plan'
});
}
if (results.ok === undefined) results.ok = true;
var last = results.asserts.length

@@ -169,6 +186,7 @@ && results.asserts[results.asserts.length - 1].number

start: Number(m[1]),
end: Number(m[2])
});
end: Number(m[2]),
},
m[3]); // reason, if SKIP
}
}
};
{
"name" : "tap-parser",
"version" : "0.1.0",
"version" : "0.2.0",
"description" : "parse the test anything protocol",

@@ -5,0 +5,0 @@ "main" : "index.js",

@@ -40,3 +40,3 @@ var test = require('tape');

test('no plan', function (t) {
t.plan(5 * 2 + 4 + 2);
t.plan(6 * 2 + 4 + 2);

@@ -49,3 +49,3 @@ var p = parser(onresults);

asserts.push(assert);
t.same(assert, expected.asserts.shift());
t.same(assert, expected.asserts.shift(), 'next assert');
});

@@ -58,3 +58,3 @@

p.on('comment', function (c) {
t.equal(c, expected.comments.shift());
t.equal(c, expected.comments.shift(), 'next comment');
});

@@ -68,8 +68,9 @@

function onresults (results) {
t.equal(results.ok, false);
t.equal(results.ok, false, 'onresults: ok');
t.equal(results.errors[0].message, 'no plan found');
t.equal(results.errors[0].line, lines.length + 1);
t.same(asserts.length, 4);
t.same(results.asserts, asserts);
t.same(asserts.length, 4, 'onresults: asserts.length');
t.same(results.asserts, asserts, 'onresults: asserts');
t.equal(expected.comments.length, 0, 'onresults: leftover comments');
}
});

Sorry, the diff of this file is not supported yet

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