Chimp does not kill child processes when test fails in Cucumber and hangs gulp task
Opened this issue · 1 comments
Issue by MacDennis76
Wednesday Feb 08, 2017 at 07:36 GMT
Originally opened as xolvio/chimp#570
Expected behaviour
When a Cucumber (Chai) test fails all child processes should be killed.
Actual behaviour
In a Gulp task I am calling chimp.run multiple times synchronously with different options. This loop will then hangs when a Cucumber test fails, it returns a status code 2. This happens when I test locally with the chromedriver.
To me this is because the various child processes are not interrupted in this case.
Exact steps to reproduce / repository that demonstrates the problem
Call chimp.run synchronously from a Gulp task.
Let the test fail. This hangs the task.
Version & tools:
- Chimp: 0.47.1
- Node.js: 6.9.4
- Java: 1.8.0_91
- Operation system: Windows 10
Console / Log Output
When a test succeeds, the debug logs contains:
[chimp][cucumber] Closed with code 0
[chimp][cucumber] Cucumber not in a stopping state
[chimp][cucumber] Ensuring directory exists ./_output
[chimp][cucumber] Writing json results to ./_output/report.json
[chimp][cucumber] Finished writing results
[chimp] Finished running async processes
[chimp] interrupting
[chimp] 2 processes to interrupt
[chimp][cucumber] interrupting cucumber
[chimp][cucumber] kill called on cucumber process with pid 22440
[chimp][cucumber] checking if process exists
[chimp][cucumber] cucumber process does not exists, ignoring
[chimp][chromedriver] interrupt called
[chimp][chromedriver] stopping process
[chimp][chromedriver] kill called on chromedriver process with pid 11552
[chimp][chromedriver] checking if process exists
[chimp][chromedriver] chromedriver process exists, killing it with SIGTERM
[chimp][chromedriver] waiting for process to die (0/10)
[chimp][chromedriver] process is dead
[chimp] Finished interrupting processes
[chimp] run complete
When a test fails, the debug log contains:
[chimp][cucumber] Closed with code 2
[chimp][cucumber] Cucumber not in a stopping state
[chimp][cucumber] Ensuring directory exists ./_output
[chimp][cucumber] Writing json results to ./_output/report.json
[chimp][cucumber] Finished writing results
[chimp] Finished running async processes with errors
[chimp] run complete with errors Cucumber steps failed
My workaround is that in my Gulp task I kill the processes after a chimp.run by using the following function, logic taken from chimp.js:
function killChimpChildProcesses(chimp) {
var reverseProcesses = [];
while (chimp.processes.length !== 0) {
reverseProcesses.push(chimp.processes.pop());
}
var processes = _.collect(reverseProcesses, function (process) {
return process.interrupt.bind(process);
});
async.series(processes, function (error, r) {
if (error) {
console.log(error);
}
});
}
If I call this function my chimp.run loop continues normally.