skip rotating-file test on node 0.8; warn about rotating-file issues

master
Trent Mick 2014-05-31 22:57:36 -07:00
parent 1ad4a7596f
commit 4670906256
3 changed files with 29 additions and 10 deletions

View File

@ -10,7 +10,8 @@ Known issues:
- [pull #125, pull #97, issue #73] Unref rotating-file timeout which was
preventing processes from exiting (by https://github.com/chakrit and
https://github.com/glenn-murray-bse).
https://github.com/glenn-murray-bse). Note: this only fixes the issue
for node 0.10 and above.
## bunyan 0.23.0

View File

@ -643,6 +643,14 @@ used for anything else.</td>
## stream type: `rotating-file`
**WARNING:** Users of Bunyan's `rotating-file` should (a) be using at least
bunyan 0.23.1 (with the fix for [this
issue](https://github.com/trentm/node-bunyan/pull/97)), and (b) should use at
least node 0.10 (node 0.8 does not support the `unref()` method on
`setTimeout(...)` needed for the mentioned fix). The symptom is that process
termination will hang for up to a full rotation period.
A `type === 'rotating-file'` is a file stream that handles file automatic
rotation.

View File

@ -1,6 +1,10 @@
'use strict';
/*
* Test that bunyan process will terminate
* Test that bunyan process will terminate.
*
* Note: Currently (bunyan 0.23.1) this fails on node 0.8, because there is
* no `unref` in node 0.8 and bunyan doesn't yet have `Logger.prototype.close()`
* support.
*/
var exec = require('child_process').exec;
@ -11,12 +15,18 @@ if (require.cache[__dirname + '/tap4nodeunit.js'])
var tap4nodeunit = require('./tap4nodeunit.js');
var test = tap4nodeunit.test;
test('log with rotating file stream will terminate gracefully', function (t) {
exec('node ' +__dirname + '/process-exit.js', {timeout: 1000},
function (err, stdout, stderr) {
t.ifError(err);
t.equal(stdout, 'done\n');
t.equal(stderr, '');
t.end();
var nodeVer = process.versions.node.split('.').map(Number);
if (nodeVer[0] <= 0 && nodeVer[1] <= 8) {
console.warn('skip test (node <= 0.8)');
} else {
test('log with rotating file stream will terminate gracefully', function (t) {
exec('node ' +__dirname + '/process-exit.js', {timeout: 1000},
function (err, stdout, stderr) {
t.ifError(err);
t.equal(stdout, 'done\n');
t.equal(stderr, '');
t.end();
});
});
});
}