Skip to content

Commit a11e272

Browse files
committed
Merge tag 'v4.12.1'
2 parents 67ba418 + 25bcbc6 commit a11e272

File tree

7 files changed

+25
-26
lines changed

7 files changed

+25
-26
lines changed

lib/test.js

+4-3
Original file line numberDiff line numberDiff line change
@@ -286,15 +286,16 @@ Test.prototype._assert = function assert(ok, opts) {
286286
287287
/((?:\/|[a-zA-Z]:\\)[^:\)]+:(\d+)(?::(\d+))?)/
288288
*/
289-
var re = /^(?:[^\s]*\s*\bat\s+)(?:(.*)\s+\()?((?:\/|[a-zA-Z]:\\)[^:\)]+:(\d+)(?::(\d+))?)/;
290-
var m = re.exec(err[i]);
289+
var re = /^(?:[^\s]*\s*\bat\s+)(?:(.*)\s+\()?((?:\/|[a-zA-Z]:\\)[^:\)]+:(\d+)(?::(\d+))?)\)$/;
290+
var lineWithTokens = err[i].replace(process.cwd(), '/\$CWD').replace(__dirname, '/\$TEST');
291+
var m = re.exec(lineWithTokens);
291292

292293
if (!m) {
293294
continue;
294295
}
295296

296297
var callDescription = m[1] || '<anonymous>';
297-
var filePath = m[2];
298+
var filePath = m[2].replace('/$CWD', process.cwd()).replace('/$TEST', __dirname);
298299

299300
if (filePath.slice(0, dir.length) === dir) {
300301
continue;

package.json

+2-2
Original file line numberDiff line numberDiff line change
@@ -19,15 +19,15 @@
1919
"is-regex": "^1.0.5",
2020
"minimist": "^1.2.0",
2121
"object-inspect": "^1.7.0",
22-
"resolve": "^1.14.0",
22+
"resolve": "^1.14.1",
2323
"resumer": "^0.0.0",
2424
"string.prototype.trim": "^1.2.1",
2525
"through": "^2.3.8"
2626
},
2727
"devDependencies": {
2828
"concat-stream": "^1.6.2",
2929
"eclint": "^2.8.1",
30-
"eslint": "^6.7.2",
30+
"eslint": "^6.8.0",
3131
"falafel": "^2.1.0",
3232
"js-yaml": "^3.13.1",
3333
"tap": "^8.0.1",

test/anonymous-fn.js

+3-3
Original file line numberDiff line numberDiff line change
@@ -14,8 +14,8 @@ tap.test('inside anonymous functions', function (tt) {
1414

1515
// Handle stack trace variation in Node v0.8
1616
body = body.replace(
17-
'at Test.module.exports',
18-
'at Test.<anonymous>'
17+
/at(:?) Test\.module\.exports/g,
18+
'at$1 Test.<anonymous>'
1919
);
2020

2121
tt.same(body, [
@@ -24,7 +24,7 @@ tap.test('inside anonymous functions', function (tt) {
2424
'not ok 1 fail',
2525
' ---',
2626
' operator: fail',
27-
' at: <anonymous> ($TEST/anonymous-fn.js:$LINE:$COL)',
27+
' at: Test.<anonymous> ($TEST/anonymous-fn/test-wrapper.js:$LINE:$COL)',
2828
' stack: |-',
2929
' Error: fail',
3030
' [... stack stripped ...]',

test/common.js

+13-15
Original file line numberDiff line numberDiff line change
@@ -33,27 +33,25 @@ module.exports.getDiag = function (body) {
3333
// these changes are irrelevant to the tests themselves. To counter this, we
3434
// strip out all stack frames that aren't directly under our test directory,
3535
// and replace them with placeholders.
36+
37+
var stripChangingData = function (line) {
38+
var withoutTestDir = line.replace(__dirname, '$TEST');
39+
var withoutPackageDir = withoutTestDir.replace(path.dirname(__dirname), '$TAPE');
40+
var withoutPathSep = withoutPackageDir.replace(new RegExp('\\' + path.sep, 'g'), '/');
41+
var withoutLineNumbers = withoutPathSep.replace(/:\d+:\d+/g, ':$LINE:$COL');
42+
var withoutNestedLineNumbers = withoutLineNumbers.replace(/, \<anonymous\>:\$LINE:\$COL\)$/, ')');
43+
return withoutNestedLineNumbers;
44+
};
45+
3646
module.exports.stripFullStack = function (output) {
3747
var stripped = ' [... stack stripped ...]';
38-
var withDuplicates = output.split('\n').map(function (line) {
48+
var withDuplicates = output.split('\n').map(stripChangingData).map(function (line) {
3949
var m = line.match(/[ ]{8}at .*\((.*)\)/);
4050

41-
var stripChangingData = function (line) {
42-
var withoutTestDir = line.replace(__dirname, '$TEST');
43-
var withoutPackageDir = withoutTestDir.replace(path.dirname(__dirname), '$TAPE');
44-
var withoutPathSep = withoutPackageDir.replace(new RegExp('\\' + path.sep, 'g'), '/');
45-
var withoutLineNumbers = withoutPathSep.replace(/:\d+:\d+/g, ':$LINE:$COL');
46-
var withoutNestedLineNumbers = withoutLineNumbers.replace(/, \<anonymous\>:\$LINE:\$COL\)$/, ')');
47-
return withoutNestedLineNumbers;
48-
};
49-
50-
if (m) {
51-
if (m[1].slice(0, __dirname.length) === __dirname) {
52-
return stripChangingData(line);
53-
}
51+
if (m && m[1].slice(0, 5) !== '$TEST') {
5452
return stripped;
5553
}
56-
return stripChangingData(line);
54+
return line;
5755
});
5856

5957
var deduped = withDuplicates.filter(function (line, ix) {

test/exit.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@ tap.test('exit fail', function (t) {
5252
' operator: deepEqual',
5353
' expected: [ [ 1, 2, [ 3, 4444 ] ], [ 5, 6 ] ]',
5454
' actual: [ [ 1, 2, [ 3, 4 ] ], [ 5, 6 ] ]',
55-
' at: <anonymous> ($TEST/exit/fail.js:$LINE:$COL)',
55+
' at: Test.<anonymous> ($TEST/exit/fail.js:$LINE:$COL)',
5656
' stack: |-',
5757
' Error: should be equivalent',
5858
' [... stack stripped ...]',

test/fail.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ tap.test('array test', function (tt) {
2222
' operator: deepEqual',
2323
' expected: [ [ 1, 2, [ 3, 4444 ] ], [ 5, 6 ] ]',
2424
' actual: [ [ 1, 2, [ 3, 4 ] ], [ 5, 6 ] ]',
25-
' at: <anonymous> ($TEST/fail.js:$LINE:$COL)',
25+
' at: Test.<anonymous> ($TEST/fail.js:$LINE:$COL)',
2626
' stack: |-',
2727
' Error: should be equivalent',
2828
' [... stack stripped ...]',

test/too_many.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ tap.test('array test', function (tt) {
2222
' operator: fail',
2323
' expected: 3',
2424
' actual: 4',
25-
' at: <anonymous> ($TEST/too_many.js:$LINE:$COL)',
25+
' at: Test.<anonymous> ($TEST/too_many.js:$LINE:$COL)',
2626
' stack: |-',
2727
' Error: plan != count',
2828
' [... stack stripped ...]',

0 commit comments

Comments
 (0)