Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/nodejs/node.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
path: root/test
diff options
context:
space:
mode:
authorRyan Dahl <ry@tinyclouds.org>2011-07-30 02:22:21 +0400
committerRyan Dahl <ry@tinyclouds.org>2011-07-30 05:03:44 +0400
commitf01b241057567818160f8cd4f58cf9cafdccf1ed (patch)
tree8a0eafc1e67504c5a3c77957eccc54cb4438d6a4 /test
parent874260b40fefc03aec7638a736b004b3ca0c23f3 (diff)
add wrapper for uv_spawn
process.binding('process_wrap')
Diffstat (limited to 'test')
-rw-r--r--test/simple/test-process-wrap.js63
1 files changed, 63 insertions, 0 deletions
diff --git a/test/simple/test-process-wrap.js b/test/simple/test-process-wrap.js
new file mode 100644
index 00000000000..70c1e43fce1
--- /dev/null
+++ b/test/simple/test-process-wrap.js
@@ -0,0 +1,63 @@
+// Copyright Joyent, Inc. and other Node contributors.
+//
+// Permission is hereby granted, free of charge, to any person obtaining a
+// copy of this software and associated documentation files (the
+// "Software"), to deal in the Software without restriction, including
+// without limitation the rights to use, copy, modify, merge, publish,
+// distribute, sublicense, and/or sell copies of the Software, and to permit
+// persons to whom the Software is furnished to do so, subject to the
+// following conditions:
+//
+// The above copyright notice and this permission notice shall be included
+// in all copies or substantial portions of the Software.
+//
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+// OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN
+// NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
+// DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
+// OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE
+// USE OR OTHER DEALINGS IN THE SOFTWARE.
+
+var common = require('../common');
+var assert = require('assert');
+var Process = process.binding('process_wrap').Process;
+var Pipe = process.binding('pipe_wrap').Pipe;
+var pipe = new Pipe();
+var p = new Process();
+
+var processExited = false;
+var gotPipeEOF = false;
+var gotPipeData = false;
+
+p.onexit = function() {
+ console.log("exit");
+ p.close();
+ pipe.readStart();
+
+ processExited = true;
+}
+
+pipe.onread = function(b, off, len) {
+ assert.ok(processExited);
+ if (b) {
+ gotPipeData = true;
+ console.log("read %d", len);
+ } else {
+ gotPipeEOF = true;
+ pipe.close();
+ }
+}
+
+p.spawn({
+ file: process.execPath,
+ args: [ process.execPath, "-v" ],
+ stdoutStream: pipe
+});
+
+
+process.on('exit', function() {
+ assert.ok(processExited);
+ assert.ok(gotPipeEOF);
+ assert.ok(gotPipeData);
+});