11cb0ef41Sopenharmony_ci'use strict';
21cb0ef41Sopenharmony_ciconst common = require('../common');
31cb0ef41Sopenharmony_ci
41cb0ef41Sopenharmony_cicommon.skipIfInspectorDisabled();
51cb0ef41Sopenharmony_ci
61cb0ef41Sopenharmony_ciconst fixtures = require('../common/fixtures');
71cb0ef41Sopenharmony_ciconst startCLI = require('../common/debugger');
81cb0ef41Sopenharmony_ci
91cb0ef41Sopenharmony_ciconst assert = require('assert');
101cb0ef41Sopenharmony_ciconst fs = require('fs');
111cb0ef41Sopenharmony_ciconst path = require('path');
121cb0ef41Sopenharmony_ci
131cb0ef41Sopenharmony_ciconst cli = startCLI(['--port=0', fixtures.path('debugger/empty.js')]);
141cb0ef41Sopenharmony_ci
151cb0ef41Sopenharmony_ciconst rootDir = path.resolve(__dirname, '..', '..');
161cb0ef41Sopenharmony_ci
171cb0ef41Sopenharmony_ci(async () => {
181cb0ef41Sopenharmony_ci  await cli.waitForInitialBreak();
191cb0ef41Sopenharmony_ci  await cli.waitForPrompt();
201cb0ef41Sopenharmony_ci  await cli.command('profile');
211cb0ef41Sopenharmony_ci  await cli.command('profileEnd');
221cb0ef41Sopenharmony_ci  assert.match(cli.output, /\[Profile \d+μs\]/);
231cb0ef41Sopenharmony_ci  await cli.command('profiles');
241cb0ef41Sopenharmony_ci  assert.match(cli.output, /\[ \[Profile \d+μs\] \]/);
251cb0ef41Sopenharmony_ci  await cli.command('profiles[0].save()');
261cb0ef41Sopenharmony_ci  assert.match(cli.output, /Saved profile to .*node\.cpuprofile/);
271cb0ef41Sopenharmony_ci
281cb0ef41Sopenharmony_ci  const cpuprofile = path.resolve(rootDir, 'node.cpuprofile');
291cb0ef41Sopenharmony_ci  const data = JSON.parse(fs.readFileSync(cpuprofile, 'utf8'));
301cb0ef41Sopenharmony_ci  assert.strictEqual(Array.isArray(data.nodes), true);
311cb0ef41Sopenharmony_ci
321cb0ef41Sopenharmony_ci  fs.rmSync(cpuprofile);
331cb0ef41Sopenharmony_ci})()
341cb0ef41Sopenharmony_ci.then(common.mustCall())
351cb0ef41Sopenharmony_ci.finally(() => cli.quit());
36