diff --git a/test/common.js b/test/common.js index 2b97a33d1e82c6..6f7a4e1c77de90 100644 --- a/test/common.js +++ b/test/common.js @@ -3,6 +3,7 @@ var path = require("path"); exports.testDir = path.dirname(__filename); exports.fixturesDir = path.join(exports.testDir, "fixtures"); exports.libDir = path.join(exports.testDir, "../lib"); +exports.PORT = 12346; require.paths.unshift(exports.libDir); diff --git a/test/disabled/test-cat.js b/test/disabled/test-cat.js index 2ae15beaba845e..f5110404dc1bb3 100644 --- a/test/disabled/test-cat.js +++ b/test/disabled/test-cat.js @@ -1,6 +1,5 @@ process.mixin(require("../common.js")); http = require("/http.js"); -PORT = 8888; puts("hello world"); diff --git a/test/disabled/test-dns.js b/test/disabled/test-dns.js index 47fa6e144c3b14..0d2bc2c3950188 100644 --- a/test/disabled/test-dns.js +++ b/test/disabled/test-dns.js @@ -1,4 +1,4 @@ -process.mixin(require("./common")); +process.mixin(require("../common")); var dns = require("dns"), sys = require("sys"); diff --git a/test/disabled/test-eio-race3.js b/test/disabled/test-eio-race3.js index bcfc6e095d0909..c911c077d91e5e 100644 --- a/test/disabled/test-eio-race3.js +++ b/test/disabled/test-eio-race3.js @@ -1,6 +1,6 @@ /* XXX Can this test be modified to not call the now-removed wait()? */ -process.mixin(require("./common")); +process.mixin(require("../common")); puts('first stat ...'); diff --git a/test/disabled/test-fs-sendfile.js b/test/disabled/test-fs-sendfile.js index 41e16dffcf5f3d..225657205b3c93 100644 --- a/test/disabled/test-fs-sendfile.js +++ b/test/disabled/test-fs-sendfile.js @@ -1,8 +1,7 @@ -process.mixin(require("./common")); +process.mixin(require("../common")); tcp = require("tcp"); sys = require("sys"); -PORT = 23123; var x = path.join(fixturesDir, "x.txt"); var expected = "xyz"; diff --git a/test/disabled/test-http-stress.js b/test/disabled/test-http-stress.js index 003d19fdd2b338..da07bb72dff476 100644 --- a/test/disabled/test-http-stress.js +++ b/test/disabled/test-http-stress.js @@ -1,6 +1,5 @@ process.mixin(require('../common.js')); -var PORT = 8003; var request_count = 1000; var response_body = '{"ok": true}'; diff --git a/test/pummel/test-http-client-reconnect-bug.js b/test/pummel/test-http-client-reconnect-bug.js index 0440a52a1fc089..67149e6a7626bf 100644 --- a/test/pummel/test-http-client-reconnect-bug.js +++ b/test/pummel/test-http-client-reconnect-bug.js @@ -4,8 +4,6 @@ var tcp = require("tcp"), sys = require("sys"), http = require("http"); -var PORT = 2143; - var errorCount = 0; var eofCount = 0; diff --git a/test/pummel/test-keep-alive.js b/test/pummel/test-keep-alive.js index d9d444d21cc2b8..b77d815aeb69eb 100644 --- a/test/pummel/test-keep-alive.js +++ b/test/pummel/test-keep-alive.js @@ -2,7 +2,6 @@ process.mixin(require("../common")); http = require("http"); sys = require("sys"); -PORT = 8891; body = "hello world\n"; server = http.createServer(function (req, res) { diff --git a/test/pummel/test-multipart.js b/test/pummel/test-multipart.js index 4ba19e2ebcd602..c3fb9492eed7db 100644 --- a/test/pummel/test-multipart.js +++ b/test/pummel/test-multipart.js @@ -3,7 +3,6 @@ process.mixin(require("../common")); var http = require("http"), multipart = require("multipart"), sys = require("sys"), - PORT = 8222, fixture = require("../fixtures/multipart"), events = require("events"), testPart = function (expect, part) { diff --git a/test/pummel/test-tcp-many-clients.js b/test/pummel/test-tcp-many-clients.js index 4653733faadf36..517b66ea4aa433 100644 --- a/test/pummel/test-tcp-many-clients.js +++ b/test/pummel/test-tcp-many-clients.js @@ -1,7 +1,6 @@ process.mixin(require("../common")); tcp = require("tcp"); // settings -var port = 20743; var bytes = 1024*40; var concurrency = 100; var connections_per_client = 5; @@ -22,10 +21,10 @@ var server = tcp.createServer(function (c) { c.close(); }); }); -server.listen(port); +server.listen(PORT); function runClient (callback) { - var client = tcp.createConnection(port); + var client = tcp.createConnection(PORT); client.connections = 0; client.setEncoding("utf8"); @@ -48,7 +47,7 @@ function runClient (callback) { assert.equal(false, had_error); assert.equal(bytes, client.recved.length); if (this.connections < connections_per_client) { - this.connect(port); + this.connect(PORT); } else { callback(); } diff --git a/test/pummel/test-tcp-pingpong-delay.js b/test/pummel/test-tcp-pingpong-delay.js index ae6868a8a2d35b..5afe0eacddce6e 100644 --- a/test/pummel/test-tcp-pingpong-delay.js +++ b/test/pummel/test-tcp-pingpong-delay.js @@ -84,7 +84,7 @@ function pingPongTest (port, host, on_complete) { }); } -pingPongTest(21988); +pingPongTest(PORT); process.addListener("exit", function () { assert.equal(1, tests_run); diff --git a/test/pummel/test-tcp-pingpong.js b/test/pummel/test-tcp-pingpong.js index 75e302c5f92884..9fa231ee28d516 100644 --- a/test/pummel/test-tcp-pingpong.js +++ b/test/pummel/test-tcp-pingpong.js @@ -1,7 +1,6 @@ process.mixin(require("../common")); tcp = require("tcp"); - var tests_run = 0; function pingPongTest (port, host, on_complete) { @@ -81,9 +80,9 @@ function pingPongTest (port, host, on_complete) { } /* All are run at once, so run on different ports */ -pingPongTest(20989, "localhost"); -pingPongTest(20988, null); -pingPongTest(20997, "::1"); +pingPongTest(PORT, "localhost"); +pingPongTest(PORT+1, null); +pingPongTest(PORT+2, "::1"); process.addListener("exit", function () { assert.equal(3, tests_run); diff --git a/test/pummel/test-tcp-throttle-kernel-buffer.js b/test/pummel/test-tcp-throttle-kernel-buffer.js index 6f966fbc8810f6..8914e3556d6f92 100644 --- a/test/pummel/test-tcp-throttle-kernel-buffer.js +++ b/test/pummel/test-tcp-throttle-kernel-buffer.js @@ -1,6 +1,5 @@ process.mixin(require("../common")); tcp = require("tcp"); -PORT = 20444; N = 30*1024; // 500kb puts("build big string"); diff --git a/test/pummel/test-tcp-throttle.js b/test/pummel/test-tcp-throttle.js index 57ccec190a4a24..0316e7797d5988 100644 --- a/test/pummel/test-tcp-throttle.js +++ b/test/pummel/test-tcp-throttle.js @@ -1,6 +1,5 @@ process.mixin(require("../common")); tcp = require("tcp"); -PORT = 20443; N = 200; server = tcp.createServer(function (connection) { diff --git a/test/pummel/test-tcp-timeout.js b/test/pummel/test-tcp-timeout.js index 1fd95540cbd64d..6c04768dcf7281 100644 --- a/test/pummel/test-tcp-timeout.js +++ b/test/pummel/test-tcp-timeout.js @@ -1,6 +1,5 @@ process.mixin(require("../common")); tcp = require("tcp"); -port = 9992; exchanges = 0; starttime = null; timeouttime = null; @@ -25,10 +24,10 @@ var echo_server = tcp.createServer(function (socket) { }); }); -echo_server.listen(port); -puts("server listening at " + port); +echo_server.listen(PORT); +puts("server listening at " + PORT); -var client = tcp.createConnection(port); +var client = tcp.createConnection(PORT); client.setEncoding("UTF8"); client.setTimeout(0); // disable the timeout for client client.addListener("connect", function () { diff --git a/test/pummel/test-tcp-tls.js b/test/pummel/test-tcp-tls.js index 0635ea58dc3dcf..9cdad204dbffcf 100644 --- a/test/pummel/test-tcp-tls.js +++ b/test/pummel/test-tcp-tls.js @@ -110,8 +110,8 @@ if (have_tls) { var keyPem = fs.readFileSync(fixturesDir+"/test_key.pem"); /* All are run at once, so run on different ports */ - tlsTest(20443, "localhost", caPem, keyPem, certPem); - tlsTest(21443, null, caPem, keyPem, certPem); + tlsTest(PORT, "localhost", caPem, keyPem, certPem); + tlsTest(PORT+1, null, caPem, keyPem, certPem); process.addListener("exit", function () { assert.equal(2, tests_run); diff --git a/test/simple/test-http-1.0.js b/test/simple/test-http-1.0.js index 455b9e225446ba..8a54b9034285ce 100644 --- a/test/simple/test-http-1.0.js +++ b/test/simple/test-http-1.0.js @@ -2,8 +2,6 @@ process.mixin(require("../common")); tcp = require("tcp"); http = require("http"); -var port = 7333; - var body = "hello world\n"; var server_response = ""; var client_got_eof = false; @@ -13,9 +11,9 @@ var server = http.createServer(function (req, res) { res.write(body); res.close(); }) -server.listen(port); +server.listen(PORT); -var c = tcp.createConnection(port); +var c = tcp.createConnection(PORT); c.setEncoding("utf8"); diff --git a/test/simple/test-http-cat.js b/test/simple/test-http-cat.js index c6c2de845ba720..7e729b275e0826 100644 --- a/test/simple/test-http-cat.js +++ b/test/simple/test-http-cat.js @@ -1,6 +1,5 @@ process.mixin(require("../common")); http = require("http"); -PORT = 8888; var body = "exports.A = function() { return 'A';}"; var server = http.createServer(function (req, res) { diff --git a/test/simple/test-http-chunked.js b/test/simple/test-http-chunked.js index 2ff677c2f0feb2..4bcabcc942f204 100644 --- a/test/simple/test-http-chunked.js +++ b/test/simple/test-http-chunked.js @@ -1,6 +1,5 @@ process.mixin(require("../common")); var http = require("http"); -var PORT = 8888; var UTF8_STRING = "Il était tué"; diff --git a/test/simple/test-http-client-race.js b/test/simple/test-http-client-race.js index 2ae92bcaeb672d..acea6993f3e48b 100644 --- a/test/simple/test-http-client-race.js +++ b/test/simple/test-http-client-race.js @@ -1,7 +1,6 @@ process.mixin(require("../common")); http = require("http"); url = require("url"); -PORT = 8888; var body1_s = "1111111111111111"; var body2_s = "22222"; diff --git a/test/simple/test-http-client-upload.js b/test/simple/test-http-client-upload.js index 91fc6606512cb3..8c05de4d37a520 100644 --- a/test/simple/test-http-client-upload.js +++ b/test/simple/test-http-client-upload.js @@ -1,6 +1,5 @@ process.mixin(require("../common")); http = require("http"); -var PORT = 18032; var sent_body = ""; var server_req_complete = false; diff --git a/test/simple/test-http-eof-on-connect.js b/test/simple/test-http-eof-on-connect.js index 6be2e71a66a28a..ffa07b1ebb5879 100644 --- a/test/simple/test-http-eof-on-connect.js +++ b/test/simple/test-http-eof-on-connect.js @@ -5,12 +5,11 @@ http = require("http"); // This is a regression test for http://github.com/ry/node/issues/#issue/44 // It is separate from test-http-malformed-request.js because it is only // reproduceable on the first packet on the first connection to a server. -port = 9999; server = http.createServer(function (req, res) {}); -server.listen(port); +server.listen(PORT); -tcp.createConnection(port).addListener("connect", function () { +tcp.createConnection(PORT).addListener("connect", function () { this.close(); }).addListener("close", function () { server.close(); diff --git a/test/simple/test-http-malformed-request.js b/test/simple/test-http-malformed-request.js index 27b6e80fcef793..5121df4d4ab221 100644 --- a/test/simple/test-http-malformed-request.js +++ b/test/simple/test-http-malformed-request.js @@ -5,7 +5,6 @@ url = require("url"); // Make sure no exceptions are thrown when receiving malformed HTTP // requests. -port = 9999; nrequests_completed = 0; nrequests_expected = 1; @@ -19,9 +18,9 @@ var s = http.createServer(function (req, res) { if (++nrequests_completed == nrequests_expected) s.close(); }); -s.listen(port); +s.listen(PORT); -var c = tcp.createConnection(port); +var c = tcp.createConnection(PORT); c.addListener("connect", function () { c.write("GET /hello?foo=%99bar HTTP/1.1\r\n\r\n"); c.close(); diff --git a/test/simple/test-http-proxy.js b/test/simple/test-http-proxy.js index f3bd0a8e93db06..6f3af1d4492718 100644 --- a/test/simple/test-http-proxy.js +++ b/test/simple/test-http-proxy.js @@ -2,8 +2,8 @@ process.mixin(require("../common")); http = require("http"); url = require("url"); -var PROXY_PORT = 8869; -var BACKEND_PORT = 8870; +var PROXY_PORT = PORT; +var BACKEND_PORT = PORT+1; var backend = http.createServer(function (req, res) { // debug("backend"); diff --git a/test/simple/test-http-server.js b/test/simple/test-http-server.js index 307256b74857a8..fc5e6f1552b2bb 100644 --- a/test/simple/test-http-server.js +++ b/test/simple/test-http-server.js @@ -4,8 +4,6 @@ http = require("http"); url = require("url"); qs = require("querystring"); -var port = 8222; - var request_number = 0; var requests_sent = 0; var server_response = ""; @@ -43,9 +41,9 @@ http.createServer(function (req, res) { res.close(); }, 1); -}).listen(port); +}).listen(PORT); -var c = tcp.createConnection(port); +var c = tcp.createConnection(PORT); c.setEncoding("utf8"); diff --git a/test/simple/test-http-tls.js b/test/simple/test-http-tls.js index c250adf8e63df4..1a6e33b6d82ff7 100644 --- a/test/simple/test-http-tls.js +++ b/test/simple/test-http-tls.js @@ -1,7 +1,6 @@ process.mixin(require("../common")); http = require("http"); url = require("url"); -PORT = 8888; HOST = "localhost"; diff --git a/test/simple/test-http-wget.js b/test/simple/test-http-wget.js index 1184c463605a99..dfe9701e61ad96 100644 --- a/test/simple/test-http-wget.js +++ b/test/simple/test-http-wget.js @@ -17,8 +17,6 @@ http = require("http"); // content-length is not provided, that the connection is in fact // closed. -var port = 7333; - var server_response = ""; var client_got_eof = false; var connection_was_closed = false; @@ -29,9 +27,9 @@ var server = http.createServer(function (req, res) { res.write("world\n"); res.close(); }) -server.listen(port); +server.listen(PORT); -var c = tcp.createConnection(port); +var c = tcp.createConnection(PORT); c.setEncoding("utf8"); diff --git a/test/simple/test-http.js b/test/simple/test-http.js index 815ebf925e6455..cd91d499043a88 100644 --- a/test/simple/test-http.js +++ b/test/simple/test-http.js @@ -1,7 +1,6 @@ process.mixin(require("../common")); http = require("http"); url = require("url"); -PORT = 8888; var responses_sent = 0; var responses_recvd = 0; diff --git a/test/simple/test-remote-module-loading.js b/test/simple/test-remote-module-loading.js index 3b99ea629bc023..f2463a4ebd7772 100644 --- a/test/simple/test-remote-module-loading.js +++ b/test/simple/test-remote-module-loading.js @@ -1,6 +1,5 @@ process.mixin(require("../common")); -var PORT = 8889; var http = require('http'); var sys = require('sys'); var url = require("url"); diff --git a/test/simple/test-tcp-binary.js b/test/simple/test-tcp-binary.js index fb2b8b4f2bbff8..796061b0a0d81d 100644 --- a/test/simple/test-tcp-binary.js +++ b/test/simple/test-tcp-binary.js @@ -1,6 +1,5 @@ process.mixin(require("../common")); tcp = require("tcp"); -PORT = 23123; binaryString = ""; for (var i = 255; i >= 0; i--) { diff --git a/test/simple/test-tcp-reconnect.js b/test/simple/test-tcp-reconnect.js index 65563b644b890d..090ec61be1508e 100644 --- a/test/simple/test-tcp-reconnect.js +++ b/test/simple/test-tcp-reconnect.js @@ -1,7 +1,6 @@ process.mixin(require("../common")); tcp = require("tcp"); var N = 50; -var port = 8921; var c = 0; var client_recv_count = 0; @@ -21,9 +20,9 @@ var server = tcp.createServer(function (socket) { assert.equal(false, had_error); }); }); -server.listen(port); +server.listen(PORT); -var client = tcp.createConnection(port); +var client = tcp.createConnection(PORT); client.setEncoding("UTF8"); @@ -42,7 +41,7 @@ client.addListener("close", function (had_error) { puts("disconnect"); assert.equal(false, had_error); if (disconnect_count++ < N) - client.connect(port); // reconnect + client.connect(PORT); // reconnect else server.close(); });