From 30e9063b14e925ba50904d14d466c24305f07473 Mon Sep 17 00:00:00 2001 From: Moshe Atlow Date: Mon, 10 Apr 2023 22:55:00 +0300 Subject: [PATCH 01/12] test: migrate message tests to use assertSnapshot --- test/common/assertSnapshot.js | 10 +- test/common/index.js | 5 +- test/{ => fixtures}/message/2100bytes.js | 2 +- .../message/2100bytes.snapshot} | 0 .../message/async_error_eval_cjs.js | 4 +- .../message/async_error_eval_cjs.snapshot} | 3 +- .../message/async_error_eval_esm.js | 4 +- .../message/async_error_eval_esm.snapshot} | 1 + .../message/async_error_microtask_main.js | 4 +- .../async_error_microtask_main.snapshot} | 2 +- .../message/async_error_nexttick_main.js | 4 +- .../async_error_nexttick_main.snapshot} | 4 +- .../message/async_error_sync_esm.mjs | 4 +- .../message/async_error_sync_esm.snapshot} | 2 +- .../message/async_error_sync_main.js | 4 +- .../message/async_error_sync_main.snapshot} | 2 +- test/{ => fixtures}/message/console.js | 2 +- .../message/console.snapshot} | 2 +- .../message/console_low_stack_space.js | 2 +- .../message/console_low_stack_space.snapshot} | 0 .../message/error_aggregateTwoErrors.js | 2 +- .../error_aggregateTwoErrors.snapshot} | 5 +- test/{ => fixtures}/message/error_exit.js | 2 +- .../message/error_exit.snapshot} | 2 +- test/{ => fixtures}/message/error_with_nul.js | 2 +- .../message/error_with_nul.snapshot} | Bin .../events_unhandled_error_common_trace.js | 2 +- ...nts_unhandled_error_common_trace.snapshot} | 2 +- .../events_unhandled_error_nexttick.js | 2 +- .../events_unhandled_error_nexttick.snapshot} | 2 +- .../events_unhandled_error_sameline.js | 2 +- .../events_unhandled_error_sameline.snapshot} | 2 +- .../events_unhandled_error_subclass.js | 2 +- .../events_unhandled_error_subclass.snapshot} | 2 +- test/{ => fixtures}/message/hello_world.js | 2 +- .../message/hello_world.snapshot} | 0 .../message/promise_always_throw_unhandled.js | 2 +- .../promise_always_throw_unhandled.snapshot} | 5 +- .../message/source_map_disabled_by_api.js | 8 +- .../source_map_disabled_by_api.snapshot} | 0 .../message/source_map_enabled_by_api.js | 8 +- .../source_map_enabled_by_api.snapshot} | 0 .../{ => fixtures}/message/source_map_eval.js | 4 +- .../message/source_map_eval.snapshot} | 3 +- .../message/source_map_no_source_file.js | 4 +- .../source_map_no_source_file.snapshot} | 0 .../message/source_map_throw_first_tick.js | 4 +- .../source_map_throw_first_tick.snapshot} | 6 +- test/{ => fixtures}/message/stack_overflow.js | 2 +- .../message/stack_overflow.snapshot} | 2 +- .../message/throw_custom_error.js | 2 +- .../message/throw_custom_error.snapshot} | 3 +- .../message/throw_in_line_with_tabs.js | 2 +- .../message/throw_in_line_with_tabs.snapshot} | 3 +- .../{ => fixtures}/message/throw_non_error.js | 2 +- .../message/throw_non_error.snapshot} | 3 +- .../message/vm_caught_custom_runtime_error.js | 2 +- .../vm_caught_custom_runtime_error.snapshot} | 0 .../message/vm_display_runtime_error.js | 2 +- .../vm_display_runtime_error.snapshot} | 4 +- .../message/vm_display_syntax_error.js | 2 +- .../message/vm_display_syntax_error.snapshot} | 6 +- .../message/vm_dont_display_runtime_error.js | 2 +- .../vm_dont_display_runtime_error.snapshot} | 2 +- .../message/vm_dont_display_syntax_error.js | 2 +- .../vm_dont_display_syntax_error.snapshot} | 2 +- test/parallel/test-node-output.mjs | 123 ++++++++++++++++++ 67 files changed, 218 insertions(+), 84 deletions(-) rename test/{ => fixtures}/message/2100bytes.js (99%) rename test/{message/2100bytes.out => fixtures/message/2100bytes.snapshot} (100%) rename test/{ => fixtures}/message/async_error_eval_cjs.js (88%) rename test/{message/async_error_eval_cjs.out => fixtures/message/async_error_eval_cjs.snapshot} (79%) rename test/{ => fixtures}/message/async_error_eval_esm.js (88%) rename test/{message/async_error_eval_esm.out => fixtures/message/async_error_eval_esm.snapshot} (99%) rename test/{ => fixtures}/message/async_error_microtask_main.js (65%) rename test/{message/async_error_sync_main.out => fixtures/message/async_error_microtask_main.snapshot} (73%) rename test/{ => fixtures}/message/async_error_nexttick_main.js (65%) rename test/{message/async_error_nexttick_main.out => fixtures/message/async_error_nexttick_main.snapshot} (56%) rename test/{ => fixtures}/message/async_error_sync_esm.mjs (57%) rename test/{message/async_error_microtask_main.out => fixtures/message/async_error_sync_esm.snapshot} (73%) rename test/{ => fixtures}/message/async_error_sync_main.js (62%) rename test/{message/async_error_sync_esm.out => fixtures/message/async_error_sync_main.snapshot} (74%) rename test/{ => fixtures}/message/console.js (60%) rename test/{message/console.out => fixtures/message/console.snapshot} (59%) rename test/{ => fixtures}/message/console_low_stack_space.js (97%) rename test/{message/console_low_stack_space.out => fixtures/message/console_low_stack_space.snapshot} (100%) rename test/{ => fixtures}/message/error_aggregateTwoErrors.js (92%) rename test/{message/error_aggregateTwoErrors.out => fixtures/message/error_aggregateTwoErrors.snapshot} (60%) rename test/{ => fixtures}/message/error_exit.js (98%) rename test/{message/error_exit.out => fixtures/message/error_exit.snapshot} (81%) rename test/{ => fixtures}/message/error_with_nul.js (88%) rename test/{message/error_with_nul.out => fixtures/message/error_with_nul.snapshot} (100%) rename test/{ => fixtures}/message/events_unhandled_error_common_trace.js (91%) rename test/{message/events_unhandled_error_common_trace.out => fixtures/message/events_unhandled_error_common_trace.snapshot} (88%) rename test/{ => fixtures}/message/events_unhandled_error_nexttick.js (87%) rename test/{message/events_unhandled_error_nexttick.out => fixtures/message/events_unhandled_error_nexttick.snapshot} (80%) rename test/{ => fixtures}/message/events_unhandled_error_sameline.js (83%) rename test/{message/events_unhandled_error_sameline.out => fixtures/message/events_unhandled_error_sameline.snapshot} (82%) rename test/{ => fixtures}/message/events_unhandled_error_subclass.js (86%) rename test/{message/events_unhandled_error_subclass.out => fixtures/message/events_unhandled_error_subclass.snapshot} (83%) rename test/{ => fixtures}/message/hello_world.js (97%) rename test/{message/hello_world.out => fixtures/message/hello_world.snapshot} (100%) rename test/{ => fixtures}/message/promise_always_throw_unhandled.js (94%) rename test/{message/promise_always_throw_unhandled.out => fixtures/message/promise_always_throw_unhandled.snapshot} (61%) rename test/{ => fixtures}/message/source_map_disabled_by_api.js (55%) rename test/{message/source_map_disabled_by_api.out => fixtures/message/source_map_disabled_by_api.snapshot} (100%) rename test/{ => fixtures}/message/source_map_enabled_by_api.js (51%) rename test/{message/source_map_enabled_by_api.out => fixtures/message/source_map_enabled_by_api.snapshot} (100%) rename test/{ => fixtures}/message/source_map_eval.js (50%) rename test/{message/source_map_eval.out => fixtures/message/source_map_eval.snapshot} (69%) rename test/{ => fixtures}/message/source_map_no_source_file.js (51%) rename test/{message/source_map_no_source_file.out => fixtures/message/source_map_no_source_file.snapshot} (100%) rename test/{ => fixtures}/message/source_map_throw_first_tick.js (50%) rename test/{message/source_map_throw_first_tick.out => fixtures/message/source_map_throw_first_tick.snapshot} (51%) rename test/{ => fixtures}/message/stack_overflow.js (98%) rename test/{message/stack_overflow.out => fixtures/message/stack_overflow.snapshot} (69%) rename test/{ => fixtures}/message/throw_custom_error.js (98%) rename test/{message/throw_custom_error.out => fixtures/message/throw_custom_error.snapshot} (79%) rename test/{ => fixtures}/message/throw_in_line_with_tabs.js (98%) rename test/{message/throw_in_line_with_tabs.out => fixtures/message/throw_in_line_with_tabs.snapshot} (58%) rename test/{ => fixtures}/message/throw_non_error.js (98%) rename test/{message/throw_non_error.out => fixtures/message/throw_non_error.snapshot} (59%) rename test/{ => fixtures}/message/vm_caught_custom_runtime_error.js (94%) rename test/{message/vm_caught_custom_runtime_error.out => fixtures/message/vm_caught_custom_runtime_error.snapshot} (100%) rename test/{ => fixtures}/message/vm_display_runtime_error.js (98%) rename test/{message/vm_display_runtime_error.out => fixtures/message/vm_display_runtime_error.snapshot} (67%) rename test/{ => fixtures}/message/vm_display_syntax_error.js (98%) rename test/{message/vm_display_syntax_error.out => fixtures/message/vm_display_syntax_error.snapshot} (68%) rename test/{ => fixtures}/message/vm_dont_display_runtime_error.js (98%) rename test/{message/vm_dont_display_runtime_error.out => fixtures/message/vm_dont_display_runtime_error.snapshot} (68%) rename test/{ => fixtures}/message/vm_dont_display_syntax_error.js (98%) rename test/{message/vm_dont_display_syntax_error.out => fixtures/message/vm_dont_display_syntax_error.snapshot} (69%) create mode 100644 test/parallel/test-node-output.mjs diff --git a/test/common/assertSnapshot.js b/test/common/assertSnapshot.js index afde9b5d371cd3..98d7b3f03a4758 100644 --- a/test/common/assertSnapshot.js +++ b/test/common/assertSnapshot.js @@ -8,8 +8,8 @@ const assert = require('node:assert/strict'); const stackFramesRegexp = /(\s+)((.+?)\s+\()?(?:\(?(.+?):(\d+)(?::(\d+))?)\)?(\s+\{)?(\n|$)/g; const windowNewlineRegexp = /\r/g; -function replaceStackTrace(str) { - return str.replace(stackFramesRegexp, '$1*$7\n'); +function replaceStackTrace(str, replacement = '$1*$7\n') { + return str.replace(stackFramesRegexp, replacement); } function replaceWindowsLineEndings(str) { @@ -36,11 +36,9 @@ async function assertSnapshot(actual, filename = process.argv[1]) { } async function spawnAndAssert(filename, transform = (x) => x) { - // TODO: Add an option to this function to alternatively or additionally compare stderr. - // For now, tests that want to check stderr or both stdout and stderr can use spawnPromisified. const flags = common.parseTestFlags(filename); - const { stdout } = await common.spawnPromisified(process.execPath, [...flags, filename]); - await assertSnapshot(transform(stdout), filename); + const { stdout, stderr } = await common.spawnPromisified(process.execPath, [...flags, filename]); + await assertSnapshot(transform(`${stdout}${stderr}`), filename); } module.exports = { diff --git a/test/common/index.js b/test/common/index.js index 50ec5eb5d0c8c7..f3caa9d1d4bdce 100644 --- a/test/common/index.js +++ b/test/common/index.js @@ -70,7 +70,7 @@ function parseTestFlags(filename = process.argv[1]) { fs.closeSync(fd); const source = buffer.toString('utf8', 0, bytesRead); - const flagStart = source.indexOf('// Flags: --') + 10; + const flagStart = source.search(/\/\/ Flags:\s+--/) + 10; if (flagStart === 9) { return []; @@ -83,7 +83,8 @@ function parseTestFlags(filename = process.argv[1]) { return source .substring(flagStart, flagEnd) .replace(/_/g, '-') - .split(' '); + .split(/\s+/) + .filter(Boolean); } // Check for flags. Skip this for workers (both, the `cluster` module and diff --git a/test/message/2100bytes.js b/test/fixtures/message/2100bytes.js similarity index 99% rename from test/message/2100bytes.js rename to test/fixtures/message/2100bytes.js index abd8c4b55246ae..5b2a28451160ec 100644 --- a/test/message/2100bytes.js +++ b/test/fixtures/message/2100bytes.js @@ -20,7 +20,7 @@ // USE OR OTHER DEALINGS IN THE SOFTWARE. 'use strict'; -require('../common'); +require('../../common'); console.log([ '_______________________________________________50', diff --git a/test/message/2100bytes.out b/test/fixtures/message/2100bytes.snapshot similarity index 100% rename from test/message/2100bytes.out rename to test/fixtures/message/2100bytes.snapshot diff --git a/test/message/async_error_eval_cjs.js b/test/fixtures/message/async_error_eval_cjs.js similarity index 88% rename from test/message/async_error_eval_cjs.js rename to test/fixtures/message/async_error_eval_cjs.js index d76cabeab116d7..22fbe876582c17 100644 --- a/test/message/async_error_eval_cjs.js +++ b/test/fixtures/message/async_error_eval_cjs.js @@ -1,9 +1,9 @@ 'use strict'; -require('../common'); +require('../../common'); const { spawnSync } = require('child_process'); -const four = require('../common/fixtures') +const four = require('../../common/fixtures') .readSync('async-error.js') .toString() .split('\n') diff --git a/test/message/async_error_eval_cjs.out b/test/fixtures/message/async_error_eval_cjs.snapshot similarity index 79% rename from test/message/async_error_eval_cjs.out rename to test/fixtures/message/async_error_eval_cjs.snapshot index a8d89eebcb6ada..ae9979251f6e0c 100644 --- a/test/message/async_error_eval_cjs.out +++ b/test/fixtures/message/async_error_eval_cjs.snapshot @@ -3,4 +3,5 @@ Error: test at two ([eval]:15:9) at async three ([eval]:18:3) at async four ([eval]:22:3) - at async main ([eval]:28:5) \ No newline at end of file + at async main ([eval]:28:5) + diff --git a/test/message/async_error_eval_esm.js b/test/fixtures/message/async_error_eval_esm.js similarity index 88% rename from test/message/async_error_eval_esm.js rename to test/fixtures/message/async_error_eval_esm.js index efacef779b1712..d568902638b94d 100644 --- a/test/message/async_error_eval_esm.js +++ b/test/fixtures/message/async_error_eval_esm.js @@ -1,9 +1,9 @@ 'use strict'; -require('../common'); +require('../../common'); const { spawnSync } = require('child_process'); -const four = require('../common/fixtures') +const four = require('../../common/fixtures') .readSync('async-error.js') .toString() .split('\n') diff --git a/test/message/async_error_eval_esm.out b/test/fixtures/message/async_error_eval_esm.snapshot similarity index 99% rename from test/message/async_error_eval_esm.out rename to test/fixtures/message/async_error_eval_esm.snapshot index 769fac7a0d408e..0c22264f94de61 100644 --- a/test/message/async_error_eval_esm.out +++ b/test/fixtures/message/async_error_eval_esm.snapshot @@ -4,3 +4,4 @@ Error: test at async three (file:*/[eval1]:18:3) at async four (file:*/[eval1]:22:3) at async main (file:*/[eval1]:28:5) + diff --git a/test/message/async_error_microtask_main.js b/test/fixtures/message/async_error_microtask_main.js similarity index 65% rename from test/message/async_error_microtask_main.js rename to test/fixtures/message/async_error_microtask_main.js index 5520c650addeac..25822ba2f700c0 100644 --- a/test/message/async_error_microtask_main.js +++ b/test/fixtures/message/async_error_microtask_main.js @@ -1,6 +1,6 @@ 'use strict'; -require('../common'); -const four = require('../fixtures/async-error'); +require('../../common'); +const four = require('../async-error'); async function main() { try { diff --git a/test/message/async_error_sync_main.out b/test/fixtures/message/async_error_microtask_main.snapshot similarity index 73% rename from test/message/async_error_sync_main.out rename to test/fixtures/message/async_error_microtask_main.snapshot index 565affbaf750d9..f00abd2b205c60 100644 --- a/test/message/async_error_sync_main.out +++ b/test/fixtures/message/async_error_microtask_main.snapshot @@ -3,4 +3,4 @@ Error: test at two (*fixtures*async-error.js:17:9) at async three (*fixtures*async-error.js:20:3) at async four (*fixtures*async-error.js:24:3) - at async main (*message*async_error_sync_main.js:7:5) + at async main (*fixtures*message*async_error_microtask_main.js:7:5) diff --git a/test/message/async_error_nexttick_main.js b/test/fixtures/message/async_error_nexttick_main.js similarity index 65% rename from test/message/async_error_nexttick_main.js rename to test/fixtures/message/async_error_nexttick_main.js index ecd0531852da8f..8ffa6ae0b9ba56 100644 --- a/test/message/async_error_nexttick_main.js +++ b/test/fixtures/message/async_error_nexttick_main.js @@ -1,6 +1,6 @@ 'use strict'; -require('../common'); -const four = require('../fixtures/async-error'); +require('../../common'); +const four = require('../async-error'); async function main() { try { diff --git a/test/message/async_error_nexttick_main.out b/test/fixtures/message/async_error_nexttick_main.snapshot similarity index 56% rename from test/message/async_error_nexttick_main.out rename to test/fixtures/message/async_error_nexttick_main.snapshot index 9669e9b5102ff9..e765055f684555 100644 --- a/test/message/async_error_nexttick_main.out +++ b/test/fixtures/message/async_error_nexttick_main.snapshot @@ -1,7 +1,7 @@ Error: test at one (*fixtures*async-error.js:4:9) at two (*fixtures*async-error.js:17:9) - at process.processTicksAndRejections (node:internal/process/task_queues:*:*) + at process.processTicksAndRejections (node:internal*process*task_queues:95:5) at async three (*fixtures*async-error.js:20:3) at async four (*fixtures*async-error.js:24:3) - at async main (*message*async_error_nexttick_main.js:7:5) + at async main (*fixtures*message*async_error_nexttick_main.js:7:5) diff --git a/test/message/async_error_sync_esm.mjs b/test/fixtures/message/async_error_sync_esm.mjs similarity index 57% rename from test/message/async_error_sync_esm.mjs rename to test/fixtures/message/async_error_sync_esm.mjs index fdb6a260d1284b..d368ad53f9e172 100644 --- a/test/message/async_error_sync_esm.mjs +++ b/test/fixtures/message/async_error_sync_esm.mjs @@ -1,5 +1,5 @@ -import '../common/index.mjs'; -import four from '../fixtures/async-error.js'; +import '../../common/index.mjs'; +import four from '../async-error.js'; async function main() { try { diff --git a/test/message/async_error_microtask_main.out b/test/fixtures/message/async_error_sync_esm.snapshot similarity index 73% rename from test/message/async_error_microtask_main.out rename to test/fixtures/message/async_error_sync_esm.snapshot index 9512270730a976..b1674e262eede0 100644 --- a/test/message/async_error_microtask_main.out +++ b/test/fixtures/message/async_error_sync_esm.snapshot @@ -3,4 +3,4 @@ Error: test at two (*fixtures*async-error.js:17:9) at async three (*fixtures*async-error.js:20:3) at async four (*fixtures*async-error.js:24:3) - at async main (*message*async_error_microtask_main.js:7:5) + at async main (file:**fixtures*message*async_error_sync_esm.mjs:6:5) diff --git a/test/message/async_error_sync_main.js b/test/fixtures/message/async_error_sync_main.js similarity index 62% rename from test/message/async_error_sync_main.js rename to test/fixtures/message/async_error_sync_main.js index fa33c86d2cf911..4a7b402e2a815f 100644 --- a/test/message/async_error_sync_main.js +++ b/test/fixtures/message/async_error_sync_main.js @@ -1,6 +1,6 @@ 'use strict'; -require('../common'); -const four = require('../fixtures/async-error'); +require('../../common'); +const four = require('../async-error'); async function main() { try { diff --git a/test/message/async_error_sync_esm.out b/test/fixtures/message/async_error_sync_main.snapshot similarity index 74% rename from test/message/async_error_sync_esm.out rename to test/fixtures/message/async_error_sync_main.snapshot index 6054fc7cc22de0..6629d066880491 100644 --- a/test/message/async_error_sync_esm.out +++ b/test/fixtures/message/async_error_sync_main.snapshot @@ -3,4 +3,4 @@ Error: test at two (*fixtures*async-error.js:17:9) at async three (*fixtures*async-error.js:20:3) at async four (*fixtures*async-error.js:24:3) - at async main (*message*async_error_sync_esm.mjs:6:5) + at async main (*fixtures*message*async_error_sync_main.js:7:5) diff --git a/test/message/console.js b/test/fixtures/message/console.js similarity index 60% rename from test/message/console.js rename to test/fixtures/message/console.js index e93e27b3d4f5d2..65916e019f38bd 100644 --- a/test/message/console.js +++ b/test/fixtures/message/console.js @@ -1,5 +1,5 @@ 'use strict'; -require('../common'); +require('../../common'); console.trace('foo'); diff --git a/test/message/console.out b/test/fixtures/message/console.snapshot similarity index 59% rename from test/message/console.out rename to test/fixtures/message/console.snapshot index 57d56028663120..9aabbe5c5f275a 100644 --- a/test/message/console.out +++ b/test/fixtures/message/console.snapshot @@ -1,5 +1,5 @@ Trace: foo - at Object. (*console.js:*:*) + at * at * at * at * diff --git a/test/message/console_low_stack_space.js b/test/fixtures/message/console_low_stack_space.js similarity index 97% rename from test/message/console_low_stack_space.js rename to test/fixtures/message/console_low_stack_space.js index 8954b777d464f6..5093b0c307be0a 100644 --- a/test/message/console_low_stack_space.js +++ b/test/fixtures/message/console_low_stack_space.js @@ -7,7 +7,7 @@ Object.defineProperty(global, 'console', { value: {}, }); -require('../common'); +require('../../common'); // This test checks that, if Node cannot put together the `console` object // because it is low on stack space while doing so, it can succeed later diff --git a/test/message/console_low_stack_space.out b/test/fixtures/message/console_low_stack_space.snapshot similarity index 100% rename from test/message/console_low_stack_space.out rename to test/fixtures/message/console_low_stack_space.snapshot diff --git a/test/message/error_aggregateTwoErrors.js b/test/fixtures/message/error_aggregateTwoErrors.js similarity index 92% rename from test/message/error_aggregateTwoErrors.js rename to test/fixtures/message/error_aggregateTwoErrors.js index 6cb6cce095b295..7a5b3b7b35538c 100644 --- a/test/message/error_aggregateTwoErrors.js +++ b/test/fixtures/message/error_aggregateTwoErrors.js @@ -1,7 +1,7 @@ // Flags: --expose-internals 'use strict'; -require('../common'); +require('../../common'); Error.stackTraceLimit = 1; const { aggregateTwoErrors } = require('internal/errors'); diff --git a/test/message/error_aggregateTwoErrors.out b/test/fixtures/message/error_aggregateTwoErrors.snapshot similarity index 60% rename from test/message/error_aggregateTwoErrors.out rename to test/fixtures/message/error_aggregateTwoErrors.snapshot index a84ae7325000b9..a8d13c461b2cb0 100644 --- a/test/message/error_aggregateTwoErrors.out +++ b/test/fixtures/message/error_aggregateTwoErrors.snapshot @@ -1,15 +1,16 @@ *error_aggregateTwoErrors.js:* throw aggregateTwoErrors(err, originalError); ^ + [AggregateError: original] { code: 'ERR0', [errors]: [ Error: original - at Object. (*test*message*error_aggregateTwoErrors.js:*:*) { + at Object. (*error_aggregateTwoErrors.js:*:*) { code: 'ERR0' }, Error: second error - at Object. (*test*message*error_aggregateTwoErrors.js:*:*) { + at Object. (*error_aggregateTwoErrors.js:*:*) { code: 'ERR1' } ] diff --git a/test/message/error_exit.js b/test/fixtures/message/error_exit.js similarity index 98% rename from test/message/error_exit.js rename to test/fixtures/message/error_exit.js index 51d303015fd8ac..dbe66b8ee0d568 100644 --- a/test/message/error_exit.js +++ b/test/fixtures/message/error_exit.js @@ -20,7 +20,7 @@ // USE OR OTHER DEALINGS IN THE SOFTWARE. 'use strict'; -require('../common'); +require('../../common'); Error.stackTraceLimit = 1; const assert = require('assert'); diff --git a/test/message/error_exit.out b/test/fixtures/message/error_exit.snapshot similarity index 81% rename from test/message/error_exit.out rename to test/fixtures/message/error_exit.snapshot index 4ee2f083b63569..778165dc25c4fc 100644 --- a/test/message/error_exit.out +++ b/test/fixtures/message/error_exit.snapshot @@ -7,7 +7,7 @@ AssertionError [ERR_ASSERTION]: Expected values to be strictly equal: 1 !== 2 - at Object. (*test*message*error_exit.js:*:*) { + at Object. (*error_exit.js:*:*) { generatedMessage: true, code: 'ERR_ASSERTION', actual: 1, diff --git a/test/message/error_with_nul.js b/test/fixtures/message/error_with_nul.js similarity index 88% rename from test/message/error_with_nul.js rename to test/fixtures/message/error_with_nul.js index de49c383fd41a0..086672b9bbcb1e 100644 --- a/test/message/error_with_nul.js +++ b/test/fixtures/message/error_with_nul.js @@ -1,5 +1,5 @@ 'use strict'; -require('../common'); +require('../../common'); Error.stackTraceLimit = 2; function test() { diff --git a/test/message/error_with_nul.out b/test/fixtures/message/error_with_nul.snapshot similarity index 100% rename from test/message/error_with_nul.out rename to test/fixtures/message/error_with_nul.snapshot diff --git a/test/message/events_unhandled_error_common_trace.js b/test/fixtures/message/events_unhandled_error_common_trace.js similarity index 91% rename from test/message/events_unhandled_error_common_trace.js rename to test/fixtures/message/events_unhandled_error_common_trace.js index 6ec4bed948d404..1e35a3a9832254 100644 --- a/test/message/events_unhandled_error_common_trace.js +++ b/test/fixtures/message/events_unhandled_error_common_trace.js @@ -1,5 +1,5 @@ 'use strict'; -require('../common'); +require('../../common'); Error.stackTraceLimit = 2; const EventEmitter = require('events'); diff --git a/test/message/events_unhandled_error_common_trace.out b/test/fixtures/message/events_unhandled_error_common_trace.snapshot similarity index 88% rename from test/message/events_unhandled_error_common_trace.out rename to test/fixtures/message/events_unhandled_error_common_trace.snapshot index a3747cfdd32c31..a482c105b75e48 100644 --- a/test/message/events_unhandled_error_common_trace.out +++ b/test/fixtures/message/events_unhandled_error_common_trace.snapshot @@ -1,5 +1,5 @@ node:events:* - throw er; // Unhandled 'error' event + throw er; * Unhandled 'error' event ^ Error: foo:bar diff --git a/test/message/events_unhandled_error_nexttick.js b/test/fixtures/message/events_unhandled_error_nexttick.js similarity index 87% rename from test/message/events_unhandled_error_nexttick.js rename to test/fixtures/message/events_unhandled_error_nexttick.js index bf508c9788757d..7072781586ddaf 100644 --- a/test/message/events_unhandled_error_nexttick.js +++ b/test/fixtures/message/events_unhandled_error_nexttick.js @@ -1,5 +1,5 @@ 'use strict'; -require('../common'); +require('../../common'); Error.stackTraceLimit = 1; const EventEmitter = require('events'); diff --git a/test/message/events_unhandled_error_nexttick.out b/test/fixtures/message/events_unhandled_error_nexttick.snapshot similarity index 80% rename from test/message/events_unhandled_error_nexttick.out rename to test/fixtures/message/events_unhandled_error_nexttick.snapshot index 7b616c22e37302..450d4910a385b5 100644 --- a/test/message/events_unhandled_error_nexttick.out +++ b/test/fixtures/message/events_unhandled_error_nexttick.snapshot @@ -1,5 +1,5 @@ node:events:* - throw er; // Unhandled 'error' event + throw er; * Unhandled 'error' event ^ Error diff --git a/test/message/events_unhandled_error_sameline.js b/test/fixtures/message/events_unhandled_error_sameline.js similarity index 83% rename from test/message/events_unhandled_error_sameline.js rename to test/fixtures/message/events_unhandled_error_sameline.js index 6dad22dd58e393..d9a01050feab12 100644 --- a/test/message/events_unhandled_error_sameline.js +++ b/test/fixtures/message/events_unhandled_error_sameline.js @@ -1,5 +1,5 @@ 'use strict'; -require('../common'); +require('../../common'); Error.stackTraceLimit = 1; const EventEmitter = require('events'); diff --git a/test/message/events_unhandled_error_sameline.out b/test/fixtures/message/events_unhandled_error_sameline.snapshot similarity index 82% rename from test/message/events_unhandled_error_sameline.out rename to test/fixtures/message/events_unhandled_error_sameline.snapshot index dd12176259badf..520601e617083c 100644 --- a/test/message/events_unhandled_error_sameline.out +++ b/test/fixtures/message/events_unhandled_error_sameline.snapshot @@ -1,5 +1,5 @@ node:events:* - throw er; // Unhandled 'error' event + throw er; * Unhandled 'error' event ^ Error diff --git a/test/message/events_unhandled_error_subclass.js b/test/fixtures/message/events_unhandled_error_subclass.js similarity index 86% rename from test/message/events_unhandled_error_subclass.js rename to test/fixtures/message/events_unhandled_error_subclass.js index 5fc3bc26fb4e93..2131771944faf5 100644 --- a/test/message/events_unhandled_error_subclass.js +++ b/test/fixtures/message/events_unhandled_error_subclass.js @@ -1,5 +1,5 @@ 'use strict'; -require('../common'); +require('../../common'); Error.stackTraceLimit = 1; const EventEmitter = require('events'); diff --git a/test/message/events_unhandled_error_subclass.out b/test/fixtures/message/events_unhandled_error_subclass.snapshot similarity index 83% rename from test/message/events_unhandled_error_subclass.out rename to test/fixtures/message/events_unhandled_error_subclass.snapshot index 3d5d0307e6d792..6a9cfd4a1a0b21 100644 --- a/test/message/events_unhandled_error_subclass.out +++ b/test/fixtures/message/events_unhandled_error_subclass.snapshot @@ -1,5 +1,5 @@ node:events:* - throw er; // Unhandled 'error' event + throw er; * Unhandled 'error' event ^ Error diff --git a/test/message/hello_world.js b/test/fixtures/message/hello_world.js similarity index 97% rename from test/message/hello_world.js rename to test/fixtures/message/hello_world.js index f3b1f8377f37f2..c32cb09f6009b2 100644 --- a/test/message/hello_world.js +++ b/test/fixtures/message/hello_world.js @@ -20,6 +20,6 @@ // USE OR OTHER DEALINGS IN THE SOFTWARE. 'use strict'; -require('../common'); +require('../../common'); console.log('hello world'); diff --git a/test/message/hello_world.out b/test/fixtures/message/hello_world.snapshot similarity index 100% rename from test/message/hello_world.out rename to test/fixtures/message/hello_world.snapshot diff --git a/test/message/promise_always_throw_unhandled.js b/test/fixtures/message/promise_always_throw_unhandled.js similarity index 94% rename from test/message/promise_always_throw_unhandled.js rename to test/fixtures/message/promise_always_throw_unhandled.js index d9128f34a5c9f1..25d1642a65de41 100644 --- a/test/message/promise_always_throw_unhandled.js +++ b/test/fixtures/message/promise_always_throw_unhandled.js @@ -1,7 +1,7 @@ // Flags: --unhandled-rejections=strict 'use strict'; -require('../common'); +require('../../common'); // Check that the process will exit on the first unhandled rejection in case the // unhandled rejections mode is set to `'strict'`. diff --git a/test/message/promise_always_throw_unhandled.out b/test/fixtures/message/promise_always_throw_unhandled.snapshot similarity index 61% rename from test/message/promise_always_throw_unhandled.out rename to test/fixtures/message/promise_always_throw_unhandled.snapshot index bc2949391c16d7..c97540f5499f87 100644 --- a/test/message/promise_always_throw_unhandled.out +++ b/test/fixtures/message/promise_always_throw_unhandled.snapshot @@ -1,10 +1,11 @@ *promise_always_throw_unhandled.js:* throw new Error('One'); ^ + Error: One - at *promise_always_throw_unhandled.js:*:* + at * at new Promise () - at Object. (*promise_always_throw_unhandled.js:*:*) + at * at * at * at * diff --git a/test/message/source_map_disabled_by_api.js b/test/fixtures/message/source_map_disabled_by_api.js similarity index 55% rename from test/message/source_map_disabled_by_api.js rename to test/fixtures/message/source_map_disabled_by_api.js index 93c87f10c14931..3d24f4458a6435 100644 --- a/test/message/source_map_disabled_by_api.js +++ b/test/fixtures/message/source_map_disabled_by_api.js @@ -1,25 +1,25 @@ // Flags: --enable-source-maps 'use strict'; -require('../common'); +require('../../common'); Error.stackTraceLimit = 5; process.setSourceMapsEnabled(false); try { - require('../fixtures/source-map/enclosing-call-site-min.js'); + require('../source-map/enclosing-call-site-min.js'); } catch (e) { console.log(e); } delete require.cache[require - .resolve('../fixtures/source-map/enclosing-call-site-min.js')]; + .resolve('../source-map/enclosing-call-site-min.js')]; // Re-enable. process.setSourceMapsEnabled(true); try { - require('../fixtures/source-map/enclosing-call-site-min.js'); + require('../source-map/enclosing-call-site-min.js'); } catch (e) { console.log(e); } diff --git a/test/message/source_map_disabled_by_api.out b/test/fixtures/message/source_map_disabled_by_api.snapshot similarity index 100% rename from test/message/source_map_disabled_by_api.out rename to test/fixtures/message/source_map_disabled_by_api.snapshot diff --git a/test/message/source_map_enabled_by_api.js b/test/fixtures/message/source_map_enabled_by_api.js similarity index 51% rename from test/message/source_map_enabled_by_api.js rename to test/fixtures/message/source_map_enabled_by_api.js index f0308b19598988..42fec15e9a8875 100644 --- a/test/message/source_map_enabled_by_api.js +++ b/test/fixtures/message/source_map_enabled_by_api.js @@ -1,22 +1,22 @@ 'use strict'; -require('../common'); +require('../../common'); Error.stackTraceLimit = 5; process.setSourceMapsEnabled(true); try { - require('../fixtures/source-map/enclosing-call-site-min.js'); + require('../source-map/enclosing-call-site-min.js'); } catch (e) { console.log(e); } delete require.cache[require - .resolve('../fixtures/source-map/enclosing-call-site-min.js')]; + .resolve('../source-map/enclosing-call-site-min.js')]; process.setSourceMapsEnabled(false); try { - require('../fixtures/source-map/enclosing-call-site-min.js'); + require('../source-map/enclosing-call-site-min.js'); } catch (e) { console.log(e); } diff --git a/test/message/source_map_enabled_by_api.out b/test/fixtures/message/source_map_enabled_by_api.snapshot similarity index 100% rename from test/message/source_map_enabled_by_api.out rename to test/fixtures/message/source_map_enabled_by_api.snapshot diff --git a/test/message/source_map_eval.js b/test/fixtures/message/source_map_eval.js similarity index 50% rename from test/message/source_map_eval.js rename to test/fixtures/message/source_map_eval.js index 404793f05412e4..f03ddf0fb1ddb0 100644 --- a/test/message/source_map_eval.js +++ b/test/fixtures/message/source_map_eval.js @@ -1,10 +1,10 @@ // Flags: --enable-source-maps 'use strict'; -require('../common'); +require('../../common'); Error.stackTraceLimit = 3; const fs = require('fs'); -const content = fs.readFileSync(require.resolve('../fixtures/source-map/tabs.js'), 'utf8'); +const content = fs.readFileSync(require.resolve('../source-map/tabs.js'), 'utf8'); eval(content); diff --git a/test/message/source_map_eval.out b/test/fixtures/message/source_map_eval.snapshot similarity index 69% rename from test/message/source_map_eval.out rename to test/fixtures/message/source_map_eval.snapshot index 5d97e137f7f824..080615f16a3dfd 100644 --- a/test/message/source_map_eval.out +++ b/test/fixtures/message/source_map_eval.snapshot @@ -2,9 +2,10 @@ alert "I knew it!" ^ + ReferenceError: alert is not defined at Object.eval (*tabs.coffee:26:2) at eval (*tabs.coffee:1:14) - at Object. (*source_map_eval.js:*:*) + at Object. (*fixtures*message*source_map_eval.js:10:1) Node.js * diff --git a/test/message/source_map_no_source_file.js b/test/fixtures/message/source_map_no_source_file.js similarity index 51% rename from test/message/source_map_no_source_file.js rename to test/fixtures/message/source_map_no_source_file.js index 53c53416248b77..4a71cb9aacf0cf 100644 --- a/test/message/source_map_no_source_file.js +++ b/test/fixtures/message/source_map_no_source_file.js @@ -1,7 +1,7 @@ // Flags: --enable-source-maps 'use strict'; -require('../common'); +require('../../common'); Error.stackTraceLimit = 2; -require('../fixtures/source-map/no-source.js'); +require('..//source-map/no-source.js'); diff --git a/test/message/source_map_no_source_file.out b/test/fixtures/message/source_map_no_source_file.snapshot similarity index 100% rename from test/message/source_map_no_source_file.out rename to test/fixtures/message/source_map_no_source_file.snapshot diff --git a/test/message/source_map_throw_first_tick.js b/test/fixtures/message/source_map_throw_first_tick.js similarity index 50% rename from test/message/source_map_throw_first_tick.js rename to test/fixtures/message/source_map_throw_first_tick.js index 9bf1a353cf18be..302818eabadb99 100644 --- a/test/message/source_map_throw_first_tick.js +++ b/test/fixtures/message/source_map_throw_first_tick.js @@ -1,7 +1,7 @@ // Flags: --enable-source-maps 'use strict'; -require('../common'); +require('../../common'); Error.stackTraceLimit = 2; -require('../fixtures/source-map/typescript-throw'); +require('../source-map/typescript-throw'); diff --git a/test/message/source_map_throw_first_tick.out b/test/fixtures/message/source_map_throw_first_tick.snapshot similarity index 51% rename from test/message/source_map_throw_first_tick.out rename to test/fixtures/message/source_map_throw_first_tick.snapshot index 792be67aae089f..fba8c95cc1103f 100644 --- a/test/message/source_map_throw_first_tick.out +++ b/test/fixtures/message/source_map_throw_first_tick.snapshot @@ -2,8 +2,10 @@ reachable *typescript-throw.ts:18 throw Error('an exception'); ^ + + Error: an exception - at *typescript-throw.ts:18:11* - at *typescript-throw.ts:24:1* + at branch (*typescript-throw.ts:18:11) + at Object. (*typescript-throw.ts:24:1) Node.js * diff --git a/test/message/stack_overflow.js b/test/fixtures/message/stack_overflow.js similarity index 98% rename from test/message/stack_overflow.js rename to test/fixtures/message/stack_overflow.js index 9541ee78409b5d..565692b6d6e4ba 100644 --- a/test/message/stack_overflow.js +++ b/test/fixtures/message/stack_overflow.js @@ -20,7 +20,7 @@ // USE OR OTHER DEALINGS IN THE SOFTWARE. 'use strict'; -require('../common'); +require('../../common'); Error.stackTraceLimit = 0; diff --git a/test/message/stack_overflow.out b/test/fixtures/message/stack_overflow.snapshot similarity index 69% rename from test/message/stack_overflow.out rename to test/fixtures/message/stack_overflow.snapshot index fb378994672288..2aa5a13dc4f0ef 100644 --- a/test/message/stack_overflow.out +++ b/test/fixtures/message/stack_overflow.snapshot @@ -1,5 +1,5 @@ before -*test*message*stack_overflow.js:* +*test*fixtures*message*stack_overflow.js:* JSON.stringify(array); ^ diff --git a/test/message/throw_custom_error.js b/test/fixtures/message/throw_custom_error.js similarity index 98% rename from test/message/throw_custom_error.js rename to test/fixtures/message/throw_custom_error.js index 3e0e6a271c7415..1cf6108af716a1 100644 --- a/test/message/throw_custom_error.js +++ b/test/fixtures/message/throw_custom_error.js @@ -20,7 +20,7 @@ // USE OR OTHER DEALINGS IN THE SOFTWARE. 'use strict'; -require('../common'); +require('../../common'); // Custom error throwing // eslint-disable-next-line no-throw-literal diff --git a/test/message/throw_custom_error.out b/test/fixtures/message/throw_custom_error.snapshot similarity index 79% rename from test/message/throw_custom_error.out rename to test/fixtures/message/throw_custom_error.snapshot index 920cbf62310f39..ba80020c897a32 100644 --- a/test/message/throw_custom_error.out +++ b/test/fixtures/message/throw_custom_error.snapshot @@ -1,4 +1,5 @@ -*test*message*throw_custom_error.js:* + +*throw_custom_error.js:* throw ({ name: 'MyCustomError', message: 'This is a custom message' }); ^ { name: 'MyCustomError', message: 'This is a custom message' } diff --git a/test/message/throw_in_line_with_tabs.js b/test/fixtures/message/throw_in_line_with_tabs.js similarity index 98% rename from test/message/throw_in_line_with_tabs.js rename to test/fixtures/message/throw_in_line_with_tabs.js index ab059916b2c8da..b62d422597904a 100644 --- a/test/message/throw_in_line_with_tabs.js +++ b/test/fixtures/message/throw_in_line_with_tabs.js @@ -21,7 +21,7 @@ /* eslint-disable indent, no-tabs */ 'use strict'; -require('../common'); +require('../../common'); console.error('before'); diff --git a/test/message/throw_in_line_with_tabs.out b/test/fixtures/message/throw_in_line_with_tabs.snapshot similarity index 58% rename from test/message/throw_in_line_with_tabs.out rename to test/fixtures/message/throw_in_line_with_tabs.snapshot index 0d71e91b75c2e7..29c7e1ec3587d9 100644 --- a/test/message/throw_in_line_with_tabs.out +++ b/test/fixtures/message/throw_in_line_with_tabs.snapshot @@ -1,5 +1,6 @@ before -*test*message*throw_in_line_with_tabs.js:* + +*throw_in_line_with_tabs.js:* throw ({ foo: 'bar' }); ^ { foo: 'bar' } diff --git a/test/message/throw_non_error.js b/test/fixtures/message/throw_non_error.js similarity index 98% rename from test/message/throw_non_error.js rename to test/fixtures/message/throw_non_error.js index fc1a568015aaf2..e1b239aa261d28 100644 --- a/test/message/throw_non_error.js +++ b/test/fixtures/message/throw_non_error.js @@ -20,7 +20,7 @@ // USE OR OTHER DEALINGS IN THE SOFTWARE. 'use strict'; -require('../common'); +require('../../common'); // Custom error throwing // eslint-disable-next-line no-throw-literal diff --git a/test/message/throw_non_error.out b/test/fixtures/message/throw_non_error.snapshot similarity index 59% rename from test/message/throw_non_error.out rename to test/fixtures/message/throw_non_error.snapshot index 665c9b4fd1d0c3..4ad80df4f6a9cb 100644 --- a/test/message/throw_non_error.out +++ b/test/fixtures/message/throw_non_error.snapshot @@ -1,4 +1,5 @@ -*test*message*throw_non_error.js:* + +*throw_non_error.js:* throw ({ foo: 'bar' }); ^ { foo: 'bar' } diff --git a/test/message/vm_caught_custom_runtime_error.js b/test/fixtures/message/vm_caught_custom_runtime_error.js similarity index 94% rename from test/message/vm_caught_custom_runtime_error.js rename to test/fixtures/message/vm_caught_custom_runtime_error.js index 237e8e3a105436..81349fc9bf0ec5 100644 --- a/test/message/vm_caught_custom_runtime_error.js +++ b/test/fixtures/message/vm_caught_custom_runtime_error.js @@ -1,5 +1,5 @@ 'use strict'; -require('../common'); +require('../../common'); const vm = require('vm'); console.error('beginning'); diff --git a/test/message/vm_caught_custom_runtime_error.out b/test/fixtures/message/vm_caught_custom_runtime_error.snapshot similarity index 100% rename from test/message/vm_caught_custom_runtime_error.out rename to test/fixtures/message/vm_caught_custom_runtime_error.snapshot diff --git a/test/message/vm_display_runtime_error.js b/test/fixtures/message/vm_display_runtime_error.js similarity index 98% rename from test/message/vm_display_runtime_error.js rename to test/fixtures/message/vm_display_runtime_error.js index 80505cb02f3f3b..390727d1f00988 100644 --- a/test/message/vm_display_runtime_error.js +++ b/test/fixtures/message/vm_display_runtime_error.js @@ -20,7 +20,7 @@ // USE OR OTHER DEALINGS IN THE SOFTWARE. 'use strict'; -require('../common'); +require('../../common'); Error.stackTraceLimit = 4; const vm = require('vm'); diff --git a/test/message/vm_display_runtime_error.out b/test/fixtures/message/vm_display_runtime_error.snapshot similarity index 67% rename from test/message/vm_display_runtime_error.out rename to test/fixtures/message/vm_display_runtime_error.snapshot index 6dc8a703b4b7cd..4d613dacd2947b 100644 --- a/test/message/vm_display_runtime_error.out +++ b/test/fixtures/message/vm_display_runtime_error.snapshot @@ -7,7 +7,7 @@ Error: boo! at test.vm:1:7 at Script.runInThisContext (node:vm:*) at Object.runInThisContext (node:vm:*) - at Object. (*test*message*vm_display_runtime_error.js:*) + at Object. (*fixtures*message*vm_display_runtime_error.js:31:6) test.vm:1 throw new Error("spooky!") ^ @@ -16,6 +16,6 @@ Error: spooky! at test.vm:1:7 at Script.runInThisContext (node:vm:*) at Object.runInThisContext (node:vm:*) - at Object. (*test*message*vm_display_runtime_error.js:*) + at Object. (*fixtures*message*vm_display_runtime_error.js:36:4) Node.js * diff --git a/test/message/vm_display_syntax_error.js b/test/fixtures/message/vm_display_syntax_error.js similarity index 98% rename from test/message/vm_display_syntax_error.js rename to test/fixtures/message/vm_display_syntax_error.js index f47d8d477ececc..9d802eac624f76 100644 --- a/test/message/vm_display_syntax_error.js +++ b/test/fixtures/message/vm_display_syntax_error.js @@ -20,7 +20,7 @@ // USE OR OTHER DEALINGS IN THE SOFTWARE. 'use strict'; -require('../common'); +require('../../common'); Error.stackTraceLimit = 4; const vm = require('vm'); diff --git a/test/message/vm_display_syntax_error.out b/test/fixtures/message/vm_display_syntax_error.snapshot similarity index 68% rename from test/message/vm_display_syntax_error.out rename to test/fixtures/message/vm_display_syntax_error.snapshot index 371ebfccdc3e1d..5bc8fc7cd64656 100644 --- a/test/message/vm_display_syntax_error.out +++ b/test/fixtures/message/vm_display_syntax_error.snapshot @@ -2,18 +2,20 @@ beginning foo.vm:1 var 4; ^ + SyntaxError: Unexpected number at new Script (node:vm:*) at createScript (node:vm:*) at Object.runInThisContext (node:vm:*) - at Object. (*test*message*vm_display_syntax_error.js:*) + at Object. (*fixtures*message*vm_display_syntax_error.js:31:6) test.vm:1 var 5; ^ + SyntaxError: Unexpected number at new Script (node:vm:*) at createScript (node:vm:*) at Object.runInThisContext (node:vm:*) - at Object. (*test*message*vm_display_syntax_error.js:*) + at Object. (*fixtures*message*vm_display_syntax_error.js:36:4) Node.js * diff --git a/test/message/vm_dont_display_runtime_error.js b/test/fixtures/message/vm_dont_display_runtime_error.js similarity index 98% rename from test/message/vm_dont_display_runtime_error.js rename to test/fixtures/message/vm_dont_display_runtime_error.js index 2dff567fb9e4c6..128a312cc8979f 100644 --- a/test/message/vm_dont_display_runtime_error.js +++ b/test/fixtures/message/vm_dont_display_runtime_error.js @@ -20,7 +20,7 @@ // USE OR OTHER DEALINGS IN THE SOFTWARE. 'use strict'; -require('../common'); +require('../../common'); Error.stackTraceLimit = 4; const vm = require('vm'); diff --git a/test/message/vm_dont_display_runtime_error.out b/test/fixtures/message/vm_dont_display_runtime_error.snapshot similarity index 68% rename from test/message/vm_dont_display_runtime_error.out rename to test/fixtures/message/vm_dont_display_runtime_error.snapshot index 78b6a67c5aff2f..9c10435edf86ac 100644 --- a/test/message/vm_dont_display_runtime_error.out +++ b/test/fixtures/message/vm_dont_display_runtime_error.snapshot @@ -8,6 +8,6 @@ Error: boo! at test.vm:1:7 at Script.runInThisContext (node:vm:*) at Object.runInThisContext (node:vm:*) - at Object. (*test*message*vm_dont_display_runtime_error.js:*) + at Object. (*fixtures*message*vm_dont_display_runtime_error.js:41:4) Node.js * diff --git a/test/message/vm_dont_display_syntax_error.js b/test/fixtures/message/vm_dont_display_syntax_error.js similarity index 98% rename from test/message/vm_dont_display_syntax_error.js rename to test/fixtures/message/vm_dont_display_syntax_error.js index 821933a6113bb9..6ce013b42364a8 100644 --- a/test/message/vm_dont_display_syntax_error.js +++ b/test/fixtures/message/vm_dont_display_syntax_error.js @@ -20,7 +20,7 @@ // USE OR OTHER DEALINGS IN THE SOFTWARE. 'use strict'; -require('../common'); +require('../../common'); Error.stackTraceLimit = 4; const vm = require('vm'); diff --git a/test/message/vm_dont_display_syntax_error.out b/test/fixtures/message/vm_dont_display_syntax_error.snapshot similarity index 69% rename from test/message/vm_dont_display_syntax_error.out rename to test/fixtures/message/vm_dont_display_syntax_error.snapshot index d7849361d5d230..fdbf879895e8a2 100644 --- a/test/message/vm_dont_display_syntax_error.out +++ b/test/fixtures/message/vm_dont_display_syntax_error.snapshot @@ -8,6 +8,6 @@ SyntaxError: Unexpected number at new Script (node:vm:*) at createScript (node:vm:*) at Object.runInThisContext (node:vm:*) - at Object. (*test*message*vm_dont_display_syntax_error.js:*) + at Object. (*fixtures*message*vm_dont_display_syntax_error.js:41:4) Node.js * diff --git a/test/parallel/test-node-output.mjs b/test/parallel/test-node-output.mjs new file mode 100644 index 00000000000000..2112962548ad8d --- /dev/null +++ b/test/parallel/test-node-output.mjs @@ -0,0 +1,123 @@ +import '../common/index.mjs'; +import * as fixtures from '../common/fixtures.mjs'; +import * as snapshot from '../common/assertSnapshot.js'; +import { describe, it } from 'node:test'; + +function replaceNodeVersion(str) { + return str.replaceAll(process.version, '*'); +} + +function replaceStackTrace(str) { + return snapshot.replaceStackTrace(str, '$1at *$7\n'); +} + +describe('console', { concurrency: true }, () => { + function stackTrace(str) { + return str.replaceAll(process.cwd(), '').replaceAll('/', '*').replaceAll(/\d+/g, '*'); + } + const tests = [ + { name: 'message/2100bytes.js' }, + { name: 'message/console_low_stack_space.js' }, + { name: 'message/console.js' }, + { name: 'message/hello_world.js' }, + { + name: 'message/stack_overflow.js', + transform: snapshot.transform(snapshot.replaceWindowsLineEndings, replaceNodeVersion, stackTrace) + }, + ]; + const defaultTransform = snapshot.transform(snapshot.replaceWindowsLineEndings, replaceStackTrace); + for (const { name, transform } of tests) { + it(name, async () => { + await snapshot.spawnAndAssert(fixtures.path(name), transform ?? defaultTransform); + }); + } +}); + +describe('errors', { concurrency: true }, () => { + function normalize(str) { + return str.replaceAll(process.cwd(), '').replaceAll('//', '*').replaceAll(/\/(\w)/g, '*$1').replaceAll('*test*', '*'); + } + + function normalizeNoNumbers(str) { + return normalize(str).replaceAll(/\d+:\d+/g, '*:*').replaceAll(/:\d+/g, ':*').replaceAll('*fixtures*message*', '*'); + } + const defaultTransform = snapshot.transform(snapshot.replaceWindowsLineEndings, replaceNodeVersion, normalize); + const errTransform = snapshot.transform(snapshot.replaceWindowsLineEndings, replaceNodeVersion, normalizeNoNumbers); + const promiseTransform = snapshot + .transform(snapshot.replaceWindowsLineEndings, replaceStackTrace, normalizeNoNumbers, replaceNodeVersion); + + const tests = [ + { name: 'message/async_error_eval_cjs.js' }, + { name: 'message/async_error_eval_esm.js' }, + { name: 'message/async_error_microtask_main.js' }, + { name: 'message/async_error_nexttick_main.js' }, + { name: 'message/async_error_sync_main.js' }, + { name: 'message/async_error_sync_esm.mjs' }, + { name: 'message/error_aggregateTwoErrors.js', transform: errTransform }, + { name: 'message/error_exit.js', transform: errTransform }, + { name: 'message/error_with_nul.js', transform: errTransform }, + { name: 'message/events_unhandled_error_common_trace.js', transform: errTransform }, + { name: 'message/events_unhandled_error_nexttick.js', transform: errTransform }, + { name: 'message/events_unhandled_error_sameline.js', transform: errTransform }, + { name: 'message/events_unhandled_error_subclass.js', transform: errTransform }, + { name: 'message/throw_custom_error.js', transform: errTransform }, + { name: 'message/throw_in_line_with_tabs.js', transform: errTransform }, + { name: 'message/throw_non_error.js', transform: errTransform }, + { name: 'message/promise_always_throw_unhandled.js', transform: promiseTransform }, + ]; + for (const { name, transform } of tests) { + it(name, async () => { + await snapshot.spawnAndAssert(fixtures.path(name), transform ?? defaultTransform); + }); + } +}); + +describe('sourcemaps', { concurrency: true }, () => { + function normalize(str) { + return str.replaceAll(process.cwd(), '') + .replaceAll('//', '*') + .replaceAll('/Users/bencoe/oss/coffee-script-test', '') + .replaceAll(/\/(\w)/g, '*$1') + .replaceAll('*test*', '*') + .replaceAll('*fixtures*source-map*', '*'); + } + const defaultTransform = snapshot.transform(snapshot.replaceWindowsLineEndings, replaceNodeVersion, normalize); + + const tests = [ + { name: 'message/source_map_disabled_by_api.js' }, + { name: 'message/source_map_enabled_by_api.js' }, + { name: 'message/source_map_eval.js' }, + { name: 'message/source_map_no_source_file.js' }, + { name: 'message/source_map_throw_first_tick.js' }, + ]; + for (const { name, transform } of tests) { + it(name, async () => { + await snapshot.spawnAndAssert(fixtures.path(name), transform ?? defaultTransform); + }); + } +}); + +describe('vm', { concurrency: true }, () => { + function normalize(str) { + return str.replaceAll(process.cwd(), '').replaceAll('//', '*').replaceAll(/\/(\w)/g, '*$1').replaceAll('*test*', '*'); + } + + function normalizeNoNumbers(str) { + return normalize(str).replaceAll(/node:vm:\d+:\d+/g, 'node:vm:*'); + } + const defaultTransform = snapshot + .transform(snapshot.replaceWindowsLineEndings, replaceNodeVersion, normalizeNoNumbers); + + const tests = [ + { name: 'message/vm_caught_custom_runtime_error.js' }, + { name: 'message/vm_display_runtime_error.js' }, + { name: 'message/vm_display_syntax_error.js' }, + { name: 'message/vm_dont_display_runtime_error.js' }, + { name: 'message/vm_dont_display_syntax_error.js' }, + ]; + for (const { name, transform } of tests) { + it(name, async () => { + await snapshot.spawnAndAssert(fixtures.path(name), transform ?? defaultTransform); + }); + } +}); From 9642476c45f329bc303fee99735d4c8cb46a94ed Mon Sep 17 00:00:00 2001 From: Moshe Atlow Date: Tue, 25 Apr 2023 01:12:27 +0300 Subject: [PATCH 02/12] CR --- test/common/assertSnapshot.js | 14 ++ .../{message => console}/2100bytes.js | 0 .../{message => console}/2100bytes.snapshot | 0 test/fixtures/{message => console}/console.js | 0 .../{message => console}/console.snapshot | 0 .../console_low_stack_space.js | 0 .../console_low_stack_space.snapshot | 0 .../{message => console}/hello_world.js | 0 .../{message => console}/hello_world.snapshot | 0 .../{message => console}/stack_overflow.js | 0 .../stack_overflow.snapshot | 2 +- .../async_error_eval_cjs.js | 0 .../async_error_eval_cjs.snapshot | 0 .../async_error_eval_esm.js | 0 .../async_error_eval_esm.snapshot | 0 .../async_error_microtask_main.js | 0 .../async_error_microtask_main.snapshot | 2 +- .../async_error_nexttick_main.js | 0 .../async_error_nexttick_main.snapshot | 2 +- .../async_error_sync_esm.mjs | 0 .../async_error_sync_esm.snapshot | 2 +- .../async_error_sync_main.js | 0 .../async_error_sync_main.snapshot | 2 +- .../error_aggregateTwoErrors.js | 0 .../error_aggregateTwoErrors.snapshot | 6 +- .../{message => errors}/error_exit.js | 0 .../{message => errors}/error_exit.snapshot | 2 +- .../{message => errors}/error_with_nul.js | 0 test/fixtures/errors/error_with_nul.snapshot | Bin 0 -> 222 bytes .../events_unhandled_error_common_trace.js | 0 ...ents_unhandled_error_common_trace.snapshot | 12 ++ .../events_unhandled_error_nexttick.js | 0 .../events_unhandled_error_nexttick.snapshot | 10 ++ .../events_unhandled_error_sameline.js | 0 .../events_unhandled_error_sameline.snapshot | 10 ++ .../events_unhandled_error_subclass.js | 0 .../events_unhandled_error_subclass.snapshot | 10 ++ .../promise_always_throw_unhandled.js | 0 .../promise_always_throw_unhandled.snapshot | 2 +- .../{message => errors}/throw_custom_error.js | 0 .../throw_custom_error.snapshot | 2 +- .../throw_in_line_with_tabs.js | 0 .../throw_in_line_with_tabs.snapshot | 2 +- .../{message => errors}/throw_non_error.js | 0 .../throw_non_error.snapshot | 2 +- test/fixtures/message/error_with_nul.snapshot | Bin 174 -> 0 bytes ...ents_unhandled_error_common_trace.snapshot | 12 -- .../events_unhandled_error_nexttick.snapshot | 10 -- .../events_unhandled_error_sameline.snapshot | 10 -- .../events_unhandled_error_subclass.snapshot | 10 -- .../source_map_disabled_by_api.snapshot | 12 -- .../source_map_enabled_by_api.snapshot | 12 -- .../fixtures/message/source_map_eval.snapshot | 11 -- .../source_map_no_source_file.snapshot | 9 -- .../source_map_throw_first_tick.snapshot | 11 -- .../output}/source_map_disabled_by_api.js | 0 .../source_map_disabled_by_api.snapshot | 24 ++++ .../output}/source_map_enabled_by_api.js | 0 .../output/source_map_enabled_by_api.snapshot | 24 ++++ .../output}/source_map_eval.js | 0 .../output/source_map_eval.snapshot | 24 ++++ .../output}/source_map_no_source_file.js | 2 +- .../output/source_map_no_source_file.snapshot | 24 ++++ .../output}/source_map_throw_first_tick.js | 0 .../source_map_throw_first_tick.snapshot | 24 ++++ .../vm_caught_custom_runtime_error.js | 0 .../vm_caught_custom_runtime_error.snapshot | 0 .../vm_display_runtime_error.js | 0 .../vm_display_runtime_error.snapshot | 4 +- .../vm_display_syntax_error.js | 0 .../vm_display_syntax_error.snapshot | 4 +- .../vm_dont_display_runtime_error.js | 0 .../vm_dont_display_runtime_error.snapshot | 2 +- .../vm_dont_display_syntax_error.js | 0 .../vm_dont_display_syntax_error.snapshot | 2 +- test/parallel/test-node-output-console.mjs | 34 +++++ test/parallel/test-node-output-errors.mjs | 51 ++++++++ test/parallel/test-node-output-sourcemaps.mjs | 33 +++++ test/parallel/test-node-output-vm.mjs | 33 +++++ test/parallel/test-node-output.mjs | 123 ------------------ 80 files changed, 347 insertions(+), 240 deletions(-) rename test/fixtures/{message => console}/2100bytes.js (100%) rename test/fixtures/{message => console}/2100bytes.snapshot (100%) rename test/fixtures/{message => console}/console.js (100%) rename test/fixtures/{message => console}/console.snapshot (100%) rename test/fixtures/{message => console}/console_low_stack_space.js (100%) rename test/fixtures/{message => console}/console_low_stack_space.snapshot (100%) rename test/fixtures/{message => console}/hello_world.js (100%) rename test/fixtures/{message => console}/hello_world.snapshot (100%) rename test/fixtures/{message => console}/stack_overflow.js (100%) rename test/fixtures/{message => console}/stack_overflow.snapshot (69%) rename test/fixtures/{message => errors}/async_error_eval_cjs.js (100%) rename test/fixtures/{message => errors}/async_error_eval_cjs.snapshot (100%) rename test/fixtures/{message => errors}/async_error_eval_esm.js (100%) rename test/fixtures/{message => errors}/async_error_eval_esm.snapshot (100%) rename test/fixtures/{message => errors}/async_error_microtask_main.js (100%) rename test/fixtures/{message => errors}/async_error_microtask_main.snapshot (73%) rename test/fixtures/{message => errors}/async_error_nexttick_main.js (100%) rename test/fixtures/{message => errors}/async_error_nexttick_main.snapshot (79%) rename test/fixtures/{message => errors}/async_error_sync_esm.mjs (100%) rename test/fixtures/{message => errors}/async_error_sync_esm.snapshot (73%) rename test/fixtures/{message => errors}/async_error_sync_main.js (100%) rename test/fixtures/{message => errors}/async_error_sync_main.snapshot (74%) rename test/fixtures/{message => errors}/error_aggregateTwoErrors.js (100%) rename test/fixtures/{message => errors}/error_aggregateTwoErrors.snapshot (50%) rename test/fixtures/{message => errors}/error_exit.js (100%) rename test/fixtures/{message => errors}/error_exit.snapshot (80%) rename test/fixtures/{message => errors}/error_with_nul.js (100%) create mode 100644 test/fixtures/errors/error_with_nul.snapshot rename test/fixtures/{message => errors}/events_unhandled_error_common_trace.js (100%) create mode 100644 test/fixtures/errors/events_unhandled_error_common_trace.snapshot rename test/fixtures/{message => errors}/events_unhandled_error_nexttick.js (100%) create mode 100644 test/fixtures/errors/events_unhandled_error_nexttick.snapshot rename test/fixtures/{message => errors}/events_unhandled_error_sameline.js (100%) create mode 100644 test/fixtures/errors/events_unhandled_error_sameline.snapshot rename test/fixtures/{message => errors}/events_unhandled_error_subclass.js (100%) create mode 100644 test/fixtures/errors/events_unhandled_error_subclass.snapshot rename test/fixtures/{message => errors}/promise_always_throw_unhandled.js (100%) rename test/fixtures/{message => errors}/promise_always_throw_unhandled.snapshot (75%) rename test/fixtures/{message => errors}/throw_custom_error.js (100%) rename test/fixtures/{message => errors}/throw_custom_error.snapshot (78%) rename test/fixtures/{message => errors}/throw_in_line_with_tabs.js (100%) rename test/fixtures/{message => errors}/throw_in_line_with_tabs.snapshot (57%) rename test/fixtures/{message => errors}/throw_non_error.js (100%) rename test/fixtures/{message => errors}/throw_non_error.snapshot (58%) delete mode 100644 test/fixtures/message/error_with_nul.snapshot delete mode 100644 test/fixtures/message/events_unhandled_error_common_trace.snapshot delete mode 100644 test/fixtures/message/events_unhandled_error_nexttick.snapshot delete mode 100644 test/fixtures/message/events_unhandled_error_sameline.snapshot delete mode 100644 test/fixtures/message/events_unhandled_error_subclass.snapshot delete mode 100644 test/fixtures/message/source_map_disabled_by_api.snapshot delete mode 100644 test/fixtures/message/source_map_enabled_by_api.snapshot delete mode 100644 test/fixtures/message/source_map_eval.snapshot delete mode 100644 test/fixtures/message/source_map_no_source_file.snapshot delete mode 100644 test/fixtures/message/source_map_throw_first_tick.snapshot rename test/fixtures/{message => source-map/output}/source_map_disabled_by_api.js (100%) create mode 100644 test/fixtures/source-map/output/source_map_disabled_by_api.snapshot rename test/fixtures/{message => source-map/output}/source_map_enabled_by_api.js (100%) create mode 100644 test/fixtures/source-map/output/source_map_enabled_by_api.snapshot rename test/fixtures/{message => source-map/output}/source_map_eval.js (100%) create mode 100644 test/fixtures/source-map/output/source_map_eval.snapshot rename test/fixtures/{message => source-map/output}/source_map_no_source_file.js (71%) create mode 100644 test/fixtures/source-map/output/source_map_no_source_file.snapshot rename test/fixtures/{message => source-map/output}/source_map_throw_first_tick.js (100%) create mode 100644 test/fixtures/source-map/output/source_map_throw_first_tick.snapshot rename test/fixtures/{message => vm}/vm_caught_custom_runtime_error.js (100%) rename test/fixtures/{message => vm}/vm_caught_custom_runtime_error.snapshot (100%) rename test/fixtures/{message => vm}/vm_display_runtime_error.js (100%) rename test/fixtures/{message => vm}/vm_display_runtime_error.snapshot (67%) rename test/fixtures/{message => vm}/vm_display_syntax_error.js (100%) rename test/fixtures/{message => vm}/vm_display_syntax_error.snapshot (68%) rename test/fixtures/{message => vm}/vm_dont_display_runtime_error.js (100%) rename test/fixtures/{message => vm}/vm_dont_display_runtime_error.snapshot (68%) rename test/fixtures/{message => vm}/vm_dont_display_syntax_error.js (100%) rename test/fixtures/{message => vm}/vm_dont_display_syntax_error.snapshot (69%) create mode 100644 test/parallel/test-node-output-console.mjs create mode 100644 test/parallel/test-node-output-errors.mjs create mode 100644 test/parallel/test-node-output-sourcemaps.mjs create mode 100644 test/parallel/test-node-output-vm.mjs delete mode 100644 test/parallel/test-node-output.mjs diff --git a/test/common/assertSnapshot.js b/test/common/assertSnapshot.js index 98d7b3f03a4758..06da88717417b2 100644 --- a/test/common/assertSnapshot.js +++ b/test/common/assertSnapshot.js @@ -35,6 +35,20 @@ async function assertSnapshot(actual, filename = process.argv[1]) { } } +/** + * Spawn a process and assert its output against a snapshot. + * if you want to automatically update the snapshot, run tests with NODE_REGENERATE_SNAPSHOTS=1 + * transform is a function that takes the output and returns a string that will be compared against the snapshot + * this is useful for normalizing output such as stack traces + * there are some predefined transforms in this file such as replaceStackTrace and replaceWindowsLineEndings + * both of which can be used as an example for writing your own + * compose multiple transforms by passing them as arguments to the transform function: + * assertSnapshot.transform(assertSnapshot.replaceStackTrace, assertSnapshot.replaceWindowsLineEndings) + * + * @param {string} filename + * @param {function(string): string} [transform] + * @returns {Promise} + */ async function spawnAndAssert(filename, transform = (x) => x) { const flags = common.parseTestFlags(filename); const { stdout, stderr } = await common.spawnPromisified(process.execPath, [...flags, filename]); diff --git a/test/fixtures/message/2100bytes.js b/test/fixtures/console/2100bytes.js similarity index 100% rename from test/fixtures/message/2100bytes.js rename to test/fixtures/console/2100bytes.js diff --git a/test/fixtures/message/2100bytes.snapshot b/test/fixtures/console/2100bytes.snapshot similarity index 100% rename from test/fixtures/message/2100bytes.snapshot rename to test/fixtures/console/2100bytes.snapshot diff --git a/test/fixtures/message/console.js b/test/fixtures/console/console.js similarity index 100% rename from test/fixtures/message/console.js rename to test/fixtures/console/console.js diff --git a/test/fixtures/message/console.snapshot b/test/fixtures/console/console.snapshot similarity index 100% rename from test/fixtures/message/console.snapshot rename to test/fixtures/console/console.snapshot diff --git a/test/fixtures/message/console_low_stack_space.js b/test/fixtures/console/console_low_stack_space.js similarity index 100% rename from test/fixtures/message/console_low_stack_space.js rename to test/fixtures/console/console_low_stack_space.js diff --git a/test/fixtures/message/console_low_stack_space.snapshot b/test/fixtures/console/console_low_stack_space.snapshot similarity index 100% rename from test/fixtures/message/console_low_stack_space.snapshot rename to test/fixtures/console/console_low_stack_space.snapshot diff --git a/test/fixtures/message/hello_world.js b/test/fixtures/console/hello_world.js similarity index 100% rename from test/fixtures/message/hello_world.js rename to test/fixtures/console/hello_world.js diff --git a/test/fixtures/message/hello_world.snapshot b/test/fixtures/console/hello_world.snapshot similarity index 100% rename from test/fixtures/message/hello_world.snapshot rename to test/fixtures/console/hello_world.snapshot diff --git a/test/fixtures/message/stack_overflow.js b/test/fixtures/console/stack_overflow.js similarity index 100% rename from test/fixtures/message/stack_overflow.js rename to test/fixtures/console/stack_overflow.js diff --git a/test/fixtures/message/stack_overflow.snapshot b/test/fixtures/console/stack_overflow.snapshot similarity index 69% rename from test/fixtures/message/stack_overflow.snapshot rename to test/fixtures/console/stack_overflow.snapshot index 2aa5a13dc4f0ef..e723d53adc866e 100644 --- a/test/fixtures/message/stack_overflow.snapshot +++ b/test/fixtures/console/stack_overflow.snapshot @@ -1,5 +1,5 @@ before -*test*fixtures*message*stack_overflow.js:* +*test*fixtures*console*stack_overflow.js:* JSON.stringify(array); ^ diff --git a/test/fixtures/message/async_error_eval_cjs.js b/test/fixtures/errors/async_error_eval_cjs.js similarity index 100% rename from test/fixtures/message/async_error_eval_cjs.js rename to test/fixtures/errors/async_error_eval_cjs.js diff --git a/test/fixtures/message/async_error_eval_cjs.snapshot b/test/fixtures/errors/async_error_eval_cjs.snapshot similarity index 100% rename from test/fixtures/message/async_error_eval_cjs.snapshot rename to test/fixtures/errors/async_error_eval_cjs.snapshot diff --git a/test/fixtures/message/async_error_eval_esm.js b/test/fixtures/errors/async_error_eval_esm.js similarity index 100% rename from test/fixtures/message/async_error_eval_esm.js rename to test/fixtures/errors/async_error_eval_esm.js diff --git a/test/fixtures/message/async_error_eval_esm.snapshot b/test/fixtures/errors/async_error_eval_esm.snapshot similarity index 100% rename from test/fixtures/message/async_error_eval_esm.snapshot rename to test/fixtures/errors/async_error_eval_esm.snapshot diff --git a/test/fixtures/message/async_error_microtask_main.js b/test/fixtures/errors/async_error_microtask_main.js similarity index 100% rename from test/fixtures/message/async_error_microtask_main.js rename to test/fixtures/errors/async_error_microtask_main.js diff --git a/test/fixtures/message/async_error_microtask_main.snapshot b/test/fixtures/errors/async_error_microtask_main.snapshot similarity index 73% rename from test/fixtures/message/async_error_microtask_main.snapshot rename to test/fixtures/errors/async_error_microtask_main.snapshot index f00abd2b205c60..ae1ccdd748daf9 100644 --- a/test/fixtures/message/async_error_microtask_main.snapshot +++ b/test/fixtures/errors/async_error_microtask_main.snapshot @@ -3,4 +3,4 @@ Error: test at two (*fixtures*async-error.js:17:9) at async three (*fixtures*async-error.js:20:3) at async four (*fixtures*async-error.js:24:3) - at async main (*fixtures*message*async_error_microtask_main.js:7:5) + at async main (*fixtures*errors*async_error_microtask_main.js:7:5) diff --git a/test/fixtures/message/async_error_nexttick_main.js b/test/fixtures/errors/async_error_nexttick_main.js similarity index 100% rename from test/fixtures/message/async_error_nexttick_main.js rename to test/fixtures/errors/async_error_nexttick_main.js diff --git a/test/fixtures/message/async_error_nexttick_main.snapshot b/test/fixtures/errors/async_error_nexttick_main.snapshot similarity index 79% rename from test/fixtures/message/async_error_nexttick_main.snapshot rename to test/fixtures/errors/async_error_nexttick_main.snapshot index e765055f684555..07420efe48fe0d 100644 --- a/test/fixtures/message/async_error_nexttick_main.snapshot +++ b/test/fixtures/errors/async_error_nexttick_main.snapshot @@ -4,4 +4,4 @@ Error: test at process.processTicksAndRejections (node:internal*process*task_queues:95:5) at async three (*fixtures*async-error.js:20:3) at async four (*fixtures*async-error.js:24:3) - at async main (*fixtures*message*async_error_nexttick_main.js:7:5) + at async main (*fixtures*errors*async_error_nexttick_main.js:7:5) diff --git a/test/fixtures/message/async_error_sync_esm.mjs b/test/fixtures/errors/async_error_sync_esm.mjs similarity index 100% rename from test/fixtures/message/async_error_sync_esm.mjs rename to test/fixtures/errors/async_error_sync_esm.mjs diff --git a/test/fixtures/message/async_error_sync_esm.snapshot b/test/fixtures/errors/async_error_sync_esm.snapshot similarity index 73% rename from test/fixtures/message/async_error_sync_esm.snapshot rename to test/fixtures/errors/async_error_sync_esm.snapshot index b1674e262eede0..e5571eae656c8b 100644 --- a/test/fixtures/message/async_error_sync_esm.snapshot +++ b/test/fixtures/errors/async_error_sync_esm.snapshot @@ -3,4 +3,4 @@ Error: test at two (*fixtures*async-error.js:17:9) at async three (*fixtures*async-error.js:20:3) at async four (*fixtures*async-error.js:24:3) - at async main (file:**fixtures*message*async_error_sync_esm.mjs:6:5) + at async main (file:**fixtures*errors*async_error_sync_esm.mjs:6:5) diff --git a/test/fixtures/message/async_error_sync_main.js b/test/fixtures/errors/async_error_sync_main.js similarity index 100% rename from test/fixtures/message/async_error_sync_main.js rename to test/fixtures/errors/async_error_sync_main.js diff --git a/test/fixtures/message/async_error_sync_main.snapshot b/test/fixtures/errors/async_error_sync_main.snapshot similarity index 74% rename from test/fixtures/message/async_error_sync_main.snapshot rename to test/fixtures/errors/async_error_sync_main.snapshot index 6629d066880491..4ad9ddad4ff206 100644 --- a/test/fixtures/message/async_error_sync_main.snapshot +++ b/test/fixtures/errors/async_error_sync_main.snapshot @@ -3,4 +3,4 @@ Error: test at two (*fixtures*async-error.js:17:9) at async three (*fixtures*async-error.js:20:3) at async four (*fixtures*async-error.js:24:3) - at async main (*fixtures*message*async_error_sync_main.js:7:5) + at async main (*fixtures*errors*async_error_sync_main.js:7:5) diff --git a/test/fixtures/message/error_aggregateTwoErrors.js b/test/fixtures/errors/error_aggregateTwoErrors.js similarity index 100% rename from test/fixtures/message/error_aggregateTwoErrors.js rename to test/fixtures/errors/error_aggregateTwoErrors.js diff --git a/test/fixtures/message/error_aggregateTwoErrors.snapshot b/test/fixtures/errors/error_aggregateTwoErrors.snapshot similarity index 50% rename from test/fixtures/message/error_aggregateTwoErrors.snapshot rename to test/fixtures/errors/error_aggregateTwoErrors.snapshot index a8d13c461b2cb0..6bb4aed30a5003 100644 --- a/test/fixtures/message/error_aggregateTwoErrors.snapshot +++ b/test/fixtures/errors/error_aggregateTwoErrors.snapshot @@ -1,4 +1,4 @@ -*error_aggregateTwoErrors.js:* +*fixtures*errors*error_aggregateTwoErrors.js:* throw aggregateTwoErrors(err, originalError); ^ @@ -6,11 +6,11 @@ throw aggregateTwoErrors(err, originalError); code: 'ERR0', [errors]: [ Error: original - at Object. (*error_aggregateTwoErrors.js:*:*) { + at Object. (*fixtures*errors*error_aggregateTwoErrors.js:*:*) { code: 'ERR0' }, Error: second error - at Object. (*error_aggregateTwoErrors.js:*:*) { + at Object. (*fixtures*errors*error_aggregateTwoErrors.js:*:*) { code: 'ERR1' } ] diff --git a/test/fixtures/message/error_exit.js b/test/fixtures/errors/error_exit.js similarity index 100% rename from test/fixtures/message/error_exit.js rename to test/fixtures/errors/error_exit.js diff --git a/test/fixtures/message/error_exit.snapshot b/test/fixtures/errors/error_exit.snapshot similarity index 80% rename from test/fixtures/message/error_exit.snapshot rename to test/fixtures/errors/error_exit.snapshot index 778165dc25c4fc..4eb813b187e7dd 100644 --- a/test/fixtures/message/error_exit.snapshot +++ b/test/fixtures/errors/error_exit.snapshot @@ -7,7 +7,7 @@ AssertionError [ERR_ASSERTION]: Expected values to be strictly equal: 1 !== 2 - at Object. (*error_exit.js:*:*) { + at Object. (*fixtures*errors*error_exit.js:*:*) { generatedMessage: true, code: 'ERR_ASSERTION', actual: 1, diff --git a/test/fixtures/message/error_with_nul.js b/test/fixtures/errors/error_with_nul.js similarity index 100% rename from test/fixtures/message/error_with_nul.js rename to test/fixtures/errors/error_with_nul.js diff --git a/test/fixtures/errors/error_with_nul.snapshot b/test/fixtures/errors/error_with_nul.snapshot new file mode 100644 index 0000000000000000000000000000000000000000..a1e86b2e0a32458df712d2c547cd333a2a013cb7 GIT binary patch literal 222 zcma)$K@Nj33 (*fixtures*errors*events_unhandled_error_common_trace.js:*:*) + +Node.js * diff --git a/test/fixtures/message/events_unhandled_error_nexttick.js b/test/fixtures/errors/events_unhandled_error_nexttick.js similarity index 100% rename from test/fixtures/message/events_unhandled_error_nexttick.js rename to test/fixtures/errors/events_unhandled_error_nexttick.js diff --git a/test/fixtures/errors/events_unhandled_error_nexttick.snapshot b/test/fixtures/errors/events_unhandled_error_nexttick.snapshot new file mode 100644 index 00000000000000..d057375e8f2da4 --- /dev/null +++ b/test/fixtures/errors/events_unhandled_error_nexttick.snapshot @@ -0,0 +1,10 @@ +node:events:* + throw er; * Unhandled 'error' event + ^ + +Error + at Object. (*fixtures*errors*events_unhandled_error_nexttick.js:*:*) +Emitted 'error' event at: + at *fixtures*errors*events_unhandled_error_nexttick.js:*:* + +Node.js * diff --git a/test/fixtures/message/events_unhandled_error_sameline.js b/test/fixtures/errors/events_unhandled_error_sameline.js similarity index 100% rename from test/fixtures/message/events_unhandled_error_sameline.js rename to test/fixtures/errors/events_unhandled_error_sameline.js diff --git a/test/fixtures/errors/events_unhandled_error_sameline.snapshot b/test/fixtures/errors/events_unhandled_error_sameline.snapshot new file mode 100644 index 00000000000000..ae9676dc113b86 --- /dev/null +++ b/test/fixtures/errors/events_unhandled_error_sameline.snapshot @@ -0,0 +1,10 @@ +node:events:* + throw er; * Unhandled 'error' event + ^ + +Error + at Object. (*fixtures*errors*events_unhandled_error_sameline.js:*:*) +Emitted 'error' event at: + at Object. (*fixtures*errors*events_unhandled_error_sameline.js:*:*) + +Node.js * diff --git a/test/fixtures/message/events_unhandled_error_subclass.js b/test/fixtures/errors/events_unhandled_error_subclass.js similarity index 100% rename from test/fixtures/message/events_unhandled_error_subclass.js rename to test/fixtures/errors/events_unhandled_error_subclass.js diff --git a/test/fixtures/errors/events_unhandled_error_subclass.snapshot b/test/fixtures/errors/events_unhandled_error_subclass.snapshot new file mode 100644 index 00000000000000..b86e50d2ca36e6 --- /dev/null +++ b/test/fixtures/errors/events_unhandled_error_subclass.snapshot @@ -0,0 +1,10 @@ +node:events:* + throw er; * Unhandled 'error' event + ^ + +Error + at Object. (*fixtures*errors*events_unhandled_error_subclass.js:*:*) +Emitted 'error' event on Foo instance at: + at Object. (*fixtures*errors*events_unhandled_error_subclass.js:*:*) + +Node.js * diff --git a/test/fixtures/message/promise_always_throw_unhandled.js b/test/fixtures/errors/promise_always_throw_unhandled.js similarity index 100% rename from test/fixtures/message/promise_always_throw_unhandled.js rename to test/fixtures/errors/promise_always_throw_unhandled.js diff --git a/test/fixtures/message/promise_always_throw_unhandled.snapshot b/test/fixtures/errors/promise_always_throw_unhandled.snapshot similarity index 75% rename from test/fixtures/message/promise_always_throw_unhandled.snapshot rename to test/fixtures/errors/promise_always_throw_unhandled.snapshot index c97540f5499f87..e864583478412b 100644 --- a/test/fixtures/message/promise_always_throw_unhandled.snapshot +++ b/test/fixtures/errors/promise_always_throw_unhandled.snapshot @@ -1,4 +1,4 @@ -*promise_always_throw_unhandled.js:* +*fixtures*errors*promise_always_throw_unhandled.js:* throw new Error('One'); ^ diff --git a/test/fixtures/message/throw_custom_error.js b/test/fixtures/errors/throw_custom_error.js similarity index 100% rename from test/fixtures/message/throw_custom_error.js rename to test/fixtures/errors/throw_custom_error.js diff --git a/test/fixtures/message/throw_custom_error.snapshot b/test/fixtures/errors/throw_custom_error.snapshot similarity index 78% rename from test/fixtures/message/throw_custom_error.snapshot rename to test/fixtures/errors/throw_custom_error.snapshot index ba80020c897a32..d470ed394dbf03 100644 --- a/test/fixtures/message/throw_custom_error.snapshot +++ b/test/fixtures/errors/throw_custom_error.snapshot @@ -1,5 +1,5 @@ -*throw_custom_error.js:* +*fixtures*errors*throw_custom_error.js:* throw ({ name: 'MyCustomError', message: 'This is a custom message' }); ^ { name: 'MyCustomError', message: 'This is a custom message' } diff --git a/test/fixtures/message/throw_in_line_with_tabs.js b/test/fixtures/errors/throw_in_line_with_tabs.js similarity index 100% rename from test/fixtures/message/throw_in_line_with_tabs.js rename to test/fixtures/errors/throw_in_line_with_tabs.js diff --git a/test/fixtures/message/throw_in_line_with_tabs.snapshot b/test/fixtures/errors/throw_in_line_with_tabs.snapshot similarity index 57% rename from test/fixtures/message/throw_in_line_with_tabs.snapshot rename to test/fixtures/errors/throw_in_line_with_tabs.snapshot index 29c7e1ec3587d9..69282be63fe7ce 100644 --- a/test/fixtures/message/throw_in_line_with_tabs.snapshot +++ b/test/fixtures/errors/throw_in_line_with_tabs.snapshot @@ -1,6 +1,6 @@ before -*throw_in_line_with_tabs.js:* +*fixtures*errors*throw_in_line_with_tabs.js:* throw ({ foo: 'bar' }); ^ { foo: 'bar' } diff --git a/test/fixtures/message/throw_non_error.js b/test/fixtures/errors/throw_non_error.js similarity index 100% rename from test/fixtures/message/throw_non_error.js rename to test/fixtures/errors/throw_non_error.js diff --git a/test/fixtures/message/throw_non_error.snapshot b/test/fixtures/errors/throw_non_error.snapshot similarity index 58% rename from test/fixtures/message/throw_non_error.snapshot rename to test/fixtures/errors/throw_non_error.snapshot index 4ad80df4f6a9cb..4cc15afdd27b46 100644 --- a/test/fixtures/message/throw_non_error.snapshot +++ b/test/fixtures/errors/throw_non_error.snapshot @@ -1,5 +1,5 @@ -*throw_non_error.js:* +*fixtures*errors*throw_non_error.js:* throw ({ foo: 'bar' }); ^ { foo: 'bar' } diff --git a/test/fixtures/message/error_with_nul.snapshot b/test/fixtures/message/error_with_nul.snapshot deleted file mode 100644 index 7dd4d665555874863591d5ba33d4833ebea75717..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 174 zcmYdHN@hq&P2ZhmR8 S9d0dLe)%b>KnE#kaRC7IY&Pov diff --git a/test/fixtures/message/events_unhandled_error_common_trace.snapshot b/test/fixtures/message/events_unhandled_error_common_trace.snapshot deleted file mode 100644 index a482c105b75e48..00000000000000 --- a/test/fixtures/message/events_unhandled_error_common_trace.snapshot +++ /dev/null @@ -1,12 +0,0 @@ -node:events:* - throw er; * Unhandled 'error' event - ^ - -Error: foo:bar - at bar (*events_unhandled_error_common_trace.js:*:*) - at foo (*events_unhandled_error_common_trace.js:*:*) -Emitted 'error' event at: - at quux (*events_unhandled_error_common_trace.js:*:*) - at Object. (*events_unhandled_error_common_trace.js:*:*) - -Node.js * diff --git a/test/fixtures/message/events_unhandled_error_nexttick.snapshot b/test/fixtures/message/events_unhandled_error_nexttick.snapshot deleted file mode 100644 index 450d4910a385b5..00000000000000 --- a/test/fixtures/message/events_unhandled_error_nexttick.snapshot +++ /dev/null @@ -1,10 +0,0 @@ -node:events:* - throw er; * Unhandled 'error' event - ^ - -Error - at Object. (*events_unhandled_error_nexttick.js:*:*) -Emitted 'error' event at: - at *events_unhandled_error_nexttick.js:*:* - -Node.js * diff --git a/test/fixtures/message/events_unhandled_error_sameline.snapshot b/test/fixtures/message/events_unhandled_error_sameline.snapshot deleted file mode 100644 index 520601e617083c..00000000000000 --- a/test/fixtures/message/events_unhandled_error_sameline.snapshot +++ /dev/null @@ -1,10 +0,0 @@ -node:events:* - throw er; * Unhandled 'error' event - ^ - -Error - at Object. (*events_unhandled_error_sameline.js:*:*) -Emitted 'error' event at: - at Object. (*events_unhandled_error_sameline.js:*:*) - -Node.js * diff --git a/test/fixtures/message/events_unhandled_error_subclass.snapshot b/test/fixtures/message/events_unhandled_error_subclass.snapshot deleted file mode 100644 index 6a9cfd4a1a0b21..00000000000000 --- a/test/fixtures/message/events_unhandled_error_subclass.snapshot +++ /dev/null @@ -1,10 +0,0 @@ -node:events:* - throw er; * Unhandled 'error' event - ^ - -Error - at Object. (*events_unhandled_error_subclass.js:*:*) -Emitted 'error' event on Foo instance at: - at Object. (*events_unhandled_error_subclass.js:*:*) - -Node.js * diff --git a/test/fixtures/message/source_map_disabled_by_api.snapshot b/test/fixtures/message/source_map_disabled_by_api.snapshot deleted file mode 100644 index 655cd6695e1116..00000000000000 --- a/test/fixtures/message/source_map_disabled_by_api.snapshot +++ /dev/null @@ -1,12 +0,0 @@ -Error: an error! - at functionD (*enclosing-call-site-min.js:1:156) - at functionC (*enclosing-call-site-min.js:1:97) - at functionB (*enclosing-call-site-min.js:1:60) - at functionA (*enclosing-call-site-min.js:1:26) - at Object. (*enclosing-call-site-min.js:1:199) -Error: an error! - at functionD (*enclosing-call-site.js:16:17) - at functionC (*enclosing-call-site.js:10:3) - at functionB (*enclosing-call-site.js:6:3) - at functionA (*enclosing-call-site.js:2:3) - at Object. (*enclosing-call-site.js:24:3) diff --git a/test/fixtures/message/source_map_enabled_by_api.snapshot b/test/fixtures/message/source_map_enabled_by_api.snapshot deleted file mode 100644 index 082b3f310ed4f9..00000000000000 --- a/test/fixtures/message/source_map_enabled_by_api.snapshot +++ /dev/null @@ -1,12 +0,0 @@ -Error: an error! - at functionD (*enclosing-call-site.js:16:17) - at functionC (*enclosing-call-site.js:10:3) - at functionB (*enclosing-call-site.js:6:3) - at functionA (*enclosing-call-site.js:2:3) - at Object. (*enclosing-call-site.js:24:3) -Error: an error! - at functionD (*enclosing-call-site-min.js:1:156) - at functionC (*enclosing-call-site-min.js:1:97) - at functionB (*enclosing-call-site-min.js:1:60) - at functionA (*enclosing-call-site-min.js:1:26) - at Object. (*enclosing-call-site-min.js:1:199) diff --git a/test/fixtures/message/source_map_eval.snapshot b/test/fixtures/message/source_map_eval.snapshot deleted file mode 100644 index 080615f16a3dfd..00000000000000 --- a/test/fixtures/message/source_map_eval.snapshot +++ /dev/null @@ -1,11 +0,0 @@ -*tabs.coffee:26 - alert "I knew it!" - ^ - - -ReferenceError: alert is not defined - at Object.eval (*tabs.coffee:26:2) - at eval (*tabs.coffee:1:14) - at Object. (*fixtures*message*source_map_eval.js:10:1) - -Node.js * diff --git a/test/fixtures/message/source_map_no_source_file.snapshot b/test/fixtures/message/source_map_no_source_file.snapshot deleted file mode 100644 index cf9329747ba692..00000000000000 --- a/test/fixtures/message/source_map_no_source_file.snapshot +++ /dev/null @@ -1,9 +0,0 @@ -*no-source.js:2 - throw new Error('foo'); - ^ - -Error: foo - at Throw (*file-not-exists.ts:2:9) - at Object. (*file-not-exists.ts:5:1) - -Node.js * diff --git a/test/fixtures/message/source_map_throw_first_tick.snapshot b/test/fixtures/message/source_map_throw_first_tick.snapshot deleted file mode 100644 index fba8c95cc1103f..00000000000000 --- a/test/fixtures/message/source_map_throw_first_tick.snapshot +++ /dev/null @@ -1,11 +0,0 @@ -reachable -*typescript-throw.ts:18 - throw Error('an exception'); - ^ - - -Error: an exception - at branch (*typescript-throw.ts:18:11) - at Object. (*typescript-throw.ts:24:1) - -Node.js * diff --git a/test/fixtures/message/source_map_disabled_by_api.js b/test/fixtures/source-map/output/source_map_disabled_by_api.js similarity index 100% rename from test/fixtures/message/source_map_disabled_by_api.js rename to test/fixtures/source-map/output/source_map_disabled_by_api.js diff --git a/test/fixtures/source-map/output/source_map_disabled_by_api.snapshot b/test/fixtures/source-map/output/source_map_disabled_by_api.snapshot new file mode 100644 index 00000000000000..67204cb199b031 --- /dev/null +++ b/test/fixtures/source-map/output/source_map_disabled_by_api.snapshot @@ -0,0 +1,24 @@ +node:internal*modules*cjs*loader:1085 + throw err; + ^ + +Error: Cannot find module '../..*common' +Require stack: +- *output*source_map_disabled_by_api.js + at Module._resolveFilename (node:internal*modules*cjs*loader:1082:15) + at Module._load (node:internal*modules*cjs*loader:928:27) + at Module.require (node:internal*modules*cjs*loader:1149:19) + at require (node:internal*modules*helpers:121:18) + at Object. (*output*source_map_disabled_by_api.js:4:1) + at Module._compile (node:internal*modules*cjs*loader:1267:14) + at Module._extensions..js (node:internal*modules*cjs*loader:1321:10) + at Module.load (node:internal*modules*cjs*loader:1125:32) + at Module._load (node:internal*modules*cjs*loader:965:12) + at Function.executeUserEntryPoint [as runMain] (node:internal*modules*run_main:83:12) { + code: 'MODULE_NOT_FOUND', + requireStack: [ + '*output*source_map_disabled_by_api.js' + ] +} + +Node.js * diff --git a/test/fixtures/message/source_map_enabled_by_api.js b/test/fixtures/source-map/output/source_map_enabled_by_api.js similarity index 100% rename from test/fixtures/message/source_map_enabled_by_api.js rename to test/fixtures/source-map/output/source_map_enabled_by_api.js diff --git a/test/fixtures/source-map/output/source_map_enabled_by_api.snapshot b/test/fixtures/source-map/output/source_map_enabled_by_api.snapshot new file mode 100644 index 00000000000000..5ae7d983c54b79 --- /dev/null +++ b/test/fixtures/source-map/output/source_map_enabled_by_api.snapshot @@ -0,0 +1,24 @@ +node:internal*modules*cjs*loader:1085 + throw err; + ^ + +Error: Cannot find module '../..*common' +Require stack: +- *output*source_map_enabled_by_api.js + at Module._resolveFilename (node:internal*modules*cjs*loader:1082:15) + at Module._load (node:internal*modules*cjs*loader:928:27) + at Module.require (node:internal*modules*cjs*loader:1149:19) + at require (node:internal*modules*helpers:121:18) + at Object. (*output*source_map_enabled_by_api.js:2:1) + at Module._compile (node:internal*modules*cjs*loader:1267:14) + at Module._extensions..js (node:internal*modules*cjs*loader:1321:10) + at Module.load (node:internal*modules*cjs*loader:1125:32) + at Module._load (node:internal*modules*cjs*loader:965:12) + at Function.executeUserEntryPoint [as runMain] (node:internal*modules*run_main:83:12) { + code: 'MODULE_NOT_FOUND', + requireStack: [ + '*output*source_map_enabled_by_api.js' + ] +} + +Node.js * diff --git a/test/fixtures/message/source_map_eval.js b/test/fixtures/source-map/output/source_map_eval.js similarity index 100% rename from test/fixtures/message/source_map_eval.js rename to test/fixtures/source-map/output/source_map_eval.js diff --git a/test/fixtures/source-map/output/source_map_eval.snapshot b/test/fixtures/source-map/output/source_map_eval.snapshot new file mode 100644 index 00000000000000..84efd83c652b1d --- /dev/null +++ b/test/fixtures/source-map/output/source_map_eval.snapshot @@ -0,0 +1,24 @@ +node:internal*modules*cjs*loader:1085 + throw err; + ^ + +Error: Cannot find module '../..*common' +Require stack: +- *output*source_map_eval.js + at Module._resolveFilename (node:internal*modules*cjs*loader:1082:15) + at Module._load (node:internal*modules*cjs*loader:928:27) + at Module.require (node:internal*modules*cjs*loader:1149:19) + at require (node:internal*modules*helpers:121:18) + at Object. (*output*source_map_eval.js:4:1) + at Module._compile (node:internal*modules*cjs*loader:1267:14) + at Module._extensions..js (node:internal*modules*cjs*loader:1321:10) + at Module.load (node:internal*modules*cjs*loader:1125:32) + at Module._load (node:internal*modules*cjs*loader:965:12) + at Function.executeUserEntryPoint [as runMain] (node:internal*modules*run_main:83:12) { + code: 'MODULE_NOT_FOUND', + requireStack: [ + '*output*source_map_eval.js' + ] +} + +Node.js * diff --git a/test/fixtures/message/source_map_no_source_file.js b/test/fixtures/source-map/output/source_map_no_source_file.js similarity index 71% rename from test/fixtures/message/source_map_no_source_file.js rename to test/fixtures/source-map/output/source_map_no_source_file.js index 4a71cb9aacf0cf..05adfdf8e21b1e 100644 --- a/test/fixtures/message/source_map_no_source_file.js +++ b/test/fixtures/source-map/output/source_map_no_source_file.js @@ -4,4 +4,4 @@ require('../../common'); Error.stackTraceLimit = 2; -require('..//source-map/no-source.js'); +require('../source-map/no-source.js'); diff --git a/test/fixtures/source-map/output/source_map_no_source_file.snapshot b/test/fixtures/source-map/output/source_map_no_source_file.snapshot new file mode 100644 index 00000000000000..12366a2acc93a5 --- /dev/null +++ b/test/fixtures/source-map/output/source_map_no_source_file.snapshot @@ -0,0 +1,24 @@ +node:internal*modules*cjs*loader:1085 + throw err; + ^ + +Error: Cannot find module '../..*common' +Require stack: +- *output*source_map_no_source_file.js + at Module._resolveFilename (node:internal*modules*cjs*loader:1082:15) + at Module._load (node:internal*modules*cjs*loader:928:27) + at Module.require (node:internal*modules*cjs*loader:1149:19) + at require (node:internal*modules*helpers:121:18) + at Object. (*output*source_map_no_source_file.js:4:1) + at Module._compile (node:internal*modules*cjs*loader:1267:14) + at Module._extensions..js (node:internal*modules*cjs*loader:1321:10) + at Module.load (node:internal*modules*cjs*loader:1125:32) + at Module._load (node:internal*modules*cjs*loader:965:12) + at Function.executeUserEntryPoint [as runMain] (node:internal*modules*run_main:83:12) { + code: 'MODULE_NOT_FOUND', + requireStack: [ + '*output*source_map_no_source_file.js' + ] +} + +Node.js * diff --git a/test/fixtures/message/source_map_throw_first_tick.js b/test/fixtures/source-map/output/source_map_throw_first_tick.js similarity index 100% rename from test/fixtures/message/source_map_throw_first_tick.js rename to test/fixtures/source-map/output/source_map_throw_first_tick.js diff --git a/test/fixtures/source-map/output/source_map_throw_first_tick.snapshot b/test/fixtures/source-map/output/source_map_throw_first_tick.snapshot new file mode 100644 index 00000000000000..f27d74fd6da560 --- /dev/null +++ b/test/fixtures/source-map/output/source_map_throw_first_tick.snapshot @@ -0,0 +1,24 @@ +node:internal*modules*cjs*loader:1085 + throw err; + ^ + +Error: Cannot find module '../..*common' +Require stack: +- *output*source_map_throw_first_tick.js + at Module._resolveFilename (node:internal*modules*cjs*loader:1082:15) + at Module._load (node:internal*modules*cjs*loader:928:27) + at Module.require (node:internal*modules*cjs*loader:1149:19) + at require (node:internal*modules*helpers:121:18) + at Object. (*output*source_map_throw_first_tick.js:4:1) + at Module._compile (node:internal*modules*cjs*loader:1267:14) + at Module._extensions..js (node:internal*modules*cjs*loader:1321:10) + at Module.load (node:internal*modules*cjs*loader:1125:32) + at Module._load (node:internal*modules*cjs*loader:965:12) + at Function.executeUserEntryPoint [as runMain] (node:internal*modules*run_main:83:12) { + code: 'MODULE_NOT_FOUND', + requireStack: [ + '*output*source_map_throw_first_tick.js' + ] +} + +Node.js * diff --git a/test/fixtures/message/vm_caught_custom_runtime_error.js b/test/fixtures/vm/vm_caught_custom_runtime_error.js similarity index 100% rename from test/fixtures/message/vm_caught_custom_runtime_error.js rename to test/fixtures/vm/vm_caught_custom_runtime_error.js diff --git a/test/fixtures/message/vm_caught_custom_runtime_error.snapshot b/test/fixtures/vm/vm_caught_custom_runtime_error.snapshot similarity index 100% rename from test/fixtures/message/vm_caught_custom_runtime_error.snapshot rename to test/fixtures/vm/vm_caught_custom_runtime_error.snapshot diff --git a/test/fixtures/message/vm_display_runtime_error.js b/test/fixtures/vm/vm_display_runtime_error.js similarity index 100% rename from test/fixtures/message/vm_display_runtime_error.js rename to test/fixtures/vm/vm_display_runtime_error.js diff --git a/test/fixtures/message/vm_display_runtime_error.snapshot b/test/fixtures/vm/vm_display_runtime_error.snapshot similarity index 67% rename from test/fixtures/message/vm_display_runtime_error.snapshot rename to test/fixtures/vm/vm_display_runtime_error.snapshot index 4d613dacd2947b..47c7d54bae4481 100644 --- a/test/fixtures/message/vm_display_runtime_error.snapshot +++ b/test/fixtures/vm/vm_display_runtime_error.snapshot @@ -7,7 +7,7 @@ Error: boo! at test.vm:1:7 at Script.runInThisContext (node:vm:*) at Object.runInThisContext (node:vm:*) - at Object. (*fixtures*message*vm_display_runtime_error.js:31:6) + at Object. (*fixtures*vm*vm_display_runtime_error.js:31:6) test.vm:1 throw new Error("spooky!") ^ @@ -16,6 +16,6 @@ Error: spooky! at test.vm:1:7 at Script.runInThisContext (node:vm:*) at Object.runInThisContext (node:vm:*) - at Object. (*fixtures*message*vm_display_runtime_error.js:36:4) + at Object. (*fixtures*vm*vm_display_runtime_error.js:36:4) Node.js * diff --git a/test/fixtures/message/vm_display_syntax_error.js b/test/fixtures/vm/vm_display_syntax_error.js similarity index 100% rename from test/fixtures/message/vm_display_syntax_error.js rename to test/fixtures/vm/vm_display_syntax_error.js diff --git a/test/fixtures/message/vm_display_syntax_error.snapshot b/test/fixtures/vm/vm_display_syntax_error.snapshot similarity index 68% rename from test/fixtures/message/vm_display_syntax_error.snapshot rename to test/fixtures/vm/vm_display_syntax_error.snapshot index 5bc8fc7cd64656..84f52ce4dba0bc 100644 --- a/test/fixtures/message/vm_display_syntax_error.snapshot +++ b/test/fixtures/vm/vm_display_syntax_error.snapshot @@ -7,7 +7,7 @@ SyntaxError: Unexpected number at new Script (node:vm:*) at createScript (node:vm:*) at Object.runInThisContext (node:vm:*) - at Object. (*fixtures*message*vm_display_syntax_error.js:31:6) + at Object. (*fixtures*vm*vm_display_syntax_error.js:31:6) test.vm:1 var 5; ^ @@ -16,6 +16,6 @@ SyntaxError: Unexpected number at new Script (node:vm:*) at createScript (node:vm:*) at Object.runInThisContext (node:vm:*) - at Object. (*fixtures*message*vm_display_syntax_error.js:36:4) + at Object. (*fixtures*vm*vm_display_syntax_error.js:36:4) Node.js * diff --git a/test/fixtures/message/vm_dont_display_runtime_error.js b/test/fixtures/vm/vm_dont_display_runtime_error.js similarity index 100% rename from test/fixtures/message/vm_dont_display_runtime_error.js rename to test/fixtures/vm/vm_dont_display_runtime_error.js diff --git a/test/fixtures/message/vm_dont_display_runtime_error.snapshot b/test/fixtures/vm/vm_dont_display_runtime_error.snapshot similarity index 68% rename from test/fixtures/message/vm_dont_display_runtime_error.snapshot rename to test/fixtures/vm/vm_dont_display_runtime_error.snapshot index 9c10435edf86ac..045183d4a37bde 100644 --- a/test/fixtures/message/vm_dont_display_runtime_error.snapshot +++ b/test/fixtures/vm/vm_dont_display_runtime_error.snapshot @@ -8,6 +8,6 @@ Error: boo! at test.vm:1:7 at Script.runInThisContext (node:vm:*) at Object.runInThisContext (node:vm:*) - at Object. (*fixtures*message*vm_dont_display_runtime_error.js:41:4) + at Object. (*fixtures*vm*vm_dont_display_runtime_error.js:41:4) Node.js * diff --git a/test/fixtures/message/vm_dont_display_syntax_error.js b/test/fixtures/vm/vm_dont_display_syntax_error.js similarity index 100% rename from test/fixtures/message/vm_dont_display_syntax_error.js rename to test/fixtures/vm/vm_dont_display_syntax_error.js diff --git a/test/fixtures/message/vm_dont_display_syntax_error.snapshot b/test/fixtures/vm/vm_dont_display_syntax_error.snapshot similarity index 69% rename from test/fixtures/message/vm_dont_display_syntax_error.snapshot rename to test/fixtures/vm/vm_dont_display_syntax_error.snapshot index fdbf879895e8a2..27c4faf563617c 100644 --- a/test/fixtures/message/vm_dont_display_syntax_error.snapshot +++ b/test/fixtures/vm/vm_dont_display_syntax_error.snapshot @@ -8,6 +8,6 @@ SyntaxError: Unexpected number at new Script (node:vm:*) at createScript (node:vm:*) at Object.runInThisContext (node:vm:*) - at Object. (*fixtures*message*vm_dont_display_syntax_error.js:41:4) + at Object. (*fixtures*vm*vm_dont_display_syntax_error.js:41:4) Node.js * diff --git a/test/parallel/test-node-output-console.mjs b/test/parallel/test-node-output-console.mjs new file mode 100644 index 00000000000000..d47536d9468f92 --- /dev/null +++ b/test/parallel/test-node-output-console.mjs @@ -0,0 +1,34 @@ +import '../common/index.mjs'; +import * as fixtures from '../common/fixtures.mjs'; +import * as snapshot from '../common/assertSnapshot.js'; +import { describe, it } from 'node:test'; + +function replaceNodeVersion(str) { + return str.replaceAll(process.version, '*'); +} + +function replaceStackTrace(str) { + return snapshot.replaceStackTrace(str, '$1at *$7\n'); +} + +describe('console output', { concurrency: true }, () => { + function stackTrace(str) { + return str.replaceAll(process.cwd(), '').replaceAll('/', '*').replaceAll(/\d+/g, '*'); + } + const tests = [ + { name: 'console/2100bytes.js' }, + { name: 'console/console_low_stack_space.js' }, + { name: 'console/console.js' }, + { name: 'console/hello_world.js' }, + { + name: 'console/stack_overflow.js', + transform: snapshot.transform(snapshot.replaceWindowsLineEndings, replaceNodeVersion, stackTrace) + }, + ]; + const defaultTransform = snapshot.transform(snapshot.replaceWindowsLineEndings, replaceStackTrace); + for (const { name, transform } of tests) { + it(name, async () => { + await snapshot.spawnAndAssert(fixtures.path(name), transform ?? defaultTransform); + }); + } +}); diff --git a/test/parallel/test-node-output-errors.mjs b/test/parallel/test-node-output-errors.mjs new file mode 100644 index 00000000000000..06647858f916ae --- /dev/null +++ b/test/parallel/test-node-output-errors.mjs @@ -0,0 +1,51 @@ +import '../common/index.mjs'; +import * as fixtures from '../common/fixtures.mjs'; +import * as snapshot from '../common/assertSnapshot.js'; +import { describe, it } from 'node:test'; + +function replaceNodeVersion(str) { + return str.replaceAll(process.version, '*'); +} + +function replaceStackTrace(str) { + return snapshot.replaceStackTrace(str, '$1at *$7\n'); +} + +describe('errors output', { concurrency: true }, () => { + function normalize(str) { + return str.replaceAll(process.cwd(), '').replaceAll('//', '*').replaceAll(/\/(\w)/g, '*$1').replaceAll('*test*', '*'); + } + + function normalizeNoNumbers(str) { + return normalize(str).replaceAll(/\d+:\d+/g, '*:*').replaceAll(/:\d+/g, ':*').replaceAll('*fixtures*message*', '*'); + } + const defaultTransform = snapshot.transform(snapshot.replaceWindowsLineEndings, replaceNodeVersion, normalize); + const errTransform = snapshot.transform(snapshot.replaceWindowsLineEndings, replaceNodeVersion, normalizeNoNumbers); + const promiseTransform = snapshot + .transform(snapshot.replaceWindowsLineEndings, replaceStackTrace, normalizeNoNumbers, replaceNodeVersion); + + const tests = [ + { name: 'errors/async_error_eval_cjs.js' }, + { name: 'errors/async_error_eval_esm.js' }, + { name: 'errors/async_error_microtask_main.js' }, + { name: 'errors/async_error_nexttick_main.js' }, + { name: 'errors/async_error_sync_main.js' }, + { name: 'errors/async_error_sync_esm.mjs' }, + { name: 'errors/error_aggregateTwoErrors.js', transform: errTransform }, + { name: 'errors/error_exit.js', transform: errTransform }, + { name: 'errors/error_with_nul.js', transform: errTransform }, + { name: 'errors/events_unhandled_error_common_trace.js', transform: errTransform }, + { name: 'errors/events_unhandled_error_nexttick.js', transform: errTransform }, + { name: 'errors/events_unhandled_error_sameline.js', transform: errTransform }, + { name: 'errors/events_unhandled_error_subclass.js', transform: errTransform }, + { name: 'errors/throw_custom_error.js', transform: errTransform }, + { name: 'errors/throw_in_line_with_tabs.js', transform: errTransform }, + { name: 'errors/throw_non_error.js', transform: errTransform }, + { name: 'errors/promise_always_throw_unhandled.js', transform: promiseTransform }, + ]; + for (const { name, transform } of tests) { + it(name, async () => { + await snapshot.spawnAndAssert(fixtures.path(name), transform ?? defaultTransform); + }); + } +}); diff --git a/test/parallel/test-node-output-sourcemaps.mjs b/test/parallel/test-node-output-sourcemaps.mjs new file mode 100644 index 00000000000000..cc6307d8366338 --- /dev/null +++ b/test/parallel/test-node-output-sourcemaps.mjs @@ -0,0 +1,33 @@ +import '../common/index.mjs'; +import * as fixtures from '../common/fixtures.mjs'; +import * as snapshot from '../common/assertSnapshot.js'; +import { describe, it } from 'node:test'; + +function replaceNodeVersion(str) { + return str.replaceAll(process.version, '*'); +} + +describe('sourcemaps output', { concurrency: true }, () => { + function normalize(str) { + return str.replaceAll(process.cwd(), '') + .replaceAll('//', '*') + .replaceAll('/Users/bencoe/oss/coffee-script-test', '') + .replaceAll(/\/(\w)/g, '*$1') + .replaceAll('*test*', '*') + .replaceAll('*fixtures*source-map*', '*'); + } + const defaultTransform = snapshot.transform(snapshot.replaceWindowsLineEndings, replaceNodeVersion, normalize); + + const tests = [ + { name: 'source-map/output/source_map_disabled_by_api.js' }, + { name: 'source-map/output/source_map_enabled_by_api.js' }, + { name: 'source-map/output/source_map_eval.js' }, + { name: 'source-map/output/source_map_no_source_file.js' }, + { name: 'source-map/output/source_map_throw_first_tick.js' }, + ]; + for (const { name, transform } of tests) { + it(name, async () => { + await snapshot.spawnAndAssert(fixtures.path(name), transform ?? defaultTransform); + }); + } +}); diff --git a/test/parallel/test-node-output-vm.mjs b/test/parallel/test-node-output-vm.mjs new file mode 100644 index 00000000000000..ccae772d2f3d6a --- /dev/null +++ b/test/parallel/test-node-output-vm.mjs @@ -0,0 +1,33 @@ +import '../common/index.mjs'; +import * as fixtures from '../common/fixtures.mjs'; +import * as snapshot from '../common/assertSnapshot.js'; +import { describe, it } from 'node:test'; + +function replaceNodeVersion(str) { + return str.replaceAll(process.version, '*'); +} + +describe('vm output', { concurrency: true }, () => { + function normalize(str) { + return str.replaceAll(process.cwd(), '').replaceAll('//', '*').replaceAll(/\/(\w)/g, '*$1').replaceAll('*test*', '*'); + } + + function normalizeNoNumbers(str) { + return normalize(str).replaceAll(/node:vm:\d+:\d+/g, 'node:vm:*'); + } + const defaultTransform = snapshot + .transform(snapshot.replaceWindowsLineEndings, replaceNodeVersion, normalizeNoNumbers); + + const tests = [ + { name: 'vm/vm_caught_custom_runtime_error.js' }, + { name: 'vm/vm_display_runtime_error.js' }, + { name: 'vm/vm_display_syntax_error.js' }, + { name: 'vm/vm_dont_display_runtime_error.js' }, + { name: 'vm/vm_dont_display_syntax_error.js' }, + ]; + for (const { name, transform } of tests) { + it(name, async () => { + await snapshot.spawnAndAssert(fixtures.path(name), transform ?? defaultTransform); + }); + } +}); diff --git a/test/parallel/test-node-output.mjs b/test/parallel/test-node-output.mjs deleted file mode 100644 index 2112962548ad8d..00000000000000 --- a/test/parallel/test-node-output.mjs +++ /dev/null @@ -1,123 +0,0 @@ -import '../common/index.mjs'; -import * as fixtures from '../common/fixtures.mjs'; -import * as snapshot from '../common/assertSnapshot.js'; -import { describe, it } from 'node:test'; - -function replaceNodeVersion(str) { - return str.replaceAll(process.version, '*'); -} - -function replaceStackTrace(str) { - return snapshot.replaceStackTrace(str, '$1at *$7\n'); -} - -describe('console', { concurrency: true }, () => { - function stackTrace(str) { - return str.replaceAll(process.cwd(), '').replaceAll('/', '*').replaceAll(/\d+/g, '*'); - } - const tests = [ - { name: 'message/2100bytes.js' }, - { name: 'message/console_low_stack_space.js' }, - { name: 'message/console.js' }, - { name: 'message/hello_world.js' }, - { - name: 'message/stack_overflow.js', - transform: snapshot.transform(snapshot.replaceWindowsLineEndings, replaceNodeVersion, stackTrace) - }, - ]; - const defaultTransform = snapshot.transform(snapshot.replaceWindowsLineEndings, replaceStackTrace); - for (const { name, transform } of tests) { - it(name, async () => { - await snapshot.spawnAndAssert(fixtures.path(name), transform ?? defaultTransform); - }); - } -}); - -describe('errors', { concurrency: true }, () => { - function normalize(str) { - return str.replaceAll(process.cwd(), '').replaceAll('//', '*').replaceAll(/\/(\w)/g, '*$1').replaceAll('*test*', '*'); - } - - function normalizeNoNumbers(str) { - return normalize(str).replaceAll(/\d+:\d+/g, '*:*').replaceAll(/:\d+/g, ':*').replaceAll('*fixtures*message*', '*'); - } - const defaultTransform = snapshot.transform(snapshot.replaceWindowsLineEndings, replaceNodeVersion, normalize); - const errTransform = snapshot.transform(snapshot.replaceWindowsLineEndings, replaceNodeVersion, normalizeNoNumbers); - const promiseTransform = snapshot - .transform(snapshot.replaceWindowsLineEndings, replaceStackTrace, normalizeNoNumbers, replaceNodeVersion); - - const tests = [ - { name: 'message/async_error_eval_cjs.js' }, - { name: 'message/async_error_eval_esm.js' }, - { name: 'message/async_error_microtask_main.js' }, - { name: 'message/async_error_nexttick_main.js' }, - { name: 'message/async_error_sync_main.js' }, - { name: 'message/async_error_sync_esm.mjs' }, - { name: 'message/error_aggregateTwoErrors.js', transform: errTransform }, - { name: 'message/error_exit.js', transform: errTransform }, - { name: 'message/error_with_nul.js', transform: errTransform }, - { name: 'message/events_unhandled_error_common_trace.js', transform: errTransform }, - { name: 'message/events_unhandled_error_nexttick.js', transform: errTransform }, - { name: 'message/events_unhandled_error_sameline.js', transform: errTransform }, - { name: 'message/events_unhandled_error_subclass.js', transform: errTransform }, - { name: 'message/throw_custom_error.js', transform: errTransform }, - { name: 'message/throw_in_line_with_tabs.js', transform: errTransform }, - { name: 'message/throw_non_error.js', transform: errTransform }, - { name: 'message/promise_always_throw_unhandled.js', transform: promiseTransform }, - ]; - for (const { name, transform } of tests) { - it(name, async () => { - await snapshot.spawnAndAssert(fixtures.path(name), transform ?? defaultTransform); - }); - } -}); - -describe('sourcemaps', { concurrency: true }, () => { - function normalize(str) { - return str.replaceAll(process.cwd(), '') - .replaceAll('//', '*') - .replaceAll('/Users/bencoe/oss/coffee-script-test', '') - .replaceAll(/\/(\w)/g, '*$1') - .replaceAll('*test*', '*') - .replaceAll('*fixtures*source-map*', '*'); - } - const defaultTransform = snapshot.transform(snapshot.replaceWindowsLineEndings, replaceNodeVersion, normalize); - - const tests = [ - { name: 'message/source_map_disabled_by_api.js' }, - { name: 'message/source_map_enabled_by_api.js' }, - { name: 'message/source_map_eval.js' }, - { name: 'message/source_map_no_source_file.js' }, - { name: 'message/source_map_throw_first_tick.js' }, - ]; - for (const { name, transform } of tests) { - it(name, async () => { - await snapshot.spawnAndAssert(fixtures.path(name), transform ?? defaultTransform); - }); - } -}); - -describe('vm', { concurrency: true }, () => { - function normalize(str) { - return str.replaceAll(process.cwd(), '').replaceAll('//', '*').replaceAll(/\/(\w)/g, '*$1').replaceAll('*test*', '*'); - } - - function normalizeNoNumbers(str) { - return normalize(str).replaceAll(/node:vm:\d+:\d+/g, 'node:vm:*'); - } - const defaultTransform = snapshot - .transform(snapshot.replaceWindowsLineEndings, replaceNodeVersion, normalizeNoNumbers); - - const tests = [ - { name: 'message/vm_caught_custom_runtime_error.js' }, - { name: 'message/vm_display_runtime_error.js' }, - { name: 'message/vm_display_syntax_error.js' }, - { name: 'message/vm_dont_display_runtime_error.js' }, - { name: 'message/vm_dont_display_syntax_error.js' }, - ]; - for (const { name, transform } of tests) { - it(name, async () => { - await snapshot.spawnAndAssert(fixtures.path(name), transform ?? defaultTransform); - }); - } -}); From 15e9d07a2c8114615872db8546f48a6f8ebef35c Mon Sep 17 00:00:00 2001 From: Moshe Atlow Date: Tue, 25 Apr 2023 01:16:31 +0300 Subject: [PATCH 03/12] fix --- .../output/source_map_disabled_by_api.js | 8 ++--- .../source_map_disabled_by_api.snapshot | 36 +++++++------------ .../output/source_map_enabled_by_api.js | 8 ++--- .../output/source_map_enabled_by_api.snapshot | 36 +++++++------------ .../source-map/output/source_map_eval.js | 4 +-- .../output/source_map_eval.snapshot | 29 +++++---------- .../output/source_map_no_source_file.js | 4 +-- .../output/source_map_no_source_file.snapshot | 27 ++++---------- .../output/source_map_throw_first_tick.js | 4 +-- .../source_map_throw_first_tick.snapshot | 29 +++++---------- 10 files changed, 60 insertions(+), 125 deletions(-) diff --git a/test/fixtures/source-map/output/source_map_disabled_by_api.js b/test/fixtures/source-map/output/source_map_disabled_by_api.js index 3d24f4458a6435..b1a28d0eae1c2e 100644 --- a/test/fixtures/source-map/output/source_map_disabled_by_api.js +++ b/test/fixtures/source-map/output/source_map_disabled_by_api.js @@ -1,25 +1,25 @@ // Flags: --enable-source-maps 'use strict'; -require('../../common'); +require('../../../common'); Error.stackTraceLimit = 5; process.setSourceMapsEnabled(false); try { - require('../source-map/enclosing-call-site-min.js'); + require('../enclosing-call-site-min.js'); } catch (e) { console.log(e); } delete require.cache[require - .resolve('../source-map/enclosing-call-site-min.js')]; + .resolve('../enclosing-call-site-min.js')]; // Re-enable. process.setSourceMapsEnabled(true); try { - require('../source-map/enclosing-call-site-min.js'); + require('../enclosing-call-site-min.js'); } catch (e) { console.log(e); } diff --git a/test/fixtures/source-map/output/source_map_disabled_by_api.snapshot b/test/fixtures/source-map/output/source_map_disabled_by_api.snapshot index 67204cb199b031..655cd6695e1116 100644 --- a/test/fixtures/source-map/output/source_map_disabled_by_api.snapshot +++ b/test/fixtures/source-map/output/source_map_disabled_by_api.snapshot @@ -1,24 +1,12 @@ -node:internal*modules*cjs*loader:1085 - throw err; - ^ - -Error: Cannot find module '../..*common' -Require stack: -- *output*source_map_disabled_by_api.js - at Module._resolveFilename (node:internal*modules*cjs*loader:1082:15) - at Module._load (node:internal*modules*cjs*loader:928:27) - at Module.require (node:internal*modules*cjs*loader:1149:19) - at require (node:internal*modules*helpers:121:18) - at Object. (*output*source_map_disabled_by_api.js:4:1) - at Module._compile (node:internal*modules*cjs*loader:1267:14) - at Module._extensions..js (node:internal*modules*cjs*loader:1321:10) - at Module.load (node:internal*modules*cjs*loader:1125:32) - at Module._load (node:internal*modules*cjs*loader:965:12) - at Function.executeUserEntryPoint [as runMain] (node:internal*modules*run_main:83:12) { - code: 'MODULE_NOT_FOUND', - requireStack: [ - '*output*source_map_disabled_by_api.js' - ] -} - -Node.js * +Error: an error! + at functionD (*enclosing-call-site-min.js:1:156) + at functionC (*enclosing-call-site-min.js:1:97) + at functionB (*enclosing-call-site-min.js:1:60) + at functionA (*enclosing-call-site-min.js:1:26) + at Object. (*enclosing-call-site-min.js:1:199) +Error: an error! + at functionD (*enclosing-call-site.js:16:17) + at functionC (*enclosing-call-site.js:10:3) + at functionB (*enclosing-call-site.js:6:3) + at functionA (*enclosing-call-site.js:2:3) + at Object. (*enclosing-call-site.js:24:3) diff --git a/test/fixtures/source-map/output/source_map_enabled_by_api.js b/test/fixtures/source-map/output/source_map_enabled_by_api.js index 42fec15e9a8875..4c70fa1cb2a240 100644 --- a/test/fixtures/source-map/output/source_map_enabled_by_api.js +++ b/test/fixtures/source-map/output/source_map_enabled_by_api.js @@ -1,22 +1,22 @@ 'use strict'; -require('../../common'); +require('../../../common'); Error.stackTraceLimit = 5; process.setSourceMapsEnabled(true); try { - require('../source-map/enclosing-call-site-min.js'); + require('../enclosing-call-site-min.js'); } catch (e) { console.log(e); } delete require.cache[require - .resolve('../source-map/enclosing-call-site-min.js')]; + .resolve('../enclosing-call-site-min.js')]; process.setSourceMapsEnabled(false); try { - require('../source-map/enclosing-call-site-min.js'); + require('../enclosing-call-site-min.js'); } catch (e) { console.log(e); } diff --git a/test/fixtures/source-map/output/source_map_enabled_by_api.snapshot b/test/fixtures/source-map/output/source_map_enabled_by_api.snapshot index 5ae7d983c54b79..082b3f310ed4f9 100644 --- a/test/fixtures/source-map/output/source_map_enabled_by_api.snapshot +++ b/test/fixtures/source-map/output/source_map_enabled_by_api.snapshot @@ -1,24 +1,12 @@ -node:internal*modules*cjs*loader:1085 - throw err; - ^ - -Error: Cannot find module '../..*common' -Require stack: -- *output*source_map_enabled_by_api.js - at Module._resolveFilename (node:internal*modules*cjs*loader:1082:15) - at Module._load (node:internal*modules*cjs*loader:928:27) - at Module.require (node:internal*modules*cjs*loader:1149:19) - at require (node:internal*modules*helpers:121:18) - at Object. (*output*source_map_enabled_by_api.js:2:1) - at Module._compile (node:internal*modules*cjs*loader:1267:14) - at Module._extensions..js (node:internal*modules*cjs*loader:1321:10) - at Module.load (node:internal*modules*cjs*loader:1125:32) - at Module._load (node:internal*modules*cjs*loader:965:12) - at Function.executeUserEntryPoint [as runMain] (node:internal*modules*run_main:83:12) { - code: 'MODULE_NOT_FOUND', - requireStack: [ - '*output*source_map_enabled_by_api.js' - ] -} - -Node.js * +Error: an error! + at functionD (*enclosing-call-site.js:16:17) + at functionC (*enclosing-call-site.js:10:3) + at functionB (*enclosing-call-site.js:6:3) + at functionA (*enclosing-call-site.js:2:3) + at Object. (*enclosing-call-site.js:24:3) +Error: an error! + at functionD (*enclosing-call-site-min.js:1:156) + at functionC (*enclosing-call-site-min.js:1:97) + at functionB (*enclosing-call-site-min.js:1:60) + at functionA (*enclosing-call-site-min.js:1:26) + at Object. (*enclosing-call-site-min.js:1:199) diff --git a/test/fixtures/source-map/output/source_map_eval.js b/test/fixtures/source-map/output/source_map_eval.js index f03ddf0fb1ddb0..5492c179248180 100644 --- a/test/fixtures/source-map/output/source_map_eval.js +++ b/test/fixtures/source-map/output/source_map_eval.js @@ -1,10 +1,10 @@ // Flags: --enable-source-maps 'use strict'; -require('../../common'); +require('../../../common'); Error.stackTraceLimit = 3; const fs = require('fs'); -const content = fs.readFileSync(require.resolve('../source-map/tabs.js'), 'utf8'); +const content = fs.readFileSync(require.resolve('../tabs.js'), 'utf8'); eval(content); diff --git a/test/fixtures/source-map/output/source_map_eval.snapshot b/test/fixtures/source-map/output/source_map_eval.snapshot index 84efd83c652b1d..a4fcdb25282dfa 100644 --- a/test/fixtures/source-map/output/source_map_eval.snapshot +++ b/test/fixtures/source-map/output/source_map_eval.snapshot @@ -1,24 +1,11 @@ -node:internal*modules*cjs*loader:1085 - throw err; - ^ +*tabs.coffee:26 + alert "I knew it!" + ^ -Error: Cannot find module '../..*common' -Require stack: -- *output*source_map_eval.js - at Module._resolveFilename (node:internal*modules*cjs*loader:1082:15) - at Module._load (node:internal*modules*cjs*loader:928:27) - at Module.require (node:internal*modules*cjs*loader:1149:19) - at require (node:internal*modules*helpers:121:18) - at Object. (*output*source_map_eval.js:4:1) - at Module._compile (node:internal*modules*cjs*loader:1267:14) - at Module._extensions..js (node:internal*modules*cjs*loader:1321:10) - at Module.load (node:internal*modules*cjs*loader:1125:32) - at Module._load (node:internal*modules*cjs*loader:965:12) - at Function.executeUserEntryPoint [as runMain] (node:internal*modules*run_main:83:12) { - code: 'MODULE_NOT_FOUND', - requireStack: [ - '*output*source_map_eval.js' - ] -} + +ReferenceError: alert is not defined + at Object.eval (*tabs.coffee:26:2) + at eval (*tabs.coffee:1:14) + at Object. (*output*source_map_eval.js:10:1) Node.js * diff --git a/test/fixtures/source-map/output/source_map_no_source_file.js b/test/fixtures/source-map/output/source_map_no_source_file.js index 05adfdf8e21b1e..eb7a107fa2f8ce 100644 --- a/test/fixtures/source-map/output/source_map_no_source_file.js +++ b/test/fixtures/source-map/output/source_map_no_source_file.js @@ -1,7 +1,7 @@ // Flags: --enable-source-maps 'use strict'; -require('../../common'); +require('../../../common'); Error.stackTraceLimit = 2; -require('../source-map/no-source.js'); +require('../no-source.js'); diff --git a/test/fixtures/source-map/output/source_map_no_source_file.snapshot b/test/fixtures/source-map/output/source_map_no_source_file.snapshot index 12366a2acc93a5..cf9329747ba692 100644 --- a/test/fixtures/source-map/output/source_map_no_source_file.snapshot +++ b/test/fixtures/source-map/output/source_map_no_source_file.snapshot @@ -1,24 +1,9 @@ -node:internal*modules*cjs*loader:1085 - throw err; - ^ +*no-source.js:2 + throw new Error('foo'); + ^ -Error: Cannot find module '../..*common' -Require stack: -- *output*source_map_no_source_file.js - at Module._resolveFilename (node:internal*modules*cjs*loader:1082:15) - at Module._load (node:internal*modules*cjs*loader:928:27) - at Module.require (node:internal*modules*cjs*loader:1149:19) - at require (node:internal*modules*helpers:121:18) - at Object. (*output*source_map_no_source_file.js:4:1) - at Module._compile (node:internal*modules*cjs*loader:1267:14) - at Module._extensions..js (node:internal*modules*cjs*loader:1321:10) - at Module.load (node:internal*modules*cjs*loader:1125:32) - at Module._load (node:internal*modules*cjs*loader:965:12) - at Function.executeUserEntryPoint [as runMain] (node:internal*modules*run_main:83:12) { - code: 'MODULE_NOT_FOUND', - requireStack: [ - '*output*source_map_no_source_file.js' - ] -} +Error: foo + at Throw (*file-not-exists.ts:2:9) + at Object. (*file-not-exists.ts:5:1) Node.js * diff --git a/test/fixtures/source-map/output/source_map_throw_first_tick.js b/test/fixtures/source-map/output/source_map_throw_first_tick.js index 302818eabadb99..62c2b41c693e9d 100644 --- a/test/fixtures/source-map/output/source_map_throw_first_tick.js +++ b/test/fixtures/source-map/output/source_map_throw_first_tick.js @@ -1,7 +1,7 @@ // Flags: --enable-source-maps 'use strict'; -require('../../common'); +require('../../../common'); Error.stackTraceLimit = 2; -require('../source-map/typescript-throw'); +require('../typescript-throw'); diff --git a/test/fixtures/source-map/output/source_map_throw_first_tick.snapshot b/test/fixtures/source-map/output/source_map_throw_first_tick.snapshot index f27d74fd6da560..fba8c95cc1103f 100644 --- a/test/fixtures/source-map/output/source_map_throw_first_tick.snapshot +++ b/test/fixtures/source-map/output/source_map_throw_first_tick.snapshot @@ -1,24 +1,11 @@ -node:internal*modules*cjs*loader:1085 - throw err; - ^ +reachable +*typescript-throw.ts:18 + throw Error('an exception'); + ^ -Error: Cannot find module '../..*common' -Require stack: -- *output*source_map_throw_first_tick.js - at Module._resolveFilename (node:internal*modules*cjs*loader:1082:15) - at Module._load (node:internal*modules*cjs*loader:928:27) - at Module.require (node:internal*modules*cjs*loader:1149:19) - at require (node:internal*modules*helpers:121:18) - at Object. (*output*source_map_throw_first_tick.js:4:1) - at Module._compile (node:internal*modules*cjs*loader:1267:14) - at Module._extensions..js (node:internal*modules*cjs*loader:1321:10) - at Module.load (node:internal*modules*cjs*loader:1125:32) - at Module._load (node:internal*modules*cjs*loader:965:12) - at Function.executeUserEntryPoint [as runMain] (node:internal*modules*run_main:83:12) { - code: 'MODULE_NOT_FOUND', - requireStack: [ - '*output*source_map_throw_first_tick.js' - ] -} + +Error: an exception + at branch (*typescript-throw.ts:18:11) + at Object. (*typescript-throw.ts:24:1) Node.js * From b3863d87a5368282ebb86e56d9e48f108985d75b Mon Sep 17 00:00:00 2001 From: Moshe Atlow Date: Tue, 25 Apr 2023 01:21:11 +0300 Subject: [PATCH 04/12] reduce diff --- .../errors/async_error_microtask_main.snapshot | 2 +- .../errors/async_error_nexttick_main.snapshot | 2 +- .../errors/async_error_sync_esm.snapshot | 2 +- .../errors/async_error_sync_main.snapshot | 2 +- .../errors/error_aggregateTwoErrors.snapshot | 6 +++--- test/fixtures/errors/error_exit.snapshot | 2 +- test/fixtures/errors/error_with_nul.snapshot | Bin 222 -> 174 bytes ...events_unhandled_error_common_trace.snapshot | 8 ++++---- .../events_unhandled_error_nexttick.snapshot | 4 ++-- .../events_unhandled_error_sameline.snapshot | 4 ++-- .../events_unhandled_error_subclass.snapshot | 4 ++-- .../promise_always_throw_unhandled.snapshot | 2 +- .../fixtures/errors/throw_custom_error.snapshot | 2 +- .../errors/throw_in_line_with_tabs.snapshot | 2 +- test/fixtures/errors/throw_non_error.snapshot | 2 +- test/parallel/test-node-output-errors.mjs | 2 +- 16 files changed, 23 insertions(+), 23 deletions(-) diff --git a/test/fixtures/errors/async_error_microtask_main.snapshot b/test/fixtures/errors/async_error_microtask_main.snapshot index ae1ccdd748daf9..9d84b96c35de68 100644 --- a/test/fixtures/errors/async_error_microtask_main.snapshot +++ b/test/fixtures/errors/async_error_microtask_main.snapshot @@ -3,4 +3,4 @@ Error: test at two (*fixtures*async-error.js:17:9) at async three (*fixtures*async-error.js:20:3) at async four (*fixtures*async-error.js:24:3) - at async main (*fixtures*errors*async_error_microtask_main.js:7:5) + at async main (*async_error_microtask_main.js:7:5) diff --git a/test/fixtures/errors/async_error_nexttick_main.snapshot b/test/fixtures/errors/async_error_nexttick_main.snapshot index 07420efe48fe0d..eff2c0569cce82 100644 --- a/test/fixtures/errors/async_error_nexttick_main.snapshot +++ b/test/fixtures/errors/async_error_nexttick_main.snapshot @@ -4,4 +4,4 @@ Error: test at process.processTicksAndRejections (node:internal*process*task_queues:95:5) at async three (*fixtures*async-error.js:20:3) at async four (*fixtures*async-error.js:24:3) - at async main (*fixtures*errors*async_error_nexttick_main.js:7:5) + at async main (*async_error_nexttick_main.js:7:5) diff --git a/test/fixtures/errors/async_error_sync_esm.snapshot b/test/fixtures/errors/async_error_sync_esm.snapshot index e5571eae656c8b..7437ec8bd9dc27 100644 --- a/test/fixtures/errors/async_error_sync_esm.snapshot +++ b/test/fixtures/errors/async_error_sync_esm.snapshot @@ -3,4 +3,4 @@ Error: test at two (*fixtures*async-error.js:17:9) at async three (*fixtures*async-error.js:20:3) at async four (*fixtures*async-error.js:24:3) - at async main (file:**fixtures*errors*async_error_sync_esm.mjs:6:5) + at async main (file:**async_error_sync_esm.mjs:6:5) diff --git a/test/fixtures/errors/async_error_sync_main.snapshot b/test/fixtures/errors/async_error_sync_main.snapshot index 4ad9ddad4ff206..34aaec5fed2d5f 100644 --- a/test/fixtures/errors/async_error_sync_main.snapshot +++ b/test/fixtures/errors/async_error_sync_main.snapshot @@ -3,4 +3,4 @@ Error: test at two (*fixtures*async-error.js:17:9) at async three (*fixtures*async-error.js:20:3) at async four (*fixtures*async-error.js:24:3) - at async main (*fixtures*errors*async_error_sync_main.js:7:5) + at async main (*async_error_sync_main.js:7:5) diff --git a/test/fixtures/errors/error_aggregateTwoErrors.snapshot b/test/fixtures/errors/error_aggregateTwoErrors.snapshot index 6bb4aed30a5003..a8d13c461b2cb0 100644 --- a/test/fixtures/errors/error_aggregateTwoErrors.snapshot +++ b/test/fixtures/errors/error_aggregateTwoErrors.snapshot @@ -1,4 +1,4 @@ -*fixtures*errors*error_aggregateTwoErrors.js:* +*error_aggregateTwoErrors.js:* throw aggregateTwoErrors(err, originalError); ^ @@ -6,11 +6,11 @@ throw aggregateTwoErrors(err, originalError); code: 'ERR0', [errors]: [ Error: original - at Object. (*fixtures*errors*error_aggregateTwoErrors.js:*:*) { + at Object. (*error_aggregateTwoErrors.js:*:*) { code: 'ERR0' }, Error: second error - at Object. (*fixtures*errors*error_aggregateTwoErrors.js:*:*) { + at Object. (*error_aggregateTwoErrors.js:*:*) { code: 'ERR1' } ] diff --git a/test/fixtures/errors/error_exit.snapshot b/test/fixtures/errors/error_exit.snapshot index 4eb813b187e7dd..778165dc25c4fc 100644 --- a/test/fixtures/errors/error_exit.snapshot +++ b/test/fixtures/errors/error_exit.snapshot @@ -7,7 +7,7 @@ AssertionError [ERR_ASSERTION]: Expected values to be strictly equal: 1 !== 2 - at Object. (*fixtures*errors*error_exit.js:*:*) { + at Object. (*error_exit.js:*:*) { generatedMessage: true, code: 'ERR_ASSERTION', actual: 1, diff --git a/test/fixtures/errors/error_with_nul.snapshot b/test/fixtures/errors/error_with_nul.snapshot index a1e86b2e0a32458df712d2c547cd333a2a013cb7..7dd4d665555874863591d5ba33d4833ebea75717 100644 GIT binary patch delta 22 dcmcb|xQ>w{F)5iLB{hv}qD0`tO5=%plmJv(2b=%^ delta 70 wcmZ3-c#lycF)5iLB{hvpD=o94q_iltSSz)tD8Hz9B1a%Ux=@4(hETUM0E31aR{#J2 diff --git a/test/fixtures/errors/events_unhandled_error_common_trace.snapshot b/test/fixtures/errors/events_unhandled_error_common_trace.snapshot index 1ca5f3b5bc6484..a482c105b75e48 100644 --- a/test/fixtures/errors/events_unhandled_error_common_trace.snapshot +++ b/test/fixtures/errors/events_unhandled_error_common_trace.snapshot @@ -3,10 +3,10 @@ node:events:* ^ Error: foo:bar - at bar (*fixtures*errors*events_unhandled_error_common_trace.js:*:*) - at foo (*fixtures*errors*events_unhandled_error_common_trace.js:*:*) + at bar (*events_unhandled_error_common_trace.js:*:*) + at foo (*events_unhandled_error_common_trace.js:*:*) Emitted 'error' event at: - at quux (*fixtures*errors*events_unhandled_error_common_trace.js:*:*) - at Object. (*fixtures*errors*events_unhandled_error_common_trace.js:*:*) + at quux (*events_unhandled_error_common_trace.js:*:*) + at Object. (*events_unhandled_error_common_trace.js:*:*) Node.js * diff --git a/test/fixtures/errors/events_unhandled_error_nexttick.snapshot b/test/fixtures/errors/events_unhandled_error_nexttick.snapshot index d057375e8f2da4..450d4910a385b5 100644 --- a/test/fixtures/errors/events_unhandled_error_nexttick.snapshot +++ b/test/fixtures/errors/events_unhandled_error_nexttick.snapshot @@ -3,8 +3,8 @@ node:events:* ^ Error - at Object. (*fixtures*errors*events_unhandled_error_nexttick.js:*:*) + at Object. (*events_unhandled_error_nexttick.js:*:*) Emitted 'error' event at: - at *fixtures*errors*events_unhandled_error_nexttick.js:*:* + at *events_unhandled_error_nexttick.js:*:* Node.js * diff --git a/test/fixtures/errors/events_unhandled_error_sameline.snapshot b/test/fixtures/errors/events_unhandled_error_sameline.snapshot index ae9676dc113b86..520601e617083c 100644 --- a/test/fixtures/errors/events_unhandled_error_sameline.snapshot +++ b/test/fixtures/errors/events_unhandled_error_sameline.snapshot @@ -3,8 +3,8 @@ node:events:* ^ Error - at Object. (*fixtures*errors*events_unhandled_error_sameline.js:*:*) + at Object. (*events_unhandled_error_sameline.js:*:*) Emitted 'error' event at: - at Object. (*fixtures*errors*events_unhandled_error_sameline.js:*:*) + at Object. (*events_unhandled_error_sameline.js:*:*) Node.js * diff --git a/test/fixtures/errors/events_unhandled_error_subclass.snapshot b/test/fixtures/errors/events_unhandled_error_subclass.snapshot index b86e50d2ca36e6..6a9cfd4a1a0b21 100644 --- a/test/fixtures/errors/events_unhandled_error_subclass.snapshot +++ b/test/fixtures/errors/events_unhandled_error_subclass.snapshot @@ -3,8 +3,8 @@ node:events:* ^ Error - at Object. (*fixtures*errors*events_unhandled_error_subclass.js:*:*) + at Object. (*events_unhandled_error_subclass.js:*:*) Emitted 'error' event on Foo instance at: - at Object. (*fixtures*errors*events_unhandled_error_subclass.js:*:*) + at Object. (*events_unhandled_error_subclass.js:*:*) Node.js * diff --git a/test/fixtures/errors/promise_always_throw_unhandled.snapshot b/test/fixtures/errors/promise_always_throw_unhandled.snapshot index e864583478412b..c97540f5499f87 100644 --- a/test/fixtures/errors/promise_always_throw_unhandled.snapshot +++ b/test/fixtures/errors/promise_always_throw_unhandled.snapshot @@ -1,4 +1,4 @@ -*fixtures*errors*promise_always_throw_unhandled.js:* +*promise_always_throw_unhandled.js:* throw new Error('One'); ^ diff --git a/test/fixtures/errors/throw_custom_error.snapshot b/test/fixtures/errors/throw_custom_error.snapshot index d470ed394dbf03..ba80020c897a32 100644 --- a/test/fixtures/errors/throw_custom_error.snapshot +++ b/test/fixtures/errors/throw_custom_error.snapshot @@ -1,5 +1,5 @@ -*fixtures*errors*throw_custom_error.js:* +*throw_custom_error.js:* throw ({ name: 'MyCustomError', message: 'This is a custom message' }); ^ { name: 'MyCustomError', message: 'This is a custom message' } diff --git a/test/fixtures/errors/throw_in_line_with_tabs.snapshot b/test/fixtures/errors/throw_in_line_with_tabs.snapshot index 69282be63fe7ce..29c7e1ec3587d9 100644 --- a/test/fixtures/errors/throw_in_line_with_tabs.snapshot +++ b/test/fixtures/errors/throw_in_line_with_tabs.snapshot @@ -1,6 +1,6 @@ before -*fixtures*errors*throw_in_line_with_tabs.js:* +*throw_in_line_with_tabs.js:* throw ({ foo: 'bar' }); ^ { foo: 'bar' } diff --git a/test/fixtures/errors/throw_non_error.snapshot b/test/fixtures/errors/throw_non_error.snapshot index 4cc15afdd27b46..4ad80df4f6a9cb 100644 --- a/test/fixtures/errors/throw_non_error.snapshot +++ b/test/fixtures/errors/throw_non_error.snapshot @@ -1,5 +1,5 @@ -*fixtures*errors*throw_non_error.js:* +*throw_non_error.js:* throw ({ foo: 'bar' }); ^ { foo: 'bar' } diff --git a/test/parallel/test-node-output-errors.mjs b/test/parallel/test-node-output-errors.mjs index 06647858f916ae..e523f90b5de378 100644 --- a/test/parallel/test-node-output-errors.mjs +++ b/test/parallel/test-node-output-errors.mjs @@ -13,7 +13,7 @@ function replaceStackTrace(str) { describe('errors output', { concurrency: true }, () => { function normalize(str) { - return str.replaceAll(process.cwd(), '').replaceAll('//', '*').replaceAll(/\/(\w)/g, '*$1').replaceAll('*test*', '*'); + return str.replaceAll(process.cwd(), '').replaceAll('//', '*').replaceAll(/\/(\w)/g, '*$1').replaceAll('*test*', '*').replaceAll('*fixtures*errors*', '*'); } function normalizeNoNumbers(str) { From cbcf3ec67f4157945dd4c77f73d35691504afedd Mon Sep 17 00:00:00 2001 From: Moshe Atlow Date: Tue, 25 Apr 2023 02:02:12 +0300 Subject: [PATCH 05/12] fix windows --- test/common/assertSnapshot.js | 5 +++++ test/parallel/test-node-output-console.mjs | 6 ++++-- test/parallel/test-node-output-errors.mjs | 9 +++++---- test/parallel/test-node-output-sourcemaps.mjs | 3 ++- test/parallel/test-node-output-vm.mjs | 7 ++----- 5 files changed, 18 insertions(+), 12 deletions(-) diff --git a/test/common/assertSnapshot.js b/test/common/assertSnapshot.js index 06da88717417b2..4986103fe92245 100644 --- a/test/common/assertSnapshot.js +++ b/test/common/assertSnapshot.js @@ -16,6 +16,10 @@ function replaceWindowsLineEndings(str) { return str.replace(windowNewlineRegexp, ''); } +function replaceWindowsPaths(str) { + return str.replaceAll(path.win32.sep, path.posix.sep); +} + function transform(...args) { return (str) => args.reduce((acc, fn) => fn(acc), str); } @@ -60,6 +64,7 @@ module.exports = { getSnapshotPath, replaceStackTrace, replaceWindowsLineEndings, + replaceWindowsPaths, spawnAndAssert, transform, }; diff --git a/test/parallel/test-node-output-console.mjs b/test/parallel/test-node-output-console.mjs index d47536d9468f92..743d64bea4281a 100644 --- a/test/parallel/test-node-output-console.mjs +++ b/test/parallel/test-node-output-console.mjs @@ -22,10 +22,12 @@ describe('console output', { concurrency: true }, () => { { name: 'console/hello_world.js' }, { name: 'console/stack_overflow.js', - transform: snapshot.transform(snapshot.replaceWindowsLineEndings, replaceNodeVersion, stackTrace) + transform: snapshot + .transform(snapshot.replaceWindowsLineEndings, snapshot.replaceWindowsPaths, replaceNodeVersion, stackTrace) }, ]; - const defaultTransform = snapshot.transform(snapshot.replaceWindowsLineEndings, replaceStackTrace); + const defaultTransform = snapshot + .transform(snapshot.replaceWindowsLineEndings, snapshot.replaceWindowsPaths, replaceStackTrace); for (const { name, transform } of tests) { it(name, async () => { await snapshot.spawnAndAssert(fixtures.path(name), transform ?? defaultTransform); diff --git a/test/parallel/test-node-output-errors.mjs b/test/parallel/test-node-output-errors.mjs index e523f90b5de378..283656cc440742 100644 --- a/test/parallel/test-node-output-errors.mjs +++ b/test/parallel/test-node-output-errors.mjs @@ -19,10 +19,11 @@ describe('errors output', { concurrency: true }, () => { function normalizeNoNumbers(str) { return normalize(str).replaceAll(/\d+:\d+/g, '*:*').replaceAll(/:\d+/g, ':*').replaceAll('*fixtures*message*', '*'); } - const defaultTransform = snapshot.transform(snapshot.replaceWindowsLineEndings, replaceNodeVersion, normalize); - const errTransform = snapshot.transform(snapshot.replaceWindowsLineEndings, replaceNodeVersion, normalizeNoNumbers); - const promiseTransform = snapshot - .transform(snapshot.replaceWindowsLineEndings, replaceStackTrace, normalizeNoNumbers, replaceNodeVersion); + const common = snapshot + .transform(snapshot.replaceWindowsLineEndings, snapshot.replaceWindowsPaths, replaceNodeVersion); + const defaultTransform = snapshot.transform(common, normalize); + const errTransform = snapshot.transform(common, normalizeNoNumbers); + const promiseTransform = snapshot.transform(common, replaceStackTrace, normalizeNoNumbers); const tests = [ { name: 'errors/async_error_eval_cjs.js' }, diff --git a/test/parallel/test-node-output-sourcemaps.mjs b/test/parallel/test-node-output-sourcemaps.mjs index cc6307d8366338..2a3c6a648d2d77 100644 --- a/test/parallel/test-node-output-sourcemaps.mjs +++ b/test/parallel/test-node-output-sourcemaps.mjs @@ -16,7 +16,8 @@ describe('sourcemaps output', { concurrency: true }, () => { .replaceAll('*test*', '*') .replaceAll('*fixtures*source-map*', '*'); } - const defaultTransform = snapshot.transform(snapshot.replaceWindowsLineEndings, replaceNodeVersion, normalize); + const defaultTransform = snapshot + .transform(snapshot.replaceWindowsLineEndings, snapshot.replaceWindowsPaths, replaceNodeVersion, normalize); const tests = [ { name: 'source-map/output/source_map_disabled_by_api.js' }, diff --git a/test/parallel/test-node-output-vm.mjs b/test/parallel/test-node-output-vm.mjs index ccae772d2f3d6a..21a5780635c047 100644 --- a/test/parallel/test-node-output-vm.mjs +++ b/test/parallel/test-node-output-vm.mjs @@ -9,14 +9,11 @@ function replaceNodeVersion(str) { describe('vm output', { concurrency: true }, () => { function normalize(str) { - return str.replaceAll(process.cwd(), '').replaceAll('//', '*').replaceAll(/\/(\w)/g, '*$1').replaceAll('*test*', '*'); + return str.replaceAll(process.cwd(), '').replaceAll('//', '*').replaceAll(/\/(\w)/g, '*$1').replaceAll('*test*', '*').replaceAll(/node:vm:\d+:\d+/g, 'node:vm:*'); } - function normalizeNoNumbers(str) { - return normalize(str).replaceAll(/node:vm:\d+:\d+/g, 'node:vm:*'); - } const defaultTransform = snapshot - .transform(snapshot.replaceWindowsLineEndings, replaceNodeVersion, normalizeNoNumbers); + .transform(snapshot.replaceWindowsLineEndings, snapshot.replaceWindowsPaths, replaceNodeVersion, normalize); const tests = [ { name: 'vm/vm_caught_custom_runtime_error.js' }, From aa243f07991bfd1f1de6d7ff46b569242c16c264 Mon Sep 17 00:00:00 2001 From: Moshe Atlow Date: Tue, 25 Apr 2023 08:48:12 +0300 Subject: [PATCH 06/12] fix again --- test/parallel/test-node-output-console.mjs | 2 +- test/parallel/test-node-output-errors.mjs | 2 +- test/parallel/test-node-output-sourcemaps.mjs | 3 ++- test/parallel/test-node-output-vm.mjs | 2 +- 4 files changed, 5 insertions(+), 4 deletions(-) diff --git a/test/parallel/test-node-output-console.mjs b/test/parallel/test-node-output-console.mjs index 743d64bea4281a..6656028bae4795 100644 --- a/test/parallel/test-node-output-console.mjs +++ b/test/parallel/test-node-output-console.mjs @@ -13,7 +13,7 @@ function replaceStackTrace(str) { describe('console output', { concurrency: true }, () => { function stackTrace(str) { - return str.replaceAll(process.cwd(), '').replaceAll('/', '*').replaceAll(/\d+/g, '*'); + return str.replaceAll(snapshot.replaceWindowsPaths(process.cwd()), '').replaceAll('/', '*').replaceAll(/\d+/g, '*'); } const tests = [ { name: 'console/2100bytes.js' }, diff --git a/test/parallel/test-node-output-errors.mjs b/test/parallel/test-node-output-errors.mjs index 283656cc440742..b4d9a845d3ae60 100644 --- a/test/parallel/test-node-output-errors.mjs +++ b/test/parallel/test-node-output-errors.mjs @@ -13,7 +13,7 @@ function replaceStackTrace(str) { describe('errors output', { concurrency: true }, () => { function normalize(str) { - return str.replaceAll(process.cwd(), '').replaceAll('//', '*').replaceAll(/\/(\w)/g, '*$1').replaceAll('*test*', '*').replaceAll('*fixtures*errors*', '*'); + return str.replaceAll(snapshot.replaceWindowsPaths(process.cwd()), '').replaceAll('//', '*').replaceAll(/\/(\w)/g, '*$1').replaceAll('*test*', '*').replaceAll('*fixtures*errors*', '*'); } function normalizeNoNumbers(str) { diff --git a/test/parallel/test-node-output-sourcemaps.mjs b/test/parallel/test-node-output-sourcemaps.mjs index 2a3c6a648d2d77..7191bda30edb83 100644 --- a/test/parallel/test-node-output-sourcemaps.mjs +++ b/test/parallel/test-node-output-sourcemaps.mjs @@ -9,7 +9,8 @@ function replaceNodeVersion(str) { describe('sourcemaps output', { concurrency: true }, () => { function normalize(str) { - return str.replaceAll(process.cwd(), '') + return str + .replaceAll(snapshot.replaceWindowsPaths(process.cwd()), '') .replaceAll('//', '*') .replaceAll('/Users/bencoe/oss/coffee-script-test', '') .replaceAll(/\/(\w)/g, '*$1') diff --git a/test/parallel/test-node-output-vm.mjs b/test/parallel/test-node-output-vm.mjs index 21a5780635c047..52dc9a0d57607c 100644 --- a/test/parallel/test-node-output-vm.mjs +++ b/test/parallel/test-node-output-vm.mjs @@ -9,7 +9,7 @@ function replaceNodeVersion(str) { describe('vm output', { concurrency: true }, () => { function normalize(str) { - return str.replaceAll(process.cwd(), '').replaceAll('//', '*').replaceAll(/\/(\w)/g, '*$1').replaceAll('*test*', '*').replaceAll(/node:vm:\d+:\d+/g, 'node:vm:*'); + return str.replaceAll(snapshot.replaceWindowsPaths(process.cwd()), '').replaceAll('//', '*').replaceAll(/\/(\w)/g, '*$1').replaceAll('*test*', '*').replaceAll(/node:vm:\d+:\d+/g, 'node:vm:*'); } const defaultTransform = snapshot From 97701508eb3568e0fb259ea014b471102d2a39a3 Mon Sep 17 00:00:00 2001 From: Moshe Atlow Date: Tue, 25 Apr 2023 10:30:53 +0300 Subject: [PATCH 07/12] fix again --- test/fixtures/errors/async_error_sync_esm.snapshot | 2 +- test/parallel/test-node-output-errors.mjs | 2 +- test/parallel/test-node-output-sourcemaps.mjs | 1 + 3 files changed, 3 insertions(+), 2 deletions(-) diff --git a/test/fixtures/errors/async_error_sync_esm.snapshot b/test/fixtures/errors/async_error_sync_esm.snapshot index 7437ec8bd9dc27..3d232a3243e0da 100644 --- a/test/fixtures/errors/async_error_sync_esm.snapshot +++ b/test/fixtures/errors/async_error_sync_esm.snapshot @@ -3,4 +3,4 @@ Error: test at two (*fixtures*async-error.js:17:9) at async three (*fixtures*async-error.js:20:3) at async four (*fixtures*async-error.js:24:3) - at async main (file:**async_error_sync_esm.mjs:6:5) + at async main (file:*/async_error_sync_esm.mjs:6:5) diff --git a/test/parallel/test-node-output-errors.mjs b/test/parallel/test-node-output-errors.mjs index b4d9a845d3ae60..5668fca4dc89b8 100644 --- a/test/parallel/test-node-output-errors.mjs +++ b/test/parallel/test-node-output-errors.mjs @@ -13,7 +13,7 @@ function replaceStackTrace(str) { describe('errors output', { concurrency: true }, () => { function normalize(str) { - return str.replaceAll(snapshot.replaceWindowsPaths(process.cwd()), '').replaceAll('//', '*').replaceAll(/\/(\w)/g, '*$1').replaceAll('*test*', '*').replaceAll('*fixtures*errors*', '*'); + return str.replaceAll(snapshot.replaceWindowsPaths(process.cwd()), '').replaceAll('//', '*').replaceAll(/\/(\w)/g, '*$1').replaceAll('*test*', '*').replaceAll('*fixtures*errors*', '*').replaceAll('file:**', 'file:*/'); } function normalizeNoNumbers(str) { diff --git a/test/parallel/test-node-output-sourcemaps.mjs b/test/parallel/test-node-output-sourcemaps.mjs index 7191bda30edb83..d06e4287910c86 100644 --- a/test/parallel/test-node-output-sourcemaps.mjs +++ b/test/parallel/test-node-output-sourcemaps.mjs @@ -12,6 +12,7 @@ describe('sourcemaps output', { concurrency: true }, () => { return str .replaceAll(snapshot.replaceWindowsPaths(process.cwd()), '') .replaceAll('//', '*') + .replaceAll('C:/Users/bencoe/oss/coffee-script-test', '') .replaceAll('/Users/bencoe/oss/coffee-script-test', '') .replaceAll(/\/(\w)/g, '*$1') .replaceAll('*test*', '*') From 0d68d34851edc888b4158714da4e4ae6774a2353 Mon Sep 17 00:00:00 2001 From: Moshe Atlow Date: Tue, 25 Apr 2023 11:16:21 +0300 Subject: [PATCH 08/12] fix again --- test/parallel/test-node-output-sourcemaps.mjs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/test/parallel/test-node-output-sourcemaps.mjs b/test/parallel/test-node-output-sourcemaps.mjs index d06e4287910c86..8e749de5e7606c 100644 --- a/test/parallel/test-node-output-sourcemaps.mjs +++ b/test/parallel/test-node-output-sourcemaps.mjs @@ -1,6 +1,7 @@ import '../common/index.mjs'; import * as fixtures from '../common/fixtures.mjs'; import * as snapshot from '../common/assertSnapshot.js'; +import { resolve } from 'node:path'; import { describe, it } from 'node:test'; function replaceNodeVersion(str) { @@ -12,8 +13,7 @@ describe('sourcemaps output', { concurrency: true }, () => { return str .replaceAll(snapshot.replaceWindowsPaths(process.cwd()), '') .replaceAll('//', '*') - .replaceAll('C:/Users/bencoe/oss/coffee-script-test', '') - .replaceAll('/Users/bencoe/oss/coffee-script-test', '') + .replaceAll(resolve('/Users/bencoe/oss/coffee-script-test'), '') .replaceAll(/\/(\w)/g, '*$1') .replaceAll('*test*', '*') .replaceAll('*fixtures*source-map*', '*'); From 49cb24b05fc534ea80cf484c6b56cd3d2af37df1 Mon Sep 17 00:00:00 2001 From: Moshe Atlow Date: Tue, 25 Apr 2023 12:10:01 +0300 Subject: [PATCH 09/12] try once again --- test/parallel/test-node-output-sourcemaps.mjs | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/test/parallel/test-node-output-sourcemaps.mjs b/test/parallel/test-node-output-sourcemaps.mjs index 8e749de5e7606c..be6e84241812c9 100644 --- a/test/parallel/test-node-output-sourcemaps.mjs +++ b/test/parallel/test-node-output-sourcemaps.mjs @@ -1,7 +1,6 @@ -import '../common/index.mjs'; +import * as common from '../common/index.mjs'; import * as fixtures from '../common/fixtures.mjs'; import * as snapshot from '../common/assertSnapshot.js'; -import { resolve } from 'node:path'; import { describe, it } from 'node:test'; function replaceNodeVersion(str) { @@ -10,13 +9,19 @@ function replaceNodeVersion(str) { describe('sourcemaps output', { concurrency: true }, () => { function normalize(str) { - return str + const result = str .replaceAll(snapshot.replaceWindowsPaths(process.cwd()), '') .replaceAll('//', '*') - .replaceAll(resolve('/Users/bencoe/oss/coffee-script-test'), '') + .replaceAll('/Users/bencoe/oss/coffee-script-test', '') .replaceAll(/\/(\w)/g, '*$1') .replaceAll('*test*', '*') .replaceAll('*fixtures*source-map*', '*'); + if (common.isWindows) { + const currentDeviceLetter = path.parse(process.cwd()).root.substring(0, 2); + const regex = new RegExp(`${currentDeviceLetter}:/`, 'g') + return result.replaceAll(regex, ''); + } + return result; } const defaultTransform = snapshot .transform(snapshot.replaceWindowsLineEndings, snapshot.replaceWindowsPaths, replaceNodeVersion, normalize); From 4ce3fa9709c5ada5a150386038093f823221c195 Mon Sep 17 00:00:00 2001 From: Moshe Atlow Date: Tue, 25 Apr 2023 12:12:53 +0300 Subject: [PATCH 10/12] fix --- test/parallel/test-node-output-sourcemaps.mjs | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/test/parallel/test-node-output-sourcemaps.mjs b/test/parallel/test-node-output-sourcemaps.mjs index be6e84241812c9..c4bcbc7d911dd6 100644 --- a/test/parallel/test-node-output-sourcemaps.mjs +++ b/test/parallel/test-node-output-sourcemaps.mjs @@ -1,6 +1,7 @@ import * as common from '../common/index.mjs'; import * as fixtures from '../common/fixtures.mjs'; import * as snapshot from '../common/assertSnapshot.js'; +import * as path from 'node:path'; import { describe, it } from 'node:test'; function replaceNodeVersion(str) { @@ -18,7 +19,7 @@ describe('sourcemaps output', { concurrency: true }, () => { .replaceAll('*fixtures*source-map*', '*'); if (common.isWindows) { const currentDeviceLetter = path.parse(process.cwd()).root.substring(0, 2); - const regex = new RegExp(`${currentDeviceLetter}:/`, 'g') + const regex = new RegExp(`${currentDeviceLetter}:/`, 'g'); return result.replaceAll(regex, ''); } return result; From 062070a17eef7dd716ce55860c1067451de0bfa7 Mon Sep 17 00:00:00 2001 From: Moshe Atlow Date: Wed, 26 Apr 2023 21:07:40 +0300 Subject: [PATCH 11/12] fix --- test/parallel/test-node-output-sourcemaps.mjs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/parallel/test-node-output-sourcemaps.mjs b/test/parallel/test-node-output-sourcemaps.mjs index c4bcbc7d911dd6..61df08d2d6214b 100644 --- a/test/parallel/test-node-output-sourcemaps.mjs +++ b/test/parallel/test-node-output-sourcemaps.mjs @@ -19,7 +19,7 @@ describe('sourcemaps output', { concurrency: true }, () => { .replaceAll('*fixtures*source-map*', '*'); if (common.isWindows) { const currentDeviceLetter = path.parse(process.cwd()).root.substring(0, 2); - const regex = new RegExp(`${currentDeviceLetter}:/`, 'g'); + const regex = new RegExp(`${currentDeviceLetter}:/?`, 'gi'); return result.replaceAll(regex, ''); } return result; From bd913bee367e1ecd308bb7a3e5f6869813add31e Mon Sep 17 00:00:00 2001 From: Moshe Atlow Date: Wed, 26 Apr 2023 23:36:26 +0300 Subject: [PATCH 12/12] fix --- test/parallel/test-node-output-sourcemaps.mjs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/parallel/test-node-output-sourcemaps.mjs b/test/parallel/test-node-output-sourcemaps.mjs index 61df08d2d6214b..a226cd9800d14e 100644 --- a/test/parallel/test-node-output-sourcemaps.mjs +++ b/test/parallel/test-node-output-sourcemaps.mjs @@ -18,7 +18,7 @@ describe('sourcemaps output', { concurrency: true }, () => { .replaceAll('*test*', '*') .replaceAll('*fixtures*source-map*', '*'); if (common.isWindows) { - const currentDeviceLetter = path.parse(process.cwd()).root.substring(0, 2); + const currentDeviceLetter = path.parse(process.cwd()).root.substring(0, 1).toLowerCase(); const regex = new RegExp(`${currentDeviceLetter}:/?`, 'gi'); return result.replaceAll(regex, ''); }