Make path prefixes optional

Commit d281271b106e3e4cc5e06eb8f1589c02cd0d5219 in source-map
means that we get foo.js instead of ./foo.js so the regular
expressions need to adjust to allow that.
master
Tom Hughes 9 years ago
parent 70c54a8ab6
commit a56fba43ff

@ -129,7 +129,7 @@ it('normal throw', function() {
'throw new Error("test");'
], [
'Error: test',
/^ at Object\.exports\.test \(.*\/line1\.js:1001:101\)$/
/^ at Object\.exports\.test \((?:.*\/)?line1\.js:1001:101\)$/
]);
});
@ -141,8 +141,8 @@ it('throw inside function', function() {
'foo();'
], [
'Error: test',
/^ at foo \(.*\/line2\.js:1002:102\)$/,
/^ at Object\.exports\.test \(.*\/line4\.js:1004:104\)$/
/^ at foo \((?:.*\/)?line2\.js:1002:102\)$/,
/^ at Object\.exports\.test \((?:.*\/)?line4\.js:1004:104\)$/
]);
});
@ -157,9 +157,9 @@ it('throw inside function inside function', function() {
'foo();'
], [
'Error: test',
/^ at bar \(.*\/line3\.js:1003:103\)$/,
/^ at foo \(.*\/line5\.js:1005:105\)$/,
/^ at Object\.exports\.test \(.*\/line7\.js:1007:107\)$/
/^ at bar \((?:.*\/)?line3\.js:1003:103\)$/,
/^ at foo \((?:.*\/)?line5\.js:1005:105\)$/,
/^ at Object\.exports\.test \((?:.*\/)?line7\.js:1007:107\)$/
]);
});
@ -170,9 +170,9 @@ it('eval', function() {
'Error: test',
// Before Node 4, `Object.eval`, after just `eval`.
/^ at (?:Object\.)?eval \(eval at <anonymous> \(.*\/line1\.js:1001:101\)/,
/^ at (?:Object\.)?eval \(eval at <anonymous> \((?:.*\/)?line1\.js:1001:101\)/,
/^ at Object\.exports\.test \(.*\/line1\.js:1001:101\)$/
/^ at Object\.exports\.test \((?:.*\/)?line1\.js:1001:101\)$/
]);
});
@ -181,9 +181,9 @@ it('eval inside eval', function() {
'eval("eval(\'throw new Error(\\"test\\")\')");'
], [
'Error: test',
/^ at (?:Object\.)?eval \(eval at <anonymous> \(eval at <anonymous> \(.*\/line1\.js:1001:101\)/,
/^ at (?:Object\.)?eval \(eval at <anonymous> \(.*\/line1\.js:1001:101\)/,
/^ at Object\.exports\.test \(.*\/line1\.js:1001:101\)$/
/^ at (?:Object\.)?eval \(eval at <anonymous> \(eval at <anonymous> \((?:.*\/)?line1\.js:1001:101\)/,
/^ at (?:Object\.)?eval \(eval at <anonymous> \((?:.*\/)?line1\.js:1001:101\)/,
/^ at Object\.exports\.test \((?:.*\/)?line1\.js:1001:101\)$/
]);
});
@ -195,9 +195,9 @@ it('eval inside function', function() {
'foo();'
], [
'Error: test',
/^ at eval \(eval at foo \(.*\/line2\.js:1002:102\)/,
/^ at foo \(.*\/line2\.js:1002:102\)/,
/^ at Object\.exports\.test \(.*\/line4\.js:1004:104\)$/
/^ at eval \(eval at foo \((?:.*\/)?line2\.js:1002:102\)/,
/^ at foo \((?:.*\/)?line2\.js:1002:102\)/,
/^ at Object\.exports\.test \((?:.*\/)?line4\.js:1004:104\)$/
]);
});
@ -207,7 +207,7 @@ it('eval with sourceURL', function() {
], [
'Error: test',
/^ at (?:Object\.)?eval \(sourceURL\.js:1:7\)$/,
/^ at Object\.exports\.test \(.*\/line1\.js:1001:101\)$/
/^ at Object\.exports\.test \((?:.*\/)?line1\.js:1001:101\)$/
]);
});
@ -217,8 +217,8 @@ it('eval with sourceURL inside eval', function() {
], [
'Error: test',
/^ at (?:Object\.)?eval \(sourceURL\.js:1:7\)$/,
/^ at (?:Object\.)?eval \(eval at <anonymous> \(.*\/line1\.js:1001:101\)/,
/^ at Object\.exports\.test \(.*\/line1\.js:1001:101\)$/
/^ at (?:Object\.)?eval \(eval at <anonymous> \((?:.*\/)?line1\.js:1001:101\)/,
/^ at Object\.exports\.test \((?:.*\/)?line1\.js:1001:101\)$/
]);
});
@ -228,7 +228,7 @@ it('function constructor', function() {
], [
'SyntaxError: Unexpected token )',
/^ at (?:Object\.)?Function \((?:unknown source|<anonymous>|native)\)$/,
/^ at Object\.exports\.test \(.*\/line1\.js:1001:101\)$/,
/^ at Object\.exports\.test \((?:.*\/)?line1\.js:1001:101\)$/,
]);
});
@ -237,7 +237,7 @@ it('throw with empty source map', function() {
'throw new Error("test");'
], [
'Error: test',
/^ at Object\.exports\.test \(.*\/.generated.js:1:34\)$/
/^ at Object\.exports\.test \((?:.*\/)?.generated.js:1:34\)$/
]);
});
@ -246,7 +246,7 @@ it('throw with source map with gap', function() {
'throw new Error("test");'
], [
'Error: test',
/^ at Object\.exports\.test \(.*\/.generated.js:1:34\)$/
/^ at Object\.exports\.test \((?:.*\/)?.generated.js:1:34\)$/
]);
});
@ -255,7 +255,7 @@ it('sourcesContent with data URL', function() {
'throw new Error("test");'
], [
'Error: test',
/^ at Object\.exports\.test \(.*\/original.js:1001:5\)$/
/^ at Object\.exports\.test \((?:.*\/)?original.js:1001:5\)$/
]);
});
@ -265,7 +265,7 @@ it('finds the last sourceMappingURL', function() {
'throw new Error("test");'
], [
'Error: test',
/^ at Object\.exports\.test \(.*\/original.js:1002:5\)$/
/^ at Object\.exports\.test \((?:.*\/)?original.js:1002:5\)$/
]);
});
@ -281,7 +281,7 @@ it('default options', function(done) {
'this is the original code',
'^',
'Error: this is the error',
/^ at foo \(.*\/.original\.js:1:1\)$/
/^ at foo \((?:.*\/)?.original\.js:1:1\)$/
]);
});
@ -296,7 +296,7 @@ it('handleUncaughtExceptions is true', function(done) {
'this is the original code',
'^',
'Error: this is the error',
/^ at foo \(.*\/.original\.js:1:1\)$/
/^ at foo \((?:.*\/)?.original\.js:1:1\)$/
]);
});
@ -315,7 +315,7 @@ it('handleUncaughtExceptions is false', function(done) {
/^ (?: )?\^$/,
'Error: this is the error',
/^ at foo \(.*\/.original\.js:1:1\)$/
/^ at foo \((?:.*\/)?.original\.js:1:1\)$/
]);
});
@ -330,7 +330,7 @@ it('default options with empty source map', function(done) {
'function foo() { throw new Error("this is the error"); }',
/^ (?: )?\^$/,
'Error: this is the error',
/^ at foo \(.*\/.generated.js:2:24\)$/
/^ at foo \((?:.*\/)?.generated.js:2:24\)$/
]);
});
@ -345,7 +345,7 @@ it('default options with source map with gap', function(done) {
'function foo() { throw new Error("this is the error"); }',
/^ (?: )?\^$/,
'Error: this is the error',
/^ at foo \(.*\/.generated.js:2:24\)$/
/^ at foo \((?:.*\/)?.generated.js:2:24\)$/
]);
});
@ -376,7 +376,7 @@ it('sourcesContent', function(done) {
' line 2',
' ^',
'Error: this is the error',
/^ at foo \(.*\/original\.js:1002:5\)$/
/^ at foo \((?:.*\/)?original\.js:1002:5\)$/
]);
});
@ -399,9 +399,9 @@ it('missing source maps should also be cached', function(done) {
'process.nextTick(function() { console.log(count); });',
], [
'Error: this is the error',
/^ at foo \(.*\/.generated.js:4:15\)$/,
/^ at foo \((?:.*\/)?.generated.js:4:15\)$/,
'Error: this is the error',
/^ at foo \(.*\/.generated.js:4:15\)$/,
/^ at foo \((?:.*\/)?.generated.js:4:15\)$/,
'1', // The retrieval should only be attempted once
]);
});
@ -432,9 +432,9 @@ it('should consult all retrieve source map providers', function(done) {
'process.nextTick(function() { console.log(count); });',
], [
'Error: this is the error',
/^ at foo \(.*\/original.js:1004:5\)$/,
/^ at foo \((?:.*\/)?original.js:1004:5\)$/,
'Error: this is the error',
/^ at foo \(.*\/original.js:1004:5\)$/,
/^ at foo \((?:.*\/)?original.js:1004:5\)$/,
'1', // The retrieval should only be attempted once
]);
});
@ -448,7 +448,7 @@ it('finds source maps with charset specified', function() {
var source = [ 'throw new Error("test");' ];
var expected = [
'Error: test',
/^ at Object\.exports\.test \(.*\/line1\.js:1001:101\)$/
/^ at Object\.exports\.test \((?:.*\/)?line1\.js:1001:101\)$/
];
fs.writeFileSync('.generated.js', 'exports.test = function() {' +
@ -472,7 +472,7 @@ it('allows code/comments after sourceMappingURL', function() {
var source = [ 'throw new Error("test");' ];
var expected = [
'Error: test',
/^ at Object\.exports\.test \(.*\/line1\.js:1001:101\)$/
/^ at Object\.exports\.test \((?:.*\/)?line1\.js:1001:101\)$/
];
fs.writeFileSync('.generated.js', 'exports.test = function() {' +

Loading…
Cancel
Save