Skip to content

Commit 517e715

Browse files
cjihrigFishrock123
authored andcommitted
test: add abort test for backtrace validation
This commit adds a test that validates backtraces which are printed on fatal errors. PR-URL: #6734 Reviewed-By: Anna Henningsen <anna@addaleax.net> Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl>
1 parent c96d701 commit 517e715

File tree

1 file changed

+24
-0
lines changed

1 file changed

+24
-0
lines changed

test/abort/test-abort-backtrace.js

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
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+
}

0 commit comments

Comments
 (0)