Skip to content

Commit

Permalink
test: add abort test for backtrace validation
Browse files Browse the repository at this point in the history
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>
  • Loading branch information
cjihrig authored and Fishrock123 committed Jul 5, 2016
1 parent c96d701 commit 517e715
Showing 1 changed file with 24 additions and 0 deletions.
24 changes: 24 additions & 0 deletions test/abort/test-abort-backtrace.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
'use strict';
const common = require('../common');
const assert = require('assert');
const cp = require('child_process');

if (common.isWindows) {
common.skip('Backtraces unimplemented on Windows.');
return;
}

if (process.argv[2] === 'child') {
process.abort();
} else {
const child = cp.spawnSync(`${process.execPath}`, [`${__filename}`, 'child']);
const frames =
child.stderr.toString().trimRight().split('\n').map((s) => s.trim());

assert.strictEqual(child.stdout.toString(), '');
assert.ok(frames.length > 0);
// All frames should start with a frame number.
assert.ok(frames.every((frame, index) => frame.startsWith(`${index + 1}:`)));
// At least some of the frames should include the binary name.
assert.ok(frames.some((frame) => frame.includes(`[${process.execPath}]`)));
}

0 comments on commit 517e715

Please sign in to comment.