Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/nodejs/node.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLuke Karrys <luke@lukekarrys.com>2022-11-01 08:45:47 +0300
committerGitHub <noreply@github.com>2022-11-01 08:45:47 +0300
commit590cf569fefbe5cb2356dac47177ff79a46a9492 (patch)
tree0b7e6a0d24b4fdf672a9b3cc4cc510d9fd229b02
parent6ccb069c4ec5169030a15ac8627ccb10b6ac26ec (diff)
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>
-rw-r--r--test/sequential/test-debugger-pid.js59
1 files changed, 21 insertions, 38 deletions
diff --git a/test/sequential/test-debugger-pid.js b/test/sequential/test-debugger-pid.js
index 0056113ecae..99062149dfe 100644
--- a/test/sequential/test-debugger-pid.js
+++ b/test/sequential/test-debugger-pid.js
@@ -9,44 +9,27 @@ const startCLI = require('../common/debugger');
const assert = require('assert');
const { spawn } = require('child_process');
-
-function launchTarget(...args) {
- const childProc = spawn(process.execPath, args);
- return Promise.resolve(childProc);
-}
-
-{
- 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;
- }
+const script = fixtures.path('debugger', 'alive.js');
+
+const runTest = async () => {
+ const target = spawn(process.execPath, [script]);
+ const cli = startCLI(['-p', `${target.pid}`]);
+
+ 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());