Closed dwittner closed 10 years ago
The reason for that issue is, that we do a process.exit
and the data of stdout
and stderr
isn't passed to the process of buster-autotest
. We do process.exit
in two places:
buster-cli.js
->exit
: process.exit(code || 0);
buster-test
:}).run(process.argv.slice(2), function (err) {
if (err) { process.exit(1); }
});
The call of 1. and 2. is made in test-cli.js
->exit
:
exit: function (exitCode, callback) {
callback(exitCode); // 2.
this.cli.exit(exitCode); // 1.
},
First of all i think we shouldn't do an exit call in case of an exit code 0. Further i don't know, why we need two exit calls. I would like to eliminate one call.
If i comment out the call of 1., changing buster-test
the following way fixes the issue:
}).run(process.argv.slice(2), function (err) {
if (err) { setTimeout(process.exit.bind(null, 1), 5); }
});
I tried out some timeout values. The value 1 doesn't work, but any value greater than 1 works.
My first attempt was to use that function for a safely exit (found here):
function exit(exitCode) {
if (process.stdout._pendingWriteReqs || process.stderr._pendingWriteReqs) {
process.nextTick(function() {
exit(exitCode);
});
} else {
process.exit(exitCode);
}
}
But that function doesn't fix the issue. I tried some other ways too to find out if stdout
and stderr
are flushed, but i think that the problem isn't that they are not flushed at the time we do the process.exit
, but the data isn't passed to the calling autotest process. Because calling buster-test directly, without the buster-autotest process wrapped around doesn't lead to the issue.
We will use setTimeout
for a safely exit for both places. It is not planned to eliminate one of the exit calls at the moment.
Fixed by e09bab10ee and b23c6215e0.
If you run
buster-autotest
on windows, the last message you will see is "Running tests...", but not the result of the test run.