|
| 1 | +'use strict'; |
| 2 | +const common = require('../common'); |
| 3 | + |
| 4 | +common.skipIfInspectorDisabled(); |
| 5 | + |
| 6 | +const fixtures = require('../common/fixtures'); |
| 7 | +const startCLI = require('../common/debugger'); |
| 8 | + |
| 9 | +const assert = require('assert'); |
| 10 | +const fs = require('fs'); |
| 11 | +const path = require('path'); |
| 12 | + |
| 13 | +const cli = startCLI([fixtures.path('debugger/empty.js')]); |
| 14 | + |
| 15 | +const rootDir = path.resolve(__dirname, '..', '..'); |
| 16 | + |
| 17 | +(async () => { |
| 18 | + await cli.waitForInitialBreak(); |
| 19 | + await cli.waitForPrompt(); |
| 20 | + await cli.command('profile'); |
| 21 | + await cli.command('profileEnd'); |
| 22 | + assert.match(cli.output, /\[Profile \d+μs\]/); |
| 23 | + await cli.command('profiles'); |
| 24 | + assert.match(cli.output, /\[ \[Profile \d+μs\] \]/); |
| 25 | + await cli.command('profiles[0].save()'); |
| 26 | + assert.match(cli.output, /Saved profile to .*node\.cpuprofile/); |
| 27 | + |
| 28 | + const cpuprofile = path.resolve(rootDir, 'node.cpuprofile'); |
| 29 | + const data = JSON.parse(fs.readFileSync(cpuprofile, 'utf8')); |
| 30 | + assert.strictEqual(Array.isArray(data.nodes), true); |
| 31 | + |
| 32 | + fs.rmSync(cpuprofile); |
| 33 | +})() |
| 34 | +.then(common.mustCall()) |
| 35 | +.finally(() => cli.quit()); |
0 commit comments