From c6e8d9d9cc37ed52647fca16c17f78037ed9d1c9 Mon Sep 17 00:00:00 2001 From: ml7181 Date: Fri, 16 Sep 2022 17:13:18 -0400 Subject: [PATCH 1/2] test: update test-debugger-low-level to use await/async --- test/sequential/test-debugger-low-level.js | 35 ++++++++++------------ 1 file changed, 16 insertions(+), 19 deletions(-) diff --git a/test/sequential/test-debugger-low-level.js b/test/sequential/test-debugger-low-level.js index f6d97f2dfe153d..1dec550bc4399f 100644 --- a/test/sequential/test-debugger-low-level.js +++ b/test/sequential/test-debugger-low-level.js @@ -12,28 +12,25 @@ const assert = require('assert'); const cli = startCLI([fixtures.path('debugger/three-lines.js')]); const scriptPattern = /^\* (\d+): \S+debugger(?:\/|\\)three-lines\.js/m; - function onFatal(error) { - cli.quit(); - throw error; - } - - return cli.waitForInitialBreak() - .then(() => cli.waitForPrompt()) - .then(() => cli.command('scripts')) - .then(() => { + async function testDebuggerLowLevel() + { + try{ + await cli.waitForInitialBreak(); + await cli.waitForPrompt(); + await cli.command('scripts'); const [, scriptId] = cli.output.match(scriptPattern); - return cli.command( + await cli.command( `Debugger.getScriptSource({ scriptId: '${scriptId}' })` ); - }) - .then(() => { assert.match( - cli.output, - /scriptSource:[ \n]*'(?:\(function \(|let x = 1)/); + cli.output, + /scriptSource:[ \n]*'(?:\(function \(|let x = 1)/); assert.match( - cli.output, - /let x = 1;/); - }) - .then(() => cli.quit()) - .then(null, onFatal); + cli.output, + /let x = 1;/); + } finally{ + await cli.quit(); + } + } + testDebuggerLowLevel(); } From 848bd35b7503dcddedb0ab97edd298f3a69e7230 Mon Sep 17 00:00:00 2001 From: Rich Trott Date: Tue, 20 Sep 2022 20:20:46 -0700 Subject: [PATCH 2/2] fix lint issues --- test/sequential/test-debugger-low-level.js | 15 +++++++-------- 1 file changed, 7 insertions(+), 8 deletions(-) diff --git a/test/sequential/test-debugger-low-level.js b/test/sequential/test-debugger-low-level.js index 1dec550bc4399f..93c8e1b625591d 100644 --- a/test/sequential/test-debugger-low-level.js +++ b/test/sequential/test-debugger-low-level.js @@ -12,9 +12,8 @@ const assert = require('assert'); const cli = startCLI([fixtures.path('debugger/three-lines.js')]); const scriptPattern = /^\* (\d+): \S+debugger(?:\/|\\)three-lines\.js/m; - async function testDebuggerLowLevel() - { - try{ + async function testDebuggerLowLevel() { + try { await cli.waitForInitialBreak(); await cli.waitForPrompt(); await cli.command('scripts'); @@ -23,12 +22,12 @@ const assert = require('assert'); `Debugger.getScriptSource({ scriptId: '${scriptId}' })` ); assert.match( - cli.output, - /scriptSource:[ \n]*'(?:\(function \(|let x = 1)/); + cli.output, + /scriptSource:[ \n]*'(?:\(function \(|let x = 1)/); assert.match( - cli.output, - /let x = 1;/); - } finally{ + cli.output, + /let x = 1;/); + } finally { await cli.quit(); } }