1'use strict'; 2const common = require('../common'); 3const assert = require('assert'); 4const cp = require('child_process'); 5 6if (process.argv[2] === 'child') { 7 process.abort(); 8} else { 9 const child = cp.spawnSync(`${process.execPath}`, [`${__filename}`, 'child']); 10 const stderr = child.stderr.toString(); 11 12 assert.strictEqual(child.stdout.toString(), ''); 13 // Stderr will be empty for systems that don't support backtraces. 14 if (stderr !== '') { 15 const frames = stderr.trimRight().split('\n').map((s) => s.trim()); 16 17 if (!frames.every((frame, index) => frame.startsWith(`${index + 1}:`))) { 18 assert.fail(`Each frame should start with a frame number:\n${stderr}`); 19 } 20 21 if (!common.isWindows) { 22 const { getBinaryPath } = require('../common/shared-lib-util'); 23 if (!frames.some((frame) => frame.includes(`[${getBinaryPath()}]`))) { 24 assert.fail(`Some frames should include the binary name:\n${stderr}`); 25 } 26 } 27 } 28} 29