Skip to content

Commit 9bb81dc

Browse files
committed
Exit with SIGTERM when there's a timeout SIGTERM
Also, ignore in coverage, since it happens after nyc, and thus can't be covered.
1 parent 7510a6d commit 9bb81dc

File tree

5 files changed

+11
-6
lines changed

5 files changed

+11
-6
lines changed

lib/tap.js

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -67,8 +67,9 @@ tap.synonyms = require('./synonyms.js')
6767

6868
// SIGTERM means being forcibly killed, almost always by timeout
6969
var onExit = require('signal-exit')
70+
var didTimeoutKill = false
7071
onExit(function (code, signal) {
71-
if (signal !== 'SIGTERM' || !didPipe)
72+
if (signal !== 'SIGTERM' || !didPipe || didTimeoutKill)
7273
return
7374

7475
var handles = process._getActiveHandles().filter(function (h) {
@@ -113,6 +114,9 @@ onExit(function (code, signal) {
113114
})
114115
}
115116

117+
// this is impossible to cover, because it happens after nyc has
118+
// already done its stuff.
119+
/* istanbul ignore else */
116120
if (!tap.results && tap.timeout)
117121
tap.timeout(extra)
118122
else {
@@ -125,6 +129,7 @@ onExit(function (code, signal) {
125129
var yaml = require('js-yaml')
126130
console.error(objToYaml(extra))
127131
}
128-
process.exit(1)
132+
didTimeoutKill = true
133+
process.kill(process.pid, 'SIGTERM')
129134
}
130135
})

test/test/child-sigterm-after-end--bail--buffer.tap

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ possible timeout: SIGTERM received after tap end
88
{"handles":[{"type":"Timer"}]}
99
...
1010

11-
# child end code=1 signal=null
11+
# child end code=null signal="SIGTERM"
1212
ok 1 - should not be equal
1313
1..1
1414

test/test/child-sigterm-after-end--bail.tap

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ possible timeout: SIGTERM received after tap end
88
{"handles":[{"type":"Timer"}]}
99
...
1010

11-
# child end code=1 signal=null
11+
# child end code=null signal="SIGTERM"
1212
ok 1 - should not be equal
1313
1..1
1414

test/test/child-sigterm-after-end--buffer.tap

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ possible timeout: SIGTERM received after tap end
88
{"handles":[{"type":"Timer"}]}
99
...
1010

11-
# child end code=1 signal=null
11+
# child end code=null signal="SIGTERM"
1212
ok 1 - should not be equal
1313
1..1
1414

test/test/child-sigterm-after-end.tap

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ possible timeout: SIGTERM received after tap end
88
{"handles":[{"type":"Timer"}]}
99
...
1010

11-
# child end code=1 signal=null
11+
# child end code=null signal="SIGTERM"
1212
ok 1 - should not be equal
1313
1..1
1414

0 commit comments

Comments
 (0)