From c05b5d8b59b4f18926825f091b4d364f439cecb2 Mon Sep 17 00:00:00 2001 From: Mikeal Rogers Date: Thu, 7 Jan 2010 00:41:59 -0800 Subject: [PATCH] Adding test for bug in stdio. http://groups.google.com/group/nodejs/browse_thread/thread/10fda8eaf7276642/e5d5147f2b666abd --- test/mjsunit/fixtures/echo.js | 5 +++++ test/mjsunit/test-readdir.js | 15 ++++++++++++--- test/mjsunit/test-stdio.js | 21 +++++++++++++++++++++ 3 files changed, 38 insertions(+), 3 deletions(-) create mode 100644 test/mjsunit/fixtures/echo.js create mode 100644 test/mjsunit/test-stdio.js diff --git a/test/mjsunit/fixtures/echo.js b/test/mjsunit/fixtures/echo.js new file mode 100644 index 0000000000..49f435cc7a --- /dev/null +++ b/test/mjsunit/fixtures/echo.js @@ -0,0 +1,5 @@ +process.mixin(require("../common")); +process.stdio.open(); +process.stdio.addListener("data", function (data) { + puts(data); +}); \ No newline at end of file diff --git a/test/mjsunit/test-readdir.js b/test/mjsunit/test-readdir.js index 16c46a2aa2..766dc6ef46 100644 --- a/test/mjsunit/test-readdir.js +++ b/test/mjsunit/test-readdir.js @@ -7,9 +7,18 @@ puts("readdir " + fixturesDir); promise.addCallback(function (files) { p(files); - assert.deepEqual(["a.js", "b","cycles", "multipart.js", - "nested-index","test_ca.pem", - "test_cert.pem", "test_key.pem", "throws_error.js", "x.txt"], files.sort()); + assert.deepEqual(['a.js' + , 'b' + , 'cycles' + , 'echo.js' + , 'multipart.js' + , 'nested-index' + , 'test_ca.pem' + , 'test_cert.pem' + , 'test_key.pem' + , 'throws_error.js' + , 'x.txt' + ], files.sort()); }); promise.addErrback(function () { diff --git a/test/mjsunit/test-stdio.js b/test/mjsunit/test-stdio.js new file mode 100644 index 0000000000..9570539d7d --- /dev/null +++ b/test/mjsunit/test-stdio.js @@ -0,0 +1,21 @@ +process.mixin(require("./common")); + +var sub = path.join(fixturesDir, 'echo.js'); + +var result = false; + +var child = process.createChildProcess(path.join(libDir, "../bin/node"), [sub]); +child.addListener("error", function (data){ + puts("parent stderr: " + data); +}); +child.addListener("output", function (data){ + if (data && data[0] == 't') { + result = true; + } +}); +setTimeout(function () { + child.write('t\r\n'); +}, 100); +setTimeout(function (){ + assert.ok(result); +}, 500)