Comparing version 5.7.3 to 5.7.4
@@ -489,5 +489,4 @@ 'use strict'; | ||
/* | ||
Stack trace lines may resemble one of the following. We need | ||
to correctly extract a function name (if any) and path / line | ||
number for each line. | ||
Stack trace lines may resemble one of the following. | ||
We need to correctly extract a function name (if any) and path / line number for each line. | ||
@@ -503,24 +502,21 @@ at myFunction (/path/to/file.js:123:45) | ||
Regex has three parts. First is non-capturing group for 'at ' | ||
(plus anything preceding it). | ||
Regex has three parts. First is non-capturing group for 'at ' (plus anything preceding it). | ||
/^(?:[^\s]*\s*\bat\s+)/ | ||
Second captures function call description (optional). This is | ||
not necessarily a valid JS function name, but just what the | ||
stack trace is using to represent a function call. It may look | ||
like `<anonymous>` or 'Test.bound [as run]'. | ||
Second captures function call description (optional). | ||
This is not necessarily a valid JS function name, but just what the stack trace is using to represent a function call. | ||
It may look like `<anonymous>` or 'Test.bound [as run]'. | ||
For our purposes, we assume that, if there is a function | ||
name, it's everything leading up to the first open | ||
parentheses (trimmed) before our pathname. | ||
For our purposes, we assume that, if there is a function name, it's everything leading up to the first open parentheses (trimmed) before our pathname. | ||
/(?:(.*)\s+\()?/ | ||
Last part captures file path plus line no (and optional | ||
column no). | ||
Last part captures file path plus line no (and optional column no). | ||
/((?:[/\\]|[a-zA-Z]:\\)[^:\)]+:(\d+)(?::(\d+))?)\)?/ | ||
In the future, if node supports more ESM URL protocols than `file`, the `file:` below will need to be expanded. | ||
*/ | ||
var re = /^(?:[^\s]*\s*\bat\s+)(?:(.*)\s+\()?((?:[/\\]|[a-zA-Z]:\\)[^:)]+:(\d+)(?::(\d+))?)\)?$/; | ||
var re = /^(?:[^\s]*\s*\bat\s+)(?:(.*)\s+\()?((?:[/\\]|[a-zA-Z]:\\|file:\/\/)[^:)]+:(\d+)(?::(\d+))?)\)?$/; | ||
// first tokenize the PWD, then tokenize tape | ||
@@ -527,0 +523,0 @@ var lineWithTokens = $replace( |
{ | ||
"name": "tape", | ||
"version": "5.7.3", | ||
"version": "5.7.4", | ||
"description": "tap-producing test harness for node and browsers", | ||
@@ -39,3 +39,3 @@ "main": "index.js", | ||
"glob": "^7.2.3", | ||
"has-dynamic-import": "^2.0.1", | ||
"has-dynamic-import": "^2.1.0", | ||
"hasown": "^2.0.0", | ||
@@ -65,2 +65,3 @@ "inherits": "^2.0.4", | ||
"intl-fallback-symbol": "^1.0.0", | ||
"is-core-module": "^2.13.1", | ||
"jackspeak": "=2.1.1", | ||
@@ -67,0 +68,0 @@ "js-yaml": "^3.14.0", |
@@ -15,3 +15,4 @@ 'use strict'; | ||
var node17 = Number(majorVersion) >= 17; | ||
var node15 = Number(majorVersion) >= 15; | ||
var node17 = node15 && Number(majorVersion) >= 17; | ||
@@ -215,2 +216,5 @@ var lengthMessage = 'Cannot read property \'length\' of null'; | ||
' at Test.run ($TAPE/lib/test.js:$LINE:$COL)', | ||
node15 ? [ | ||
' at processImmediate (timers:$LINE:$COL)' | ||
] : [], | ||
node17 ? [ | ||
@@ -217,0 +221,0 @@ '', |
@@ -47,4 +47,19 @@ 'use strict'; | ||
var withoutNestedLineNumbers = withoutLineNumbers.replace(/, <anonymous>:\$LINE:\$COL\)$/, ')'); | ||
return withoutNestedLineNumbers; | ||
var withoutProcessImmediate = withoutNestedLineNumbers.replace( | ||
/^(\s+)at (?:process\.)?(processImmediate|startup\.processNextTick\.process\._tickCallback) (?:\[as _immediateCallback\] )?\((node:internal\/timers|(?:internal\/)?timers\.js|node\.js):\$LINE:\$COL\)$/g, | ||
'$1at processImmediate (timers:$$LINE:$$COL)' | ||
); | ||
var withNormalizedInternals = withoutProcessImmediate | ||
.replace(/^(\s+)at Test\.assert \[as _assert\]/g, '$1at Test.assert') | ||
.replace(/^(\s+)at (?:Object\.|Immediate\.)?next (?:\[as _onImmediate\] )?/g, '$1at Immediate.next '); | ||
if ( | ||
(/^\s+at tryOnImmediate \(timers\.js:\$LINE:\$COL\)$/g).test(withNormalizedInternals) // node 5 - 10 | ||
|| (/^\s+at runCallback \(timers\.js:\$LINE:\$COL\)$/g).test(withNormalizedInternals) // node 6 - 10 | ||
) { | ||
return null; | ||
} | ||
return withNormalizedInternals; | ||
}; | ||
module.exports.stripChangingData = stripChangingData; | ||
@@ -54,3 +69,3 @@ module.exports.stripFullStack = function (output) { | ||
var withDuplicates = output.split(/\r?\n/g).map(stripChangingData).map(function (line) { | ||
var m = line.match(/[ ]{8}at .*\((.*)\)/); | ||
var m = typeof line === 'string' && line.match(/[ ]{8}at .*\((.*)\)/); | ||
@@ -61,3 +76,3 @@ if (m && m[1].slice(0, 5) !== '$TEST') { | ||
return line; | ||
}); | ||
}).filter(function (line) { return typeof line === 'string'; }); | ||
@@ -64,0 +79,0 @@ var withoutInternals = withDuplicates.filter(function (line) { |
@@ -5,4 +5,8 @@ 'use strict'; | ||
var tap = require('tap'); | ||
var spawn = require('child_process').spawn; | ||
var url = require('url'); | ||
var concat = require('concat-stream'); | ||
var tapParser = require('tap-parser'); | ||
var assign = require('object.assign'); | ||
var hasDynamicImport = require('has-dynamic-import'); | ||
var common = require('./common'); | ||
@@ -16,2 +20,6 @@ | ||
function isString(x) { | ||
return typeof x === 'string'; | ||
} | ||
tap.test('preserves stack trace with newlines', function (tt) { | ||
@@ -293,1 +301,101 @@ tt.plan(3); | ||
}); | ||
function spawnTape(args, options) { | ||
var bin = __dirname + '/../bin/tape'; | ||
return spawn(process.execPath, [bin].concat(args.split(' ')), assign({ cwd: __dirname }, options)); | ||
} | ||
function processRows(rows) { | ||
return (typeof rows === 'string' ? rows.split('\n') : rows).map(common.stripChangingData).filter(isString).join('\n'); | ||
} | ||
tap.test('CJS vs ESM: `at`', function (tt) { | ||
tt.plan(2); | ||
tt.test('CJS', function (ttt) { | ||
ttt.plan(2); | ||
var tc = function (rows) { | ||
ttt.same(processRows(rows.toString('utf8')), processRows([ | ||
'TAP version 13', | ||
'# test', | ||
'not ok 1 should be strictly equal', | ||
' ---', | ||
' operator: equal', | ||
' expected: \'foobar\'', | ||
' actual: \'foobaz\'', | ||
' at: Test.<anonymous> ($TEST/stack_trace/cjs.js:7:4)', | ||
' stack: |-', | ||
' Error: should be strictly equal', | ||
' at Test.assert [as _assert] ($TAPE/lib/test.js:$LINE:$COL)', | ||
' at Test.strictEqual ($TAPE/lib/test.js:$LINE:$COL)', | ||
' at Test.<anonymous> ($TEST/stack_trace/cjs.js:7:4)', | ||
' at Test.run ($TAPE/lib/test.js:$LINE:$COL)', | ||
' at Immediate.next ($TAPE/lib/results.js:$LINE:$COL)', | ||
' at processImmediate (timers:$LINE:$COL)', | ||
' ...', | ||
'', | ||
'1..1', | ||
'# tests 1', | ||
'# pass 0', | ||
'# fail 1', | ||
'', | ||
'' | ||
])); | ||
}; | ||
var ps = spawnTape('stack_trace/cjs.js'); | ||
ps.stdout.pipe(concat(tc)); | ||
ps.stderr.pipe(process.stderr); | ||
ps.on('exit', function (code) { | ||
ttt.notEqual(code, 0); | ||
ttt.end(); | ||
}); | ||
}); | ||
hasDynamicImport().then(function (hasSupport) { | ||
tt.test('ESM', { skip: !url.pathToFileURL || !hasSupport }, function (ttt) { | ||
ttt.plan(2); | ||
var tc = function (rows) { | ||
ttt.same(processRows(rows.toString('utf8')), processRows([ | ||
'TAP version 13', | ||
'# test', | ||
'not ok 1 should be strictly equal', | ||
' ---', | ||
' operator: equal', | ||
' expected: \'foobar\'', | ||
' actual: \'foobaz\'', | ||
' at: Test.<anonymous> (' + url.pathToFileURL(__dirname + '/stack_trace/esm.mjs:5:4') + ')', | ||
' stack: |-', | ||
' Error: should be strictly equal', | ||
' at Test.assert [as _assert] ($TAPE/lib/test.js:$LINE:$COL)', | ||
' at Test.strictEqual ($TAPE/lib/test.js:$LINE:$COL)', | ||
' at Test.<anonymous> (' + url.pathToFileURL(__dirname + '/stack_trace/esm.mjs:5:4') + ')', | ||
' at Test.run ($TAPE/lib/test.js:$LINE:$COL)', | ||
' at Immediate.next ($TAPE/lib/results.js:$LINE:$COL)', | ||
// node ? | ||
// at runCallback (timers.js:$LINE:$COL) | ||
' at process.processImmediate (node:internal/timers:478:21)', | ||
' ...', | ||
'', | ||
'1..1', | ||
'# tests 1', | ||
'# pass 0', | ||
'# fail 1', | ||
'', | ||
'' | ||
])); | ||
}; | ||
var ps = spawnTape('stack_trace/esm.mjs'); | ||
ps.stdout.pipe(concat(tc)); | ||
ps.stderr.pipe(process.stderr); | ||
ps.on('exit', function (code) { | ||
ttt.equal(code, 1); | ||
ttt.end(); | ||
}); | ||
}); | ||
}); | ||
}); |
Sorry, the diff of this file is too big to display
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
407510
166
7629
20
27
Updatedhas-dynamic-import@^2.1.0