Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

test: add uncaught exception test for debugger #8087

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 16 additions & 0 deletions test/fixtures/debug-uncaught.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
'use strict';

require('../common');
const assert = require('assert');
const debug = require('_debugger');

function emit() {
const error = new Error('sterrance');
process.emit('uncaughtException', error);
}

assert.doesNotThrow(emit);

debug.start(['fhqwhgads']);

emit();
17 changes: 17 additions & 0 deletions test/parallel/test-debug-uncaught-exception.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
'use strict';
const common = require('../common');
const assert = require('assert');
const path = require('path');
const spawnSync = require('child_process').spawnSync;

const emitUncaught = path.join(common.fixturesDir, 'debug-uncaught.js');
const result = spawnSync(process.execPath, [emitUncaught], {encoding: 'utf8'});

const expectedMessage =
"There was an internal error in Node's debugger. Please report this bug.";
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Tiniest of nits: line continuations should have four spaces of indent.


assert.strictEqual(result.status, 1);
assert(result.stderr.includes(expectedMessage));
assert(result.stderr.includes('Error: sterrance'));

console.log(result.stdout);