From f8bb031bdc7067f3b69de771edd2c46df6386ad9 Mon Sep 17 00:00:00 2001 From: isaacs Date: Thu, 6 Dec 2012 07:29:42 -0800 Subject: [PATCH] test: Sync writables may emit finish before callbacks --- test/simple/test-stream2-writable.js | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/test/simple/test-stream2-writable.js b/test/simple/test-stream2-writable.js index bfd6bb75d6..be40664edf 100644 --- a/test/simple/test-stream2-writable.js +++ b/test/simple/test-stream2-writable.js @@ -59,6 +59,10 @@ function run() { var name = next[0]; var fn = next[1]; + + if (!fn) + return run(); + console.log('# %s', name); fn({ same: assert.deepEqual, @@ -228,9 +232,11 @@ test('write callbacks', function (t) { }); tw.on('finish', function() { - t.same(tw.buffer, chunks, 'got chunks in the right order'); - t.same(callbacks._called, chunks, 'called all callbacks'); - t.end(); + process.nextTick(function() { + t.same(tw.buffer, chunks, 'got chunks in the right order'); + t.same(callbacks._called, chunks, 'called all callbacks'); + t.end(); + }); }); chunks.forEach(function(chunk, i) {