diff --git a/test/parallel/test-child-process-default-options.js b/test/parallel/test-child-process-default-options.js index d913ea6c4a55e9..f11a2678f66f5a 100644 --- a/test/parallel/test-child-process-default-options.js +++ b/test/parallel/test-child-process-default-options.js @@ -4,11 +4,9 @@ var assert = require('assert'); var spawn = require('child_process').spawn; -var isWindows = common.isWindows; - process.env.HELLO = 'WORLD'; -if (isWindows) { +if (common.isWindows) { var child = spawn('cmd.exe', ['/c', 'set'], {}); } else { var child = spawn('/usr/bin/env', [], {}); diff --git a/test/parallel/test-child-process-env.js b/test/parallel/test-child-process-env.js index 0e53180309958f..1374c2332c2cc7 100644 --- a/test/parallel/test-child-process-env.js +++ b/test/parallel/test-child-process-env.js @@ -4,8 +4,6 @@ var assert = require('assert'); var spawn = require('child_process').spawn; -var isWindows = common.isWindows; - var env = { 'HELLO': 'WORLD' }; @@ -13,7 +11,7 @@ env.__proto__ = { 'FOO': 'BAR' }; -if (isWindows) { +if (common.isWindows) { var child = spawn('cmd.exe', ['/c', 'set'], {env: env}); } else { var child = spawn('/usr/bin/env', [], {env: env}); diff --git a/test/parallel/test-child-process-kill.js b/test/parallel/test-child-process-kill.js index 0d781b2eefc249..745816bb68766d 100644 --- a/test/parallel/test-child-process-kill.js +++ b/test/parallel/test-child-process-kill.js @@ -4,14 +4,12 @@ var assert = require('assert'); var spawn = require('child_process').spawn; -var is_windows = common.isWindows; - var exitCode; var termSignal; var gotStdoutEOF = false; var gotStderrEOF = false; -var cat = spawn(is_windows ? 'cmd' : 'cat'); +var cat = spawn(common.isWindows ? 'cmd' : 'cat'); cat.stdout.on('end', function() { diff --git a/test/parallel/test-child-process-stdin.js b/test/parallel/test-child-process-stdin.js index 5591f00827ef0d..c12b24579375dc 100644 --- a/test/parallel/test-child-process-stdin.js +++ b/test/parallel/test-child-process-stdin.js @@ -3,9 +3,8 @@ var common = require('../common'); var assert = require('assert'); var spawn = require('child_process').spawn; -var is_windows = common.isWindows; -var cat = spawn(is_windows ? 'more' : 'cat'); +var cat = spawn(common.isWindows ? 'more' : 'cat'); cat.stdin.write('hello'); cat.stdin.write(' '); cat.stdin.write('world'); @@ -51,7 +50,7 @@ cat.on('exit', function(status) { cat.on('close', function() { closed = true; - if (is_windows) { + if (common.isWindows) { assert.equal('hello world\r\n', response); } else { assert.equal('hello world', response); @@ -61,7 +60,7 @@ cat.on('close', function() { process.on('exit', function() { assert.equal(0, exitStatus); assert(closed); - if (is_windows) { + if (common.isWindows) { assert.equal('hello world\r\n', response); } else { assert.equal('hello world', response); diff --git a/test/parallel/test-fs-chmod.js b/test/parallel/test-fs-chmod.js index 399943112352d2..11c8bb6168916e 100644 --- a/test/parallel/test-fs-chmod.js +++ b/test/parallel/test-fs-chmod.js @@ -7,7 +7,6 @@ var got_error = false; var success_count = 0; var mode_async; var mode_sync; -var is_windows = common.isWindows; // Need to hijack fs.open/close to make sure that things // get closed once they're opened. @@ -44,7 +43,7 @@ function closeSync() { // On Windows chmod is only able to manipulate read-only bit -if (is_windows) { +if (common.isWindows) { mode_async = 0o400; // read-only mode_sync = 0o600; // read-write } else { @@ -61,14 +60,14 @@ fs.chmod(file1, mode_async.toString(8), function(err) { } else { console.log(fs.statSync(file1).mode); - if (is_windows) { + if (common.isWindows) { assert.ok((fs.statSync(file1).mode & 0o777) & mode_async); } else { assert.equal(mode_async, fs.statSync(file1).mode & 0o777); } fs.chmodSync(file1, mode_sync); - if (is_windows) { + if (common.isWindows) { assert.ok((fs.statSync(file1).mode & 0o777) & mode_sync); } else { assert.equal(mode_sync, fs.statSync(file1).mode & 0o777); @@ -89,14 +88,14 @@ fs.open(file2, 'a', function(err, fd) { } else { console.log(fs.fstatSync(fd).mode); - if (is_windows) { + if (common.isWindows) { assert.ok((fs.fstatSync(fd).mode & 0o777) & mode_async); } else { assert.equal(mode_async, fs.fstatSync(fd).mode & 0o777); } fs.fchmodSync(fd, mode_sync); - if (is_windows) { + if (common.isWindows) { assert.ok((fs.fstatSync(fd).mode & 0o777) & mode_sync); } else { assert.equal(mode_sync, fs.fstatSync(fd).mode & 0o777); diff --git a/test/parallel/test-fs-realpath.js b/test/parallel/test-fs-realpath.js index 22cd538915902a..9082e1d65f4d0e 100644 --- a/test/parallel/test-fs-realpath.js +++ b/test/parallel/test-fs-realpath.js @@ -5,13 +5,12 @@ var fs = require('fs'); var path = require('path'); var exec = require('child_process').exec; var async_completed = 0, async_expected = 0, unlink = []; -var isWindows = common.isWindows; var skipSymlinks = false; common.refreshTmpDir(); var root = '/'; -if (isWindows) { +if (common.isWindows) { // something like "C:\\" root = process.cwd().substr(0, 3); @@ -292,7 +291,7 @@ function test_relative_input_cwd(callback) { function test_deep_symlink_mix(callback) { console.log('test_deep_symlink_mix'); - if (isWindows) { + if (common.isWindows) { // This one is a mix of files and directories, and it's quite tricky // to get the file/dir links sorted out correctly. console.log('1..0 # Skipped: symlink test (no privs)'); @@ -503,7 +502,7 @@ function test_lying_cache_liar(cb) { '/a/b' : '/a/b', '/a/b/c' : '/a/b', '/a/b/d' : '/a/b/d' }; - if (isWindows) { + if (common.isWindows) { var wc = {}; Object.keys(cache).forEach(function(k) { wc[ path.resolve(k) ] = path.resolve(cache[k]); diff --git a/test/parallel/test-fs-symlink.js b/test/parallel/test-fs-symlink.js index 78eca54c4dc213..199add4a1ba724 100644 --- a/test/parallel/test-fs-symlink.js +++ b/test/parallel/test-fs-symlink.js @@ -9,8 +9,6 @@ var expected_async = 4; var linkTime; var fileTime; -var is_windows = common.isWindows; - common.refreshTmpDir(); var runtest = function(skip_symlinks) { @@ -57,7 +55,7 @@ var runtest = function(skip_symlinks) { }); }; -if (is_windows) { +if (common.isWindows) { // On Windows, creating symlinks requires admin privileges. // We'll only try to run symlink test if we have enough privileges. exec('whoami /priv', function(err, o) { diff --git a/test/parallel/test-fs-utimes.js b/test/parallel/test-fs-utimes.js index 71abc3ef9baa35..292636b1b69108 100644 --- a/test/parallel/test-fs-utimes.js +++ b/test/parallel/test-fs-utimes.js @@ -4,8 +4,6 @@ var assert = require('assert'); var util = require('util'); var fs = require('fs'); -var is_windows = common.isWindows; - var tests_ok = 0; var tests_run = 0; @@ -99,7 +97,7 @@ function runTest(atime, mtime, callback) { expect_errno('utimes', 'foobarbaz', err, 'ENOENT'); // don't close this fd - if (is_windows) { + if (common.isWindows) { fd = fs.openSync(__filename, 'r+'); } else { fd = fs.openSync(__filename, 'r'); diff --git a/test/parallel/test-fs-write-file-sync.js b/test/parallel/test-fs-write-file-sync.js index 841bad4839d497..37373404daf20e 100644 --- a/test/parallel/test-fs-write-file-sync.js +++ b/test/parallel/test-fs-write-file-sync.js @@ -3,7 +3,6 @@ var common = require('../common'); var assert = require('assert'); var path = require('path'); var fs = require('fs'); -var isWindows = common.isWindows; var openCount = 0; var mode; var content; @@ -20,7 +19,7 @@ var mask = process.umask(0o000); // On Windows chmod is only able to manipulate read-only bit. Test if creating // the file in read-only mode works. -if (isWindows) { +if (common.isWindows) { mode = 0o444; } else { mode = 0o755; diff --git a/test/parallel/test-module-globalpaths-nodepath.js b/test/parallel/test-module-globalpaths-nodepath.js index 5beb633bb793d8..3369df0676015b 100644 --- a/test/parallel/test-module-globalpaths-nodepath.js +++ b/test/parallel/test-module-globalpaths-nodepath.js @@ -4,12 +4,10 @@ var assert = require('assert'); var module = require('module'); -var isWindows = common.isWindows; - var partA, partB; var partC = ''; -if (isWindows) { +if (common.isWindows) { partA = 'C:\\Users\\Rocko Artischocko\\AppData\\Roaming\\npm'; partB = 'C:\\Program Files (x86)\\nodejs\\'; process.env['NODE_PATH'] = partA + ';' + partB + ';' + partC; diff --git a/test/parallel/test-module-nodemodulepaths.js b/test/parallel/test-module-nodemodulepaths.js index 1a520ac5822f3b..0c70de9f285c3c 100644 --- a/test/parallel/test-module-nodemodulepaths.js +++ b/test/parallel/test-module-nodemodulepaths.js @@ -4,11 +4,9 @@ var assert = require('assert'); var module = require('module'); -var isWindows = common.isWindows; - var file, delimiter, paths; -if (isWindows) { +if (common.isWindows) { file = 'C:\\Users\\Rocko Artischocko\\node_stuff\\foo'; delimiter = '\\'; } else { diff --git a/test/parallel/test-path.js b/test/parallel/test-path.js index 10776b93c85948..c13b8d4efd1540 100644 --- a/test/parallel/test-path.js +++ b/test/parallel/test-path.js @@ -4,8 +4,6 @@ var assert = require('assert'); var path = require('path'); -var isWindows = common.isWindows; - var f = __filename; assert.equal(path.basename(f), 'test-path.js'); @@ -33,7 +31,7 @@ assert.equal(path.posix.basename('basename.ext\\\\'), 'basename.ext\\\\'); // POSIX filenames may include control characters // c.f. http://www.dwheeler.com/essays/fixing-unix-linux-filenames.html -if (!isWindows) { +if (!common.isWindows) { var controlCharFilename = 'Icon' + String.fromCharCode(13); assert.equal(path.basename('/a/b/' + controlCharFilename), controlCharFilename); @@ -42,7 +40,7 @@ if (!isWindows) { assert.equal(path.extname(f), '.js'); assert.equal(path.dirname(f).substr(-13), - isWindows ? 'test\\parallel' : 'test/parallel'); + common.isWindows ? 'test\\parallel' : 'test/parallel'); assert.equal(path.dirname('/a/b/'), '/a'); assert.equal(path.dirname('/a/b'), '/a'); assert.equal(path.dirname('/a'), '/'); @@ -194,7 +192,7 @@ var joinTests = ]; // Windows-specific join tests -if (isWindows) { +if (common.isWindows) { joinTests = joinTests.concat( [// UNC path expected [['//foo/bar'], '//foo/bar/'], @@ -246,7 +244,7 @@ if (isWindows) { // Run the join tests. joinTests.forEach(function(test) { var actual = path.join.apply(path, test[0]); - var expected = isWindows ? test[1].replace(/\//g, '\\') : test[1]; + var expected = common.isWindows ? test[1].replace(/\//g, '\\') : test[1]; var message = 'path.join(' + test[0].map(JSON.stringify).join(',') + ')' + '\n expect=' + JSON.stringify(expected) + '\n actual=' + JSON.stringify(actual); @@ -306,7 +304,7 @@ assert.equal(path.posix.normalize('a//b//./c'), 'a/b/c'); assert.equal(path.posix.normalize('a//b//.'), 'a/b'); // path.resolve tests -if (isWindows) { +if (common.isWindows) { // windows var resolveTests = // arguments result @@ -360,7 +358,7 @@ assert.equal(path.posix.isAbsolute('bar/'), false); assert.equal(path.posix.isAbsolute('./baz'), false); // path.relative tests -if (isWindows) { +if (common.isWindows) { // windows var relativeTests = // arguments result @@ -409,7 +407,7 @@ assert.equal(path.win32.delimiter, ';'); assert.equal(path.posix.delimiter, ':'); -if (isWindows) +if (common.isWindows) assert.deepEqual(path, path.win32, 'should be win32 path module'); else assert.deepEqual(path, path.posix, 'should be posix path module'); diff --git a/test/pummel/test-child-process-spawn-loop.js b/test/pummel/test-child-process-spawn-loop.js index 3254bec134fb9d..7e686cada244b3 100644 --- a/test/pummel/test-child-process-spawn-loop.js +++ b/test/pummel/test-child-process-spawn-loop.js @@ -4,8 +4,6 @@ var assert = require('assert'); var spawn = require('child_process').spawn; -var is_windows = common.isWindows; - var SIZE = 1000 * 1024; var N = 40; var finished = false; @@ -25,7 +23,7 @@ function doSpawn(i) { child.on('close', function() { // + 1 for \n or + 2 for \r\n on Windows - assert.equal(SIZE + (is_windows ? 2 : 1), count); + assert.equal(SIZE + (common.isWindows ? 2 : 1), count); if (i < N) { doSpawn(i + 1); } else {