From 69f560cff381f336d521ebf3085b56271f750ec6 Mon Sep 17 00:00:00 2001 From: telenord Date: Wed, 6 Nov 2019 17:32:13 +0300 Subject: [PATCH 1/3] test: test cover prepare_stack_trace in case when trace is empty --- test/fixtures/source-map/emptyStackError.js | 14 ++++++++++++++ test/parallel/test-source-map.js | 12 ++++++++++++ 2 files changed, 26 insertions(+) create mode 100644 test/fixtures/source-map/emptyStackError.js diff --git a/test/fixtures/source-map/emptyStackError.js b/test/fixtures/source-map/emptyStackError.js new file mode 100644 index 00000000000000..b253fb0ef45141 --- /dev/null +++ b/test/fixtures/source-map/emptyStackError.js @@ -0,0 +1,14 @@ +const ERROR_TEXT = 'emptyStackError'; + +function Hello() { + Error.stackTraceLimit = 0; + throw Error(ERROR_TEXT) +} + +setImmediate(function () { + Hello(); +}); + +module.exports = { + ERROR_TEXT +}; \ No newline at end of file diff --git a/test/parallel/test-source-map.js b/test/parallel/test-source-map.js index 2ded13a631dd8c..63eaab3023869c 100644 --- a/test/parallel/test-source-map.js +++ b/test/parallel/test-source-map.js @@ -223,6 +223,18 @@ function nextdir() { } } +// trace.length === 0 . +{ + const { ERROR_TEXT } = require('../fixtures/source-map/emptyStackError.js'); + const output = spawnSync(process.execPath, [ + '--enable-source-maps', + require.resolve('../fixtures/source-map/emptyStackError.js') + ]); + assert.ok( + output.stderr.toString().match(ERROR_TEXT) + ); +} + function getSourceMapFromCache(fixtureFile, coverageDirectory) { const jsonFiles = fs.readdirSync(coverageDirectory); for (const jsonFile of jsonFiles) { From c92176d4ef3bd296e82edf1001fb6accff90f859 Mon Sep 17 00:00:00 2001 From: telenord Date: Wed, 6 Nov 2019 18:08:45 +0300 Subject: [PATCH 2/3] test: test cover prepare_stack_trace in case of trace is empty --- test/fixtures/source-map/emptyStackError.js | 14 +++----------- test/parallel/test-source-map.js | 5 +++-- 2 files changed, 6 insertions(+), 13 deletions(-) diff --git a/test/fixtures/source-map/emptyStackError.js b/test/fixtures/source-map/emptyStackError.js index b253fb0ef45141..b02367a180dab7 100644 --- a/test/fixtures/source-map/emptyStackError.js +++ b/test/fixtures/source-map/emptyStackError.js @@ -1,14 +1,6 @@ -const ERROR_TEXT = 'emptyStackError'; +"use strict"; -function Hello() { - Error.stackTraceLimit = 0; - throw Error(ERROR_TEXT) -} +Error.stackTraceLimit = 0; +throw new RangeError('emptyStackError'); -setImmediate(function () { - Hello(); -}); -module.exports = { - ERROR_TEXT -}; \ No newline at end of file diff --git a/test/parallel/test-source-map.js b/test/parallel/test-source-map.js index 63eaab3023869c..be589935957820 100644 --- a/test/parallel/test-source-map.js +++ b/test/parallel/test-source-map.js @@ -225,13 +225,14 @@ function nextdir() { // trace.length === 0 . { - const { ERROR_TEXT } = require('../fixtures/source-map/emptyStackError.js'); const output = spawnSync(process.execPath, [ '--enable-source-maps', require.resolve('../fixtures/source-map/emptyStackError.js') ]); + + console.log(output.stderr.toString()); assert.ok( - output.stderr.toString().match(ERROR_TEXT) + output.stderr.toString().match('emptyStackError') ); } From 2bb3e5d4cfe638fbab320f36f507f2c1a29fb21c Mon Sep 17 00:00:00 2001 From: telenord Date: Wed, 6 Nov 2019 18:21:14 +0300 Subject: [PATCH 3/3] squash! test: test cover prepare_stack_trace in case of trace is empty --- test/parallel/test-source-map.js | 1 - 1 file changed, 1 deletion(-) diff --git a/test/parallel/test-source-map.js b/test/parallel/test-source-map.js index be589935957820..ae7aa5dbd49df0 100644 --- a/test/parallel/test-source-map.js +++ b/test/parallel/test-source-map.js @@ -230,7 +230,6 @@ function nextdir() { require.resolve('../fixtures/source-map/emptyStackError.js') ]); - console.log(output.stderr.toString()); assert.ok( output.stderr.toString().match('emptyStackError') );