diff --git a/test/fixtures/event_loop/max_tick_depth.js b/test/fixtures/event_loop/max_tick_depth.js new file mode 100644 index 00000000000000..44e1560e0c3786 --- /dev/null +++ b/test/fixtures/event_loop/max_tick_depth.js @@ -0,0 +1,10 @@ +'use strict'; +require('../../common'); + +process.maxTickDepth = 10; +let i = 20; +process.nextTick(function f() { + console.error(`tick ${i}`); + if (i-- > 0) + process.nextTick(f); +}); diff --git a/test/message/max_tick_depth.out b/test/fixtures/event_loop/max_tick_depth.snapshot similarity index 100% rename from test/message/max_tick_depth.out rename to test/fixtures/event_loop/max_tick_depth.snapshot diff --git a/test/fixtures/event_loop/nexttick_throw.js b/test/fixtures/event_loop/nexttick_throw.js new file mode 100644 index 00000000000000..669acc5d5afb5e --- /dev/null +++ b/test/fixtures/event_loop/nexttick_throw.js @@ -0,0 +1,13 @@ +'use strict'; +require('../../common'); + +process.nextTick(function() { + process.nextTick(function() { + process.nextTick(function() { + process.nextTick(function() { + // eslint-disable-next-line no-undef,no-unused-expressions + undefined_reference_error_maker; + }); + }); + }); +}); diff --git a/test/fixtures/event_loop/nexttick_throw.snapshot b/test/fixtures/event_loop/nexttick_throw.snapshot new file mode 100644 index 00000000000000..493f291935b24a --- /dev/null +++ b/test/fixtures/event_loop/nexttick_throw.snapshot @@ -0,0 +1,9 @@ +/test/fixtures/event_loop/nexttick_throw.js:7 + undefined_reference_error_maker; + ^ + +ReferenceError: undefined_reference_error_maker is not defined + at /test/fixtures/event_loop/nexttick_throw.js:7:3 + at + +Node.js diff --git a/test/message/max_tick_depth.js b/test/message/max_tick_depth.js deleted file mode 100644 index 15462157d2160d..00000000000000 --- a/test/message/max_tick_depth.js +++ /dev/null @@ -1,31 +0,0 @@ -// Copyright Joyent, Inc. and other Node contributors. -// -// Permission is hereby granted, free of charge, to any person obtaining a -// copy of this software and associated documentation files (the -// "Software"), to deal in the Software without restriction, including -// without limitation the rights to use, copy, modify, merge, publish, -// distribute, sublicense, and/or sell copies of the Software, and to permit -// persons to whom the Software is furnished to do so, subject to the -// following conditions: -// -// The above copyright notice and this permission notice shall be included -// in all copies or substantial portions of the Software. -// -// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS -// OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF -// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN -// NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, -// DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR -// OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE -// USE OR OTHER DEALINGS IN THE SOFTWARE. - -'use strict'; -require('../common'); - -process.maxTickDepth = 10; -let i = 20; -process.nextTick(function f() { - console.error(`tick ${i}`); - if (i-- > 0) - process.nextTick(f); -}); diff --git a/test/message/nexttick_throw.js b/test/message/nexttick_throw.js deleted file mode 100644 index d7e51b411eda64..00000000000000 --- a/test/message/nexttick_throw.js +++ /dev/null @@ -1,34 +0,0 @@ -// Copyright Joyent, Inc. and other Node contributors. -// -// Permission is hereby granted, free of charge, to any person obtaining a -// copy of this software and associated documentation files (the -// "Software"), to deal in the Software without restriction, including -// without limitation the rights to use, copy, modify, merge, publish, -// distribute, sublicense, and/or sell copies of the Software, and to permit -// persons to whom the Software is furnished to do so, subject to the -// following conditions: -// -// The above copyright notice and this permission notice shall be included -// in all copies or substantial portions of the Software. -// -// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS -// OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF -// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN -// NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, -// DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR -// OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE -// USE OR OTHER DEALINGS IN THE SOFTWARE. - -'use strict'; -require('../common'); - -process.nextTick(function() { - process.nextTick(function() { - process.nextTick(function() { - process.nextTick(function() { - // eslint-disable-next-line no-undef,no-unused-expressions - undefined_reference_error_maker; - }); - }); - }); -}); diff --git a/test/message/nexttick_throw.out b/test/message/nexttick_throw.out deleted file mode 100644 index 2d105a5c422abc..00000000000000 --- a/test/message/nexttick_throw.out +++ /dev/null @@ -1,9 +0,0 @@ - -*test*message*nexttick_throw.js:* - undefined_reference_error_maker; - ^ -ReferenceError: undefined_reference_error_maker is not defined - at *test*message*nexttick_throw.js:*:* - at process.processTicksAndRejections (node:internal/process/task_queues:*:*) - -Node.js * diff --git a/test/parallel/test-node-output-event-loop.mjs b/test/parallel/test-node-output-event-loop.mjs new file mode 100644 index 00000000000000..78fef6aea41817 --- /dev/null +++ b/test/parallel/test-node-output-event-loop.mjs @@ -0,0 +1,19 @@ +import '../common/index.mjs'; +import * as fixtures from '../common/fixtures.mjs'; +import * as snapshot from '../common/assertSnapshot.js'; +import { describe, it } from 'node:test'; + +describe('event_loop output', { concurrency: !process.env.TEST_PARALLEL }, () => { + const tests = [ + { name: 'event_loop/max_tick_depth.js' }, + { name: 'event_loop/nexttick_throw.js' }, + ]; + for (const { name } of tests) { + it(name, async () => { + await snapshot.spawnAndAssert( + fixtures.path(name), + snapshot.defaultTransform, + ); + }); + } +});