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

Commit 96a1bed

Browse files
committed
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.
1 parent e143276 commit 96a1bed

3 files changed

Lines changed: 14 additions & 0 deletions

File tree

test/test-api-getreport.js

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,12 @@ if (process.argv[2] === 'child') {
1717
'Checking no messages on stderr');
1818
const reportFiles = common.findReports(child.pid);
1919
tap.same(reportFiles, [], 'Checking no report files were written');
20+
21+
// tap with coverage enabled wraps the child so adjust expected command line
22+
if (process.env['SPAWN_WRAP_SHIM_ROOT']) {
23+
args.unshift('.*node');
24+
}
25+
2026
tap.test('Validating report content', (t) => {
2127
common.validateContent(child.stdout, t, { pid: child.pid,
2228
commandline: process.execPath + ' ' + args.join(' ')

test/test-fatal-error.js

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,10 @@ if (process.argv[2] === 'child') {
55
require('../');
66

77
const list = [];
8+
// tap with coverage enabled installs signal handlers that prevents the
9+
// fatal error causing the process to exit. Remove them.
10+
process.removeAllListeners('SIGABRT');
11+
process.removeAllListeners('SIGTRAP');
812
while (true) {
913
const record = new MyRecord();
1014
list.push(record);

test/test-signal.js

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,10 @@ if (process.argv[2] === 'child') {
88
// Exit on loss of parent process
99
process.on('disconnect', () => process.exit(2));
1010

11+
// tap with coverage enabled installs signal handlers that prevents the
12+
// signal from causing the process to exit. Remove them.
13+
process.removeAllListeners('SIGTERM');
14+
1115
function busyLoop() {
1216
var list = [];
1317
for (var i = 0; i < 1e10; i++) {

0 commit comments

Comments
 (0)