GeezerVison is showing github.com — test: add abort test for backtrace validation · nodejs/node@517e715
File tree
Expand file treeCollapse file tree
Open diff view settings
Expand file treeCollapse file tree
Open diff view settings
Collapse file
Copy file name to clipboard +24Lines changed: 24 additions & 0 deletions | Original file line number | Diff line number | Diff line change |
|---|
|
| 1 | +'use strict'; |
| 2 | +const common = require('../common'); |
| 3 | +const assert = require('assert'); |
| 4 | +const cp = require('child_process'); |
| 5 | + |
| 6 | +if (common.isWindows) { |
| 7 | + common.skip('Backtraces unimplemented on Windows.'); |
| 8 | + return; |
| 9 | +} |
| 10 | + |
| 11 | +if (process.argv[2] === 'child') { |
| 12 | + process.abort(); |
| 13 | +} else { |
| 14 | + const child = cp.spawnSync(`${process.execPath}`, [`${__filename}`, 'child']); |
| 15 | + const frames = |
| 16 | + child.stderr.toString().trimRight().split('\n').map((s) => s.trim()); |
| 17 | + |
| 18 | + assert.strictEqual(child.stdout.toString(), ''); |
| 19 | + assert.ok(frames.length > 0); |
| 20 | + // All frames should start with a frame number. |
| 21 | + assert.ok(frames.every((frame, index) => frame.startsWith(`${index + 1}:`))); |
| 22 | + // At least some of the frames should include the binary name. |
| 23 | + assert.ok(frames.some((frame) => frame.includes(`[${process.execPath}]`))); |
| 24 | +} |