Skip to content

Commit ed3bb85

Browse files
antonioduranaduh95
authored andcommitted
test: use spawnSyncAndAssert in nested async stack overflow test
Signed-off-by: Antonio Duran <ing.antonio.duran@gmail.com> PR-URL: #67123 Reviewed-By: Ethan Arrowood <ethan@arrowood.dev> Reviewed-By: Joyee Cheung <joyeec9h3@gmail.com>
1 parent 6a56124 commit ed3bb85

1 file changed

Lines changed: 6 additions & 11 deletions

File tree

‎test/parallel/test-async-hooks-stack-overflow-nested-async.js‎

Lines changed: 6 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77

88
require('../common');
99
const assert = require('assert');
10-
const { spawnSync } = require('child_process');
10+
const { spawnSyncAndAssert } = require('../common/child_process');
1111

1212
if (process.argv[2] === 'child') {
1313
const { createHook } = require('async_hooks');
@@ -64,17 +64,12 @@ if (process.argv[2] === 'child') {
6464
}
6565
} else {
6666
// Parent process - spawn the child and check exit code
67-
const result = spawnSync(
67+
spawnSyncAndAssert(
6868
process.execPath,
6969
[__filename, 'child'],
70-
{ encoding: 'utf8', timeout: 30000 }
70+
{ encoding: 'utf8', timeout: 30000 },
71+
{
72+
stdout: /SUCCESS: try-catch caught the stack overflow/,
73+
},
7174
);
72-
73-
// Should exit successfully (try-catch worked)
74-
assert.strictEqual(result.status, 0,
75-
`Expected exit code 0, got ${result.status}.\n` +
76-
`stdout: ${result.stdout}\n` +
77-
`stderr: ${result.stderr}`);
78-
// Verify the error was handled by try-catch
79-
assert.match(result.stdout, /SUCCESS: try-catch caught the stack overflow/);
8075
}

0 commit comments

Comments
 (0)