11cb0ef41Sopenharmony_ciimport { skipIfInspectorDisabled } from '../common/index.mjs';
21cb0ef41Sopenharmony_ciskipIfInspectorDisabled();
31cb0ef41Sopenharmony_ci
41cb0ef41Sopenharmony_ci// This must be in sequential because we check that the default port is 9229.
51cb0ef41Sopenharmony_ciimport { path } from '../common/fixtures.mjs';
61cb0ef41Sopenharmony_ciimport startCLI from '../common/debugger.js';
71cb0ef41Sopenharmony_ci
81cb0ef41Sopenharmony_ciimport assert from 'assert';
91cb0ef41Sopenharmony_ci
101cb0ef41Sopenharmony_ciconst script = path('debugger', 'three-lines.js');
111cb0ef41Sopenharmony_ciconst cli = startCLI([script]);
121cb0ef41Sopenharmony_citry {
131cb0ef41Sopenharmony_ci  await cli.waitForInitialBreak();
141cb0ef41Sopenharmony_ci  await cli.waitForPrompt();
151cb0ef41Sopenharmony_ci  assert.match(cli.output, /debug>/, 'prints a prompt');
161cb0ef41Sopenharmony_ci  assert.match(
171cb0ef41Sopenharmony_ci    cli.output,
181cb0ef41Sopenharmony_ci    /< Debugger listening on [^\n]*9229/,
191cb0ef41Sopenharmony_ci    'forwards child output'
201cb0ef41Sopenharmony_ci  );
211cb0ef41Sopenharmony_ci  await cli.command('["hello", "world"].join(" ")');
221cb0ef41Sopenharmony_ci  assert.match(cli.output, /hello world/, 'prints the result');
231cb0ef41Sopenharmony_ci  await cli.command('');
241cb0ef41Sopenharmony_ci  assert.match(
251cb0ef41Sopenharmony_ci    cli.output,
261cb0ef41Sopenharmony_ci    /hello world/,
271cb0ef41Sopenharmony_ci    'repeats the last command on <enter>'
281cb0ef41Sopenharmony_ci  );
291cb0ef41Sopenharmony_ci  await cli.command('version');
301cb0ef41Sopenharmony_ci  assert.ok(
311cb0ef41Sopenharmony_ci    cli.output.includes(process.versions.v8),
321cb0ef41Sopenharmony_ci    'version prints the v8 version'
331cb0ef41Sopenharmony_ci  );
341cb0ef41Sopenharmony_ci} finally {
351cb0ef41Sopenharmony_ci  const code = await cli.quit();
361cb0ef41Sopenharmony_ci  assert.strictEqual(code, 0);
371cb0ef41Sopenharmony_ci}
38