@@ -482,7 +482,7 @@ Test.prototype._assert = function assert(ok, opts) {
482
482
if ( ! ok ) {
483
483
var e = new Error ( 'exception' ) ;
484
484
var err = $split ( e . stack || '' , '\n' ) ;
485
- var dir = __dirname + path . sep ;
485
+ var tapeDir = __dirname + path . sep ;
486
486
487
487
for ( var i = 0 ; i < err . length ; i ++ ) {
488
488
/*
@@ -521,17 +521,35 @@ Test.prototype._assert = function assert(ok, opts) {
521
521
/((?:\/|[a-zA-Z]:\\)[^:\)]+:(\d+)(?::(\d+))?)\)?/
522
522
*/
523
523
var re = / ^ (?: [ ^ \s ] * \s * \b a t \s + ) (?: ( .* ) \s + \( ) ? ( (?: \/ | [ a - z A - Z ] : \\ ) [ ^ : ) ] + : ( \d + ) (?: : ( \d + ) ) ? ) \) ? $ / ;
524
- var lineWithTokens = $replace ( $replace ( err [ i ] , process . cwd ( ) , '/$CWD' ) , __dirname , '/$TEST' ) ;
524
+ // first tokenize the PWD, then tokenize tape
525
+ var lineWithTokens = $replace (
526
+ $replace (
527
+ err [ i ] ,
528
+ process . cwd ( ) ,
529
+ path . sep + '$CWD'
530
+ ) ,
531
+ tapeDir ,
532
+ path . sep + '$TEST' + path . sep
533
+ ) ;
525
534
var m = re . exec ( lineWithTokens ) ;
526
535
527
536
if ( ! m ) {
528
537
continue ;
529
538
}
530
539
531
540
var callDescription = m [ 1 ] || '<anonymous>' ;
532
- var filePath = $replace ( $replace ( m [ 2 ] , '/$CWD' , process . cwd ( ) ) , '/$TEST' , __dirname ) ;
533
-
534
- if ( $strSlice ( filePath , 0 , dir . length ) === dir ) {
541
+ // first untokenize tape, and then untokenize the PWD, then strip the line/column
542
+ var filePath = $replace (
543
+ $replace (
544
+ $replace ( m [ 2 ] , path . sep + '$TEST' + path . sep , tapeDir ) ,
545
+ path . sep + '$CWD' ,
546
+ process . cwd ( )
547
+ ) ,
548
+ / : \d + : \d + $ / ,
549
+ ''
550
+ ) ;
551
+
552
+ if ( $strSlice ( filePath , 0 , tapeDir . length ) === tapeDir ) {
535
553
continue ;
536
554
}
537
555
@@ -542,7 +560,7 @@ Test.prototype._assert = function assert(ok, opts) {
542
560
res . line = Number ( m [ 3 ] ) ;
543
561
if ( m [ 4 ] ) { res . column = Number ( m [ 4 ] ) ; }
544
562
545
- res . at = callDescription + ' (' + filePath + ')' ;
563
+ res . at = callDescription + ' (' + filePath + ':' + res . line + ( res . column ? ':' + res . column : '' ) + ' )';
546
564
break ;
547
565
}
548
566
}
0 commit comments