summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRyan Dahl <ry@tinyclouds.org>2010-07-15 11:47:25 -0700
committerRyan Dahl <ry@tinyclouds.org>2010-07-15 14:21:31 -0700
commit9fd5e3c89cb3664be7491c2da8e7060a0c36e135 (patch)
treed748de58c1638e852d33374c328a45f6ab8d2268
parent94728125696ce05f5308ccbc111874e9fa936936 (diff)
downloadnodejs-9fd5e3c89cb3664be7491c2da8e7060a0c36e135.tar.gz
nodejs-9fd5e3c89cb3664be7491c2da8e7060a0c36e135.tar.bz2
nodejs-9fd5e3c89cb3664be7491c2da8e7060a0c36e135.zip
Update tests to work with module contexts
-rw-r--r--test/common.js2
-rw-r--r--test/disabled/test-cat.js4
-rw-r--r--test/disabled/test-dns.js3
-rw-r--r--test/disabled/test-eio-race3.js3
-rw-r--r--test/disabled/test-fs-sendfile.js9
-rw-r--r--test/disabled/test-http-big-proxy-responses.js7
-rw-r--r--test/disabled/test-http-head-request.js7
-rw-r--r--test/disabled/test-http-stress.js7
-rw-r--r--test/disabled/test-idle-watcher.js3
-rw-r--r--test/disabled/test-net-fd-passing.js2
-rw-r--r--test/disabled/test-remote-module-loading.js9
-rw-r--r--test/disabled/test-setuidgid.js3
-rw-r--r--test/disabled/tls_client.js7
-rw-r--r--test/disabled/tls_server.js7
-rw-r--r--test/fixtures/a.js2
-rw-r--r--test/fixtures/echo.js3
-rw-r--r--test/fixtures/print-chars-from-buffer.js3
-rw-r--r--test/fixtures/print-chars.js3
-rw-r--r--test/message/2100bytes.js3
-rw-r--r--test/message/hello_world.js3
-rw-r--r--test/message/undefined_reference_in_new_context.js7
-rw-r--r--test/message/undefined_reference_in_new_context.out4
-rw-r--r--test/pummel/test-child-process-spawn-loop.js3
-rw-r--r--test/pummel/test-http-client-reconnect-bug.js7
-rw-r--r--test/pummel/test-keep-alive.js7
-rw-r--r--test/pummel/test-net-many-clients.js9
-rw-r--r--test/pummel/test-net-pause.js9
-rw-r--r--test/pummel/test-net-pingpong-delay.js9
-rw-r--r--test/pummel/test-net-pingpong.js9
-rw-r--r--test/pummel/test-net-throttle.js9
-rw-r--r--test/pummel/test-net-timeout.js9
-rw-r--r--test/pummel/test-net-tls.js13
-rw-r--r--test/pummel/test-timers.js3
-rw-r--r--test/pummel/test-watch-file.js7
-rw-r--r--test/simple/test-assert.js3
-rw-r--r--test/simple/test-buffer.js3
-rw-r--r--test/simple/test-byte-length.js3
-rw-r--r--test/simple/test-c-ares.js3
-rw-r--r--test/simple/test-chdir.js3
-rw-r--r--test/simple/test-child-process-buffering.js3
-rw-r--r--test/simple/test-child-process-custom-fds.js5
-rw-r--r--test/simple/test-child-process-env.js3
-rw-r--r--test/simple/test-child-process-exit-code.js7
-rw-r--r--test/simple/test-child-process-ipc.js5
-rw-r--r--test/simple/test-child-process-kill.js3
-rw-r--r--test/simple/test-child-process-stdin.js3
-rw-r--r--test/simple/test-child-process-stdout-flush.js5
-rw-r--r--test/simple/test-crypto.js9
-rw-r--r--test/simple/test-delayed-require.js3
-rw-r--r--test/simple/test-dgram-pingpong.js3
-rw-r--r--test/simple/test-dgram-udp4.js3
-rw-r--r--test/simple/test-dgram-unix-anon.js3
-rw-r--r--test/simple/test-dgram-unix.js3
-rw-r--r--test/simple/test-eio-race.js3
-rw-r--r--test/simple/test-eio-race2.js5
-rw-r--r--test/simple/test-eio-race4.js3
-rw-r--r--test/simple/test-error-reporting.js5
-rw-r--r--test/simple/test-eval-cx.js13
-rw-r--r--test/simple/test-event-emitter-add-listeners.js3
-rw-r--r--test/simple/test-event-emitter-modify-in-emit.js3
-rw-r--r--test/simple/test-event-emitter-remove-listeners.js3
-rw-r--r--test/simple/test-exception-handler.js3
-rw-r--r--test/simple/test-exec.js3
-rw-r--r--test/simple/test-executable-path.js3
-rw-r--r--test/simple/test-file-read-noexist.js9
-rw-r--r--test/simple/test-file-write-stream.js5
-rw-r--r--test/simple/test-fs-chmod.js5
-rw-r--r--test/simple/test-fs-error-messages.js7
-rw-r--r--test/simple/test-fs-fsync.js17
-rw-r--r--test/simple/test-fs-read-buffer.js5
-rw-r--r--test/simple/test-fs-read-file-sync.js5
-rw-r--r--test/simple/test-fs-read-stream.js5
-rw-r--r--test/simple/test-fs-read.js5
-rw-r--r--test/simple/test-fs-readfile-empty.js5
-rw-r--r--test/simple/test-fs-realpath.js65
-rw-r--r--test/simple/test-fs-stat.js3
-rw-r--r--test/simple/test-fs-symlink.js9
-rw-r--r--test/simple/test-fs-write-buffer.js5
-rw-r--r--test/simple/test-fs-write-file.js21
-rw-r--r--test/simple/test-fs-write-sync.js5
-rw-r--r--test/simple/test-fs-write.js5
-rw-r--r--test/simple/test-http-1.0.js7
-rw-r--r--test/simple/test-http-304.js18
-rw-r--r--test/simple/test-http-blank-header.js13
-rw-r--r--test/simple/test-http-cat.js7
-rw-r--r--test/simple/test-http-chunked.js7
-rw-r--r--test/simple/test-http-client-race-2.js9
-rw-r--r--test/simple/test-http-client-race.js7
-rw-r--r--test/simple/test-http-client-upload.js9
-rw-r--r--test/simple/test-http-eof-on-connect.js7
-rw-r--r--test/simple/test-http-exceptions.js7
-rw-r--r--test/simple/test-http-full-response.js7
-rw-r--r--test/simple/test-http-head-request.js13
-rw-r--r--test/simple/test-http-head-response-has-no-body.js13
-rw-r--r--test/simple/test-http-malformed-request.js7
-rw-r--r--test/simple/test-http-parser.js3
-rw-r--r--test/simple/test-http-proxy.js23
-rw-r--r--test/simple/test-http-server-multiheaders.js7
-rw-r--r--test/simple/test-http-server.js15
-rw-r--r--test/simple/test-http-set-timeout.js16
-rw-r--r--test/simple/test-http-tls.js13
-rw-r--r--test/simple/test-http-upgrade-client.js10
-rw-r--r--test/simple/test-http-upgrade-server.js11
-rw-r--r--test/simple/test-http-upgrade-server2.js17
-rw-r--r--test/simple/test-http-wget.js7
-rw-r--r--test/simple/test-http-write-empty-string.js10
-rw-r--r--test/simple/test-http.js17
-rw-r--r--test/simple/test-listen-fd.js12
-rw-r--r--test/simple/test-memory-usage.js5
-rw-r--r--test/simple/test-mkdir-rmdir.js3
-rw-r--r--test/simple/test-module-loading.js15
-rw-r--r--test/simple/test-net-binary.js13
-rw-r--r--test/simple/test-net-keepalive.js7
-rw-r--r--test/simple/test-net-pingpong.js3
-rw-r--r--test/simple/test-net-reconnect.js9
-rw-r--r--test/simple/test-net-tls.js13
-rw-r--r--test/simple/test-next-tick-ordering.js3
-rw-r--r--test/simple/test-next-tick.js3
-rw-r--r--test/simple/test-path.js3
-rw-r--r--test/simple/test-pipe-head.js5
-rw-r--r--test/simple/test-pump-file2tcp.js19
-rw-r--r--test/simple/test-querystring.js3
-rw-r--r--test/simple/test-readdir.js5
-rw-r--r--test/simple/test-repl.js25
-rw-r--r--test/simple/test-script-context.js9
-rw-r--r--test/simple/test-script-new.js21
-rw-r--r--test/simple/test-script-static-context.js9
-rw-r--r--test/simple/test-script-static-new.js13
-rw-r--r--test/simple/test-script-static-this.js11
-rw-r--r--test/simple/test-script-this.js11
-rw-r--r--test/simple/test-sendfd.js7
-rw-r--r--test/simple/test-signal-handler.js3
-rw-r--r--test/simple/test-signal-unregister.js5
-rw-r--r--test/simple/test-stdin-from-file.js7
-rw-r--r--test/simple/test-stdout-to-file.js9
-rw-r--r--test/simple/test-string-decoder.js3
-rw-r--r--test/simple/test-sync-fileread.js3
-rw-r--r--test/simple/test-sys.js81
-rw-r--r--test/simple/test-umask.js3
-rw-r--r--test/simple/test-url.js3
-rw-r--r--test/simple/test-utf8-scripts.js3
141 files changed, 624 insertions, 499 deletions
diff --git a/test/common.js b/test/common.js
index 9593afdce..03d4cbccc 100644
--- a/test/common.js
+++ b/test/common.js
@@ -1,7 +1,5 @@
var path = require("path");
-exports = module.exports = global;
-
exports.testDir = path.dirname(__filename);
exports.fixturesDir = path.join(exports.testDir, "fixtures");
exports.libDir = path.join(exports.testDir, "../lib");
diff --git a/test/disabled/test-cat.js b/test/disabled/test-cat.js
index 4f12327ab..7dd6baf1b 100644
--- a/test/disabled/test-cat.js
+++ b/test/disabled/test-cat.js
@@ -13,12 +13,12 @@ var server = http.createServer(function (req, res) {
res.sendBody(body);
res.finish();
});
-server.listen(PORT);
+server.listen(common.PORT);
var errors = 0;
var successes = 0;
-var promise = process.cat("http://localhost:"+PORT, "utf8");
+var promise = process.cat("http://localhost:"+common.PORT, "utf8");
promise.addCallback(function (content) {
assert.equal(body, content);
diff --git a/test/disabled/test-dns.js b/test/disabled/test-dns.js
index 503a282c7..e5f2d7092 100644
--- a/test/disabled/test-dns.js
+++ b/test/disabled/test-dns.js
@@ -1,4 +1,5 @@
-require("../common");
+common = require("../common");
+assert = common.assert
var dns = require("dns"),
child_process = require("child_process"),
diff --git a/test/disabled/test-eio-race3.js b/test/disabled/test-eio-race3.js
index 9f9f245de..7dc239fb1 100644
--- a/test/disabled/test-eio-race3.js
+++ b/test/disabled/test-eio-race3.js
@@ -1,6 +1,7 @@
/* XXX Can this test be modified to not call the now-removed wait()? */
-require("../common");
+common = require("../common");
+assert = common.assert
console.log('first stat ...');
diff --git a/test/disabled/test-fs-sendfile.js b/test/disabled/test-fs-sendfile.js
index eb8ac13b3..e70463ad2 100644
--- a/test/disabled/test-fs-sendfile.js
+++ b/test/disabled/test-fs-sendfile.js
@@ -1,8 +1,9 @@
-require("../common");
+common = require("../common");
+assert = common.assert
tcp = require("tcp");
sys = require("sys");
-var x = path.join(fixturesDir, "x.txt");
+var x = path.join(common.fixturesDir, "x.txt");
var expected = "xyz";
var server = tcp.createServer(function (socket) {
@@ -14,9 +15,9 @@ var server = tcp.createServer(function (socket) {
assert.equal(expected, found);
});
});
-server.listen(PORT);
+server.listen(common.PORT);
-var client = tcp.createConnection(PORT);
+var client = tcp.createConnection(common.PORT);
client.addListener("connect", function () {
fs.open(x, 'r').addCallback(function (fd) {
fs.sendfile(client.fd, fd, 0, expected.length).addCallback(function (size) {
diff --git a/test/disabled/test-http-big-proxy-responses.js b/test/disabled/test-http-big-proxy-responses.js
index f3925d37c..b5cba80cf 100644
--- a/test/disabled/test-http-big-proxy-responses.js
+++ b/test/disabled/test-http-big-proxy-responses.js
@@ -1,4 +1,5 @@
-require('../common');
+common = require("../common");
+assert = common.assert
var sys = require("sys"),
fs = require("fs"),
http = require("http"),
@@ -63,7 +64,7 @@ function call_chargen(list) {
if (list.length > 0) {
var len = list.shift();
- sys.debug("calling chargen for " + len + " chunks.");
+ sys.common.debug("calling chargen for " + len + " chunks.");
var recved = 0;
@@ -78,7 +79,7 @@ function call_chargen(list) {
res.addListener('end', function() {
assert.ok(recved <= (len*chunk.length));
- sys.debug("end for " + len + " chunks.");
+ sys.common.debug("end for " + len + " chunks.");
call_chargen(list);
});
diff --git a/test/disabled/test-http-head-request.js b/test/disabled/test-http-head-request.js
index 5956df339..c6e9084fb 100644
--- a/test/disabled/test-http-head-request.js
+++ b/test/disabled/test-http-head-request.js
@@ -1,4 +1,5 @@
-require('../common');
+common = require("../common");
+assert = common.assert
var assert = require("assert");
var http = require("http");
@@ -14,12 +15,12 @@ server = http.createServer(function (req, res) {
if (req.method != 'HEAD') res.write(body);
res.end();
});
-server.listen(PORT);
+server.listen(common.PORT);
var gotEnd = false;
server.addListener('listening', function() {
- var client = http.createClient(PORT);
+ var client = http.createClient(common.PORT);
var request = client.request("HEAD", "/");
request.addListener('response', function (response) {
console.log('got response');
diff --git a/test/disabled/test-http-stress.js b/test/disabled/test-http-stress.js
index 5d0eda361..6568b1bb2 100644
--- a/test/disabled/test-http-stress.js
+++ b/test/disabled/test-http-stress.js
@@ -1,4 +1,5 @@
-require("../common");
+common = require("../common");
+assert = common.assert
http = require("http");
@@ -10,14 +11,14 @@ var server = http.createServer(function(req, res) {
res.write(body);
res.end();
});
-server.listen(PORT);
+server.listen(common.PORT);
var requests_ok = 0;
var requests_complete = 0;
server.addListener('listening', function () {
for (var i = 0; i < request_count; i++) {
- http.cat('http://localhost:'+PORT+'/', 'utf8', function (err, content) {
+ http.cat('http://localhost:'+common.PORT+'/', 'utf8', function (err, content) {
requests_complete++;
if (err) {
print("-");
diff --git a/test/disabled/test-idle-watcher.js b/test/disabled/test-idle-watcher.js
index 5debfa4f7..cc6662171 100644
--- a/test/disabled/test-idle-watcher.js
+++ b/test/disabled/test-idle-watcher.js
@@ -1,4 +1,5 @@
-require("../common");
+common = require("../common");
+assert = common.assert
var complete = false;
var idle = new process.IdleWatcher();
diff --git a/test/disabled/test-net-fd-passing.js b/test/disabled/test-net-fd-passing.js
index 3d16ff62d..fcffa9311 100644
--- a/test/disabled/test-net-fd-passing.js
+++ b/test/disabled/test-net-fd-passing.js
@@ -8,7 +8,7 @@ function fdPassingTest(path, port) {
var message = "beep toot";
var expectedData = ["[greeting] " + greeting, "[echo] " + message];
- var receiverArgs = [fixturesDir + "/net-fd-passing-receiver.js", path, greeting];
+ var receiverArgs = [common.fixturesDir + "/net-fd-passing-receiver.js", path, greeting];
var receiver = process.createChildProcess(process.ARGV[0], receiverArgs);
var initializeSender = function() {
diff --git a/test/disabled/test-remote-module-loading.js b/test/disabled/test-remote-module-loading.js
index b098c3e93..36f3d9831 100644
--- a/test/disabled/test-remote-module-loading.js
+++ b/test/disabled/test-remote-module-loading.js
@@ -1,4 +1,5 @@
-require("../common");
+common = require("../common");
+assert = common.assert
var http = require('http');
var sys = require('sys');
@@ -14,16 +15,16 @@ var server = http.createServer(function(req, res) {
res.write(body);
res.end();
});
-server.listen(PORT);
+server.listen(common.PORT);
assert.throws(function () {
- var httpModule = require('http://localhost:'+PORT+'/moduleA.js');
+ var httpModule = require('http://localhost:'+common.PORT+'/moduleA.js');
assert.equal('/moduleA.js', httpModule.httpPath());
modulesLoaded++;
});
var nodeBinary = process.ARGV[0];
-var cmd = 'NODE_PATH='+libDir+' '+nodeBinary+' http://localhost:'+PORT+'/moduleB.js';
+var cmd = 'NODE_PATH='+libDir+' '+nodeBinary+' http://localhost:'+common.PORT+'/moduleB.js';
sys.exec(cmd, function (err, stdout, stderr) {
if (err) throw err;
diff --git a/test/disabled/test-setuidgid.js b/test/disabled/test-setuidgid.js
index c34864bf2..76fb2b229 100644
--- a/test/disabled/test-setuidgid.js
+++ b/test/disabled/test-setuidgid.js
@@ -1,5 +1,6 @@
// Requires special privlages
-require('../common');
+common = require("../common");
+assert = common.assert
var assert = require('assert');
var oldgid = process.getgid();
diff --git a/test/disabled/tls_client.js b/test/disabled/tls_client.js
index 909ec7d9c..9ade5595b 100644
--- a/test/disabled/tls_client.js
+++ b/test/disabled/tls_client.js
@@ -1,4 +1,5 @@
-require('../common');
+common = require("../common");
+assert = common.assert
var sys=require('sys');
var net=require('net');
var fs=require('fs');
@@ -8,7 +9,7 @@ var crypto=require('crypto');
var client = net.createConnection(443, "www.microsoft.com");
//var client = net.createConnection(443, "www.google.com");
-var caPem = fs.readFileSync(fixturesDir+"/msca.pem");
+var caPem = fs.readFileSync(common.fixturesDir+"/msca.pem");
//var caPem = fs.readFileSync("ca.pem");
var credentials = crypto.createCredentials({ca:caPem});
@@ -27,7 +28,7 @@ client.addListener("secure", function () {
});
client.addListener("data", function (chunk) {
- sys.error(chunk);
+ sys.common.error(chunk);
});
client.addListener("end", function () {
diff --git a/test/disabled/tls_server.js b/test/disabled/tls_server.js
index 5aef382c3..239129f54 100644
--- a/test/disabled/tls_server.js
+++ b/test/disabled/tls_server.js
@@ -1,12 +1,13 @@
-require('../common');
+common = require("../common");
+assert = common.assert
var sys=require('sys');
var net=require('net');
var fs=require('fs');
var crypto=require('crypto');
-var keyPem = fs.readFileSync(fixturesDir + "/cert.pem");
-var certPem = fs.readFileSync(fixturesDir + "/cert.pem");
+var keyPem = fs.readFileSync(common.fixturesDir + "/cert.pem");
+var certPem = fs.readFileSync(common.fixturesDir + "/cert.pem");
var credentials = crypto.createCredentials({key:keyPem, cert:certPem});
var i = 0;
diff --git a/test/fixtures/a.js b/test/fixtures/a.js
index 4b9927ee4..4eed91f08 100644
--- a/test/fixtures/a.js
+++ b/test/fixtures/a.js
@@ -1,6 +1,6 @@
var c = require("./b/c");
-debug("load fixtures/a.js");
+common.debug("load fixtures/a.js");
var string = "A";
diff --git a/test/fixtures/echo.js b/test/fixtures/echo.js
index 4a963c914..ded07f1c6 100644
--- a/test/fixtures/echo.js
+++ b/test/fixtures/echo.js
@@ -1,4 +1,5 @@
-require("../common");
+common = require("../common");
+assert = common.assert
print("hello world\r\n");
diff --git a/test/fixtures/print-chars-from-buffer.js b/test/fixtures/print-chars-from-buffer.js
index 94fce0888..d8c287038 100644
--- a/test/fixtures/print-chars-from-buffer.js
+++ b/test/fixtures/print-chars-from-buffer.js
@@ -1,4 +1,5 @@
-require("../common");
+common = require("../common");
+assert = common.assert
Buffer = require("buffer").Buffer;
var n = parseInt(process.argv[2]);
diff --git a/test/fixtures/print-chars.js b/test/fixtures/print-chars.js
index 13a4c3d0b..4ceda97df 100644
--- a/test/fixtures/print-chars.js
+++ b/test/fixtures/print-chars.js
@@ -1,4 +1,5 @@
-require("../common");
+common = require("../common");
+assert = common.assert
var n = parseInt(process.argv[2]);
diff --git a/test/message/2100bytes.js b/test/message/2100bytes.js
index 9418698d0..13778b055 100644
--- a/test/message/2100bytes.js
+++ b/test/message/2100bytes.js
@@ -1,4 +1,5 @@
-require('../common');
+common = require("../common");
+assert = common.assert
sys = require('sys');
console.log([
diff --git a/test/message/hello_world.js b/test/message/hello_world.js
index 55b231e59..522d64903 100644
--- a/test/message/hello_world.js
+++ b/test/message/hello_world.js
@@ -1,3 +1,4 @@
-require('../common');
+common = require("../common");
+assert = common.assert
console.log('hello world');
diff --git a/test/message/undefined_reference_in_new_context.js b/test/message/undefined_reference_in_new_context.js
index 7430869f5..b7d8d2254 100644
--- a/test/message/undefined_reference_in_new_context.js
+++ b/test/message/undefined_reference_in_new_context.js
@@ -1,6 +1,7 @@
-require('../common');
+common = require("../common");
+assert = common.assert
-error('before');
+common.error('before');
var Script = process.binding('evals').Script;
@@ -8,4 +9,4 @@ var Script = process.binding('evals').Script;
script = new Script('foo.bar = 5;');
script.runInNewContext();
-error('after');
+common.error('after');
diff --git a/test/message/undefined_reference_in_new_context.out b/test/message/undefined_reference_in_new_context.out
index 43d910d67..197695688 100644
--- a/test/message/undefined_reference_in_new_context.out
+++ b/test/message/undefined_reference_in_new_context.out
@@ -1,7 +1,7 @@
before
-*test/message/undefined_reference_in_new_context.js:9
+*test/message/undefined_reference_in_new_context.js:10
script.runInNewContext();
^
ReferenceError: foo is not defined
@@ -11,4 +11,4 @@ ReferenceError: foo is not defined
at Module._loadScriptSync (module:*)
at Module.loadSync (module:*)
at Object.runMain (module:*)
- at node.js:*242:10
+ at node.js:*
diff --git a/test/pummel/test-child-process-spawn-loop.js b/test/pummel/test-child-process-spawn-loop.js
index fb426acd6..8624fff8d 100644
--- a/test/pummel/test-child-process-spawn-loop.js
+++ b/test/pummel/test-child-process-spawn-loop.js
@@ -1,4 +1,5 @@
-require("../common");
+common = require("../common");
+assert = common.assert
var spawn = require('child_process').spawn;
diff --git a/test/pummel/test-http-client-reconnect-bug.js b/test/pummel/test-http-client-reconnect-bug.js
index 4e74efd0e..791c89bc4 100644
--- a/test/pummel/test-http-client-reconnect-bug.js
+++ b/test/pummel/test-http-client-reconnect-bug.js
@@ -1,4 +1,5 @@
-require("../common");
+common = require("../common");
+assert = common.assert
var tcp = require("tcp"),
sys = require("sys"),
@@ -10,9 +11,9 @@ var eofCount = 0;
var server = tcp.createServer(function(socket) {
socket.end();
});
-server.listen(PORT);
+server.listen(common.PORT);
-var client = http.createClient(PORT);
+var client = http.createClient(common.PORT);
client.addListener("error", function() {
console.log("ERROR!");
diff --git a/test/pummel/test-keep-alive.js b/test/pummel/test-keep-alive.js
index 42867831b..d2980e15e 100644
--- a/test/pummel/test-keep-alive.js
+++ b/test/pummel/test-keep-alive.js
@@ -1,5 +1,6 @@
// This test requires the program "ab"
-require("../common");
+common = require("../common");
+assert = common.assert
http = require("http");
exec = require("child_process").exec;
@@ -18,7 +19,7 @@ var normalReqSec = 0;
function runAb(opts, callback) {
- var command = "ab " + opts + " http://127.0.0.1:" + PORT + "/";
+ var command = "ab " + opts + " http://127.0.0.1:" + common.PORT + "/";
exec(command, function (err, stdout, stderr) {
if (err) {
console.log("ab not installed? skipping test.\n" + stderr);
@@ -41,7 +42,7 @@ function runAb(opts, callback) {
});
}
-server.listen(PORT, function () {
+server.listen(common.PORT, function () {
runAb("-k -c 100 -t 2", function (reqSec, keepAliveRequests) {
keepAliveReqSec = reqSec;
assert.equal(true, keepAliveRequests > 0);
diff --git a/test/pummel/test-net-many-clients.js b/test/pummel/test-net-many-clients.js
index fe026b9c6..9d123e7ca 100644
--- a/test/pummel/test-net-many-clients.js
+++ b/test/pummel/test-net-many-clients.js
@@ -1,4 +1,5 @@
-require("../common");
+common = require("../common");
+assert = common.assert
net = require("net");
// settings
var bytes = 1024*40;
@@ -23,7 +24,7 @@ var server = net.createServer(function (c) {
});
function runClient (callback) {
- var client = net.createConnection(PORT);
+ var client = net.createConnection(common.PORT);
client.connections = 0;
@@ -59,14 +60,14 @@ function runClient (callback) {
assert.ok(!client.fd);
if (this.connections < connections_per_client) {
- this.connect(PORT);
+ this.connect(common.PORT);
} else {
callback();
}
});
}
-server.listen(PORT, function () {
+server.listen(common.PORT, function () {
var finished_clients = 0;
for (var i = 0; i < concurrency; i++) {
runClient(function () {
diff --git a/test/pummel/test-net-pause.js b/test/pummel/test-net-pause.js
index 0dbf65acc..5482b6892 100644
--- a/test/pummel/test-net-pause.js
+++ b/test/pummel/test-net-pause.js
@@ -1,4 +1,5 @@
-require("../common");
+common = require("../common");
+assert = common.assert
net = require("net");
N = 200;
@@ -15,13 +16,13 @@ server = net.createServer(function (connection) {
}
write(0);
});
-server.listen(PORT);
+server.listen(common.PORT);
recv = "";
chars_recved = 0;
-client = net.createConnection(PORT);
+client = net.createConnection(common.PORT);
client.setEncoding("ascii");
client.addListener("data", function (d) {
print(d);
@@ -63,5 +64,5 @@ client.addListener("end", function () {
process.addListener("exit", function () {
assert.equal(N, recv.length);
- debug("Exit");
+ common.debug("Exit");
});
diff --git a/test/pummel/test-net-pingpong-delay.js b/test/pummel/test-net-pingpong-delay.js
index 6f1886592..ba68d641a 100644
--- a/test/pummel/test-net-pingpong-delay.js
+++ b/test/pummel/test-net-pingpong-delay.js
@@ -1,4 +1,5 @@
-require("../common");
+common = require("../common");
+assert = common.assert
net = require("net");
@@ -25,7 +26,7 @@ function pingPongTest (port, host, on_complete) {
});
socket.addListener("timeout", function () {
- debug("server-side timeout!!");
+ common.debug("server-side timeout!!");
assert.equal(false, true);
});
@@ -71,7 +72,7 @@ function pingPongTest (port, host, on_complete) {
});
client.addListener("timeout", function () {
- debug("client-side timeout!!");
+ common.debug("client-side timeout!!");
assert.equal(false, true);
});
@@ -84,7 +85,7 @@ function pingPongTest (port, host, on_complete) {
});
}
-pingPongTest(PORT);
+pingPongTest(common.PORT);
process.addListener("exit", function () {
assert.equal(1, tests_run);
diff --git a/test/pummel/test-net-pingpong.js b/test/pummel/test-net-pingpong.js
index a57234a53..59bf3b4ce 100644
--- a/test/pummel/test-net-pingpong.js
+++ b/test/pummel/test-net-pingpong.js
@@ -1,4 +1,5 @@
-require("../common");
+common = require("../common");
+assert = common.assert
net = require("net");
var tests_run = 0;
@@ -84,12 +85,12 @@ function pingPongTest (port, host, on_complete) {
}
/* All are run at once, so run on different ports */
-pingPongTest(PORT, "localhost");
-pingPongTest(PORT+1, null);
+pingPongTest(common.PORT, "localhost");
+pingPongTest(common.PORT+1, null);
// This IPv6 isn't working on Solaris
var solaris = /sunos/i.test(process.platform);
-if (!solaris) pingPongTest(PORT+2, "::1");
+if (!solaris) pingPongTest(common.PORT+2, "::1");
process.addListener("exit", function () {
assert.equal(solaris ? 2 : 3, tests_run);
diff --git a/test/pummel/test-net-throttle.js b/test/pummel/test-net-throttle.js
index 7205317e7..74dc57001 100644
--- a/test/pummel/test-net-throttle.js
+++ b/test/pummel/test-net-throttle.js
@@ -1,4 +1,5 @@
-require("../common");
+common = require("../common");
+assert = common.assert
net = require("net");
N = 160*1024; // 30kb
@@ -8,7 +9,7 @@ for (var i = 0; i < N; i++) {
body += "C";
}
-console.log("start server on port " + PORT);
+console.log("start server on port " + common.PORT);
server = net.createServer(function (connection) {
connection.addListener("connect", function () {
@@ -16,7 +17,7 @@ server = net.createServer(function (connection) {
connection.end();
});
});
-server.listen(PORT);
+server.listen(common.PORT);
chars_recved = 0;
@@ -24,7 +25,7 @@ npauses = 0;
var paused = false;
-client = net.createConnection(PORT);
+client = net.createConnection(common.PORT);
client.setEncoding("ascii");
client.addListener("data", function (d) {
chars_recved += d.length;
diff --git a/test/pummel/test-net-timeout.js b/test/pummel/test-net-timeout.js
index e1938abf6..8bdf7b7c2 100644
--- a/test/pummel/test-net-timeout.js
+++ b/test/pummel/test-net-timeout.js
@@ -1,4 +1,5 @@
-require("../common");
+common = require("../common");
+assert = common.assert
net = require("net");
exchanges = 0;
starttime = null;
@@ -29,11 +30,11 @@ var echo_server = net.createServer(function (socket) {
});
});
-echo_server.listen(PORT, function () {
- console.log("server listening at " + PORT);
+echo_server.listen(common.PORT, function () {
+ console.log("server listening at " + common.PORT);
});
-var client = net.createConnection(PORT);
+var client = net.createConnection(common.PORT);
client.setEncoding("UTF8");
client.setTimeout(0); // disable the timeout for client
client.addListener("connect", function () {
diff --git a/test/pummel/test-net-tls.js b/test/pummel/test-net-tls.js
index bad71ea50..0298abd8a 100644
--- a/test/pummel/test-net-tls.js
+++ b/test/pummel/test-net-tls.js
@@ -1,4 +1,5 @@
-require("../common");
+common = require("../common");
+assert = common.assert
tcp = require("tcp");
fs=require("fs");
@@ -105,13 +106,13 @@ try {
}
if (have_tls) {
- var caPem = fs.readFileSync(fixturesDir+"/test_ca.pem");
- var certPem = fs.readFileSync(fixturesDir+"/test_cert.pem");
- var keyPem = fs.readFileSync(fixturesDir+"/test_key.pem");
+ var caPem = fs.readFileSync(common.fixturesDir+"/test_ca.pem");
+ var certPem = fs.readFileSync(common.fixturesDir+"/test_cert.pem");
+ var keyPem = fs.readFileSync(common.fixturesDir+"/test_key.pem");
/* All are run at once, so run on different ports */
- tlsTest(PORT, "localhost", caPem, keyPem, certPem);
- tlsTest(PORT+1, null, caPem, keyPem, certPem);
+ tlsTest(common.PORT, "localhost", caPem, keyPem, certPem);
+ tlsTest(common.PORT+1, null, caPem, keyPem, certPem);
process.addListener("exit", function () {
assert.equal(2, tests_run);
diff --git a/test/pummel/test-timers.js b/test/pummel/test-timers.js
index aa4e9892e..d656f2bf9 100644
--- a/test/pummel/test-timers.js
+++ b/test/pummel/test-timers.js
@@ -1,4 +1,5 @@
-require("../common");
+common = require("../common");
+assert = common.assert
assert = require('assert');
diff --git a/test/pummel/test-watch-file.js b/test/pummel/test-watch-file.js
index 492177b3c..8c594410e 100644
--- a/test/pummel/test-watch-file.js
+++ b/test/pummel/test-watch-file.js
@@ -1,10 +1,11 @@
-require("../common");
+common = require("../common");
+assert = common.assert
var fs = require("fs");
var path = require("path");
-var f = path.join(fixturesDir, "x.txt");
-var f2 = path.join(fixturesDir, "x2.txt");
+var f = path.join(common.fixturesDir, "x.txt");
+var f2 = path.join(common.fixturesDir, "x2.txt");
console.log("watching for changes of " + f);
diff --git a/test/simple/test-assert.js b/test/simple/test-assert.js
index 10aeb5cc5..0985faafa 100644
--- a/test/simple/test-assert.js
+++ b/test/simple/test-assert.js
@@ -1,4 +1,5 @@
-require("../common");
+common = require("../common");
+assert = common.assert
var a = require('assert');
diff --git a/test/simple/test-buffer.js b/test/simple/test-buffer.js
index a1495b031..3ef85b97b 100644
--- a/test/simple/test-buffer.js
+++ b/test/simple/test-buffer.js
@@ -1,4 +1,5 @@
-require("../common");
+common = require("../common");
+assert = common.assert
assert = require("assert");
var Buffer = require('buffer').Buffer;
diff --git a/test/simple/test-byte-length.js b/test/simple/test-byte-length.js
index 465b6649c..9f7da8c31 100644
--- a/test/simple/test-byte-length.js
+++ b/test/simple/test-byte-length.js
@@ -1,4 +1,5 @@
-require("../common");
+common = require("../common");
+assert = common.assert
assert.equal(14, process._byteLength("Il était tué"));
assert.equal(14, process._byteLength("Il était tué", "utf8"));
diff --git a/test/simple/test-c-ares.js b/test/simple/test-c-ares.js
index e84c240de..f46ef24c9 100644
--- a/test/simple/test-c-ares.js
+++ b/test/simple/test-c-ares.js
@@ -1,4 +1,5 @@
-require('../common');
+common = require("../common");
+assert = common.assert
var dns = require("dns");
diff --git a/test/simple/test-chdir.js b/test/simple/test-chdir.js
index bd9c522bf..c4ece6a3b 100644
--- a/test/simple/test-chdir.js
+++ b/test/simple/test-chdir.js
@@ -1,4 +1,5 @@
-require("../common");
+common = require("../common");
+assert = common.assert
assert.equal(true, process.cwd() !== __dirname);
diff --git a/test/simple/test-child-process-buffering.js b/test/simple/test-child-process-buffering.js
index f6662a281..bff45dc7b 100644
--- a/test/simple/test-child-process-buffering.js
+++ b/test/simple/test-child-process-buffering.js
@@ -1,4 +1,5 @@
-require("../common");
+common = require("../common");
+assert = common.assert
var spawn = require('child_process').spawn;
diff --git a/test/simple/test-child-process-custom-fds.js b/test/simple/test-child-process-custom-fds.js
index 39e704b1d..8d3d2cd11 100644
--- a/test/simple/test-child-process-custom-fds.js
+++ b/test/simple/test-child-process-custom-fds.js
@@ -1,4 +1,5 @@
-require("../common");
+common = require("../common");
+assert = common.assert
var assert = require('assert');
var spawn = require('child_process').spawn;
@@ -7,7 +8,7 @@ var fs = require('fs');
var sys = require('sys');
function fixtPath(p) {
- return path.join(fixturesDir, p);
+ return path.join(common.fixturesDir, p);
}
var expected = "hello world";
diff --git a/test/simple/test-child-process-env.js b/test/simple/test-child-process-env.js
index 5a0244831..ced574a6a 100644
--- a/test/simple/test-child-process-env.js
+++ b/test/simple/test-child-process-env.js
@@ -1,4 +1,5 @@
-require("../common");
+common = require("../common");
+assert = common.assert
var spawn = require('child_process').spawn;
child = spawn('/usr/bin/env', [], {'HELLO' : 'WORLD'});
diff --git a/test/simple/test-child-process-exit-code.js b/test/simple/test-child-process-exit-code.js
index 5b14cfd6b..f81437141 100644
--- a/test/simple/test-child-process-exit-code.js
+++ b/test/simple/test-child-process-exit-code.js
@@ -1,10 +1,11 @@
-require("../common");
+common = require("../common");
+assert = common.assert
spawn = require('child_process').spawn,
path = require('path');
exits = 0;
-exitScript = path.join(fixturesDir, 'exit.js')
+exitScript = path.join(common.fixturesDir, 'exit.js')
exitChild = spawn(process.argv[0], [exitScript, 23]);
exitChild.addListener('exit', function(code, signal) {
assert.strictEqual(code, 23);
@@ -15,7 +16,7 @@ exitChild.addListener('exit', function(code, signal) {
-errorScript = path.join(fixturesDir, 'child_process_should_emit_error.js')
+errorScript = path.join(common.fixturesDir, 'child_process_should_emit_error.js')
errorChild = spawn(process.argv[0], [errorScript]);
errorChild.addListener('exit', function(code, signal) {
assert.ok(code !== 0);
diff --git a/test/simple/test-child-process-ipc.js b/test/simple/test-child-process-ipc.js
index f1482767b..b3eac8166 100644
--- a/test/simple/test-child-process-ipc.js
+++ b/test/simple/test-child-process-ipc.js
@@ -1,10 +1,11 @@
-require("../common");
+common = require("../common");
+assert = common.assert
var spawn = require('child_process').spawn;
var path = require('path');
-var sub = path.join(fixturesDir, 'echo.js');
+var sub = path.join(common.fixturesDir, 'echo.js');
var gotHelloWorld = false;
var gotEcho = false;
diff --git a/test/simple/test-child-process-kill.js b/test/simple/test-child-process-kill.js
index ccdb23864..eef723a93 100644
--- a/test/simple/test-child-process-kill.js
+++ b/test/simple/test-child-process-kill.js
@@ -1,4 +1,5 @@
-require("../common");
+common = require("../common");
+assert = common.assert
var spawn = require('child_process').spawn;
diff --git a/test/simple/test-child-process-stdin.js b/test/simple/test-child-process-stdin.js
index 730ae5ca1..c3b93c489 100644
--- a/test/simple/test-child-process-stdin.js
+++ b/test/simple/test-child-process-stdin.js
@@ -1,4 +1,5 @@
-require("../common");
+common = require("../common");
+assert = common.assert
var spawn = require('child_process').spawn;
diff --git a/test/simple/test-child-process-stdout-flush.js b/test/simple/test-child-process-stdout-flush.js
index 00cdbe0c6..dd35e9a60 100644
--- a/test/simple/test-child-process-stdout-flush.js
+++ b/test/simple/test-child-process-stdout-flush.js
@@ -1,7 +1,8 @@
-require("../common");
+common = require("../common");
+assert = common.assert
var path = require('path');
var spawn = require('child_process').spawn;
-var sub = path.join(fixturesDir, 'print-chars.js');
+var sub = path.join(common.fixturesDir, 'print-chars.js');
n = 500000;
diff --git a/test/simple/test-crypto.js b/test/simple/test-crypto.js
index a8276c387..0510c93d7 100644
--- a/test/simple/test-crypto.js
+++ b/test/simple/test-crypto.js
@@ -1,4 +1,5 @@
-require("../common");
+common = require("../common");
+assert = common.assert
try {
var crypto = require('crypto');
@@ -11,9 +12,9 @@ var fs = require('fs');
var sys = require('sys');
// Test Certificates
-var caPem = fs.readFileSync(fixturesDir+"/test_ca.pem", 'ascii');
-var certPem = fs.readFileSync(fixturesDir+"/test_cert.pem", 'ascii');
-var keyPem = fs.readFileSync(fixturesDir+"/test_key.pem", 'ascii');
+var caPem = fs.readFileSync(common.fixturesDir+"/test_ca.pem", 'ascii');
+var certPem = fs.readFileSync(common.fixturesDir+"/test_cert.pem", 'ascii');
+var keyPem = fs.readFileSync(common.fixturesDir+"/test_key.pem", 'ascii');
var credentials = crypto.createCredentials({key:keyPem, cert:certPem, ca:caPem});
diff --git a/test/simple/test-delayed-require.js b/test/simple/test-delayed-require.js
index 971cc271a..f44aa9910 100644
--- a/test/simple/test-delayed-require.js
+++ b/test/simple/test-delayed-require.js
@@ -1,4 +1,5 @@
-require("../common");
+common = require("../common");
+assert = common.assert
setTimeout(function () {
a = require("../fixtures/a");
diff --git a/test/simple/test-dgram-pingpong.js b/test/simple/test-dgram-pingpong.js
index 67aa83c35..10652372c 100644
--- a/test/simple/test-dgram-pingpong.js
+++ b/test/simple/test-dgram-pingpong.js
@@ -1,4 +1,5 @@
-require("../common");
+common = require("../common");
+assert = common.assert
var Buffer = require('buffer').Buffer;
var dgram = require("dgram");
diff --git a/test/simple/test-dgram-udp4.js b/test/simple/test-dgram-udp4.js
index 65840ac3b..755d629aa 100644
--- a/test/simple/test-dgram-udp4.js
+++ b/test/simple/test-dgram-udp4.js
@@ -1,4 +1,5 @@
-require("../common");
+common = require("../common");
+assert = common.assert
var Buffer = require("buffer").Buffer,
fs = require("fs"),
diff --git a/test/simple/test-dgram-unix-anon.js b/test/simple/test-dgram-unix-anon.js
index 1d93ffa10..e8e788b6f 100644
--- a/test/simple/test-dgram-unix-anon.js
+++ b/test/simple/test-dgram-unix-anon.js
@@ -1,4 +1,5 @@
-require("../common");
+common = require("../common");
+assert = common.assert
var Buffer = require("buffer").Buffer,
fs = require("fs"),
diff --git a/test/simple/test-dgram-unix.js b/test/simple/test-dgram-unix.js
index 7249369a2..ddb608490 100644
--- a/test/simple/test-dgram-unix.js
+++ b/test/simple/test-dgram-unix.js
@@ -1,4 +1,5 @@
-require("../common");
+common = require("../common");
+assert = common.assert
var Buffer = require("buffer").Buffer,
fs = require("fs"),
diff --git a/test/simple/test-eio-race.js b/test/simple/test-eio-race.js
index 387cc79e5..d21b03593 100644
--- a/test/simple/test-eio-race.js
+++ b/test/simple/test-eio-race.js
@@ -1,4 +1,5 @@
-require("../common");
+common = require("../common");
+assert = common.assert
var count = 100;
var fs = require('fs');
diff --git a/test/simple/test-eio-race2.js b/test/simple/test-eio-race2.js
index 207a5926b..3d2277819 100644
--- a/test/simple/test-eio-race2.js
+++ b/test/simple/test-eio-race2.js
@@ -1,6 +1,7 @@
-require("../common");
+common = require("../common");
+assert = common.assert
var path = require('path');
-var testTxt = path.join(fixturesDir, "x.txt");
+var testTxt = path.join(common.fixturesDir, "x.txt");
var fs = require('fs');
setTimeout(function () {
diff --git a/test/simple/test-eio-race4.js b/test/simple/test-eio-race4.js
index 9ab0c0d3a..4f322b235 100644
--- a/test/simple/test-eio-race4.js
+++ b/test/simple/test-eio-race4.js
@@ -1,4 +1,5 @@
-require("../common");
+common = require("../common");
+assert = common.assert
var fs = require('fs');
var N = 100;
var j = 0;
diff --git a/test/simple/test-error-reporting.js b/test/simple/test-error-reporting.js
index 46c8982c2..1aa39d224 100644
--- a/test/simple/test-error-reporting.js
+++ b/test/simple/test-error-reporting.js
@@ -1,11 +1,12 @@
-require("../common");
+common = require("../common");
+assert = common.assert
exec = require('child_process').exec,
path = require('path');
exits = 0;
function errExec (script, callback) {
- var cmd = process.argv[0] + ' ' + path.join(fixturesDir, script);
+ var cmd = process.argv[0] + ' ' + path.join(common.fixturesDir, script);
return exec(cmd, function (err, stdout, stderr) {
// There was some error
assert.ok(err);
diff --git a/test/simple/test-eval-cx.js b/test/simple/test-eval-cx.js
index 964512f5c..352bd2ae4 100644
--- a/test/simple/test-eval-cx.js
+++ b/test/simple/test-eval-cx.js
@@ -1,10 +1,11 @@
-require("../common");
+common = require("../common");
+assert = common.assert
-debug('evalcx a string');
+common.debug('evalcx a string');
var result = process.evalcx('"passed";');
assert.equal('passed', result);
-debug('evalcx a thrown error');
+common.debug('evalcx a thrown error');
assert.throws(function() {
process.evalcx('throw new Error("test");');
});
@@ -14,7 +15,7 @@ process.evalcx('hello = 2');
assert.equal(5, hello);
-debug("pass values in and out");
+common.debug("pass values in and out");
code = "foo = 1;"
+ "bar = 2;"
+ "if (baz !== 3) throw new Error('test fail');";
@@ -25,12 +26,12 @@ assert.equal(1, obj.foo);
assert.equal(2, obj.bar);
assert.equal(2, foo);
-debug("call a function by reference");
+common.debug("call a function by reference");
function changeFoo () { foo = 100 }
process.evalcx("f()", { f : changeFoo });
assert.equal(foo, 100);
-debug("modify an object by reference");
+common.debug("modify an object by reference");
var f = { a : 1 };
process.evalcx("f.a = 2", { f : f });
assert.equal(f.a, 2);
diff --git a/test/simple/test-event-emitter-add-listeners.js b/test/simple/test-event-emitter-add-listeners.js
index c824ec607..30aba8d45 100644
--- a/test/simple/test-event-emitter-add-listeners.js
+++ b/test/simple/test-event-emitter-add-listeners.js
@@ -1,4 +1,5 @@
-require("../common");
+common = require("../common");
+assert = common.assert
var events = require('events');
var e = new events.EventEmitter();
diff --git a/test/simple/test-event-emitter-modify-in-emit.js b/test/simple/test-event-emitter-modify-in-emit.js
index 858aa9ef4..161e8c3c7 100644
--- a/test/simple/test-event-emitter-modify-in-emit.js
+++ b/test/simple/test-event-emitter-modify-in-emit.js
@@ -1,4 +1,5 @@
-require("../common");
+common = require("../common");
+assert = common.assert
var events = require('events');
var callbacks_called = [ ];
diff --git a/test/simple/test-event-emitter-remove-listeners.js b/test/simple/test-event-emitter-remove-listeners.js
index b7fdc6d80..da8628eeb 100644
--- a/test/simple/test-event-emitter-remove-listeners.js
+++ b/test/simple/test-event-emitter-remove-listeners.js
@@ -1,4 +1,5 @@
-require("../common");
+common = require("../common");
+assert = common.assert
var events = require('events');
diff --git a/test/simple/test-exception-handler.js b/test/simple/test-exception-handler.js
index 957e038d0..f1227e80a 100644
--- a/test/simple/test-exception-handler.js
+++ b/test/simple/test-exception-handler.js
@@ -1,4 +1,5 @@
-require("../common");
+common = require("../common");
+assert = common.assert
var MESSAGE = 'catch me if you can';
var caughtException = false;
diff --git a/test/simple/test-exec.js b/test/simple/test-exec.js
index 0625c1941..727fd1fae 100644
--- a/test/simple/test-exec.js
+++ b/test/simple/test-exec.js
@@ -1,4 +1,5 @@
-require("../common");
+common = require("../common");
+assert = common.assert
var exec = require('child_process').exec;
success_count = 0;
error_count = 0;
diff --git a/test/simple/test-executable-path.js b/test/simple/test-executable-path.js
index 1093621fb..099705972 100644
--- a/test/simple/test-executable-path.js
+++ b/test/simple/test-executable-path.js
@@ -1,4 +1,5 @@
-require("../common");
+common = require("../common");
+assert = common.assert
path = require("path");
diff --git a/test/simple/test-file-read-noexist.js b/test/simple/test-file-read-noexist.js
index 8589c0b73..63f049cb3 100644
--- a/test/simple/test-file-read-noexist.js
+++ b/test/simple/test-file-read-noexist.js
@@ -1,15 +1,16 @@
-require("../common");
+common = require("../common");
+assert = common.assert
var path = require('path');
var fs = require('fs');
var got_error = false;
-var filename = path.join(fixturesDir, "does_not_exist.txt");
+var filename = path.join(common.fixturesDir, "does_not_exist.txt");
fs.readFile(filename, "raw", function (err, content) {
if (err) {
got_error = true;
} else {
- debug("cat returned some content: " + content);
- debug("this shouldn't happen as the file doesn't exist...");
+ common.debug("cat returned some content: " + content);
+ common.debug("this shouldn't happen as the file doesn't exist...");
assert.equal(true, false);
}
});
diff --git a/test/simple/test-file-write-stream.js b/test/simple/test-file-write-stream.js
index d1efb17e7..a978d5920 100644
--- a/test/simple/test-file-write-stream.js
+++ b/test/simple/test-file-write-stream.js
@@ -1,9 +1,10 @@
-require('../common');
+common = require("../common");
+assert = common.assert
var
path = require('path'),
fs = require('fs'),
- fn = path.join(fixturesDir, "write.txt"),
+ fn = path.join(common.fixturesDir, "write.txt"),
file = fs.createWriteStream(fn),
EXPECTED = '012345678910',
diff --git a/test/simple/test-fs-chmod.js b/test/simple/test-fs-chmod.js
index 10e62e89b..fc870a08a 100644
--- a/test/simple/test-fs-chmod.js
+++ b/test/simple/test-fs-chmod.js
@@ -1,10 +1,11 @@
-require("../common");
+common = require("../common");
+assert = common.assert
var path = require('path');
var fs = require('fs');
var got_error = false;
var success_count = 0;
-var file = path.join(fixturesDir, "a.js");
+var file = path.join(common.fixturesDir, "a.js");
fs.chmod(file, 0777, function (err) {
if (err) {
diff --git a/test/simple/test-fs-error-messages.js b/test/simple/test-fs-error-messages.js
index e964820fc..387ceded8 100644
--- a/test/simple/test-fs-error-messages.js
+++ b/test/simple/test-fs-error-messages.js
@@ -1,9 +1,10 @@
-require('../common');
+common = require("../common");
+assert = common.assert
var path = require('path'),
fs = require('fs'),
- fn = path.join(fixturesDir, 'non-existent'),
- existingFile = path.join(fixturesDir, 'exit.js');
+ fn = path.join(common.fixturesDir, 'non-existent'),
+ existingFile = path.join(common.fixturesDir, 'exit.js');
// ASYNC_CALL
diff --git a/test/simple/test-fs-fsync.js b/test/simple/test-fs-fsync.js
index 3014743db..20ddcd425 100644
--- a/test/simple/test-fs-fsync.js
+++ b/test/simple/test-fs-fsync.js
@@ -1,32 +1,33 @@
-require("../common");
+common = require("../common");
+assert = common.assert
var path = require('path');
var fs = require('fs');
var successes = 0;
-var file = path.join(fixturesDir, "a.js");
+var file = path.join(common.fixturesDir, "a.js");
-error("open " + file);
+common.error("open " + file);
fs.open(file, "a", 0777, function (err, fd) {
- error("fd " + fd);
+ common.error("fd " + fd);
if (err) throw err;
fs.fdatasyncSync(fd);
- error("fdatasync SYNC: ok");
+ common.error("fdatasync SYNC: ok");
successes++;
fs.fsyncSync(fd);
- error("fsync SYNC: ok");
+ common.error("fsync SYNC: ok");
successes++;
fs.fdatasync(fd, function (err) {
if (err) throw err;
- error("fdatasync ASYNC: ok");
+ common.error("fdatasync ASYNC: ok");
successes++;
fs.fsync(fd, function(err) {
if (err) throw err;
- error("fsync ASYNC: ok");
+ common.error("fsync ASYNC: ok");
successes++;
});
});
diff --git a/test/simple/test-fs-read-buffer.js b/test/simple/test-fs-read-buffer.js
index 7d4ebbf2f..60c5917b2 100644
--- a/test/simple/test-fs-read-buffer.js
+++ b/test/simple/test-fs-read-buffer.js
@@ -1,8 +1,9 @@
-require('../common');
+common = require("../common");
+assert = common.assert
var path = require('path'),
Buffer = require('buffer').Buffer,
fs = require('fs'),
- filepath = path.join(fixturesDir, 'x.txt'),
+ filepath = path.join(common.fixturesDir, 'x.txt'),
fd = fs.openSync(filepath, 'r'),
expected = 'xyz\n',
bufferAsync = new Buffer(expected.length),
diff --git a/test/simple/test-fs-read-file-sync.js b/test/simple/test-fs-read-file-sync.js
index 8ba510cba..69502aef3 100644
--- a/test/simple/test-fs-read-file-sync.js
+++ b/test/simple/test-fs-read-file-sync.js
@@ -1,8 +1,9 @@
-require('../common');
+common = require("../common");
+assert = common.assert
path = require('path');
fs = require('fs');
-fn = path.join(fixturesDir, 'elipses.txt');
+fn = path.join(common.fixturesDir, 'elipses.txt');
var s = fs.readFileSync(fn, 'utf8');
for (var i = 0; i < s.length; i++) {
diff --git a/test/simple/test-fs-read-stream.js b/test/simple/test-fs-read-stream.js
index 8c27e5cf7..71165fdac 100644
--- a/test/simple/test-fs-read-stream.js
+++ b/test/simple/test-fs-read-stream.js
@@ -1,4 +1,5 @@
-require('../common');
+common = require("../common");
+assert = common.assert
// TODO Improved this test. test_ca.pem is too small. A proper test would
// great a large utf8 (with multibyte chars) file and stream it in,
@@ -7,7 +8,7 @@ require('../common');
Buffer = require('buffer').Buffer;
path = require('path');
fs = require('fs');
-fn = path.join(fixturesDir, 'elipses.txt');
+fn = path.join(common.fixturesDir, 'elipses.txt');
callbacks = { open: 0, end: 0, close: 0, destroy: 0 };
diff --git a/test/simple/test-fs-read.js b/test/simple/test-fs-read.js
index bb23bc9e2..3d0d334c0 100644
--- a/test/simple/test-fs-read.js
+++ b/test/simple/test-fs-read.js
@@ -1,7 +1,8 @@
-require('../common');
+common = require("../common");
+assert = common.assert
var path = require('path'),
fs = require('fs'),
- filepath = path.join(fixturesDir, 'x.txt'),
+ filepath = path.join(common.fixturesDir, 'x.txt'),
fd = fs.openSync(filepath, 'r'),
expected = 'xyz\n',
readCalled = 0;
diff --git a/test/simple/test-fs-readfile-empty.js b/test/simple/test-fs-readfile-empty.js
index fec0cd729..770d5e4e6 100644
--- a/test/simple/test-fs-readfile-empty.js
+++ b/test/simple/test-fs-readfile-empty.js
@@ -1,9 +1,10 @@
-require('../common');
+common = require("../common");
+assert = common.assert
var
path = require('path'),
fs = require('fs'),
- fn = path.join(fixturesDir, 'empty.txt');
+ fn = path.join(common.fixturesDir, 'empty.txt');
fs.readFile(fn, function(err, data) {
assert.ok(data);
diff --git a/test/simple/test-fs-realpath.js b/test/simple/test-fs-realpath.js
index 441ade0a8..e97e553f8 100644
--- a/test/simple/test-fs-realpath.js
+++ b/test/simple/test-fs-realpath.js
@@ -1,4 +1,5 @@
-require("../common");
+common = require("../common");
+assert = common.assert
var fs = require('fs');
var path = require('path');
var async_completed = 0, async_expected = 0, unlink = [];
@@ -30,8 +31,8 @@ function bashRealpath(path, callback) {
// sub-tests:
function test_simple_relative_symlink(callback) {
- var entry = fixturesDir+'/cycles/symlink',
- expected = fixturesDir+'/cycles/root.js';
+ var entry = common.fixturesDir+'/cycles/symlink',
+ expected = common.fixturesDir+'/cycles/root.js';
[
[entry, 'root.js'],
].forEach(function(t) {
@@ -41,15 +42,15 @@ function test_simple_relative_symlink(callback) {
});
var result = fs.realpathSync(entry);
assert.equal(result, expected,
- 'got '+inspect(result)+' expected '+inspect(expected));
+ 'got '+common.inspect(result)+' expected '+common.inspect(expected));
asynctest(fs.realpath, [entry], callback, function(err, result){
assert.equal(result, expected,
- 'got '+inspect(result)+' expected '+inspect(expected));
+ 'got '+common.inspect(result)+' expected '+common.inspect(expected));
});
}
function test_simple_absolute_symlink(callback) {
- bashRealpath(fixturesDir, function(err, fixturesAbsDir) {
+ bashRealpath(common.fixturesDir, function(err, fixturesAbsDir) {
if (err) return callback(err);
var entry = fixturesAbsDir+'/cycles/symlink',
expected = fixturesAbsDir+'/nested-index/one/index.js';
@@ -62,23 +63,23 @@ function test_simple_absolute_symlink(callback) {
});
var result = fs.realpathSync(entry);
assert.equal(result, expected,
- 'got '+inspect(result)+' expected '+inspect(expected));
+ 'got '+common.inspect(result)+' expected '+common.inspect(expected));
asynctest(fs.realpath, [entry], callback, function(err, result){
assert.equal(result, expected,
- 'got '+inspect(result)+' expected '+inspect(expected));
+ 'got '+common.inspect(result)+' expected '+common.inspect(expected));
});
});
}
function test_deep_relative_file_symlink(callback) {
- var expected = path.join(fixturesDir, 'cycles', 'root.js');
+ var expected = path.join(common.fixturesDir, 'cycles', 'root.js');
var linkData1 = "../../cycles/root.js";
- var linkPath1 = path.join(fixturesDir, "nested-index", 'one', 'symlink1.js');
+ var linkPath1 = path.join(common.fixturesDir, "nested-index", 'one', 'symlink1.js');
try {fs.unlinkSync(linkPath1);}catch(e){}
fs.symlinkSync(linkData1, linkPath1);
var linkData2 = "../one/symlink1.js";
- var entry = path.join(fixturesDir, "nested-index", 'two', 'symlink1-b.js');
+ var entry = path.join(common.fixturesDir, "nested-index", 'two', 'symlink1-b.js');
try {fs.unlinkSync(entry);}catch(e){}
fs.symlinkSync(linkData2, entry);
unlink.push(linkPath1);
@@ -87,19 +88,19 @@ function test_deep_relative_file_symlink(callback) {
assert.equal(fs.realpathSync(entry), expected);
asynctest(fs.realpath, [entry], callback, function(err, result){
assert.equal(result, expected,
- 'got '+inspect(result)+' expected '+inspect(expected));
+ 'got '+common.inspect(result)+' expected '+common.inspect(expected));
});
}
function test_deep_relative_dir_symlink(callback) {
- var expected = path.join(fixturesDir, 'cycles', 'folder');
+ var expected = path.join(common.fixturesDir, 'cycles', 'folder');
var linkData1b = "../../cycles/folder";
- var linkPath1b = path.join(fixturesDir, "nested-index", 'one', 'symlink1-dir');
+ var linkPath1b = path.join(common.fixturesDir, "nested-index", 'one', 'symlink1-dir');
try {fs.unlinkSync(linkPath1b);}catch(e){}
fs.symlinkSync(linkData1b, linkPath1b);
var linkData2b = "../one/symlink1-dir";
- var entry = path.join(fixturesDir, "nested-index", 'two', 'symlink12-dir');
+ var entry = path.join(common.fixturesDir, "nested-index", 'two', 'symlink12-dir');
try {fs.unlinkSync(entry);}catch(e){}
fs.symlinkSync(linkData2b, entry);
unlink.push(linkPath1b);
@@ -109,16 +110,16 @@ function test_deep_relative_dir_symlink(callback) {
asynctest(fs.realpath, [entry], callback, function(err, result){
assert.equal(result, expected,
- 'got '+inspect(result)+' expected '+inspect(expected));
+ 'got '+common.inspect(result)+' expected '+common.inspect(expected));
});
}
function test_cyclic_link_protection(callback) {
- var entry = fixturesDir+'/cycles/realpath-3a';
+ var entry = common.fixturesDir+'/cycles/realpath-3a';
[
[entry, '../cycles/realpath-3b'],
- [fixturesDir+'/cycles/realpath-3b', '../cycles/realpath-3c'],
- [fixturesDir+'/cycles/realpath-3c', '../cycles/realpath-3a'],
+ [common.fixturesDir+'/cycles/realpath-3b', '../cycles/realpath-3c'],
+ [common.fixturesDir+'/cycles/realpath-3c', '../cycles/realpath-3a'],
].forEach(function(t) {
try {fs.unlinkSync(t[0]);}catch(e){}
fs.symlinkSync(t[1], t[0]);
@@ -132,14 +133,14 @@ function test_cyclic_link_protection(callback) {
}
function test_relative_input_cwd(callback) {
- var p = fixturesDir.lastIndexOf('/');
- var entrydir = fixturesDir.substr(0, p);
- var entry = fixturesDir.substr(p+1)+'/cycles/realpath-3a';
- var expected = fixturesDir+'/cycles/root.js';
+ var p = common.fixturesDir.lastIndexOf('/');
+ var entrydir = common.fixturesDir.substr(0, p);
+ var entry = common.fixturesDir.substr(p+1)+'/cycles/realpath-3a';
+ var expected = common.fixturesDir+'/cycles/root.js';
[
[entry, '../cycles/realpath-3b'],
- [fixturesDir+'/cycles/realpath-3b', '../cycles/realpath-3c'],
- [fixturesDir+'/cycles/realpath-3c', 'root.js'],
+ [common.fixturesDir+'/cycles/realpath-3b', '../cycles/realpath-3c'],
+ [common.fixturesDir+'/cycles/realpath-3c', 'root.js'],
].forEach(function(t) {
var fn = t[0];
if (fn.charAt(0) !== '/') fn = entrydir + '/' + fn;
@@ -153,16 +154,16 @@ function test_relative_input_cwd(callback) {
asynctest(fs.realpath, [entry], callback, function(err, result){
process.chdir(origcwd);
assert.equal(result, expected,
- 'got '+inspect(result)+' expected '+inspect(expected));
+ 'got '+common.inspect(result)+' expected '+common.inspect(expected));
return true;
});
}
function test_deep_symlink_mix(callback) {
- // todo: check to see that fixturesDir is not rooted in the
+ // todo: check to see that common.fixturesDir is not rooted in the
// same directory as our test symlink.
// obtain our current realpath using bash (so we can test ourselves)
- bashRealpath(fixturesDir, function(err, fixturesAbsDir) {
+ bashRealpath(common.fixturesDir, function(err, fixturesAbsDir) {
if (err) return callback(err);
/*
/tmp/node-test-realpath-f1 -> ../tmp/node-test-realpath-d1/foo
@@ -188,7 +189,7 @@ function test_deep_symlink_mix(callback) {
[fixturesAbsDir+'/nested-index/one/realpath-c', fixturesAbsDir+'/nested-index/two/realpath-c'],
[fixturesAbsDir+'/nested-index/two/realpath-c', '../../cycles/root.js'],
].forEach(function(t) {
- //debug('setting up '+t[0]+' -> '+t[1]);
+ //common.debug('setting up '+t[0]+' -> '+t[1]);
try {fs.unlinkSync(t[0]);}catch(e){}
fs.symlinkSync(t[1], t[0]);
unlink.push(t[0]);
@@ -200,14 +201,14 @@ function test_deep_symlink_mix(callback) {
assert.equal(fs.realpathSync(entry), expected);
asynctest(fs.realpath, [entry], callback, function(err, result){
assert.equal(result, expected,
- 'got '+inspect(result)+' expected '+inspect(expected));
+ 'got '+common.inspect(result)+' expected '+common.inspect(expected));
return true;
});
});
}
function test_non_symlinks(callback) {
- bashRealpath(fixturesDir, function(err, fixturesAbsDir) {
+ bashRealpath(common.fixturesDir, function(err, fixturesAbsDir) {
if (err) return callback(err);
var p = fixturesAbsDir.lastIndexOf('/');
var entrydir = fixturesAbsDir.substr(0, p);
@@ -219,7 +220,7 @@ function test_non_symlinks(callback) {
asynctest(fs.realpath, [entry], callback, function(err, result){
process.chdir(origcwd);
assert.equal(result, expected,
- 'got '+inspect(result)+' expected '+inspect(expected));
+ 'got '+common.inspect(result)+' expected '+common.inspect(expected));
return true;
});
});
diff --git a/test/simple/test-fs-stat.js b/test/simple/test-fs-stat.js
index c063eb966..e626a973e 100644
--- a/test/simple/test-fs-stat.js
+++ b/test/simple/test-fs-stat.js
@@ -1,4 +1,5 @@
-require("../common");
+common = require("../common");
+assert = common.assert
var fs = require('fs');
var got_error = false;
var success_count = 0;
diff --git a/test/simple/test-fs-symlink.js b/test/simple/test-fs-symlink.js
index b35d3fe6f..e46dad355 100644
--- a/test/simple/test-fs-symlink.js
+++ b/test/simple/test-fs-symlink.js
@@ -1,11 +1,12 @@
-require("../common");
+common = require("../common");
+assert = common.assert
var path = require('path');
var fs = require('fs');
var completed = 0;
// test creating and reading symbolic link
var linkData = "../../cycles/root.js";
-var linkPath = path.join(fixturesDir, "nested-index", 'one', 'symlink1.js');
+var linkPath = path.join(common.fixturesDir, "nested-index", 'one', 'symlink1.js');
try {fs.unlinkSync(linkPath);}catch(e){}
fs.symlink(linkData, linkPath, function(err){
if (err) throw err;
@@ -19,8 +20,8 @@ fs.symlink(linkData, linkPath, function(err){
});
// test creating and reading hard link
-var srcPath = path.join(fixturesDir, "cycles", 'root.js');
-var dstPath = path.join(fixturesDir, "nested-index", 'one', 'link1.js');
+var srcPath = path.join(common.fixturesDir, "cycles", 'root.js');
+var dstPath = path.join(common.fixturesDir, "nested-index", 'one', 'link1.js');
try {fs.unlinkSync(dstPath);}catch(e){}
fs.link(srcPath, dstPath, function(err){
if (err) throw err;
diff --git a/test/simple/test-fs-write-buffer.js b/test/simple/test-fs-write-buffer.js
index a90b59aeb..13b99ef59 100644
--- a/test/simple/test-fs-write-buffer.js
+++ b/test/simple/test-fs-write-buffer.js
@@ -1,8 +1,9 @@
-require('../common');
+common = require("../common");
+assert = common.assert
var path = require('path'),
Buffer = require('buffer').Buffer,
fs = require('fs'),
- filename = path.join(fixturesDir, 'write.txt'),
+ filename = path.join(common.fixturesDir, 'write.txt'),
expected = new Buffer('hello'),
openCalled = 0,
writeCalled = 0;
diff --git a/test/simple/test-fs-write-file.js b/test/simple/test-fs-write-file.js
index ce09d26b1..a44859229 100644
--- a/test/simple/test-fs-write-file.js
+++ b/test/simple/test-fs-write-file.js
@@ -1,12 +1,13 @@
-require('../common');
+common = require("../common");
+assert = common.assert
join = require('path').join;
fs = require('fs');
Buffer = require('buffer').Buffer;
-filename = join(fixturesDir, 'test.txt');
+filename = join(common.fixturesDir, 'test.txt');
-error('writing to ' + filename);
+common.error('writing to ' + filename);
s = "南越国是前203年至前111年存在于岭南地区的一个国家,国都位于番禺,疆域包括今天中国的广东、广西两省区的大部份地区,福建省、湖南、贵州、云南的一小部份地区和越南的北部。南越国是秦朝灭亡后,由南海郡尉赵佗于前203年起兵兼并桂林郡和象郡后建立。前196年和前179年,南越国曾先后两次名义上臣属于西汉,成为西汉的“外臣”。前112年,南越国末代君主赵建德与西汉发生战争,被汉武帝于前111年所灭。南越国共存在93年,历经五代君主。南越国是岭南地区的第一个有记载的政权国家,采用封建制和郡县制并存的制度,它的建立保证了秦末乱世岭南地区社会秩序的稳定,有效的改善了岭南地区落后的政治、##济现状。\n";
@@ -16,30 +17,30 @@ fs.writeFile(filename, s, function (e) {
if (e) throw e;
ncallbacks++;
- error('file written');
+ common.error('file written');
fs.readFile(filename, function (e, buffer) {
if (e) throw e;
- error('file read');
+ common.error('file read');
ncallbacks++;
assert.equal(Buffer.byteLength(s), buffer.length);
});
});
// test that writeFile accepts buffers
-filename2 = join(fixturesDir, 'test2.txt');
+filename2 = join(common.fixturesDir, 'test2.txt');
buf = new Buffer(s, 'utf8');
-error('writing to ' + filename2);
+common.error('writing to ' + filename2);
fs.writeFile(filename2, buf, function (e) {
if (e) throw e;
ncallbacks++;
- error('file2 written');
+ common.error('file2 written');
fs.readFile(filename2, function (e, buffer) {
if (e) throw e;
- error('file2 read');
+ common.error('file2 read');
ncallbacks++;
assert.equal(buf.length, buffer.length);
});
@@ -47,7 +48,7 @@ fs.writeFile(filename2, buf, function (e) {
process.addListener('exit', function () {
- error('done');
+ common.error('done');
assert.equal(4, ncallbacks);
fs.unlinkSync(filename);
diff --git a/test/simple/test-fs-write-sync.js b/test/simple/test-fs-write-sync.js
index 27dea4af7..9e930c61f 100644
--- a/test/simple/test-fs-write-sync.js
+++ b/test/simple/test-fs-write-sync.js
@@ -1,8 +1,9 @@
-require('../common');
+common = require("../common");
+assert = common.assert
path = require('path'),
Buffer = require('buffer').Buffer
fs = require('fs')
-fn = path.join(fixturesDir, 'write.txt');
+fn = path.join(common.fixturesDir, 'write.txt');
foo = 'foo'
diff --git a/test/simple/test-fs-write.js b/test/simple/test-fs-write.js
index 3c7004d8d..8ac3f422b 100644
--- a/test/simple/test-fs-write.js
+++ b/test/simple/test-fs-write.js
@@ -1,8 +1,9 @@
-require("../common");
+common = require("../common");
+assert = common.assert
var path = require('path');
var Buffer = require('buffer').Buffer;
var fs = require('fs');
-var fn = path.join(fixturesDir, "write.txt");
+var fn = path.join(common.fixturesDir, "write.txt");
var expected = "ümlaut.";
var found;
diff --git a/test/simple/test-http-1.0.js b/test/simple/test-http-1.0.js
index c284135de..7d010ddec 100644
--- a/test/simple/test-http-1.0.js
+++ b/test/simple/test-http-1.0.js
@@ -1,4 +1,5 @@
-require("../common");
+common = require("../common");
+assert = common.assert
net = require("net");
http = require("http");
@@ -13,9 +14,9 @@ var server = http.createServer(function (req, res) {
res.writeHead(200, {"Content-Type": "text/plain"});
res.end(body);
})
-server.listen(PORT);
+server.listen(common.PORT);
-var c = net.createConnection(PORT);
+var c = net.createConnection(common.PORT);
c.setEncoding("utf8");
diff --git a/test/simple/test-http-304.js b/test/simple/test-http-304.js
index 1d986c149..d6b92ad55 100644
--- a/test/simple/test-http-304.js
+++ b/test/simple/test-http-304.js
@@ -1,21 +1,21 @@
-require('../common');
+common = require("../common");
+assert = common.assert
-var sys = require('sys'),
- http = require('http'),
- childProcess = require('child_process');
+http = require('http');
+childProcess = require('child_process');
s = http.createServer(function (request, response) {
response.writeHead(304);
response.end();
});
-s.listen(PORT, function () {
- childProcess.exec('curl -i http://127.0.0.1:'+PORT+'/', function (err, stdout, stderr) {
+s.listen(common.PORT, function () {
+ childProcess.exec('curl -i http://127.0.0.1:'+common.PORT+'/', function (err, stdout, stderr) {
if (err) throw err;
s.close();
- error('curled response correctly');
- error(sys.inspect(stdout));
+ common.error('curled response correctly');
+ common.error(common.inspect(stdout));
});
});
-console.log('Server running at http://127.0.0.1:'+PORT+'/')
+console.log('Server running at http://127.0.0.1:'+common.PORT+'/')
diff --git a/test/simple/test-http-blank-header.js b/test/simple/test-http-blank-header.js
index 1948deca3..5c8f2ebe8 100644
--- a/test/simple/test-http-blank-header.js
+++ b/test/simple/test-http-blank-header.js
@@ -1,4 +1,5 @@
-require('../common');
+common = require("../common");
+assert = common.assert
http = require('http');
net = require('net');
@@ -6,7 +7,7 @@ net = require('net');
gotReq = false;
server = http.createServer(function (req, res) {
- error('got req');
+ common.error('got req');
gotReq = true;
assert.equal('GET', req.method);
assert.equal('/blah', req.url);
@@ -18,11 +19,11 @@ server = http.createServer(function (req, res) {
});
-server.listen(PORT, function () {
- var c = net.createConnection(PORT);
+server.listen(common.PORT, function () {
+ var c = net.createConnection(common.PORT);
c.addListener('connect', function () {
- error('client wrote message');
+ common.error('client wrote message');
c.write( "GET /blah HTTP/1.1\r\n"
+ "Host: mapdevel.trolologames.ru:443\r\n"
+ "Cookie:\r\n"
@@ -36,7 +37,7 @@ server.listen(PORT, function () {
});
c.addListener('close', function () {
- error('client close');
+ common.error('client close');
server.close();
});
});
diff --git a/test/simple/test-http-cat.js b/test/simple/test-http-cat.js
index 21bef3ca2..b837dffd6 100644
--- a/test/simple/test-http-cat.js
+++ b/test/simple/test-http-cat.js
@@ -1,4 +1,5 @@
-require("../common");
+common = require("../common");
+assert = common.assert
http = require("http");
var body = "exports.A = function() { return 'A';}";
@@ -14,8 +15,8 @@ var server = http.createServer(function (req, res) {
var got_good_server_content = false;
var bad_server_got_error = false;
-server.listen(PORT, function () {
- http.cat("http://localhost:"+PORT+"/", "utf8", function (err, content) {
+server.listen(common.PORT, function () {
+ http.cat("http://localhost:"+common.PORT+"/", "utf8", function (err, content) {
if (err) {
throw err;
} else {
diff --git a/test/simple/test-http-chunked.js b/test/simple/test-http-chunked.js
index 14f026534..fa1127bb6 100644
--- a/test/simple/test-http-chunked.js
+++ b/test/simple/test-http-chunked.js
@@ -1,4 +1,5 @@
-require("../common");
+common = require("../common");
+assert = common.assert
var http = require("http");
var UTF8_STRING = "南越国是前203年至前111年存在于岭南地区的一个国家,国都位于番禺,疆域包括今天中国的广东、广西两省区的大部份地区,福建省、湖南、贵州、云南的一小部份地区和越南的北部。南越国是秦朝灭亡后,由南海郡尉赵佗于前203年起兵兼并桂林郡和象郡后建立。前196年和前179年,南越国曾先后两次名义上臣属于西汉,成为西汉的“外臣”。前112年,南越国末代君主赵建德与西汉发生战争,被汉武帝于前111年所灭。南越国共存在93年,历经五代君主。南越国是岭南地区的第一个有记载的政权国家,采用封建制和郡县制并存的制度,它的建立保证了秦末乱世岭南地区社会秩序的稳定,有效的改善了岭南地区落后的政治、经济现状。";
@@ -7,9 +8,9 @@ var server = http.createServer(function(req, res) {
res.writeHead(200, {"Content-Type": "text/plain; charset=utf8"});
res.end(UTF8_STRING, 'utf8');
});
-server.listen(PORT);
+server.listen(common.PORT);
-http.cat("http://127.0.0.1:"+PORT+"/", "utf8", function (err, data) {
+http.cat("http://127.0.0.1:"+common.PORT+"/", "utf8", function (err, data) {
if (err) throw err;
assert.equal('string', typeof data);
console.log('here is the response:');
diff --git a/test/simple/test-http-client-race-2.js b/test/simple/test-http-client-race-2.js
index 4f8604e4c..fbfa95767 100644
--- a/test/simple/test-http-client-race-2.js
+++ b/test/simple/test-http-client-race-2.js
@@ -1,4 +1,5 @@
-require("../common");
+common = require("../common");
+assert = common.assert
http = require("http");
url = require("url");
@@ -26,9 +27,9 @@ var server = http.createServer(function (req, res) {
});
res.end(body);
});
-server.listen(PORT);
+server.listen(common.PORT);
-var client = http.createClient(PORT);
+var client = http.createClient(common.PORT);
var body1 = "";
var body2 = "";
@@ -57,7 +58,7 @@ req1.addListener('response', function (res1) {
// parser that previously belonged to Client #1. But we're not finished
// with Client #1 yet!
//
- var client2 = http.createClient(PORT);
+ var client2 = http.createClient(common.PORT);
//
// At this point, the bug would manifest itself and crash because the
diff --git a/test/simple/test-http-client-race.js b/test/simple/test-http-client-race.js
index 016feae57..3e80d2f64 100644
--- a/test/simple/test-http-client-race.js
+++ b/test/simple/test-http-client-race.js
@@ -1,4 +1,5 @@
-require("../common");
+common = require("../common");
+assert = common.assert
http = require("http");
url = require("url");
@@ -12,9 +13,9 @@ var server = http.createServer(function (req, res) {
});
res.end(body);
});
-server.listen(PORT);
+server.listen(common.PORT);
-var client = http.createClient(PORT);
+var client = http.createClient(common.PORT);
var body1 = "";
var body2 = "";
diff --git a/test/simple/test-http-client-upload.js b/test/simple/test-http-client-upload.js
index 8627cdcd6..22136c1a9 100644
--- a/test/simple/test-http-client-upload.js
+++ b/test/simple/test-http-client-upload.js
@@ -1,4 +1,5 @@
-require("../common");
+common = require("../common");
+assert = common.assert
http = require("http");
var sent_body = "";
@@ -22,16 +23,16 @@ var server = http.createServer(function(req, res) {
res.end();
});
});
-server.listen(PORT);
+server.listen(common.PORT);
-var client = http.createClient(PORT);
+var client = http.createClient(common.PORT);
var req = client.request('POST', '/');
req.write('1\n');
req.write('2\n');
req.write('3\n');
req.end();
-error("client finished sending request");
+common.error("client finished sending request");
req.addListener('response', function(res) {
res.setEncoding("utf8");
diff --git a/test/simple/test-http-eof-on-connect.js b/test/simple/test-http-eof-on-connect.js
index 1f2f2e512..4fd787539 100644
--- a/test/simple/test-http-eof-on-connect.js
+++ b/test/simple/test-http-eof-on-connect.js
@@ -1,4 +1,5 @@
-require("../common");
+common = require("../common");
+assert = common.assert
net = require("net");
http = require("http");
@@ -7,9 +8,9 @@ http = require("http");
// reproduceable on the first packet on the first connection to a server.
server = http.createServer(function (req, res) {});
-server.listen(PORT);
+server.listen(common.PORT);
-net.createConnection(PORT).addListener("connect", function () {
+net.createConnection(common.PORT).addListener("connect", function () {
this.close();
}).addListener("close", function () {
server.close();
diff --git a/test/simple/test-http-exceptions.js b/test/simple/test-http-exceptions.js
index 71bd09170..04c5458d4 100644
--- a/test/simple/test-http-exceptions.js
+++ b/test/simple/test-http-exceptions.js
@@ -1,4 +1,5 @@
-require("../common");
+common = require("../common");
+assert = common.assert
var http = require("http"),
sys = require("sys"),
server,
@@ -27,7 +28,7 @@ function check_reqs() {
}
function add_client(num) {
- var req = http.createClient(PORT).request('GET', '/busy/' + num);
+ var req = http.createClient(common.PORT).request('GET', '/busy/' + num);
req.end();
req.addListener('response', function(res) {
@@ -46,7 +47,7 @@ function add_client(num) {
return req;
}
-server.listen(PORT, function () {
+server.listen(common.PORT, function () {
for (req_num = 0; req_num < 4 ; req_num += 1) {
client_requests.push(add_client(req_num));
}
diff --git a/test/simple/test-http-full-response.js b/test/simple/test-http-full-response.js
index 095ee3d0f..62588adb8 100644
--- a/test/simple/test-http-full-response.js
+++ b/test/simple/test-http-full-response.js
@@ -1,4 +1,5 @@
-require("../common");
+common = require("../common");
+assert = common.assert
// This test requires the program "ab"
http = require("http");
exec = require("child_process").exec;
@@ -19,7 +20,7 @@ server = http.createServer(function (req, res) {
runs = 0;
function runAb(opts, callback) {
- var command = "ab " + opts + " http://127.0.0.1:" + PORT + "/";
+ var command = "ab " + opts + " http://127.0.0.1:" + common.PORT + "/";
exec(command, function (err, stdout, stderr) {
if (err) {
console.log("ab not installed? skipping test.\n" + stderr);
@@ -45,7 +46,7 @@ function runAb(opts, callback) {
});
}
-server.listen(PORT, function () {
+server.listen(common.PORT, function () {
runAb("-c 1 -n 10", function () {
console.log("-c 1 -n 10 okay");
diff --git a/test/simple/test-http-head-request.js b/test/simple/test-http-head-request.js
index befc8a207..2bab5ee55 100644
--- a/test/simple/test-http-head-request.js
+++ b/test/simple/test-http-head-request.js
@@ -1,4 +1,5 @@
-require('../common');
+common = require("../common");
+assert = common.assert
assert = require("assert");
http = require("http");
@@ -8,7 +9,7 @@ sys = require("sys");
body = "hello world\n";
server = http.createServer(function (req, res) {
- error('req: ' + req.method);
+ common.error('req: ' + req.method);
res.writeHead(200, {"Content-Length": body.length});
res.end();
server.close();
@@ -16,14 +17,14 @@ server = http.createServer(function (req, res) {
var gotEnd = false;
-server.listen(PORT, function () {
- var client = http.createClient(PORT);
+server.listen(common.PORT, function () {
+ var client = http.createClient(common.PORT);
var request = client.request("HEAD", "/");
request.end();
request.addListener('response', function (response) {
- error('response start');
+ common.error('response start');
response.addListener("end", function () {
- error('response end');
+ common.error('response end');
gotEnd = true;
});
});
diff --git a/test/simple/test-http-head-response-has-no-body.js b/test/simple/test-http-head-response-has-no-body.js
index 9a46ea69e..987fa50a7 100644
--- a/test/simple/test-http-head-response-has-no-body.js
+++ b/test/simple/test-http-head-response-has-no-body.js
@@ -1,4 +1,5 @@
-require('../common');
+common = require("../common");
+assert = common.assert
var http = require('http');
@@ -10,17 +11,17 @@ var server = http.createServer(function(req, res) {
res.writeHead(200); // broken: defaults to TE chunked
res.end();
});
-server.listen(PORT);
+server.listen(common.PORT);
responseComplete = false;
-var req = http.createClient(PORT).request('HEAD', '/')
-error('req');
+var req = http.createClient(common.PORT).request('HEAD', '/')
+common.error('req');
req.end();
req.addListener('response', function (res) {
- error('response');
+ common.error('response');
res.addListener('end', function() {
- error('response end');
+ common.error('response end');
server.close();
responseComplete = true;
});
diff --git a/test/simple/test-http-malformed-request.js b/test/simple/test-http-malformed-request.js
index 71455270d..aedd6c46b 100644
--- a/test/simple/test-http-malformed-request.js
+++ b/test/simple/test-http-malformed-request.js
@@ -1,4 +1,5 @@
-require("../common");
+common = require("../common");
+assert = common.assert
net = require("net");
http = require("http");
url = require("url");
@@ -18,9 +19,9 @@ var s = http.createServer(function (req, res) {
if (++nrequests_completed == nrequests_expected) s.close();
});
-s.listen(PORT);
+s.listen(common.PORT);
-var c = net.createConnection(PORT);
+var c = net.createConnection(common.PORT);
c.addListener("connect", function () {
c.write("GET /hello?foo=%99bar HTTP/1.1\r\n\r\n");
c.end();
diff --git a/test/simple/test-http-parser.js b/test/simple/test-http-parser.js
index 159aefdbf..6a9614e95 100644
--- a/test/simple/test-http-parser.js
+++ b/test/simple/test-http-parser.js
@@ -1,4 +1,5 @@
-require("../common");
+common = require("../common");
+assert = common.assert
// The purpose of this test is not to check HTTP compliance but to test the
// binding. Tests for pathological http messages should be submitted
diff --git a/test/simple/test-http-proxy.js b/test/simple/test-http-proxy.js
index 05f0c6050..6f355f8d5 100644
--- a/test/simple/test-http-proxy.js
+++ b/test/simple/test-http-proxy.js
@@ -1,12 +1,13 @@
-require("../common");
+common = require("../common");
+assert = common.assert
http = require("http");
url = require("url");
-var PROXY_PORT = PORT;
-var BACKEND_PORT = PORT+1;
+var PROXY_PORT = common.PORT;
+var BACKEND_PORT = common.PORT+1;
var backend = http.createServer(function (req, res) {
- debug("backend request");
+ common.debug("backend request");
res.writeHead(200, {"content-type": "text/plain"});
res.write("hello world\n");
res.end();
@@ -14,7 +15,7 @@ var backend = http.createServer(function (req, res) {
var proxy_client = http.createClient(BACKEND_PORT);
var proxy = http.createServer(function (req, res) {
- debug("proxy req headers: " + JSON.stringify(req.headers));
+ common.debug("proxy req headers: " + JSON.stringify(req.headers));
var proxy_req = proxy_client.request(url.parse(req.url).pathname);
proxy_req.end();
proxy_req.addListener('response', function(proxy_res) {
@@ -24,7 +25,7 @@ var proxy = http.createServer(function (req, res) {
});
proxy_res.addListener("end", function() {
res.end();
- debug("proxy res");
+ common.debug("proxy res");
});
});
});
@@ -38,25 +39,25 @@ function startReq () {
var client = http.createClient(PROXY_PORT);
var req = client.request("/test");
- debug("client req")
+ common.debug("client req")
req.addListener('response', function (res) {
- debug("got res");
+ common.debug("got res");
assert.equal(200, res.statusCode);
res.setBodyEncoding("utf8");
res.addListener('data', function (chunk) { body += chunk; });
res.addListener('end', function () {
proxy.close();
backend.close();
- debug("closed both");
+ common.debug("closed both");
});
});
req.end();
}
-debug("listen proxy")
+common.debug("listen proxy")
proxy.listen(PROXY_PORT, startReq);
-debug("listen backend")
+common.debug("listen backend")
backend.listen(BACKEND_PORT, startReq);
process.addListener("exit", function () {
diff --git a/test/simple/test-http-server-multiheaders.js b/test/simple/test-http-server-multiheaders.js
index 3133c67f8..10fc68a4c 100644
--- a/test/simple/test-http-server-multiheaders.js
+++ b/test/simple/test-http-server-multiheaders.js
@@ -2,7 +2,8 @@
// of the same header as per RFC2616: joining the handful of fields by ', '
// that support it, and dropping duplicates for other fields.
-require('../common');
+common = require("../common");
+assert = common.assert
var http = require('http');
var srv = http.createServer(function(req, res) {
@@ -17,8 +18,8 @@ var srv = http.createServer(function(req, res) {
srv.close();
});
-srv.listen(PORT, function () {
- var hc = http.createClient(PORT, 'localhost');
+srv.listen(common.PORT, function () {
+ var hc = http.createClient(common.PORT, 'localhost');
var hr = hc.request('/',
[
['accept', 'abc'],
diff --git a/test/simple/test-http-server.js b/test/simple/test-http-server.js
index 97480f939..f3da98d58 100644
--- a/test/simple/test-http-server.js
+++ b/test/simple/test-http-server.js
@@ -1,4 +1,5 @@
-require("../common");
+common = require("../common");
+assert = common.assert
net = require("net");
http = require("http");
url = require("url");
@@ -21,21 +22,21 @@ http.createServer(function (req, res) {
}
if (req.id == 1) {
- error("req 1");
+ common.error("req 1");
assert.equal("POST", req.method);
assert.equal("/quit", url.parse(req.url).pathname);
}
if (req.id == 2) {
- error("req 2");
+ common.error("req 2");
assert.equal("foo", req.headers['x-x']);
}
if (req.id == 3) {
- error("req 3");
+ common.error("req 3");
assert.equal("bar", req.headers['x-x']);
this.close();
- error("server closed");
+ common.error("server closed");
}
setTimeout(function () {
@@ -44,9 +45,9 @@ http.createServer(function (req, res) {
res.end();
}, 1);
-}).listen(PORT);
+}).listen(common.PORT);
-var c = net.createConnection(PORT);
+var c = net.createConnection(common.PORT);
c.setEncoding("utf8");
diff --git a/test/simple/test-http-set-timeout.js b/test/simple/test-http-set-timeout.js
index d15044d9b..54abd7dc2 100644
--- a/test/simple/test-http-set-timeout.js
+++ b/test/simple/test-http-set-timeout.js
@@ -1,25 +1,25 @@
-require("../common");
-var sys = require('sys'),
- http = require('http');
+common = require("../common");
+assert = common.assert;
+http = require('http');
server = http.createServer(function (req, res) {
console.log('got request. setting 1 second timeout');
req.connection.setTimeout(500);
req.connection.addListener('timeout', function(){
- sys.debug("TIMEOUT");
+ common.debug("TIMEOUT");
server.close();
});
});
-server.listen(PORT, function () {
- console.log('Server running at http://127.0.0.1:'+PORT+'/');
+server.listen(common.PORT, function () {
+ console.log('Server running at http://127.0.0.1:'+common.PORT+'/');
- errorTimer =setTimeout(function () {
+ errorTimer = setTimeout(function () {
throw new Error('Timeout was not sucessful');
}, 2000);
- http.cat('http://localhost:'+PORT+'/', 'utf8', function (err, content) {
+ http.cat('http://localhost:'+common.PORT+'/', 'utf8', function (err, content) {
clearTimeout(errorTimer);
console.log('HTTP REQUEST COMPLETE (this is good)');
});
diff --git a/test/simple/test-http-tls.js b/test/simple/test-http-tls.js
index 7b5336fea..05dab64d8 100644
--- a/test/simple/test-http-tls.js
+++ b/test/simple/test-http-tls.js
@@ -1,4 +1,5 @@
-require("../common");
+common = require("../common");
+assert = common.assert
net = require("net");
http = require("http");
url = require("url");
@@ -22,9 +23,9 @@ var request_number = 0;
var requests_sent = 0;
var server_response = "";
var client_got_eof = false;
-var caPem = fs.readFileSync(fixturesDir+"/test_ca.pem", 'ascii');
-var certPem = fs.readFileSync(fixturesDir+"/test_cert.pem", 'ascii');
-var keyPem = fs.readFileSync(fixturesDir+"/test_key.pem", 'ascii');
+var caPem = fs.readFileSync(common.fixturesDir+"/test_ca.pem", 'ascii');
+var certPem = fs.readFileSync(common.fixturesDir+"/test_cert.pem", 'ascii');
+var keyPem = fs.readFileSync(common.fixturesDir+"/test_key.pem", 'ascii');
var credentials = crypto.createCredentials({key:keyPem, cert:certPem, ca:caPem});
@@ -71,9 +72,9 @@ var https_server = http.createServer(function (req, res) {
});
https_server.setSecure(credentials);
-https_server.listen(PORT);
+https_server.listen(common.PORT);
-var c = net.createConnection(PORT);
+var c = net.createConnection(common.PORT);
c.setEncoding("utf8");
diff --git a/test/simple/test-http-upgrade-client.js b/test/simple/test-http-upgrade-client.js
index 42babe607..7540b13a0 100644
--- a/test/simple/test-http-upgrade-client.js
+++ b/test/simple/test-http-upgrade-client.js
@@ -2,13 +2,11 @@
// the HTTP client. This test uses a raw TCP server to better control server
// behavior.
-require('../common');
+common = require("../common");
+assert = common.assert
var http = require('http');
var net = require('net');
-var sys = require('sys');
-
-var PORT = 5000 + Math.floor(Math.random() * 1000);
// Parse a string of data, returning an object if headers are complete, and
// undefined otherwise
@@ -55,10 +53,10 @@ var srv = net.createServer(function(c) {
c.end();
});
});
-srv.listen(PORT, '127.0.0.1');
+srv.listen(common.PORT, '127.0.0.1');
var gotUpgrade = false;
-var hc = http.createClient(PORT, '127.0.0.1');
+var hc = http.createClient(common.PORT, '127.0.0.1');
hc.addListener('upgrade', function(req, socket, upgradeHead) {
// XXX: This test isn't fantastic, as it assumes that the entire response
// from the server will arrive in a single data callback
diff --git a/test/simple/test-http-upgrade-server.js b/test/simple/test-http-upgrade-server.js
index a1021e95d..be516b16f 100644
--- a/test/simple/test-http-upgrade-server.js
+++ b/test/simple/test-http-upgrade-server.js
@@ -1,4 +1,5 @@
-require("../common");
+common = require("../common");
+assert = common.assert
var sys = require("sys");
var net = require("net");
@@ -60,7 +61,7 @@ function writeReq(socket, data, encoding){
connection: Upgrade with listener
-----------------------------------------------*/
function test_upgrade_with_listener(_server){
- var conn = net.createConnection(PORT);
+ var conn = net.createConnection(common.PORT);
conn.setEncoding("utf8");
var state = 0;
@@ -103,7 +104,7 @@ function test_upgrade_with_listener(_server){
var test_upgrade_no_listener_ended = false;
function test_upgrade_no_listener(){
- var conn = net.createConnection(PORT);
+ var conn = net.createConnection(common.PORT);
conn.setEncoding("utf8");
conn.addListener("connect", function () {
@@ -124,7 +125,7 @@ function test_upgrade_no_listener(){
connection: normal
-----------------------------------------------*/
function test_standard_http(){
- var conn = net.createConnection(PORT);
+ var conn = net.createConnection(common.PORT);
conn.setEncoding("utf8");
conn.addListener("connect", function () {
@@ -145,7 +146,7 @@ function test_standard_http(){
var server = createTestServer();
-server.listen(PORT, function () {
+server.listen(common.PORT, function () {
// All tests get chained after this:
test_upgrade_with_listener(server);
});
diff --git a/test/simple/test-http-upgrade-server2.js b/test/simple/test-http-upgrade-server2.js
index 3cba0f1c5..7de161ade 100644
--- a/test/simple/test-http-upgrade-server2.js
+++ b/test/simple/test-http-upgrade-server2.js
@@ -1,15 +1,16 @@
-require('../common');
+common = require("../common");
+assert = common.assert
http = require('http');
net = require('net');
server = http.createServer(function (req, res) {
- error('got req');
+ common.error('got req');
throw new Error("This shouldn't happen.");
});
server.addListener('upgrade', function (req, socket, upgradeHead) {
- error('got upgrade event');
+ common.error('got upgrade event');
// test that throwing an error from upgrade gets
// is uncaught
throw new Error('upgrade error');
@@ -18,18 +19,18 @@ server.addListener('upgrade', function (req, socket, upgradeHead) {
gotError = false;
process.addListener('uncaughtException', function (e) {
- error('got "clientError" event');
+ common.error('got "clientError" event');
assert.equal('upgrade error', e.message);
gotError = true;
process.exit(0);
});
-server.listen(PORT, function () {
- var c = net.createConnection(PORT);
+server.listen(common.PORT, function () {
+ var c = net.createConnection(common.PORT);
c.addListener('connect', function () {
- error('client wrote message');
+ common.error('client wrote message');
c.write( "GET /blah HTTP/1.1\r\n"
+ "Upgrade: WebSocket\r\n"
+ "Connection: Upgrade\r\n"
@@ -42,7 +43,7 @@ server.listen(PORT, function () {
});
c.addListener('close', function () {
- error('client close');
+ common.error('client close');
server.close();
});
});
diff --git a/test/simple/test-http-wget.js b/test/simple/test-http-wget.js
index 56372256a..3863a8df1 100644
--- a/test/simple/test-http-wget.js
+++ b/test/simple/test-http-wget.js
@@ -1,4 +1,5 @@
-require("../common");
+common = require("../common");
+assert = common.assert
net = require("net");
http = require("http");
@@ -27,9 +28,9 @@ var server = http.createServer(function (req, res) {
res.write("world\n");
res.end();
})
-server.listen(PORT);
+server.listen(common.PORT);
-var c = net.createConnection(PORT);
+var c = net.createConnection(common.PORT);
c.setEncoding("utf8");
diff --git a/test/simple/test-http-write-empty-string.js b/test/simple/test-http-write-empty-string.js
index 3b430c8b6..afe7f7f03 100644
--- a/test/simple/test-http-write-empty-string.js
+++ b/test/simple/test-http-write-empty-string.js
@@ -1,6 +1,6 @@
-require('../common');
+common = require("../common");
+assert = common.assert
-sys = require('sys');
http = require('http');
assert = require('assert');
@@ -24,8 +24,8 @@ process.addListener('exit', function () {
});
-server.listen(PORT, function () {
- var client = http.createClient(PORT);
+server.listen(common.PORT, function () {
+ var client = http.createClient(common.PORT);
var req = client.request("/");
req.end();
req.addListener('response', function (res) {
@@ -34,7 +34,7 @@ server.listen(PORT, function () {
res.addListener('data', function (chunk) {
response += chunk;
});
- sys.error("Got /hello response");
+ common.error("Got /hello response");
});
});
diff --git a/test/simple/test-http.js b/test/simple/test-http.js
index f424a2d11..5ad1b2c86 100644
--- a/test/simple/test-http.js
+++ b/test/simple/test-http.js
@@ -1,9 +1,10 @@
-require("../common");
+common = require("../common");
+assert = common.assert
http = require("http");
url = require("url");
function p (x) {
- error(inspect(x));
+ common.error(common.inspect(x));
}
var responses_sent = 0;
@@ -38,9 +39,9 @@ http.createServer(function (req, res) {
});
//assert.equal("127.0.0.1", res.connection.remoteAddress);
-}).listen(PORT);
+}).listen(common.PORT);
-var client = http.createClient(PORT);
+var client = http.createClient(common.PORT);
var req = client.request("/hello", {"Accept": "*/*", "Foo": "bar"});
req.end();
req.addListener('response', function (res) {
@@ -48,7 +49,7 @@ req.addListener('response', function (res) {
responses_recvd += 1;
res.setEncoding("utf8");
res.addListener('data', function (chunk) { body0 += chunk; });
- debug("Got /hello response");
+ common.debug("Got /hello response");
});
setTimeout(function () {
@@ -59,15 +60,15 @@ setTimeout(function () {
responses_recvd += 1;
res.setBodyEncoding("utf8");
res.addListener('data', function (chunk) { body1 += chunk; });
- debug("Got /world response");
+ common.debug("Got /world response");
});
}, 1);
process.addListener("exit", function () {
- debug("responses_recvd: " + responses_recvd);
+ common.debug("responses_recvd: " + responses_recvd);
assert.equal(2, responses_recvd);
- debug("responses_sent: " + responses_sent);
+ common.debug("responses_sent: " + responses_sent);
assert.equal(2, responses_sent);
assert.equal("The path was /hello", body0);
diff --git a/test/simple/test-listen-fd.js b/test/simple/test-listen-fd.js
index cc9c4a59d..295747897 100644
--- a/test/simple/test-listen-fd.js
+++ b/test/simple/test-listen-fd.js
@@ -1,14 +1,12 @@
// Verify that net.Server.listenFD() can be used to accept connections on an
// already-bound, already-listening socket.
-require('../common');
+common = require("../common");
+assert = common.assert
http = require('http');
netBinding = process.binding('net');
-// Select a random port for testing
-var PORT = 5000 + Math.floor(Math.random() * 1000);
-
-// Create an server and set it listening on a socket bound to PORT
+// Create an server and set it listening on a socket bound to common.PORT
var gotRequest = false;
var srv = http.createServer(function(req, resp) {
gotRequest = true;
@@ -20,12 +18,12 @@ var srv = http.createServer(function(req, resp) {
});
var fd = netBinding.socket('tcp4');
-netBinding.bind(fd, PORT, '127.0.0.1');
+netBinding.bind(fd, common.PORT, '127.0.0.1');
netBinding.listen(fd, 128);
srv.listenFD(fd);
// Make an HTTP request to the server above
-var hc = http.createClient(PORT, '127.0.0.1');
+var hc = http.createClient(common.PORT, '127.0.0.1');
hc.request('/').end();
// Verify that we're exiting after having received an HTTP request
diff --git a/test/simple/test-memory-usage.js b/test/simple/test-memory-usage.js
index 0d455466d..e4a0ea30d 100644
--- a/test/simple/test-memory-usage.js
+++ b/test/simple/test-memory-usage.js
@@ -1,6 +1,7 @@
-require("../common");
+common = require("../common");
+assert = common.assert
var r = process.memoryUsage();
-console.log(inspect(r));
+console.log(common.inspect(r));
assert.equal(true, r["rss"] > 0);
assert.equal(true, r["vsize"] > 0);
diff --git a/test/simple/test-mkdir-rmdir.js b/test/simple/test-mkdir-rmdir.js
index 1a31bf326..aa469615a 100644
--- a/test/simple/test-mkdir-rmdir.js
+++ b/test/simple/test-mkdir-rmdir.js
@@ -1,4 +1,5 @@
-require("../common");
+common = require("../common");
+assert = common.assert
var path = require('path');
var fs = require('fs');
diff --git a/test/simple/test-module-loading.js b/test/simple/test-module-loading.js
index 78183ce44..e2676f9e1 100644
--- a/test/simple/test-module-loading.js
+++ b/test/simple/test-module-loading.js
@@ -1,7 +1,8 @@
-require("../common");
+common = require("../common");
+assert = common.assert
var path = require('path');
-debug("load test-module-loading.js");
+common.debug("load test-module-loading.js");
var a = require("../fixtures/a");
var c = require("../fixtures/b/c");
@@ -37,18 +38,18 @@ assert.equal("D", d4.D());
assert.ok((new a.SomeClass) instanceof c.SomeClass);
-debug("test index.js modules ids and relative loading")
+common.debug("test index.js modules ids and relative loading")
var one = require("../fixtures/nested-index/one"),
two = require("../fixtures/nested-index/two");
assert.notEqual(one.hello, two.hello);
-debug("test cycles containing a .. path");
+common.debug("test cycles containing a .. path");
var root = require("../fixtures/cycles/root"),
foo = require("../fixtures/cycles/folder/foo");
assert.equal(root.foo, foo);
assert.equal(root.sayHello(), root.hello);
-debug("test name clashes");
+common.debug("test name clashes");
// this one exists and should import the local module
var my_path = require("./path");
assert.equal(true, my_path.path_func instanceof Function);
@@ -80,7 +81,7 @@ require.async('../fixtures/a1', function (err, a) {
asyncRun = true;
});
-debug('load custom file types with registerExtension');
+common.debug('load custom file types with registerExtension');
require.registerExtension('.test', function(content) {
assert.equal("this is custom source\n", content);
@@ -89,7 +90,7 @@ require.registerExtension('.test', function(content) {
assert.equal(require('../fixtures/registerExt').test, "passed");
-debug('load custom file types that return non-strings');
+common.debug('load custom file types that return non-strings');
require.registerExtension('.test', function(content) {
return {
custom: 'passed'
diff --git a/test/simple/test-net-binary.js b/test/simple/test-net-binary.js
index 6db43e232..89d410514 100644
--- a/test/simple/test-net-binary.js
+++ b/test/simple/test-net-binary.js
@@ -1,11 +1,12 @@
-require("../common");
+common = require("../common");
+assert = common.assert
tcp = require("tcp");
binaryString = "";
for (var i = 255; i >= 0; i--) {
var s = "'\\" + i.toString(8) + "'";
S = eval(s);
- error( s
+ common.error( s
+ " "
+ JSON.stringify(S)
+ " "
@@ -21,24 +22,24 @@ for (var i = 255; i >= 0; i--) {
var echoServer = tcp.createServer(function (connection) {
connection.setEncoding("binary");
connection.addListener("data", function (chunk) {
- error("recved: " + JSON.stringify(chunk));
+ common.error("recved: " + JSON.stringify(chunk));
connection.write(chunk, "binary");
});
connection.addListener("end", function () {
connection.end();
});
});
-echoServer.listen(PORT);
+echoServer.listen(common.PORT);
var recv = "";
var j = 0;
-var c = tcp.createConnection(PORT);
+var c = tcp.createConnection(common.PORT);
c.setEncoding("binary");
c.addListener("data", function (chunk) {
if (j < 256) {
- error("write " + j);
+ common.error("write " + j);
c.write(String.fromCharCode(j), "binary");
j++;
} else {
diff --git a/test/simple/test-net-keepalive.js b/test/simple/test-net-keepalive.js
index adf532663..56221ae82 100644
--- a/test/simple/test-net-keepalive.js
+++ b/test/simple/test-net-keepalive.js
@@ -1,4 +1,5 @@
-require("../common");
+common = require("../common");
+assert = common.assert
net = require('net');
var serverConnection;
@@ -12,9 +13,9 @@ var echoServer = net.createServer(function (connection) {
connection.end();
});
});
-echoServer.listen(PORT);
+echoServer.listen(common.PORT);
-var clientConnection = net.createConnection(PORT);
+var clientConnection = net.createConnection(common.PORT);
clientConnection.setTimeout(0);
setTimeout( function() {
diff --git a/test/simple/test-net-pingpong.js b/test/simple/test-net-pingpong.js
index cc8a0c255..f00d65281 100644
--- a/test/simple/test-net-pingpong.js
+++ b/test/simple/test-net-pingpong.js
@@ -1,4 +1,5 @@
-require("../common");
+common = require("../common");
+assert = common.assert
net = require("net");
diff --git a/test/simple/test-net-reconnect.js b/test/simple/test-net-reconnect.js
index b5be64d20..d6027de61 100644
--- a/test/simple/test-net-reconnect.js
+++ b/test/simple/test-net-reconnect.js
@@ -1,4 +1,5 @@
-require("../common");
+common = require("../common");
+assert = common.assert
net = require('net');
var N = 50;
@@ -21,9 +22,9 @@ var server = net.createServer(function (socket) {
});
});
-server.listen(PORT, function () {
+server.listen(common.PORT, function () {
console.log('listening');
- var client = net.createConnection(PORT);
+ var client = net.createConnection(common.PORT);
client.setEncoding("UTF8");
@@ -42,7 +43,7 @@ server.listen(PORT, function () {
console.log("disconnect");
assert.equal(false, had_error);
if (disconnect_count++ < N)
- client.connect(PORT); // reconnect
+ client.connect(common.PORT); // reconnect
else
server.close();
});
diff --git a/test/simple/test-net-tls.js b/test/simple/test-net-tls.js
index 737303878..0f757ca8b 100644
--- a/test/simple/test-net-tls.js
+++ b/test/simple/test-net-tls.js
@@ -1,4 +1,5 @@
-require("../common");
+common = require("../common");
+assert = common.assert
var fs = require('fs');
var sys = require('sys');
var net = require('net');
@@ -13,9 +14,9 @@ try {
process.exit();
}
-var caPem = fs.readFileSync(fixturesDir+"/test_ca.pem", 'ascii');
-var certPem = fs.readFileSync(fixturesDir+"/test_cert.pem", 'ascii');
-var keyPem = fs.readFileSync(fixturesDir+"/test_key.pem", 'ascii');
+var caPem = fs.readFileSync(common.fixturesDir+"/test_ca.pem", 'ascii');
+var certPem = fs.readFileSync(common.fixturesDir+"/test_cert.pem", 'ascii');
+var keyPem = fs.readFileSync(common.fixturesDir+"/test_key.pem", 'ascii');
var credentials = crypto.createCredentials({key:keyPem, cert:certPem, ca:caPem});
@@ -55,9 +56,9 @@ var secureServer = net.createServer(function (connection) {
self.close();
});
});
-secureServer.listen(PORT);
+secureServer.listen(common.PORT);
-var secureClient = net.createConnection(PORT);
+var secureClient = net.createConnection(common.PORT);
secureClient.setEncoding("UTF8");
secureClient.addListener("connect", function () {
diff --git a/test/simple/test-next-tick-ordering.js b/test/simple/test-next-tick-ordering.js
index b08e2276e..b6df02136 100644
--- a/test/simple/test-next-tick-ordering.js
+++ b/test/simple/test-next-tick-ordering.js
@@ -1,4 +1,5 @@
-require('../common');
+common = require("../common");
+assert = common.assert
var sys = require('sys'), i;
var N = 30;
diff --git a/test/simple/test-next-tick.js b/test/simple/test-next-tick.js
index 810ed7082..3965cba2f 100644
--- a/test/simple/test-next-tick.js
+++ b/test/simple/test-next-tick.js
@@ -1,4 +1,5 @@
-require("../common");
+common = require("../common");
+assert = common.assert
var complete = 0;
diff --git a/test/simple/test-path.js b/test/simple/test-path.js
index 4b0537874..a2c07a8d8 100644
--- a/test/simple/test-path.js
+++ b/test/simple/test-path.js
@@ -1,5 +1,6 @@
var path = require("path");
-require("../common");
+common = require("../common");
+assert = common.assert
var f = __filename;
diff --git a/test/simple/test-pipe-head.js b/test/simple/test-pipe-head.js
index 56e414726..3dbef16d9 100644
--- a/test/simple/test-pipe-head.js
+++ b/test/simple/test-pipe-head.js
@@ -1,10 +1,11 @@
-require('../common');
+common = require("../common");
+assert = common.assert
exec = require('child_process').exec;
join = require('path').join;
nodePath = process.argv[0];
-script = join(fixturesDir, 'print-10-lines.js');
+script = join(common.fixturesDir, 'print-10-lines.js');
cmd = nodePath + ' ' + script + ' | head -2';
diff --git a/test/simple/test-pump-file2tcp.js b/test/simple/test-pump-file2tcp.js
index 8dfa0a05a..1db0bd5f6 100644
--- a/test/simple/test-pump-file2tcp.js
+++ b/test/simple/test-pump-file2tcp.js
@@ -1,26 +1,27 @@
-require("../common");
+common = require("../common");
+assert = common.assert
net = require("net");
fs = require("fs");
sys = require("sys");
path = require("path");
-fn = path.join(fixturesDir, 'elipses.txt');
+fn = path.join(common.fixturesDir, 'elipses.txt');
expected = fs.readFileSync(fn, 'utf8');
server = net.createServer(function (stream) {
- error('pump!');
+ common.error('pump!');
sys.pump(fs.createReadStream(fn), stream, function () {
- error('server stream close');
- error('server close');
+ common.error('server stream close');
+ common.error('server close');
server.close();
});
});
-server.listen(PORT, function () {
- conn = net.createConnection(PORT);
+server.listen(common.PORT, function () {
+ conn = net.createConnection(common.PORT);
conn.setEncoding('utf8');
conn.addListener("data", function (chunk) {
- error('recv data! nchars = ' + chunk.length);
+ common.error('recv data! nchars = ' + chunk.length);
buffer += chunk;
});
@@ -28,7 +29,7 @@ server.listen(PORT, function () {
conn.end();
});
conn.addListener("close", function () {
- error('client connection close');
+ common.error('client connection close');
});
});
diff --git a/test/simple/test-querystring.js b/test/simple/test-querystring.js
index f3b33012d..961c1ec35 100644
--- a/test/simple/test-querystring.js
+++ b/test/simple/test-querystring.js
@@ -1,4 +1,5 @@
-require("../common");
+common = require("../common");
+assert = common.assert
// test using assert
diff --git a/test/simple/test-readdir.js b/test/simple/test-readdir.js
index b1881fcf2..8d3f6fd50 100644
--- a/test/simple/test-readdir.js
+++ b/test/simple/test-readdir.js
@@ -1,9 +1,10 @@
-require("../common");
+common = require("../common");
+assert = common.assert
var path = require('path');
var fs = require('fs');
var got_error = false,
- readdirDir = path.join(fixturesDir, "readdir")
+ readdirDir = path.join(common.fixturesDir, "readdir")
var files = ['are'
, 'dir'
diff --git a/test/simple/test-repl.js b/test/simple/test-repl.js
index 6cdcada54..d28908473 100644
--- a/test/simple/test-repl.js
+++ b/test/simple/test-repl.js
@@ -1,4 +1,5 @@
-require("../common");
+common = require("../common");
+assert = common.assert
var sys = require("sys"),
net = require("net"),
@@ -9,7 +10,7 @@ var sys = require("sys"),
prompt_tcp = "node via TCP socket> ",
server_tcp, server_unix, client_tcp, client_unix, timer;
-error('repl test');
+common.error('repl test');
// function for REPL to run
invoke_me = function (arg) {
@@ -20,7 +21,7 @@ function send_expect(list) {
if (list.length > 0) {
var cur = list.shift();
- error("sending " + JSON.stringify(cur.send));
+ common.error("sending " + JSON.stringify(cur.send));
cur.client.expect = cur.expect;
cur.client.list = list;
@@ -42,10 +43,10 @@ function tcp_test() {
repl.start(prompt_tcp, socket);
});
- server_tcp.listen(PORT, function () {
+ server_tcp.listen(common.PORT, function () {
var read_buffer = "";
- client_tcp = net.createConnection(PORT);
+ client_tcp = net.createConnection(common.PORT);
client_tcp.addListener('connect', function () {
assert.equal(true, client_tcp.readable);
@@ -60,7 +61,7 @@ function tcp_test() {
client_tcp.addListener('data', function (data) {
read_buffer += data.asciiSlice(0, data.length);
- error("TCP data: " + JSON.stringify(read_buffer) + ", expecting " + JSON.stringify(client_tcp.expect));
+ common.error("TCP data: " + JSON.stringify(read_buffer) + ", expecting " + JSON.stringify(client_tcp.expect));
if (read_buffer.indexOf(prompt_tcp) !== -1) {
assert.strictEqual(client_tcp.expect, read_buffer);
read_buffer = "";
@@ -68,14 +69,14 @@ function tcp_test() {
send_expect(client_tcp.list);
}
else {
- error("End of TCP test.");
+ common.error("End of TCP test.");
client_tcp.end();
client_unix.end();
clearTimeout(timer);
}
}
else {
- error("didn't see prompt yet, buffering");
+ common.error("didn't see prompt yet, buffering");
}
});
@@ -121,20 +122,20 @@ function unix_test() {
client_unix.addListener('data', function (data) {
read_buffer += data.asciiSlice(0, data.length);
- error("Unix data: " + JSON.stringify(read_buffer) + ", expecting " + JSON.stringify(client_unix.expect));
+ common.error("Unix data: " + JSON.stringify(read_buffer) + ", expecting " + JSON.stringify(client_unix.expect));
if (read_buffer.indexOf(prompt_unix) !== -1) {
assert.strictEqual(client_unix.expect, read_buffer);
- error("match");
+ common.error("match");
read_buffer = "";
if (client_unix.list && client_unix.list.length > 0) {
send_expect(client_unix.list);
} else {
- error("End of Unix test, running TCP test.");
+ common.error("End of Unix test, running TCP test.");
tcp_test();
}
}
else {
- error("didn't see prompt yet, bufering.");
+ common.error("didn't see prompt yet, bufering.");
}
});
diff --git a/test/simple/test-script-context.js b/test/simple/test-script-context.js
index 983006278..343eeabc6 100644
--- a/test/simple/test-script-context.js
+++ b/test/simple/test-script-context.js
@@ -1,19 +1,20 @@
-require("../common");
+common = require("../common");
+assert = common.assert
var Script = process.binding('evals').Script;
var script = new Script('"passed";');
-debug('run in a new empty context');
+common.debug('run in a new empty context');
var context = script.createContext();
var result = script.runInContext(context);
assert.equal('passed', result);
-debug('create a new pre-populated context');
+common.debug('create a new pre-populated context');
context = script.createContext({'foo': 'bar', 'thing': 'lala'});
assert.equal('bar', context.foo);
assert.equal('lala', context.thing);
-debug('test updating context');
+common.debug('test updating context');
script = new Script('foo = 3;');
result = script.runInContext(context);
assert.equal(3, context.foo);
diff --git a/test/simple/test-script-new.js b/test/simple/test-script-new.js
index a2011e688..f622aa503 100644
--- a/test/simple/test-script-new.js
+++ b/test/simple/test-script-new.js
@@ -1,15 +1,16 @@
-require("../common");
+common = require("../common");
+assert = common.assert
var Script = process.binding('evals').Script;
-debug('run a string');
+common.debug('run a string');
var script = new Script('"passed";');
-debug('script created');
+common.debug('script created');
var result1 = script.runInNewContext();
var result2 = script.runInNewContext();
assert.equal('passed', result1);
assert.equal('passed', result2);
-debug('thrown error');
+common.debug('thrown error');
script = new Script('throw new Error("test");');
assert.throws(function() {
script.runInNewContext();
@@ -17,7 +18,7 @@ assert.throws(function() {
-debug('undefined reference');
+common.debug('undefined reference');
var error;
script = new Script('foo.bar = 5;');
try {
@@ -28,7 +29,7 @@ try {
assert.ok(error);
assert.ok(error.message.indexOf('not defined') >= 0);
-debug('error.message: ' + error.message);
+common.debug('error.message: ' + error.message);
hello = 5;
@@ -37,7 +38,7 @@ script.runInNewContext();
assert.equal(5, hello);
-debug("pass values in and out");
+common.debug("pass values in and out");
code = "foo = 1;"
+ "bar = 2;"
+ "if (baz !== 3) throw new Error('test fail');";
@@ -49,19 +50,19 @@ assert.equal(1, obj.foo);
assert.equal(2, obj.bar);
assert.equal(2, foo);
-debug("call a function by reference");
+common.debug("call a function by reference");
script = new Script("f()");
function changeFoo () { foo = 100 }
script.runInNewContext({ f : changeFoo });
assert.equal(foo, 100);
-debug("modify an object by reference");
+common.debug("modify an object by reference");
script = new Script("f.a = 2");
var f = { a : 1 };
script.runInNewContext({ f : f });
assert.equal(f.a, 2);
-debug("invalid this");
+common.debug("invalid this");
assert.throws(function() {
script.runInNewContext.call('"hello";');
});
diff --git a/test/simple/test-script-static-context.js b/test/simple/test-script-static-context.js
index 12f3363d3..90df3c2df 100644
--- a/test/simple/test-script-static-context.js
+++ b/test/simple/test-script-static-context.js
@@ -1,18 +1,19 @@
-require("../common");
+common = require("../common");
+assert = common.assert
var Script = process.binding('evals').Script;
-debug('run in a new empty context');
+common.debug('run in a new empty context');
var context = Script.createContext();
var result = Script.runInContext('"passed";', context);
assert.equal('passed', result);
-debug('create a new pre-populated context');
+common.debug('create a new pre-populated context');
context = Script.createContext({'foo': 'bar', 'thing': 'lala'});
assert.equal('bar', context.foo);
assert.equal('lala', context.thing);
-debug('test updating context');
+common.debug('test updating context');
result = Script.runInContext('var foo = 3;', context);
assert.equal(3, context.foo);
assert.equal('lala', context.thing);
diff --git a/test/simple/test-script-static-new.js b/test/simple/test-script-static-new.js
index b66042138..0046f0479 100644
--- a/test/simple/test-script-static-new.js
+++ b/test/simple/test-script-static-new.js
@@ -1,12 +1,13 @@
-require("../common");
+common = require("../common");
+assert = common.assert
var Script = process.binding('evals').Script;
-debug('run a string');
+common.debug('run a string');
var result = Script.runInNewContext('"passed";');
assert.equal('passed', result);
-debug('thrown error');
+common.debug('thrown error');
assert.throws(function() {
Script.runInNewContext('throw new Error("test");');
});
@@ -16,7 +17,7 @@ Script.runInNewContext('hello = 2');
assert.equal(5, hello);
-debug("pass values in and out");
+common.debug("pass values in and out");
code = "foo = 1;"
+ "bar = 2;"
+ "if (baz !== 3) throw new Error('test fail');";
@@ -27,12 +28,12 @@ assert.equal(1, obj.foo);
assert.equal(2, obj.bar);
assert.equal(2, foo);
-debug("call a function by reference");
+common.debug("call a function by reference");
function changeFoo () { foo = 100 }
Script.runInNewContext("f()", { f : changeFoo });
assert.equal(foo, 100);
-debug("modify an object by reference");
+common.debug("modify an object by reference");
var f = { a : 1 };
Script.runInNewContext("f.a = 2", { f : f });
assert.equal(f.a, 2);
diff --git a/test/simple/test-script-static-this.js b/test/simple/test-script-static-this.js
index c6419a8f3..ed1a631ae 100644
--- a/test/simple/test-script-static-this.js
+++ b/test/simple/test-script-static-this.js
@@ -1,12 +1,13 @@
-require("../common");
+common = require("../common");
+assert = common.assert
var Script = process.binding('evals').Script;
-debug('run a string');
+common.debug('run a string');
var result = Script.runInThisContext('"passed";');
assert.equal('passed', result);
-debug('thrown error');
+common.debug('thrown error');
assert.throws(function() {
Script.runInThisContext('throw new Error("test");');
});
@@ -16,7 +17,7 @@ Script.runInThisContext('hello = 2');
assert.equal(2, hello);
-debug("pass values");
+common.debug("pass values");
code = "foo = 1;"
+ "bar = 2;"
+ "if (typeof baz !== 'undefined') throw new Error('test fail');";
@@ -27,7 +28,7 @@ assert.equal(0, obj.foo);
assert.equal(2, bar);
assert.equal(1, foo);
-debug("call a function");
+common.debug("call a function");
f = function () { foo = 100 };
Script.runInThisContext("f()");
assert.equal(100, foo);
diff --git a/test/simple/test-script-this.js b/test/simple/test-script-this.js
index 41f44b844..0cc8ce931 100644
--- a/test/simple/test-script-this.js
+++ b/test/simple/test-script-this.js
@@ -1,13 +1,14 @@
-require("../common");
+common = require("../common");
+assert = common.assert
var Script = process.binding('evals').Script;
-debug('run a string');
+common.debug('run a string');
var script = new Script('"passed";');
var result = script.runInThisContext(script);
assert.equal('passed', result);
-debug('thrown error');
+common.debug('thrown error');
script = new Script('throw new Error("test");');
assert.throws(function() {
script.runInThisContext(script);
@@ -19,7 +20,7 @@ script.runInThisContext(script);
assert.equal(2, hello);
-debug("pass values");
+common.debug("pass values");
code = "foo = 1;"
+ "bar = 2;"
+ "if (typeof baz !== 'undefined') throw new Error('test fail');";
@@ -31,7 +32,7 @@ assert.equal(0, obj.foo);
assert.equal(2, bar);
assert.equal(1, foo);
-debug("call a function");
+common.debug("call a function");
f = function () { foo = 100 };
script = new Script("f()");
script.runInThisContext(script);
diff --git a/test/simple/test-sendfd.js b/test/simple/test-sendfd.js
index 18eb33146..52dd622fb 100644
--- a/test/simple/test-sendfd.js
+++ b/test/simple/test-sendfd.js
@@ -25,7 +25,8 @@
// seen in a response yet. This is intended to ensure that all blobs
// sent out have been relayed back to us.
-require('../common');
+common = require("../common");
+assert = common.assert
var buffer = require('buffer');
var child_process = require('child_process');
@@ -53,7 +54,7 @@ var logChild = function(d) {
d.split('\n').forEach(function(l) {
if (l.length > 0) {
- sys.debug('CHILD: ' + l);
+ sys.common.debug('CHILD: ' + l);
}
});
};
@@ -108,7 +109,7 @@ srv.listen(SOCK_PATH);
// Spawn a child running test/fixtures/recvfd.js
var cp = child_process.spawn(process.argv[0],
- [path.join(fixturesDir, 'recvfd.js'), SOCK_PATH]);
+ [path.join(common.fixturesDir, 'recvfd.js'), SOCK_PATH]);
cp.stdout.addListener('data', logChild);
cp.stderr.addListener('data', logChild);
diff --git a/test/simple/test-signal-handler.js b/test/simple/test-signal-handler.js
index 50d37c037..8622e7cc9 100644
--- a/test/simple/test-signal-handler.js
+++ b/test/simple/test-signal-handler.js
@@ -1,4 +1,5 @@
-require("../common");
+common = require("../common");
+assert = common.assert
console.log("process.pid: " + process.pid);
diff --git a/test/simple/test-signal-unregister.js b/test/simple/test-signal-unregister.js
index ee4fcf823..2fbf9696d 100644
--- a/test/simple/test-signal-unregister.js
+++ b/test/simple/test-signal-unregister.js
@@ -1,4 +1,5 @@
-require("../common");
+common = require("../common");
+assert = common.assert
var childKilled = false, done = false,
spawn = require('child_process').spawn,
@@ -7,7 +8,7 @@ var childKilled = false, done = false,
var join = require('path').join;
-child = spawn(process.argv[0], [join(fixturesDir, 'should_exit.js')]);
+child = spawn(process.argv[0], [join(common.fixturesDir, 'should_exit.js')]);
child.addListener('exit', function () {
if (!done) childKilled = true;
});
diff --git a/test/simple/test-stdin-from-file.js b/test/simple/test-stdin-from-file.js
index 7e4a4458b..c433bbc85 100644
--- a/test/simple/test-stdin-from-file.js
+++ b/test/simple/test-stdin-from-file.js
@@ -1,11 +1,12 @@
-require('../common');
+common = require("../common");
+assert = common.assert
join = require('path').join;
childProccess = require('child_process');
fs = require('fs');
-stdoutScript = join(fixturesDir, 'echo.js');
-tmpFile = join(fixturesDir, 'stdin.txt');
+stdoutScript = join(common.fixturesDir, 'echo.js');
+tmpFile = join(common.fixturesDir, 'stdin.txt');
cmd = process.argv[0] + ' ' + stdoutScript + ' < ' + tmpFile;
diff --git a/test/simple/test-stdout-to-file.js b/test/simple/test-stdout-to-file.js
index 3df3bfad1..3db8183ec 100644
--- a/test/simple/test-stdout-to-file.js
+++ b/test/simple/test-stdout-to-file.js
@@ -1,10 +1,11 @@
-require('../common');
+common = require("../common");
+assert = common.assert
path = require('path');
childProccess = require('child_process');
fs = require('fs');
-scriptString = path.join(fixturesDir, 'print-chars.js');
-scriptBuffer = path.join(fixturesDir, 'print-chars-from-buffer.js');
-tmpFile = path.join(fixturesDir, 'stdout.txt');
+scriptString = path.join(common.fixturesDir, 'print-chars.js');
+scriptBuffer = path.join(common.fixturesDir, 'print-chars-from-buffer.js');
+tmpFile = path.join(common.fixturesDir, 'stdout.txt');
function test (size, useBuffer, cb) {
var cmd = process.argv[0]
diff --git a/test/simple/test-string-decoder.js b/test/simple/test-string-decoder.js
index 1f61d5c23..d9b689cd8 100644
--- a/test/simple/test-string-decoder.js
+++ b/test/simple/test-string-decoder.js
@@ -1,4 +1,5 @@
-require('../common');
+common = require("../common");
+assert = common.assert
Buffer = require('buffer').Buffer;
StringDecoder = require('string_decoder').StringDecoder;
diff --git a/test/simple/test-sync-fileread.js b/test/simple/test-sync-fileread.js
index 297652c0a..92deb3880 100644
--- a/test/simple/test-sync-fileread.js
+++ b/test/simple/test-sync-fileread.js
@@ -1,4 +1,5 @@
-require('../common');
+common = require("../common");
+assert = common.assert
var path = require('path');
var fs = require('fs');
diff --git a/test/simple/test-sys.js b/test/simple/test-sys.js
index 5d2ccdf9e..9fc6c2051 100644
--- a/test/simple/test-sys.js
+++ b/test/simple/test-sys.js
@@ -1,80 +1,81 @@
-require("../common");
+common = require("../common");
+assert = common.assert
-assert.equal("0", inspect(0));
-assert.equal("1", inspect(1));
-assert.equal("false", inspect(false));
-assert.equal("''", inspect(""));
-assert.equal("'hello'", inspect("hello"));
-assert.equal("[Function]", inspect(function() {}));
-assert.equal('undefined', inspect(undefined));
-assert.equal('null', inspect(null));
-assert.equal('/foo(bar\\n)?/gi', inspect(/foo(bar\n)?/gi));
+assert.equal("0", common.inspect(0));
+assert.equal("1", common.inspect(1));
+assert.equal("false", common.inspect(false));
+assert.equal("''", common.inspect(""));
+assert.equal("'hello'", common.inspect("hello"));
+assert.equal("[Function]", common.inspect(function() {}));
+assert.equal('undefined', common.inspect(undefined));
+assert.equal('null', common.inspect(null));
+assert.equal('/foo(bar\\n)?/gi', common.inspect(/foo(bar\n)?/gi));
assert.equal('Sun, 14 Feb 2010 11:48:40 GMT',
- inspect(new Date("Sun, 14 Feb 2010 11:48:40 GMT")));
+ common.inspect(new Date("Sun, 14 Feb 2010 11:48:40 GMT")));
-assert.equal("'\\n\\u0001'", inspect("\n\u0001"));
+assert.equal("'\\n\\u0001'", common.inspect("\n\u0001"));
-assert.equal('[]', inspect([]));
-assert.equal('[]', inspect(Object.create([])));
-assert.equal('[ 1, 2 ]', inspect([1, 2]));
-assert.equal('[ 1, [ 2, 3 ] ]', inspect([1, [2, 3]]));
+assert.equal('[]', common.inspect([]));
+assert.equal('[]', common.inspect(Object.create([])));
+assert.equal('[ 1, 2 ]', common.inspect([1, 2]));
+assert.equal('[ 1, [ 2, 3 ] ]', common.inspect([1, [2, 3]]));
-assert.equal('{}', inspect({}));
-assert.equal('{ a: 1 }', inspect({a: 1}));
-assert.equal('{ a: [Function] }', inspect({a: function() {}}));
-assert.equal('{ a: 1, b: 2 }', inspect({a: 1, b: 2}));
-assert.equal('{ a: {} }', inspect({'a': {}}));
-assert.equal('{ a: { b: 2 } }', inspect({'a': {'b': 2}}));
-assert.equal('{ a: { b: { c: [Object] } } }', inspect({'a': {'b': { 'c': { 'd': 2 }}}}));
-assert.equal('{ a: { b: { c: { d: 2 } } } }', inspect({'a': {'b': { 'c': { 'd': 2 }}}}, false, null));
-assert.equal('[ 1, 2, 3, [length]: 3 ]', inspect([1,2,3], true));
-assert.equal('{ a: [Object] }', inspect({'a': {'b': { 'c': 2}}},false,0));
-assert.equal('{ a: { b: [Object] } }', inspect({'a': {'b': { 'c': 2}}},false,1));
+assert.equal('{}', common.inspect({}));
+assert.equal('{ a: 1 }', common.inspect({a: 1}));
+assert.equal('{ a: [Function] }', common.inspect({a: function() {}}));
+assert.equal('{ a: 1, b: 2 }', common.inspect({a: 1, b: 2}));
+assert.equal('{ a: {} }', common.inspect({'a': {}}));
+assert.equal('{ a: { b: 2 } }', common.inspect({'a': {'b': 2}}));
+assert.equal('{ a: { b: { c: [Object] } } }', common.inspect({'a': {'b': { 'c': { 'd': 2 }}}}));
+assert.equal('{ a: { b: { c: { d: 2 } } } }', common.inspect({'a': {'b': { 'c': { 'd': 2 }}}}, false, null));
+assert.equal('[ 1, 2, 3, [length]: 3 ]', common.inspect([1,2,3], true));
+assert.equal('{ a: [Object] }', common.inspect({'a': {'b': { 'c': 2}}},false,0));
+assert.equal('{ a: { b: [Object] } }', common.inspect({'a': {'b': { 'c': 2}}},false,1));
assert.equal("{ visible: 1 }",
- inspect(Object.create({}, {visible:{value:1,enumerable:true},hidden:{value:2}}))
+ common.inspect(Object.create({}, {visible:{value:1,enumerable:true},hidden:{value:2}}))
);
assert.equal("{ [hidden]: 2, visible: 1 }",
- inspect(Object.create({}, {visible:{value:1,enumerable:true},hidden:{value:2}}), true)
+ common.inspect(Object.create({}, {visible:{value:1,enumerable:true},hidden:{value:2}}), true)
);
// Objects without prototype
assert.equal(
"{ [hidden]: 'secret', name: 'Tim' }",
- inspect(Object.create(null, {name: {value: "Tim", enumerable: true}, hidden: {value: "secret"}}), true)
+ common.inspect(Object.create(null, {name: {value: "Tim", enumerable: true}, hidden: {value: "secret"}}), true)
);
assert.equal(
"{ name: 'Tim' }",
- inspect(Object.create(null, {name: {value: "Tim", enumerable: true}, hidden: {value: "secret"}}))
+ common.inspect(Object.create(null, {name: {value: "Tim", enumerable: true}, hidden: {value: "secret"}}))
);
// Dynamic properties
assert.equal(
"{ readonly: [Getter] }",
- inspect({get readonly(){}})
+ common.inspect({get readonly(){}})
);
assert.equal(
"{ readwrite: [Getter/Setter] }",
- inspect({get readwrite(){},set readwrite(val){}})
+ common.inspect({get readwrite(){},set readwrite(val){}})
);
assert.equal(
"{ writeonly: [Setter] }",
- inspect({set writeonly(val){}})
+ common.inspect({set writeonly(val){}})
);
var value = {};
value['a'] = value;
-assert.equal('{ a: [Circular] }', inspect(value));
+assert.equal('{ a: [Circular] }', common.inspect(value));
value = Object.create([]);
value.push(1);
-assert.equal("[ 1, length: 1 ]", inspect(value));
+assert.equal("[ 1, length: 1 ]", common.inspect(value));
// Array with dynamic properties
value = [1,2,3];
value.__defineGetter__('growingLength', function () { this.push(true); return this.length; });
assert.equal(
"[ 1, 2, 3, growingLength: [Getter] ]",
- inspect(value)
+ common.inspect(value)
);
// Function with properties
@@ -82,7 +83,7 @@ value = function () {};
value.aprop = 42;
assert.equal(
"{ [Function] aprop: 42 }",
- inspect(value)
+ common.inspect(value)
);
// Regular expressions with properties
@@ -90,7 +91,7 @@ value = /123/ig;
value.aprop = 42;
assert.equal(
"{ /123/gi aprop: 42 }",
- inspect(value)
+ common.inspect(value)
);
// Dates with properties
@@ -98,5 +99,5 @@ value = new Date("Sun, 14 Feb 2010 11:48:40 GMT");
value.aprop = 42;
assert.equal(
"{ Sun, 14 Feb 2010 11:48:40 GMT aprop: 42 }",
- inspect(value)
+ common.inspect(value)
);
diff --git a/test/simple/test-umask.js b/test/simple/test-umask.js
index 3de9565fa..45cb92448 100644
--- a/test/simple/test-umask.js
+++ b/test/simple/test-umask.js
@@ -1,4 +1,5 @@
-require("../common");
+common = require("../common");
+assert = common.assert
var mask = 0664;
var old = process.umask(mask);
diff --git a/test/simple/test-url.js b/test/simple/test-url.js
index f3e13d8fa..f9879e4dc 100644
--- a/test/simple/test-url.js
+++ b/test/simple/test-url.js
@@ -1,4 +1,5 @@
-require("../common");
+common = require("../common");
+assert = common.assert
var url = require("url"),
sys = require("sys");
diff --git a/test/simple/test-utf8-scripts.js b/test/simple/test-utf8-scripts.js
index 6861c7e48..83b389c72 100644
--- a/test/simple/test-utf8-scripts.js
+++ b/test/simple/test-utf8-scripts.js
@@ -1,4 +1,5 @@
-require("../common");
+common = require("../common");
+assert = common.assert
// üäö