From 7bf357d664f522befe338431966442e78d0aad20 Mon Sep 17 00:00:00 2001 From: Rich Trott Date: Fri, 12 Aug 2016 15:46:40 -0700 Subject: [PATCH] test: add uncaught exception test for debugger --- test/fixtures/debug-uncaught.js | 16 ++++++++++++++++ test/parallel/test-debug-uncaught-exception.js | 17 +++++++++++++++++ 2 files changed, 33 insertions(+) create mode 100644 test/fixtures/debug-uncaught.js create mode 100644 test/parallel/test-debug-uncaught-exception.js diff --git a/test/fixtures/debug-uncaught.js b/test/fixtures/debug-uncaught.js new file mode 100644 index 00000000000000..f09d62f3580f32 --- /dev/null +++ b/test/fixtures/debug-uncaught.js @@ -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(); diff --git a/test/parallel/test-debug-uncaught-exception.js b/test/parallel/test-debug-uncaught-exception.js new file mode 100644 index 00000000000000..64c98469942dab --- /dev/null +++ b/test/parallel/test-debug-uncaught-exception.js @@ -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."; + +assert.strictEqual(result.status, 1); +assert(result.stderr.includes(expectedMessage)); +assert(result.stderr.includes('Error: sterrance')); + +console.log(result.stdout);