test: fix up tests after internal api change
authorBen Noordhuis <info@bnoordhuis.nl>
Fri, 19 Jul 2013 21:33:06 +0000 (23:33 +0200)
committerBen Noordhuis <info@bnoordhuis.nl>
Sat, 20 Jul 2013 10:13:54 +0000 (12:13 +0200)
test/simple/test-child-process-fork-getconnections.js
test/simple/test-child-process-kill-throw.js [deleted file]
test/simple/test-process-wrap.js
test/simple/test-stream2-stderr-sync.js
test/simple/test-tcp-wrap-connect.js
test/simple/test-tcp-wrap-listen.js
test/simple/test-tcp-wrap.js

index 597c23f..f8fed68 100644 (file)
@@ -36,7 +36,7 @@ if (process.argv[2] === 'child') {
       sockets.push(socket);
       socket.on('end', function() {
         if (!this.closingOnPurpose)
-          throw new Error('[c] closing by accident! ' + process._errno);
+          throw new Error('[c] closing by accident!');
       });
     }
 
diff --git a/test/simple/test-child-process-kill-throw.js b/test/simple/test-child-process-kill-throw.js
deleted file mode 100644 (file)
index 4beba7e..0000000
+++ /dev/null
@@ -1,50 +0,0 @@
-// 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');
-
-if (process.argv[2] === 'child') {
-  process.exit(0);
-} else {
-  var spawn = require('child_process').spawn;
-  var child = spawn(process.execPath, [process.argv[1], 'child']);
-
-  var error = {};
-  child.on('exit', function() {
-    child._handle = {
-      kill: function() {
-        process._errno = 42;
-        return -1;
-      }
-    };
-    child.once('error', function(err) {
-      error = err;
-    });
-    child.kill();
-  });
-
-  process.on('exit', function() {
-    // we shouldn't reset errno since it accturlly isn't set
-    // because of the fake .kill method
-    assert.equal(error.syscall, 'kill');
-  });
-}
index 655c828..d07c3ad 100644 (file)
@@ -44,7 +44,7 @@ p.onexit = function(exitCode, signal) {
   processExited = true;
 };
 
-pipe.onread = function(b, off, len) {
+pipe.onread = function(err, b, off, len) {
   assert.ok(processExited);
   if (b) {
     gotPipeData = true;
index 2b83617..efcb505 100644 (file)
@@ -23,6 +23,9 @@
 
 var common = require('../common.js');
 var assert = require('assert');
+var util = require('util');
+
+var errnoException = util._errnoException;
 
 function parent() {
   var spawn = require('child_process').spawn;
@@ -62,11 +65,12 @@ function child0() {
   }
 
   W.prototype._write = function(chunk, encoding, cb) {
-    var req = handle.writeUtf8String(chunk.toString() + '\n');
+    var req = { oncomplete: afterWrite };
+    var err = handle.writeUtf8String(req, chunk.toString() + '\n');
+    if (err) throw errnoException(err, 'write');
     // here's the problem.
     // it needs to tell the Writable machinery that it's ok to write
     // more, but that the current buffer length is handle.writeQueueSize
-    req.oncomplete = afterWrite
     if (req.writeQueueSize === 0)
       req.cb = cb;
     else
index 3da8d93..43fb37a 100644 (file)
@@ -26,14 +26,20 @@ var TCP = process.binding('tcp_wrap').TCP;
 function makeConnection() {
   var client = new TCP();
 
-  var req = client.connect('127.0.0.1', common.PORT);
+  var req = {};
+  var err = client.connect(req, '127.0.0.1', common.PORT);
+  assert.equal(err, 0);
+
   req.oncomplete = function(status, client_, req_) {
     assert.equal(0, status);
     assert.equal(client, client_);
     assert.equal(req, req_);
 
     console.log('connected');
-    var shutdownReq = client.shutdown();
+    var shutdownReq = {};
+    var err = client.shutdown(shutdownReq);
+    assert.equal(err, 0);
+
     shutdownReq.oncomplete = function(status, client_, req_) {
       console.log('shutdown complete');
       assert.equal(0, status);
index 6b805f3..1a3dc12 100644 (file)
@@ -36,7 +36,7 @@ var slice, sliceCount = 0, eofCount = 0;
 var writeCount = 0;
 var recvCount = 0;
 
-server.onconnection = function(client) {
+server.onconnection = function(err, client) {
   assert.equal(0, client.writeQueueSize);
   console.log('got connection');
 
@@ -49,13 +49,15 @@ server.onconnection = function(client) {
 
   client.readStart();
   client.pendingWrites = [];
-  client.onread = function(buffer) {
+  client.onread = function(err, buffer) {
     if (buffer) {
       assert.ok(buffer.length > 0);
 
       assert.equal(0, client.writeQueueSize);
 
-      var req = client.writeBuffer(buffer);
+      var req = {};
+      var err = client.writeBuffer(req, buffer);
+      assert.equal(err, 0);
       client.pendingWrites.push(req);
 
       console.log('client.writeQueueSize: ' + client.writeQueueSize);
@@ -112,5 +114,3 @@ process.on('exit', function() {
   assert.equal(1, writeCount);
   assert.equal(1, recvCount);
 });
-
-
index 10f7038..bc1e14e 100644 (file)
@@ -23,17 +23,16 @@ var common = require('../common');
 var assert = require('assert');
 
 var TCP = process.binding('tcp_wrap').TCP;
+var uv = process.binding('uv');
 
 var handle = new TCP();
 
 // Should be able to bind to the common.PORT
-var r = handle.bind('0.0.0.0', common.PORT);
-assert.equal(0, r);
+var err = handle.bind('0.0.0.0', common.PORT);
+assert.equal(err, 0);
 
 // Should not be able to bind to the same port again
-var r = handle.bind('0.0.0.0', common.PORT);
-assert.equal(-1, r);
-console.log(process._errno);
-assert.equal(process._errno, 'EINVAL');
+err = handle.bind('0.0.0.0', common.PORT);
+assert.equal(err, uv.UV_EINVAL);
 
 handle.close();