From 733233d3ea73ced1a9adf0cefee67483a28dc2f0 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 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit PR-URL: https://github.com/nodejs/node/pull/8087 Reviewed-By: Anna Henningsen Reviewed-By: targos - Michaƫl Zasso Reviewed-By: bnoordhuis - Ben Noordhuis Reviewed-By: cjihrig - Colin Ihrig Reviewed-By: jasnell - James M Snell --- 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);