Skip to content

Commit

Permalink
Merge tag 'v4.12.1'
Browse files Browse the repository at this point in the history
  • Loading branch information
ljharb committed Dec 24, 2019
2 parents 67ba418 + 25bcbc6 commit a11e272
Show file tree
Hide file tree
Showing 7 changed files with 25 additions and 26 deletions.
7 changes: 4 additions & 3 deletions lib/test.js
Original file line number Diff line number Diff line change
Expand Up @@ -286,15 +286,16 @@ Test.prototype._assert = function assert(ok, opts) {
/((?:\/|[a-zA-Z]:\\)[^:\)]+:(\d+)(?::(\d+))?)/
*/
var re = /^(?:[^\s]*\s*\bat\s+)(?:(.*)\s+\()?((?:\/|[a-zA-Z]:\\)[^:\)]+:(\d+)(?::(\d+))?)/;
var m = re.exec(err[i]);
var re = /^(?:[^\s]*\s*\bat\s+)(?:(.*)\s+\()?((?:\/|[a-zA-Z]:\\)[^:\)]+:(\d+)(?::(\d+))?)\)$/;
var lineWithTokens = err[i].replace(process.cwd(), '/\$CWD').replace(__dirname, '/\$TEST');
var m = re.exec(lineWithTokens);

if (!m) {
continue;
}

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

if (filePath.slice(0, dir.length) === dir) {
continue;
Expand Down
4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -19,15 +19,15 @@
"is-regex": "^1.0.5",
"minimist": "^1.2.0",
"object-inspect": "^1.7.0",
"resolve": "^1.14.0",
"resolve": "^1.14.1",
"resumer": "^0.0.0",
"string.prototype.trim": "^1.2.1",
"through": "^2.3.8"
},
"devDependencies": {
"concat-stream": "^1.6.2",
"eclint": "^2.8.1",
"eslint": "^6.7.2",
"eslint": "^6.8.0",
"falafel": "^2.1.0",
"js-yaml": "^3.13.1",
"tap": "^8.0.1",
Expand Down
6 changes: 3 additions & 3 deletions test/anonymous-fn.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,8 @@ tap.test('inside anonymous functions', function (tt) {

// Handle stack trace variation in Node v0.8
body = body.replace(
'at Test.module.exports',
'at Test.<anonymous>'
/at(:?) Test\.module\.exports/g,
'at$1 Test.<anonymous>'
);

tt.same(body, [
Expand All @@ -24,7 +24,7 @@ tap.test('inside anonymous functions', function (tt) {
'not ok 1 fail',
' ---',
' operator: fail',
' at: <anonymous> ($TEST/anonymous-fn.js:$LINE:$COL)',
' at: Test.<anonymous> ($TEST/anonymous-fn/test-wrapper.js:$LINE:$COL)',
' stack: |-',
' Error: fail',
' [... stack stripped ...]',
Expand Down
28 changes: 13 additions & 15 deletions test/common.js
Original file line number Diff line number Diff line change
Expand Up @@ -33,27 +33,25 @@ module.exports.getDiag = function (body) {
// these changes are irrelevant to the tests themselves. To counter this, we
// strip out all stack frames that aren't directly under our test directory,
// and replace them with placeholders.

var stripChangingData = function (line) {
var withoutTestDir = line.replace(__dirname, '$TEST');
var withoutPackageDir = withoutTestDir.replace(path.dirname(__dirname), '$TAPE');
var withoutPathSep = withoutPackageDir.replace(new RegExp('\\' + path.sep, 'g'), '/');
var withoutLineNumbers = withoutPathSep.replace(/:\d+:\d+/g, ':$LINE:$COL');
var withoutNestedLineNumbers = withoutLineNumbers.replace(/, \<anonymous\>:\$LINE:\$COL\)$/, ')');
return withoutNestedLineNumbers;
};

module.exports.stripFullStack = function (output) {
var stripped = ' [... stack stripped ...]';
var withDuplicates = output.split('\n').map(function (line) {
var withDuplicates = output.split('\n').map(stripChangingData).map(function (line) {
var m = line.match(/[ ]{8}at .*\((.*)\)/);

var stripChangingData = function (line) {
var withoutTestDir = line.replace(__dirname, '$TEST');
var withoutPackageDir = withoutTestDir.replace(path.dirname(__dirname), '$TAPE');
var withoutPathSep = withoutPackageDir.replace(new RegExp('\\' + path.sep, 'g'), '/');
var withoutLineNumbers = withoutPathSep.replace(/:\d+:\d+/g, ':$LINE:$COL');
var withoutNestedLineNumbers = withoutLineNumbers.replace(/, \<anonymous\>:\$LINE:\$COL\)$/, ')');
return withoutNestedLineNumbers;
};

if (m) {
if (m[1].slice(0, __dirname.length) === __dirname) {
return stripChangingData(line);
}
if (m && m[1].slice(0, 5) !== '$TEST') {
return stripped;
}
return stripChangingData(line);
return line;
});

var deduped = withDuplicates.filter(function (line, ix) {
Expand Down
2 changes: 1 addition & 1 deletion test/exit.js
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ tap.test('exit fail', function (t) {
' operator: deepEqual',
' expected: [ [ 1, 2, [ 3, 4444 ] ], [ 5, 6 ] ]',
' actual: [ [ 1, 2, [ 3, 4 ] ], [ 5, 6 ] ]',
' at: <anonymous> ($TEST/exit/fail.js:$LINE:$COL)',
' at: Test.<anonymous> ($TEST/exit/fail.js:$LINE:$COL)',
' stack: |-',
' Error: should be equivalent',
' [... stack stripped ...]',
Expand Down
2 changes: 1 addition & 1 deletion test/fail.js
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ tap.test('array test', function (tt) {
' operator: deepEqual',
' expected: [ [ 1, 2, [ 3, 4444 ] ], [ 5, 6 ] ]',
' actual: [ [ 1, 2, [ 3, 4 ] ], [ 5, 6 ] ]',
' at: <anonymous> ($TEST/fail.js:$LINE:$COL)',
' at: Test.<anonymous> ($TEST/fail.js:$LINE:$COL)',
' stack: |-',
' Error: should be equivalent',
' [... stack stripped ...]',
Expand Down
2 changes: 1 addition & 1 deletion test/too_many.js
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ tap.test('array test', function (tt) {
' operator: fail',
' expected: 3',
' actual: 4',
' at: <anonymous> ($TEST/too_many.js:$LINE:$COL)',
' at: Test.<anonymous> ($TEST/too_many.js:$LINE:$COL)',
' stack: |-',
' Error: plan != count',
' [... stack stripped ...]',
Expand Down

0 comments on commit a11e272

Please sign in to comment.