From 2df37deb7eadedfdaa8f6eaf558db8c4e60668e3 Mon Sep 17 00:00:00 2001 From: upx Date: Thu, 18 May 2023 12:56:27 -0700 Subject: [PATCH] test: migrate message tests to js fixtures squashed test: migrate message tests to js fixtures squashed Add test runners to /parallel dir and fix snapshot Update test/parallel/test-node-output-tick.mjs Co-authored-by: Moshe Atlow Update test/parallel/test-node-output-promise.mjs Co-authored-by: Moshe Atlow Update test/parallel/test-node-output-assertion.mjs Co-authored-by: Moshe Atlow Update test/parallel/test-node-output-map.mjs Co-authored-by: Moshe Atlow fixed snapshot discrepancy with output-errors.mjs Corrected test runner name prefix Removing snapshots that show as 'new' on git diff Restored deleted files Deleted files restored --- BUILDING.md | 8 ++-- .../assertion}/assert_throws_stack.js | 2 +- .../assertion/assert_throws_stack.snapshot} | 13 +++--- .../assertion}/internal_assert.js | 2 +- .../assertion/internal_assert.snapshot} | 10 ++-- .../assertion}/internal_assert_fail.js | 2 +- .../assertion/internal_assert_fail.snapshot} | 10 ++-- .../console}/core_line_numbers.js | 2 +- .../console}/eval_messages.js | 2 +- .../console}/stdin_messages.js | 2 +- .../errors}/if-error-has-good-stack.js | 2 +- .../errors/if-error-has-good-stack.snapshot} | 2 +- .../test-no-extra-info-on-fatal-exception.js | 2 +- .../errors}/throw_error_with_getter_throw.js | 4 +- .../errors}/throw_null.js | 2 +- .../errors}/throw_undefined.js | 2 +- .../errors}/timeout_throw.js | 2 +- .../undefined_reference_in_new_context.js | 2 +- .../errors}/util-inspect-error-cause.js | 2 +- .../errors}/util_inspect_error.js | 2 +- .../errors/util_inspect_error.snapshot} | 10 ++-- .../errors}/v8_warning.js | 2 +- .../map/source_map_enclosing_function.js | 7 +++ .../source_map_enclosing_function.snapshot} | 1 + .../map}/source_map_reference_error_tabs.js | 4 +- .../source_map_sourcemapping_url_string.js | 4 +- .../map}/source_map_throw_catch.js | 4 +- .../map}/source_map_throw_icu.js | 4 +- .../map/source_map_throw_set_immediate.js | 5 ++ .../promise_unhandled_warn_with_error.js | 2 +- .../unhandled_promise_trace_warnings.js | 2 +- .../tick}/max_tick_depth.js | 2 +- .../tick/max_tick_depth.snapshot} | 0 .../tick}/nexttick_throw.js | 2 +- test/parallel/test-node-output-console.mjs | 26 +++++++++-- test/parallel/test-node-output-errors.mjs | 19 ++++++-- test/parallel/test-output-assertion.mjs | 36 +++++++++++++++ test/parallel/test-output-map.mjs | 46 +++++++++++++++++++ test/parallel/test-output-promise.mjs | 35 ++++++++++++++ test/parallel/test-output-tick.mjs | 36 +++++++++++++++ 40 files changed, 262 insertions(+), 60 deletions(-) rename test/{message => fixtures/assertion}/assert_throws_stack.js (82%) rename test/{message/assert_throws_stack.out => fixtures/assertion/assert_throws_stack.snapshot} (62%) rename test/{message => fixtures/assertion}/internal_assert.js (80%) rename test/{message/internal_assert.out => fixtures/assertion/internal_assert.snapshot} (52%) rename test/{message => fixtures/assertion}/internal_assert_fail.js (82%) rename test/{message/internal_assert_fail.out => fixtures/assertion/internal_assert_fail.snapshot} (52%) rename test/{message => fixtures/console}/core_line_numbers.js (95%) rename test/{message => fixtures/console}/eval_messages.js (98%) rename test/{message => fixtures/console}/stdin_messages.js (98%) rename test/{message => fixtures/errors}/if-error-has-good-stack.js (93%) rename test/{message/if-error-has-good-stack.out => fixtures/errors/if-error-has-good-stack.snapshot} (94%) rename test/{message => fixtures/errors}/test-no-extra-info-on-fatal-exception.js (81%) rename test/{message => fixtures/errors}/throw_error_with_getter_throw.js (87%) rename test/{message => fixtures/errors}/throw_null.js (97%) rename test/{message => fixtures/errors}/throw_undefined.js (97%) rename test/{message => fixtures/errors}/timeout_throw.js (98%) rename test/{message => fixtures/errors}/undefined_reference_in_new_context.js (98%) rename test/{message => fixtures/errors}/util-inspect-error-cause.js (98%) rename test/{message => fixtures/errors}/util_inspect_error.js (92%) rename test/{message/util_inspect_error.out => fixtures/errors/util_inspect_error.snapshot} (75%) rename test/{message => fixtures/errors}/v8_warning.js (89%) create mode 100644 test/fixtures/map/source_map_enclosing_function.js rename test/{message/source_map_enclosing_function.out => fixtures/map/source_map_enclosing_function.snapshot} (99%) rename test/{message => fixtures/map}/source_map_reference_error_tabs.js (53%) rename test/{message => fixtures/map}/source_map_sourcemapping_url_string.js (61%) rename test/{message => fixtures/map}/source_map_throw_catch.js (66%) rename test/{message => fixtures/map}/source_map_throw_icu.js (54%) create mode 100644 test/fixtures/map/source_map_throw_set_immediate.js rename test/{message => fixtures/promise}/promise_unhandled_warn_with_error.js (88%) rename test/{message => fixtures/promise}/unhandled_promise_trace_warnings.js (86%) rename test/{message => fixtures/tick}/max_tick_depth.js (98%) rename test/{message/max_tick_depth.out => fixtures/tick/max_tick_depth.snapshot} (100%) rename test/{message => fixtures/tick}/nexttick_throw.js (98%) create mode 100644 test/parallel/test-output-assertion.mjs create mode 100644 test/parallel/test-output-map.mjs create mode 100644 test/parallel/test-output-promise.mjs create mode 100644 test/parallel/test-output-tick.mjs diff --git a/BUILDING.md b/BUILDING.md index ff101422f7ab32..6bba8f238aeabd 100644 --- a/BUILDING.md +++ b/BUILDING.md @@ -333,10 +333,10 @@ tools/test.py child-process ``` You can also execute the tests in a test suite directory -(such as `test/message`): +(such as `test/report`): -```bash -tools/test.py test/message +```text +$ tools/test.py test/report ``` If you want to check the other options, please refer to the help by using @@ -347,7 +347,7 @@ tools/test.py --help ``` > Note: On Windows you should use `python3` executable. -> Example: `python3 tools/test.py test/message` +> Example: `python3 tools/test.py test/report` You can usually run tests directly with node: diff --git a/test/message/assert_throws_stack.js b/test/fixtures/assertion/assert_throws_stack.js similarity index 82% rename from test/message/assert_throws_stack.js rename to test/fixtures/assertion/assert_throws_stack.js index 36bc5734cae37f..a1fca696c5ac10 100644 --- a/test/message/assert_throws_stack.js +++ b/test/fixtures/assertion/assert_throws_stack.js @@ -1,6 +1,6 @@ 'use strict'; -require('../common'); +require('../../common'); const assert = require('assert').strict; assert.throws(() => { throw new Error('foo'); }, { bar: true }); diff --git a/test/message/assert_throws_stack.out b/test/fixtures/assertion/assert_throws_stack.snapshot similarity index 62% rename from test/message/assert_throws_stack.out rename to test/fixtures/assertion/assert_throws_stack.snapshot index 06eaa906442440..f743d8ced635b7 100644 --- a/test/message/assert_throws_stack.out +++ b/test/fixtures/assertion/assert_throws_stack.snapshot @@ -9,7 +9,8 @@ AssertionError [ERR_ASSERTION]: Expected values to be strictly deep-equal: - Comparison { - bar: true - } - at Object. (*assert_throws_stack.js:*:*) + at * + at * at * at * at * @@ -19,16 +20,16 @@ AssertionError [ERR_ASSERTION]: Expected values to be strictly deep-equal: generatedMessage: true, code: 'ERR_ASSERTION', actual: Error: foo - at assert.throws.bar (*assert_throws_stack.js:*) - at getActual (node:assert:*) - at Function.throws (node:assert:*) - at Object. (*assert_throws_stack.js:*:*) at * at * at * at * at * - at *, + at * + at * + at * + at * + at node:internal*main*run_main_module:*:*, expected: { bar: true }, operator: 'throws' } diff --git a/test/message/internal_assert.js b/test/fixtures/assertion/internal_assert.js similarity index 80% rename from test/message/internal_assert.js rename to test/fixtures/assertion/internal_assert.js index fdb459b67ca0fa..871504f0925a6f 100644 --- a/test/message/internal_assert.js +++ b/test/fixtures/assertion/internal_assert.js @@ -1,7 +1,7 @@ 'use strict'; // Flags: --expose-internals -require('../common'); +require('../../common'); const assert = require('internal/assert'); assert(false); diff --git a/test/message/internal_assert.out b/test/fixtures/assertion/internal_assert.snapshot similarity index 52% rename from test/message/internal_assert.out rename to test/fixtures/assertion/internal_assert.snapshot index bd25c879478083..719ce3ebccfd41 100644 --- a/test/message/internal_assert.out +++ b/test/fixtures/assertion/internal_assert.snapshot @@ -1,13 +1,13 @@ -node:internal/assert:* +node:internal*assert:* throw new ERR_INTERNAL_ASSERTION(message); ^ Error [ERR_INTERNAL_ASSERTION]: This is caused by either a bug in Node.js or incorrect usage of Node.js internals. -Please open an issue with this stack trace at https://github.com/nodejs/node/issues +Please open an issue with this stack trace at https:*github.com*nodejs*node*issues - at new NodeError (node:internal/errors:*:*) - at assert (node:internal/assert:*:*) - at * (*test*message*internal_assert.js:7:1) + at * + at * + at * at * at * at * diff --git a/test/message/internal_assert_fail.js b/test/fixtures/assertion/internal_assert_fail.js similarity index 82% rename from test/message/internal_assert_fail.js rename to test/fixtures/assertion/internal_assert_fail.js index 1b2cf13552869b..503a1dcbc7264a 100644 --- a/test/message/internal_assert_fail.js +++ b/test/fixtures/assertion/internal_assert_fail.js @@ -1,7 +1,7 @@ 'use strict'; // Flags: --expose-internals -require('../common'); +require('../../common'); const assert = require('internal/assert'); assert.fail('Unreachable!'); diff --git a/test/message/internal_assert_fail.out b/test/fixtures/assertion/internal_assert_fail.snapshot similarity index 52% rename from test/message/internal_assert_fail.out rename to test/fixtures/assertion/internal_assert_fail.snapshot index 408d6d3364470d..643cff076e3453 100644 --- a/test/message/internal_assert_fail.out +++ b/test/fixtures/assertion/internal_assert_fail.snapshot @@ -1,14 +1,14 @@ -node:internal/assert:* +node:internal*assert:* throw new ERR_INTERNAL_ASSERTION(message); ^ Error [ERR_INTERNAL_ASSERTION]: Unreachable! This is caused by either a bug in Node.js or incorrect usage of Node.js internals. -Please open an issue with this stack trace at https://github.com/nodejs/node/issues +Please open an issue with this stack trace at https:*github.com*nodejs*node*issues - at new NodeError (node:internal/errors:*:*) - at Function.fail (node:internal/assert:*:*) - at * (*test*message*internal_assert_fail.js:7:8) + at * + at * + at * at * at * at * diff --git a/test/message/core_line_numbers.js b/test/fixtures/console/core_line_numbers.js similarity index 95% rename from test/message/core_line_numbers.js rename to test/fixtures/console/core_line_numbers.js index 585a6042652df1..5482a21bae9a1f 100644 --- a/test/message/core_line_numbers.js +++ b/test/fixtures/console/core_line_numbers.js @@ -1,5 +1,5 @@ 'use strict'; -require('../common'); +require('../../common'); Error.stackTraceLimit = 3; const punycode = require('punycode'); diff --git a/test/message/eval_messages.js b/test/fixtures/console/eval_messages.js similarity index 98% rename from test/message/eval_messages.js rename to test/fixtures/console/eval_messages.js index 69dcbd6efa23a7..171bff06b8d6e9 100644 --- a/test/message/eval_messages.js +++ b/test/fixtures/console/eval_messages.js @@ -21,7 +21,7 @@ 'use strict'; -require('../common'); +require('../../common'); const spawn = require('child_process').spawn; diff --git a/test/message/stdin_messages.js b/test/fixtures/console/stdin_messages.js similarity index 98% rename from test/message/stdin_messages.js rename to test/fixtures/console/stdin_messages.js index 79475bd4d217b6..874b473be38e00 100644 --- a/test/message/stdin_messages.js +++ b/test/fixtures/console/stdin_messages.js @@ -21,7 +21,7 @@ 'use strict'; -require('../common'); +require('../../common'); const spawn = require('child_process').spawn; diff --git a/test/message/if-error-has-good-stack.js b/test/fixtures/errors/if-error-has-good-stack.js similarity index 93% rename from test/message/if-error-has-good-stack.js rename to test/fixtures/errors/if-error-has-good-stack.js index 4f529d3e5d17ff..85c127c4e24c54 100644 --- a/test/message/if-error-has-good-stack.js +++ b/test/fixtures/errors/if-error-has-good-stack.js @@ -1,6 +1,6 @@ 'use strict'; -require('../common'); +require('../../common'); Error.stackTraceLimit = 4; const assert = require('assert'); diff --git a/test/message/if-error-has-good-stack.out b/test/fixtures/errors/if-error-has-good-stack.snapshot similarity index 94% rename from test/message/if-error-has-good-stack.out rename to test/fixtures/errors/if-error-has-good-stack.snapshot index e394127bd4c473..9296b25f10b7c6 100644 --- a/test/message/if-error-has-good-stack.out +++ b/test/fixtures/errors/if-error-has-good-stack.snapshot @@ -3,7 +3,7 @@ node:assert:* ^ AssertionError [ERR_ASSERTION]: ifError got unwanted exception: test error - at z (*if-error-has-good-stack.js:*:* + at z (*if-error-has-good-stack.js:*:*) at y (*if-error-has-good-stack.js:*:*) at x (*if-error-has-good-stack.js:*:*) at Object. (*if-error-has-good-stack.js:*:*) diff --git a/test/message/test-no-extra-info-on-fatal-exception.js b/test/fixtures/errors/test-no-extra-info-on-fatal-exception.js similarity index 81% rename from test/message/test-no-extra-info-on-fatal-exception.js rename to test/fixtures/errors/test-no-extra-info-on-fatal-exception.js index dbc61b0f2382e0..d72a7a22cd727e 100644 --- a/test/message/test-no-extra-info-on-fatal-exception.js +++ b/test/fixtures/errors/test-no-extra-info-on-fatal-exception.js @@ -1,7 +1,7 @@ // Flags: --no-extra-info-on-fatal-exception 'use strict'; -require('../common'); +require('../../common'); Error.stackTraceLimit = 1; throw new Error('foo'); diff --git a/test/message/throw_error_with_getter_throw.js b/test/fixtures/errors/throw_error_with_getter_throw.js similarity index 87% rename from test/message/throw_error_with_getter_throw.js rename to test/fixtures/errors/throw_error_with_getter_throw.js index a807ff3e2b6504..341397f28c6101 100644 --- a/test/message/throw_error_with_getter_throw.js +++ b/test/fixtures/errors/throw_error_with_getter_throw.js @@ -1,5 +1,7 @@ 'use strict'; -require('../common'); + +require('../../common'); + throw { // eslint-disable-line no-throw-literal get stack() { throw new Error('weird throw but ok'); diff --git a/test/message/throw_null.js b/test/fixtures/errors/throw_null.js similarity index 97% rename from test/message/throw_null.js rename to test/fixtures/errors/throw_null.js index fb233d1db56704..d8fc14ba784488 100644 --- a/test/message/throw_null.js +++ b/test/fixtures/errors/throw_null.js @@ -20,7 +20,7 @@ // USE OR OTHER DEALINGS IN THE SOFTWARE. 'use strict'; -require('../common'); +require('../../common'); // eslint-disable-next-line no-throw-literal throw null; diff --git a/test/message/throw_undefined.js b/test/fixtures/errors/throw_undefined.js similarity index 97% rename from test/message/throw_undefined.js rename to test/fixtures/errors/throw_undefined.js index a89aaf2ee2da59..8c486a7ff4c470 100644 --- a/test/message/throw_undefined.js +++ b/test/fixtures/errors/throw_undefined.js @@ -20,7 +20,7 @@ // USE OR OTHER DEALINGS IN THE SOFTWARE. 'use strict'; -require('../common'); +require('../../common'); // eslint-disable-next-line no-throw-literal throw undefined; diff --git a/test/message/timeout_throw.js b/test/fixtures/errors/timeout_throw.js similarity index 98% rename from test/message/timeout_throw.js rename to test/fixtures/errors/timeout_throw.js index 9bcbd85b5036e2..bd4130479b48c6 100644 --- a/test/message/timeout_throw.js +++ b/test/fixtures/errors/timeout_throw.js @@ -20,7 +20,7 @@ // USE OR OTHER DEALINGS IN THE SOFTWARE. 'use strict'; -require('../common'); +require('../../common'); setTimeout(function() { // eslint-disable-next-line no-undef,no-unused-expressions diff --git a/test/message/undefined_reference_in_new_context.js b/test/fixtures/errors/undefined_reference_in_new_context.js similarity index 98% rename from test/message/undefined_reference_in_new_context.js rename to test/fixtures/errors/undefined_reference_in_new_context.js index 29a67632f8f7dd..baa45de11ecef7 100644 --- a/test/message/undefined_reference_in_new_context.js +++ b/test/fixtures/errors/undefined_reference_in_new_context.js @@ -20,7 +20,7 @@ // USE OR OTHER DEALINGS IN THE SOFTWARE. 'use strict'; -require('../common'); +require('../../common'); const vm = require('vm'); console.error('before'); diff --git a/test/message/util-inspect-error-cause.js b/test/fixtures/errors/util-inspect-error-cause.js similarity index 98% rename from test/message/util-inspect-error-cause.js rename to test/fixtures/errors/util-inspect-error-cause.js index ed9d8230fe0c40..f08c293db9ef95 100644 --- a/test/message/util-inspect-error-cause.js +++ b/test/fixtures/errors/util-inspect-error-cause.js @@ -1,6 +1,6 @@ 'use strict'; -require('../common'); +require('../../common'); const { inspect } = require('util'); diff --git a/test/message/util_inspect_error.js b/test/fixtures/errors/util_inspect_error.js similarity index 92% rename from test/message/util_inspect_error.js rename to test/fixtures/errors/util_inspect_error.js index 20affd6c711fd8..ddec5e01a6ed16 100644 --- a/test/message/util_inspect_error.js +++ b/test/fixtures/errors/util_inspect_error.js @@ -1,6 +1,6 @@ 'use strict'; -require('../common'); +require('../../common'); const util = require('util'); const err = new Error('foo\nbar'); diff --git a/test/message/util_inspect_error.out b/test/fixtures/errors/util_inspect_error.snapshot similarity index 75% rename from test/message/util_inspect_error.out rename to test/fixtures/errors/util_inspect_error.snapshot index 644ccd58831ef7..cea1ec5419f2fd 100644 --- a/test/message/util_inspect_error.out +++ b/test/fixtures/errors/util_inspect_error.snapshot @@ -1,38 +1,38 @@ { err: Error: foo bar - at *util_inspect_error* at * at * at * at * at * at * + at node:internal*main*run_main_module:*:*, nested: { err: Error: foo bar - at *util_inspect_error* at * at * at * at * at * at * + at node:internal*main*run_main_module:*:* } } { err: Error: foo bar - at *util_inspect_error* at * at * at * at * at * at * + at node:internal*main*run_main_module:*:*, nested: { err: Error: foo bar - at *util_inspect_error* + at * at * at * at * @@ -43,7 +43,7 @@ } { Error: foo bar - at *util_inspect_error* + at * at * at * at * diff --git a/test/message/v8_warning.js b/test/fixtures/errors/v8_warning.js similarity index 89% rename from test/message/v8_warning.js rename to test/fixtures/errors/v8_warning.js index d7d1c5e7dbdff6..ab4d2bf305823f 100644 --- a/test/message/v8_warning.js +++ b/test/fixtures/errors/v8_warning.js @@ -1,6 +1,6 @@ 'use strict'; -require('../common'); +require('../../common'); function AsmModule() { 'use asm'; diff --git a/test/fixtures/map/source_map_enclosing_function.js b/test/fixtures/map/source_map_enclosing_function.js new file mode 100644 index 00000000000000..cf67a62d505fa1 --- /dev/null +++ b/test/fixtures/map/source_map_enclosing_function.js @@ -0,0 +1,7 @@ +// Flags: --enable-source-maps + +'use strict'; +require('../../common'); +Error.stackTraceLimit = 5; + +require('../source-map/enclosing-call-site-min.js'); diff --git a/test/message/source_map_enclosing_function.out b/test/fixtures/map/source_map_enclosing_function.snapshot similarity index 99% rename from test/message/source_map_enclosing_function.out rename to test/fixtures/map/source_map_enclosing_function.snapshot index 5bb920e7eba42a..976cd4fdbbc6e9 100644 --- a/test/message/source_map_enclosing_function.out +++ b/test/fixtures/map/source_map_enclosing_function.snapshot @@ -2,6 +2,7 @@ throw err ^ + Error: an error! at functionD (*enclosing-call-site.js:16:17) at functionC (*enclosing-call-site.js:10:3) diff --git a/test/message/source_map_reference_error_tabs.js b/test/fixtures/map/source_map_reference_error_tabs.js similarity index 53% rename from test/message/source_map_reference_error_tabs.js rename to test/fixtures/map/source_map_reference_error_tabs.js index fbe058a5f531bf..fbca02979e09fc 100644 --- a/test/message/source_map_reference_error_tabs.js +++ b/test/fixtures/map/source_map_reference_error_tabs.js @@ -1,7 +1,7 @@ // Flags: --enable-source-maps 'use strict'; -require('../common'); +require('../../common'); Error.stackTraceLimit = 2; -require('../fixtures/source-map/tabs.js'); +require('../source-map/tabs.js'); diff --git a/test/message/source_map_sourcemapping_url_string.js b/test/fixtures/map/source_map_sourcemapping_url_string.js similarity index 61% rename from test/message/source_map_sourcemapping_url_string.js rename to test/fixtures/map/source_map_sourcemapping_url_string.js index 254d18bd080e53..a018ba4108aca5 100644 --- a/test/message/source_map_sourcemapping_url_string.js +++ b/test/fixtures/map/source_map_sourcemapping_url_string.js @@ -1,11 +1,11 @@ // Flags: --enable-source-maps 'use strict'; -require('../common'); +require('../../common'); Error.stackTraceLimit = 2; try { - require('../fixtures/source-map/typescript-sourcemapping_url_string'); + require('../source-map/typescript-sourcemapping_url_string'); } catch (err) { setTimeout(() => { console.info(err); diff --git a/test/message/source_map_throw_catch.js b/test/fixtures/map/source_map_throw_catch.js similarity index 66% rename from test/message/source_map_throw_catch.js rename to test/fixtures/map/source_map_throw_catch.js index 603fa81867bcbe..21e1d07bb63eb6 100644 --- a/test/message/source_map_throw_catch.js +++ b/test/fixtures/map/source_map_throw_catch.js @@ -1,11 +1,11 @@ // Flags: --enable-source-maps 'use strict'; -require('../common'); +require('../../common'); Error.stackTraceLimit = 2; try { - require('../fixtures/source-map/typescript-throw'); + require('../source-map/typescript-throw'); } catch (err) { setTimeout(() => { console.info(err); diff --git a/test/message/source_map_throw_icu.js b/test/fixtures/map/source_map_throw_icu.js similarity index 54% rename from test/message/source_map_throw_icu.js rename to test/fixtures/map/source_map_throw_icu.js index 672c1575c6547a..0527e179d91f3c 100644 --- a/test/message/source_map_throw_icu.js +++ b/test/fixtures/map/source_map_throw_icu.js @@ -1,7 +1,7 @@ // Flags: --enable-source-maps 'use strict'; -require('../common'); +require('../../common'); Error.stackTraceLimit = 2; -require('../fixtures/source-map/icu'); +require('../source-map/icu'); diff --git a/test/fixtures/map/source_map_throw_set_immediate.js b/test/fixtures/map/source_map_throw_set_immediate.js new file mode 100644 index 00000000000000..44c8591366f245 --- /dev/null +++ b/test/fixtures/map/source_map_throw_set_immediate.js @@ -0,0 +1,5 @@ +// Flags: --enable-source-maps + +'use strict'; +require('../../common'); +require('../source-map/uglify-throw'); diff --git a/test/message/promise_unhandled_warn_with_error.js b/test/fixtures/promise/promise_unhandled_warn_with_error.js similarity index 88% rename from test/message/promise_unhandled_warn_with_error.js rename to test/fixtures/promise/promise_unhandled_warn_with_error.js index e07f52039101a3..b71757a259f04a 100644 --- a/test/message/promise_unhandled_warn_with_error.js +++ b/test/fixtures/promise/promise_unhandled_warn_with_error.js @@ -1,7 +1,7 @@ // Flags: --unhandled-rejections=warn-with-error-code 'use strict'; -require('../common'); +require('../../common'); const assert = require('assert'); Promise.reject(new Error('alas')); diff --git a/test/message/unhandled_promise_trace_warnings.js b/test/fixtures/promise/unhandled_promise_trace_warnings.js similarity index 86% rename from test/message/unhandled_promise_trace_warnings.js rename to test/fixtures/promise/unhandled_promise_trace_warnings.js index 66c1f39e5de091..53c5315a2dabfd 100644 --- a/test/message/unhandled_promise_trace_warnings.js +++ b/test/fixtures/promise/unhandled_promise_trace_warnings.js @@ -1,5 +1,5 @@ // Flags: --trace-warnings --unhandled-rejections=warn 'use strict'; -require('../common'); +require('../../common'); const p = Promise.reject(new Error('This was rejected')); setImmediate(() => p.catch(() => {})); diff --git a/test/message/max_tick_depth.js b/test/fixtures/tick/max_tick_depth.js similarity index 98% rename from test/message/max_tick_depth.js rename to test/fixtures/tick/max_tick_depth.js index 15462157d2160d..2370fce0af9420 100644 --- a/test/message/max_tick_depth.js +++ b/test/fixtures/tick/max_tick_depth.js @@ -20,7 +20,7 @@ // USE OR OTHER DEALINGS IN THE SOFTWARE. 'use strict'; -require('../common'); +require('../../common'); process.maxTickDepth = 10; let i = 20; diff --git a/test/message/max_tick_depth.out b/test/fixtures/tick/max_tick_depth.snapshot similarity index 100% rename from test/message/max_tick_depth.out rename to test/fixtures/tick/max_tick_depth.snapshot diff --git a/test/message/nexttick_throw.js b/test/fixtures/tick/nexttick_throw.js similarity index 98% rename from test/message/nexttick_throw.js rename to test/fixtures/tick/nexttick_throw.js index d7e51b411eda64..3aaef64b9bfe7a 100644 --- a/test/message/nexttick_throw.js +++ b/test/fixtures/tick/nexttick_throw.js @@ -20,7 +20,7 @@ // USE OR OTHER DEALINGS IN THE SOFTWARE. 'use strict'; -require('../common'); +require('../../common'); process.nextTick(function() { process.nextTick(function() { diff --git a/test/parallel/test-node-output-console.mjs b/test/parallel/test-node-output-console.mjs index 5a1b9feb6c8bed..b3b8fd23b12598 100644 --- a/test/parallel/test-node-output-console.mjs +++ b/test/parallel/test-node-output-console.mjs @@ -13,25 +13,45 @@ function replaceStackTrace(str) { describe('console output', { concurrency: true }, () => { function normalize(str) { - return str.replaceAll(snapshot.replaceWindowsPaths(process.cwd()), '').replaceAll('/', '*').replaceAll(process.version, '*').replaceAll(/\d+/g, '*'); + return str.replaceAll(snapshot.replaceWindowsPaths(process.cwd()), '').replaceAll('/', '*').replaceAll(process.version, '*').replaceAll(/\d+/g, '*').replaceAll('[*m', ''); } const tests = [ { name: 'console/2100bytes.js' }, { name: 'console/console_low_stack_space.js' }, { name: 'console/console.js' }, + { name: 'console/core_line_numbers.js', + transform: snapshot + .transform(snapshot.replaceWindowsLineEndings, snapshot.replaceWindowsPaths, normalize), + tty: true + }, + { name: 'console/eval_messages.js', + transform: snapshot + .transform(snapshot.replaceWindowsLineEndings, snapshot.replaceWindowsPaths, normalize), + tty: true + }, { name: 'console/hello_world.js' }, { name: 'console/stack_overflow.js', transform: snapshot .transform(snapshot.replaceWindowsLineEndings, snapshot.replaceWindowsPaths, normalize) }, + { name: 'console/stdin_messages.js', + transform: snapshot + .transform(snapshot.replaceWindowsLineEndings, snapshot.replaceWindowsPaths, normalize), + tty: true + }, + { name: 'console/stdin_messages.js', + transform: snapshot + .transform(snapshot.replaceWindowsLineEndings, snapshot.replaceWindowsPaths, replaceNodeVersion, stackTrace), + tty: true + }, !skipForceColors ? { name: 'console/force_colors.js', env: { FORCE_COLOR: 1 } } : null, ].filter(Boolean); const defaultTransform = snapshot .transform(snapshot.replaceWindowsLineEndings, snapshot.replaceWindowsPaths, replaceStackTrace); - for (const { name, transform, env } of tests) { + for (const { name, transform, tty = false, env } of tests) { it(name, async () => { - await snapshot.spawnAndAssert(fixtures.path(name), transform ?? defaultTransform, { env }); + await snapshot.spawnAndAssert(fixtures.path(name), transform ?? defaultTransform, { tty: tty }, { env }); }); } }); diff --git a/test/parallel/test-node-output-errors.mjs b/test/parallel/test-node-output-errors.mjs index fca2149fea3212..5ea05ce0fd80e3 100644 --- a/test/parallel/test-node-output-errors.mjs +++ b/test/parallel/test-node-output-errors.mjs @@ -22,15 +22,18 @@ 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*', '*').replaceAll('file:**', 'file:*/'); } - function normalizeNoNumbers(str) { return normalize(str).replaceAll(/\d+:\d+/g, '*:*').replaceAll(/:\d+/g, ':*').replaceAll('*fixtures*message*', '*'); } + function normalizeCustom(str) { + return normalizeNoNumbers(str).replaceAll(/\d+/g, '*').replaceAll('[*m', ''); + } const common = snapshot .transform(snapshot.replaceWindowsLineEndings, snapshot.replaceWindowsPaths); const defaultTransform = snapshot.transform(common, normalize, replaceNodeVersion); const errTransform = snapshot.transform(common, normalizeNoNumbers, replaceNodeVersion); const promiseTransform = snapshot.transform(common, replaceStackTrace, normalizeNoNumbers, replaceNodeVersion); + const customTransform = snapshot.transform(common, replaceStackTrace, normalizeCustom); const tests = [ { name: 'errors/async_error_eval_cjs.js' }, @@ -50,11 +53,21 @@ describe('errors output', { concurrency: true }, () => { { 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 }, + { name: 'errors/if-error-has-good-stack.js', transform: errTransform, tty: false }, + { name: 'errors/test-no-extra-info-on-fatal-exception.js', transform: errTransform, tty: false }, + { name: 'errors/throw_error_with_getter_throw.js', transform: errTransform, tty: true }, + { name: 'errors/throw_null.js', transform: errTransform, tty: true }, + { name: 'errors/throw_undefined.js', transform: errTransform, tty: true }, + { name: 'errors/timeout_throw.js', transform: errTransform, tty: false }, + { name: 'errors/undefined_reference_in_new_context.js', transform: errTransform, tty: false }, + { name: 'errors/util_inspect_error.js', transform: customTransform, tty: true }, + { name: 'errors/util-inspect-error-cause.js', transform: customTransform, tty: true }, + { name: 'errors/v8_warning.js', transform: errTransform, tty: true }, !skipForceColors ? { name: 'errors/force_colors.js', env: { FORCE_COLOR: 1 } } : null, ].filter(Boolean); - for (const { name, transform, env } of tests) { + for (const { name, transform, tty = false, env } of tests) { it(name, async () => { - await snapshot.spawnAndAssert(fixtures.path(name), transform ?? defaultTransform, { env }); + await snapshot.spawnAndAssert(fixtures.path(name), transform ?? defaultTransform, { tty: tty }, { env }); }); } }); diff --git a/test/parallel/test-output-assertion.mjs b/test/parallel/test-output-assertion.mjs new file mode 100644 index 00000000000000..78613be516e6e1 --- /dev/null +++ b/test/parallel/test-output-assertion.mjs @@ -0,0 +1,36 @@ +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('assertion output', { concurrency: true }, () => { + function normalize(str) { + return str.replaceAll(snapshot.replaceWindowsPaths(process.cwd()), '').replaceAll('//', '*').replaceAll(/\/(\w)/g, '*$1').replaceAll('*test*', '*').replaceAll('*fixtures*assertion*', '*').replaceAll('file:**', 'file:*/'); + } + + function normalizeNoNumbers(str) { + return normalize(str).replaceAll(/\d+:\d+/g, '*:*').replaceAll(/:\d+/g, ':*').replaceAll('*fixtures*message*', '*'); + } + const common = snapshot + .transform(snapshot.replaceWindowsLineEndings, snapshot.replaceWindowsPaths, replaceNodeVersion); + const defaultTransform = snapshot.transform(common, normalize); + const customTransform = snapshot.transform(common, replaceStackTrace, normalizeNoNumbers); + const tests = [ + { name: 'assertion/assert_throws_stack.js', transform: customTransform }, + { name: 'assertion/internal_assert_fail.js', transform: customTransform }, + { name: 'assertion/internal_assert.js', transform: customTransform }, + ]; + for (const { name, transform } of tests) { + it(name, async () => { + await snapshot.spawnAndAssert(fixtures.path(name), transform ?? defaultTransform, { tty: true }); + }); + } +}); diff --git a/test/parallel/test-output-map.mjs b/test/parallel/test-output-map.mjs new file mode 100644 index 00000000000000..16aa354aefe100 --- /dev/null +++ b/test/parallel/test-output-map.mjs @@ -0,0 +1,46 @@ +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('map output', { concurrency: true }, () => { + function normalize(str) { + return str.replaceAll(snapshot.replaceWindowsPaths(process.cwd()), '').replaceAll('//', '*').replaceAll(/\/(\w)/g, '*$1').replaceAll('*test*', '*').replaceAll('*fixtures*source-map*', '*').replaceAll('file:**', 'file:*/'); + } + + function normalizeNoNumbers(str) { + return normalize(str).replaceAll(/\d+:\d+/g, '*:*').replaceAll(/:\d+/g, ':*').replaceAll('*fixtures*source-map*', '*'); + } + function normalizeSpecialCharacters(str) { + const replacement = (match) => match.replace(/./g, '*').replace(/\s\*/g, ''); + return normalizeNoNumbers(str).replace(/(?<=\(")[^"]+/, replacement); + } + const common = snapshot + .transform(snapshot.replaceWindowsLineEndings, snapshot.replaceWindowsPaths, replaceNodeVersion); + const defaultTransform = snapshot.transform(common, normalize); + const noNumTransform = snapshot.transform(common, normalizeNoNumbers); + const customTransform = snapshot.transform(common, replaceStackTrace, normalizeNoNumbers); + const specialTransform = snapshot.transform(common, replaceStackTrace, normalizeSpecialCharacters); + + const tests = [ + { name: 'map/source_map_enclosing_function.js' }, + { name: 'map/source_map_reference_error_tabs.js' }, + { name: 'map/source_map_sourcemapping_url_string.js', transform: noNumTransform }, + { name: 'map/source_map_throw_catch.js', transform: customTransform }, + { name: 'map/source_map_throw_icu.js', transform: specialTransform }, + { name: 'map/source_map_throw_set_immediate.js', transform: customTransform }, + ]; + for (const { name, transform } of tests) { + it(name, async () => { + await snapshot.spawnAndAssert(fixtures.path(name), transform ?? defaultTransform, { tty: true }); + }); + } +}); diff --git a/test/parallel/test-output-promise.mjs b/test/parallel/test-output-promise.mjs new file mode 100644 index 00000000000000..a93776594dfbfd --- /dev/null +++ b/test/parallel/test-output-promise.mjs @@ -0,0 +1,35 @@ +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('map output', { concurrency: true }, () => { + function normalize(str) { + return str.replaceAll(snapshot.replaceWindowsPaths(process.cwd()), '').replaceAll('//', '*').replaceAll(/\/(\w)/g, '*$1').replaceAll('*test*', '*').replaceAll('*fixtures*source-map*', '*').replaceAll('file:**', 'file:*/'); + } + + function normalizeNoNumbers(str) { + return normalize(str).replaceAll(/\d+:\d+/g, '*:*').replaceAll(/:\d+/g, ':*').replaceAll('*fixtures*source-map*', '*'); + } + const common = snapshot + .transform(snapshot.replaceWindowsLineEndings, snapshot.replaceWindowsPaths, replaceNodeVersion); + const defaultTransform = snapshot.transform(common, replaceStackTrace, normalizeNoNumbers); + + const tests = [ + { name: 'promise/promise_unhandled_warn_with_error.js' }, + { name: 'promise/unhandled_promise_trace_warnings.js' }, + ]; + for (const { name, transform } of tests) { + it(name, async () => { + await snapshot.spawnAndAssert(fixtures.path(name), transform ?? defaultTransform, { tty: true }); + }); + } +}); diff --git a/test/parallel/test-output-tick.mjs b/test/parallel/test-output-tick.mjs new file mode 100644 index 00000000000000..c9672923101626 --- /dev/null +++ b/test/parallel/test-output-tick.mjs @@ -0,0 +1,36 @@ +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('map output', { concurrency: true }, () => { + function normalize(str) { + return str.replaceAll(snapshot.replaceWindowsPaths(process.cwd()), '').replaceAll('//', '*').replaceAll(/\/(\w)/g, '*$1').replaceAll('*test*', '*').replaceAll('*fixtures*source-map*', '*').replaceAll('file:**', 'file:*/'); + } + + function normalizeNoNumbers(str) { + return normalize(str).replaceAll(/\d+:\d+/g, '*:*').replaceAll(/:\d+/g, ':*').replaceAll('*fixtures*source-map*', '*'); + } + const common = snapshot + .transform(snapshot.replaceWindowsLineEndings, snapshot.replaceWindowsPaths, replaceNodeVersion); + const defaultTransform = snapshot.transform(common); + const customTransform = snapshot.transform(common, replaceStackTrace, normalizeNoNumbers); + + const tests = [ + { name: 'tick/max_tick_depth.js' }, + { name: 'tick/nexttick_throw.js', transform: customTransform }, + ]; + for (const { name, transform } of tests) { + it(name, async () => { + await snapshot.spawnAndAssert(fixtures.path(name), transform ?? defaultTransform, { tty: true }); + }); + } +});