1'use strict'; 2 3// Tests relative --heap-prof-dir works. 4 5const common = require('../common'); 6 7const fixtures = require('../common/fixtures'); 8common.skipIfInspectorDisabled(); 9 10const assert = require('assert'); 11const fs = require('fs'); 12const path = require('path'); 13const { spawnSync } = require('child_process'); 14 15const tmpdir = require('../common/tmpdir'); 16 17const { 18 getHeapProfiles, 19 verifyFrames, 20 kHeapProfInterval, 21 env 22} = require('../common/prof'); 23 24{ 25 tmpdir.refresh(); 26 const output = spawnSync(process.execPath, [ 27 '--heap-prof', 28 '--heap-prof-dir', 29 'prof', 30 '--heap-prof-interval', 31 kHeapProfInterval, 32 fixtures.path('workload', 'allocation.js'), 33 ], { 34 cwd: tmpdir.path, 35 env 36 }); 37 if (output.status !== 0) { 38 console.log(output.stderr.toString()); 39 } 40 assert.strictEqual(output.status, 0); 41 const dir = path.join(tmpdir.path, 'prof'); 42 assert(fs.existsSync(dir)); 43 const profiles = getHeapProfiles(dir); 44 assert.strictEqual(profiles.length, 1); 45 verifyFrames(output, profiles[0], 'runAllocation'); 46} 47