Skip to content

Commit 3ce55fa

Browse files
committed
test: add abort test for backtrace validation
This commit adds a test that validates backtraces which are printed on fatal errors.
1 parent aee7eea commit 3ce55fa

1 file changed

Lines changed: 20 additions & 0 deletions

File tree

test/abort/test-abort-backtrace.js

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
'use strict';
2+
require('../common');
3+
const assert = require('assert');
4+
const cp = require('child_process');
5+
6+
if (process.argv[2] === 'child') {
7+
process.abort();
8+
} else {
9+
const child = cp.spawnSync(`${process.execPath}`,
10+
[`${__filename}`, 'child']);
11+
const frames = child.stderr.toString().trim().split('\n');
12+
13+
assert.strictEqual(child.stdout.toString().trim(), '');
14+
assert.ok(frames.length > 0);
15+
assert.ok(frames.every((frame, i) => {
16+
const re = new RegExp(`\w*${i + 1}: .+( \[.+\])?`);
17+
18+
return re.test(frame);
19+
}));
20+
}

0 commit comments

Comments
 (0)