mirror of
https://github.com/nodejs/node.git
synced 2025-12-28 07:50:41 +00:00
test: convert test-debugger-pid to async/await
PR-URL: https://github.com/nodejs/node/pull/45179 Reviewed-By: Moshe Atlow <moshe@atlow.co.il> Reviewed-By: Juan José Arboleda <soyjuanarbol@gmail.com> Reviewed-By: Rich Trott <rtrott@gmail.com>
This commit is contained in:
parent
6ccb069c4e
commit
590cf569fe
@ -9,44 +9,27 @@ const startCLI = require('../common/debugger');
|
||||
const assert = require('assert');
|
||||
const { spawn } = require('child_process');
|
||||
|
||||
const script = fixtures.path('debugger', 'alive.js');
|
||||
|
||||
function launchTarget(...args) {
|
||||
const childProc = spawn(process.execPath, args);
|
||||
return Promise.resolve(childProc);
|
||||
}
|
||||
const runTest = async () => {
|
||||
const target = spawn(process.execPath, [script]);
|
||||
const cli = startCLI(['-p', `${target.pid}`]);
|
||||
|
||||
{
|
||||
const script = fixtures.path('debugger', 'alive.js');
|
||||
let cli = null;
|
||||
let target = null;
|
||||
|
||||
function cleanup(error) {
|
||||
if (cli) {
|
||||
cli.quit();
|
||||
cli = null;
|
||||
}
|
||||
if (target) {
|
||||
target.kill();
|
||||
target = null;
|
||||
}
|
||||
try {
|
||||
await cli.waitForPrompt();
|
||||
await cli.command('sb("alive.js", 3)');
|
||||
await cli.waitFor(/break/);
|
||||
await cli.waitForPrompt();
|
||||
assert.match(
|
||||
cli.output,
|
||||
/> 3 {3}\+\+x;/,
|
||||
'marks the 3rd line');
|
||||
} catch (error) {
|
||||
assert.ifError(error);
|
||||
} finally {
|
||||
await cli.quit();
|
||||
target.kill();
|
||||
}
|
||||
};
|
||||
|
||||
return launchTarget(script)
|
||||
.then((childProc) => {
|
||||
target = childProc;
|
||||
cli = startCLI(['-p', `${target.pid}`]);
|
||||
return cli.waitForPrompt();
|
||||
})
|
||||
.then(() => cli.command('sb("alive.js", 3)'))
|
||||
.then(() => cli.waitFor(/break/))
|
||||
.then(() => cli.waitForPrompt())
|
||||
.then(() => {
|
||||
assert.match(
|
||||
cli.output,
|
||||
/> 3 {3}\+\+x;/,
|
||||
'marks the 3rd line');
|
||||
})
|
||||
.then(() => cleanup())
|
||||
.then(null, cleanup);
|
||||
}
|
||||
runTest().then(common.mustCall());
|
||||
|
||||
Loading…
Reference in New Issue
Block a user