-
Notifications
You must be signed in to change notification settings - Fork 845
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
4 changed files
with
90 additions
and
28 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
'use strict' | ||
|
||
var test = require('tap').test | ||
var path = require('path') | ||
var writeStream = require('flush-write-stream') | ||
var fork = require('child_process').fork | ||
var fixturesPath = path.join(__dirname, 'fixtures', 'events') | ||
|
||
test('no event loop logs successfully', function (t) { | ||
t.plan(1) | ||
var output = '' | ||
var child = fork(path.join(fixturesPath, 'no-event-loop.js'), {silent: true}) | ||
|
||
child.stdout.pipe(writeStream(function (s, enc, cb) { | ||
output += s | ||
cb() | ||
})) | ||
|
||
child.on('close', function () { | ||
t.notEqual(output.match(/"msg":"h"/), null) | ||
}) | ||
}) | ||
|
||
test('handles no file descriptor in extreme mode', function (t) { | ||
t.plan(2) | ||
var output = '' | ||
var errorOutput = '' | ||
var child = fork(path.join(fixturesPath, 'no-fd.js'), {silent: true}) | ||
|
||
child.stdout.pipe(writeStream(function (s, enc, cb) { | ||
output += s | ||
cb() | ||
})) | ||
|
||
child.stderr.pipe(writeStream(function (s, enc, cb) { | ||
errorOutput += s | ||
cb() | ||
})) | ||
|
||
child.on('close', function () { | ||
t.is(output, '') | ||
t.notEqual(errorOutput.match(/stream must have/g), null) | ||
}) | ||
}) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
global.process = { __proto__: process, pid: 123456 } | ||
Date.now = function () { return 1459875739796 } | ||
require('os').hostname = function () { return 'abcdefghijklmnopqr' } | ||
var pino = require(require.resolve('./../../../')) | ||
var log = pino() | ||
log.info('h') |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
global.process = { __proto__: process, pid: 123456 } | ||
Date.now = function () { return 1459875739796 } | ||
require('os').hostname = function () { return 'abcdefghijklmnopqr' } | ||
var stream = require('stream') | ||
var dest = new stream.PassThrough() | ||
dest.pipe(process.stdout) | ||
var pino = require(require.resolve('./../../../')) | ||
var log = pino({extreme: true}, dest) | ||
log.info('h') |