Skip to content
This repository has been archived by the owner on Jun 18, 2021. It is now read-only.

Commit

Permalink
Add hacks to allow tests to run with coverage enabled
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
richardlau committed Jul 3, 2019
1 parent e143276 commit 96a1bed
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 0 deletions.
6 changes: 6 additions & 0 deletions test/test-api-getreport.js
Original file line number Diff line number Diff line change
Expand Up @@ -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(' ')
Expand Down
4 changes: 4 additions & 0 deletions test/test-fatal-error.js
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
4 changes: 4 additions & 0 deletions test/test-signal.js
Original file line number Diff line number Diff line change
Expand Up @@ -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++) {
Expand Down

0 comments on commit 96a1bed

Please sign in to comment.