From 96a1bed1ae121b33d4e4d10387996e9558d5eff1 Mon Sep 17 00:00:00 2001 From: Richard Lau Date: Wed, 3 Jul 2019 12:51:25 -0400 Subject: [PATCH 1/2] Add hacks to allow tests to run with coverage enabled When run through `tap` with coverage enabled (`--coverage`) child processes are wrapped and signal handlers installed which prevent some of the tests from exiting. Add workarounds to the affected tests so that the tests can be run with coverage enabled. --- test/test-api-getreport.js | 6 ++++++ test/test-fatal-error.js | 4 ++++ test/test-signal.js | 4 ++++ 3 files changed, 14 insertions(+) diff --git a/test/test-api-getreport.js b/test/test-api-getreport.js index a757727..eacf7cd 100644 --- a/test/test-api-getreport.js +++ b/test/test-api-getreport.js @@ -17,6 +17,12 @@ if (process.argv[2] === 'child') { 'Checking no messages on stderr'); const reportFiles = common.findReports(child.pid); tap.same(reportFiles, [], 'Checking no report files were written'); + + // tap with coverage enabled wraps the child so adjust expected command line + if (process.env['SPAWN_WRAP_SHIM_ROOT']) { + args.unshift('.*node'); + } + tap.test('Validating report content', (t) => { common.validateContent(child.stdout, t, { pid: child.pid, commandline: process.execPath + ' ' + args.join(' ') diff --git a/test/test-fatal-error.js b/test/test-fatal-error.js index b373c71..416af1b 100644 --- a/test/test-fatal-error.js +++ b/test/test-fatal-error.js @@ -5,6 +5,10 @@ if (process.argv[2] === 'child') { require('../'); const list = []; + // tap with coverage enabled installs signal handlers that prevents the + // fatal error causing the process to exit. Remove them. + process.removeAllListeners('SIGABRT'); + process.removeAllListeners('SIGTRAP'); while (true) { const record = new MyRecord(); list.push(record); diff --git a/test/test-signal.js b/test/test-signal.js index 5db02f6..1f71675 100644 --- a/test/test-signal.js +++ b/test/test-signal.js @@ -8,6 +8,10 @@ if (process.argv[2] === 'child') { // Exit on loss of parent process process.on('disconnect', () => process.exit(2)); + // tap with coverage enabled installs signal handlers that prevents the + // signal from causing the process to exit. Remove them. + process.removeAllListeners('SIGTERM'); + function busyLoop() { var list = []; for (var i = 0; i < 1e10; i++) { From 1693f81422765c6da6d81d91dc3a2bd110c6b966 Mon Sep 17 00:00:00 2001 From: Richard Lau Date: Wed, 3 Jul 2019 13:12:05 -0400 Subject: [PATCH 2/2] Update tap to version 14.3.1 Fixes `npm audit` warning for `handlebars`. Disable `esm` to allow tests to pass on Node.js 13 nightlies. --- .gitignore | 1 + .taprc | 1 + package.json | 2 +- 3 files changed, 3 insertions(+), 1 deletion(-) create mode 100644 .taprc diff --git a/.gitignore b/.gitignore index 1767441..14639fa 100644 --- a/.gitignore +++ b/.gitignore @@ -43,3 +43,4 @@ node-report*.txt npm-debug.log nodereport-*.tgz nodereport_test.log +package-lock.json diff --git a/.taprc b/.taprc new file mode 100644 index 0000000..13df826 --- /dev/null +++ b/.taprc @@ -0,0 +1 @@ +esm: false diff --git a/package.json b/package.json index d07942e..7e68e29 100644 --- a/package.json +++ b/package.json @@ -24,6 +24,6 @@ "url": "https://github.com/nodejs/node-report/issues" }, "devDependencies": { - "tap": "~12.4.1" + "tap": "^14.3.1" } }