GeezerVison is showing github.com — test: use spawnSyncAndAssert in nested async stack overflow test · nodejs/node@9f214f5
File tree
Expand file treeCollapse file tree
Open diff view settings
Expand file treeCollapse file tree
Open diff view settings
Collapse file
Copy file name to clipboardExpand all lines: test/parallel/test-async-hooks-stack-overflow-nested-async.js +6-11Lines changed: 6 additions & 11 deletions | Original file line number | Diff line number | Diff line change |
|---|
|
7 | 7 |
|
8 | 8 | require('../common'); |
9 | 9 | const assert = require('assert'); |
10 | | -const { spawnSync } = require('child_process'); |
| 10 | +const { spawnSyncAndAssert } = require('../common/child_process'); |
11 | 11 |
|
12 | 12 | if (process.argv[2] === 'child') { |
13 | 13 | const { createHook } = require('async_hooks'); |
@@ -64,17 +64,12 @@ if (process.argv[2] === 'child') { |
64 | 64 | } |
65 | 65 | } else { |
66 | 66 | // Parent process - spawn the child and check exit code |
67 | | - const result = spawnSync( |
| 67 | + spawnSyncAndAssert( |
68 | 68 | process.execPath, |
69 | 69 | [__filename, 'child'], |
70 | | - { encoding: 'utf8', timeout: 30000 } |
| 70 | + { encoding: 'utf8', timeout: 30000 }, |
| 71 | + { |
| 72 | + stdout: /SUCCESS: try-catch caught the stack overflow/, |
| 73 | + }, |
71 | 74 | ); |
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/); |
80 | 75 | } |