From 9797969ad49ae09a809b5332ddf965fb8e5bfe56 Mon Sep 17 00:00:00 2001 From: Jeremiah Senkpiel Date: Fri, 8 Jul 2016 14:24:53 +0200 Subject: [PATCH] test: fix old tty tests MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit test-tty-wrap hasn’t worked since StreamBase was introduced, I think. test-tty-stdout-end also happens to works with PipeWrap-s. Refs: https://github.com/nodejs/node/pull/7360 PR-URL: https://github.com/nodejs/node/pull/7613 Reviewed-By: Colin Ihrig --- test/pseudo-tty/test-tty-stdout-end.js | 1 - test/pseudo-tty/test-tty-stdout-end.out | 1 + test/pseudo-tty/test-tty-wrap.js | 31 ++++++------------------- test/pseudo-tty/test-tty-wrap.out | 2 ++ 4 files changed, 10 insertions(+), 25 deletions(-) create mode 100644 test/pseudo-tty/test-tty-stdout-end.out create mode 100644 test/pseudo-tty/test-tty-wrap.out diff --git a/test/pseudo-tty/test-tty-stdout-end.js b/test/pseudo-tty/test-tty-stdout-end.js index a33a2e5ed2..86a42c4035 100644 --- a/test/pseudo-tty/test-tty-stdout-end.js +++ b/test/pseudo-tty/test-tty-stdout-end.js @@ -1,5 +1,4 @@ 'use strict'; -// Can't test this when 'make test' doesn't assign a tty to the stdout. require('../common'); const assert = require('assert'); diff --git a/test/pseudo-tty/test-tty-stdout-end.out b/test/pseudo-tty/test-tty-stdout-end.out new file mode 100644 index 0000000000..8b13789179 --- /dev/null +++ b/test/pseudo-tty/test-tty-stdout-end.out @@ -0,0 +1 @@ + diff --git a/test/pseudo-tty/test-tty-wrap.js b/test/pseudo-tty/test-tty-wrap.js index fce4e194a8..6212d655d3 100644 --- a/test/pseudo-tty/test-tty-wrap.js +++ b/test/pseudo-tty/test-tty-wrap.js @@ -1,28 +1,11 @@ 'use strict'; -const common = require('../common'); -var assert = require('assert'); +require('../common'); -var TTY = process.binding('tty_wrap').TTY; -var isTTY = process.binding('tty_wrap').isTTY; +const TTY = process.binding('tty_wrap').TTY; +const WriteWrap = process.binding('stream_wrap').WriteWrap; -if (isTTY(1) == false) { - common.skip('fd 1 is not a tty.'); - return; -} +const handle = new TTY(1); +const req = new WriteWrap(); -var handle = new TTY(1); -var callbacks = 0; - -var req1 = handle.writeBuffer(Buffer.from('hello world\n')); -req1.oncomplete = function() { - callbacks++; -}; - -var req2 = handle.writeBuffer(Buffer.from('hello world\n')); -req2.oncomplete = function() { - callbacks++; -}; - -process.on('exit', function() { - assert.equal(2, callbacks); -}); +handle.writeBuffer(req, Buffer.from('hello world 1\n')); +handle.writeBuffer(req, Buffer.from('hello world 2\n')); diff --git a/test/pseudo-tty/test-tty-wrap.out b/test/pseudo-tty/test-tty-wrap.out new file mode 100644 index 0000000000..5dfbef9ae5 --- /dev/null +++ b/test/pseudo-tty/test-tty-wrap.out @@ -0,0 +1,2 @@ +hello world 1 +hello world 2