Skip to content
This repository has been archived by the owner on Apr 22, 2023. It is now read-only.

Commit

Permalink
Remove fs/path globals from test suite
Browse files Browse the repository at this point in the history
It is way too easy to not notice bugs due to those modules being
exported as globals while running the test suite.

See: http://github.com/ry/node/issues#issue/75
  • Loading branch information
felixge authored and ry committed Mar 8, 2010
1 parent e898c1f commit 44dde5f
Show file tree
Hide file tree
Showing 19 changed files with 32 additions and 15 deletions.
4 changes: 1 addition & 3 deletions test/common.js
Expand Up @@ -11,6 +11,4 @@ var assert = require('assert');
var sys = require("sys");

process.mixin(exports, sys);
exports.assert = require('assert');
exports.fs = require("fs");
exports.path = path;
exports.assert = require('assert');
8 changes: 3 additions & 5 deletions test/simple/test-chdir.js
@@ -1,9 +1,7 @@
process.mixin(require("../common"));

var dirname = path.dirname(__filename);
assert.equal(true, process.cwd() !== __dirname);

assert.equal(true, process.cwd() !== dirname);
process.chdir(__dirname);

process.chdir(dirname);

assert.equal(true, process.cwd() === dirname);
assert.equal(true, process.cwd() === __dirname);
1 change: 1 addition & 0 deletions test/simple/test-eio-race2.js
@@ -1,4 +1,5 @@
process.mixin(require("../common"));
var path = require('path');
var testTxt = path.join(fixturesDir, "x.txt");
var fs = require('fs');

Expand Down
2 changes: 1 addition & 1 deletion test/simple/test-eio-race4.js
@@ -1,5 +1,5 @@
process.mixin(require("../common"));

var fs = require('fs');
var N = 100;
var j = 0;

Expand Down
2 changes: 2 additions & 0 deletions test/simple/test-file-read-noexist.js
@@ -1,4 +1,6 @@
process.mixin(require("../common"));
var path = require('path');
var fs = require('fs');
var got_error = false;

var filename = path.join(fixturesDir, "does_not_exist.txt");
Expand Down
2 changes: 2 additions & 0 deletions test/simple/test-file-read-stream.js
@@ -1,6 +1,8 @@
process.mixin(require('../common'));

var
path = require('path'),
fs = require('fs'),
fn = path.join(fixturesDir, 'multipart.js'),
file = fs.createReadStream(fn),

Expand Down
2 changes: 2 additions & 0 deletions test/simple/test-file-write-stream.js
@@ -1,6 +1,8 @@
process.mixin(require('../common'));

var
path = require('path'),
fs = require('fs'),
fn = path.join(fixturesDir, "write.txt"),
file = fs.createWriteStream(fn),

Expand Down
3 changes: 2 additions & 1 deletion test/simple/test-fs-chmod.js
@@ -1,5 +1,6 @@
process.mixin(require("../common"));

var path = require('path');
var fs = require('fs');
var got_error = false;
var success_count = 0;

Expand Down
3 changes: 2 additions & 1 deletion test/simple/test-fs-realpath.js
@@ -1,5 +1,6 @@
process.mixin(require("../common"));

var fs = require('fs');
var path = require('path');
var async_completed = 0, async_expected = 0, unlink = [];

function asynctest(testBlock, args, callback, assertBlock) {
Expand Down
2 changes: 1 addition & 1 deletion test/simple/test-fs-stat.js
@@ -1,5 +1,5 @@
process.mixin(require("../common"));

var fs = require('fs');
var got_error = false;
var success_count = 0;

Expand Down
3 changes: 2 additions & 1 deletion test/simple/test-fs-symlink.js
@@ -1,5 +1,6 @@
process.mixin(require("../common"));

var path = require('path');
var fs = require('fs');
var completed = 0;

// test creating and reading symbolic link
Expand Down
3 changes: 2 additions & 1 deletion test/simple/test-fs-write.js
@@ -1,5 +1,6 @@
process.mixin(require("../common"));

var path = require('path');
var fs = require('fs');
var fn = path.join(fixturesDir, "write.txt");
var expected = "hello";
var found;
Expand Down
3 changes: 2 additions & 1 deletion test/simple/test-ini.js
@@ -1,5 +1,6 @@
process.mixin(require("../common"));
require("fs");
var path = require('path');
var fs = require("fs");
parse = require("ini").parse;

debug("load fixtures/fixture.ini");
Expand Down
2 changes: 2 additions & 0 deletions test/simple/test-mkdir-rmdir.js
@@ -1,4 +1,6 @@
process.mixin(require("../common"));
var path = require('path');
var fs = require('fs');

var dirname = path.dirname(__filename);
var fixtures = path.join(dirname, "../fixtures");
Expand Down
1 change: 1 addition & 0 deletions test/simple/test-module-loading.js
@@ -1,4 +1,5 @@
process.mixin(require("../common"));
var path = require('path');

debug("load test-module-loading.js");

Expand Down
2 changes: 2 additions & 0 deletions test/simple/test-readdir.js
@@ -1,4 +1,6 @@
process.mixin(require("../common"));
var path = require('path');
var fs = require('fs');

var got_error = false,
readdirDir = path.join(fixturesDir, "readdir")
Expand Down
1 change: 1 addition & 0 deletions test/simple/test-stdio.js
@@ -1,4 +1,5 @@
process.mixin(require("../common"));
var path = require('path');

var sub = path.join(fixturesDir, 'echo.js');

Expand Down
1 change: 1 addition & 0 deletions test/simple/test-stdout-flush.js
@@ -1,4 +1,5 @@
process.mixin(require("../common"));
var path = require('path');

var sub = path.join(fixturesDir, 'print-chars.js');

Expand Down
2 changes: 2 additions & 0 deletions test/simple/test-sync-fileread.js
@@ -1,4 +1,6 @@
process.mixin(require('../common'));
var path = require('path');
var fs = require('fs');

var fixture = path.join(__dirname, "../fixtures/x.txt");

Expand Down

0 comments on commit 44dde5f

Please sign in to comment.