test: use common.isWindows consistently

In the tests, we use "process.platform === 'win32'" in some places.
This patch replaces them with the "common.isWindows" for consistency.

PR-URL: https://github.com/nodejs/io.js/pull/2269
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl>
Reviewed-By: Jeremiah Senkpiel <fishrock123@rocketmail.com>
This commit is contained in:
Sakthipriyan Vairamani 2015-07-29 17:18:04 +05:30
parent fa98b97171
commit d5ab92bcc1
66 changed files with 114 additions and 132 deletions

View File

@ -119,7 +119,7 @@ Object.defineProperty(exports, 'opensslCli', {get: function() {
opensslCli = path.join(path.dirname(process.execPath), 'openssl-cli');
}
if (process.platform === 'win32') opensslCli += '.exe';
if (exports.isWindows) opensslCli += '.exe';
var openssl_cmd = child_process.spawnSync(opensslCli, ['version']);
if (openssl_cmd.status !== 0 || openssl_cmd.error !== undefined) {
@ -133,7 +133,7 @@ Object.defineProperty(exports, 'hasCrypto', {get: function() {
return process.versions.openssl ? true : false;
}});
if (process.platform === 'win32') {
if (exports.isWindows) {
exports.PIPE = '\\\\.\\pipe\\libuv-test';
} else {
exports.PIPE = exports.tmpDir + '/test.sock';
@ -150,7 +150,7 @@ if (process.env.NODE_COMMON_PIPE) {
}
}
if (process.platform === 'win32') {
if (exports.isWindows) {
exports.faketimeCli = false;
} else {
exports.faketimeCli = path.join(__dirname, '..', 'tools', 'faketime', 'src',
@ -183,7 +183,7 @@ exports.indirectInstanceOf = function(obj, cls) {
exports.ddCommand = function(filename, kilobytes) {
if (process.platform === 'win32') {
if (exports.isWindows) {
var p = path.resolve(exports.fixturesDir, 'create-file.js');
return '"' + process.argv[0] + '" "' + p + '" "' +
filename + '" ' + (kilobytes * 1024);
@ -196,7 +196,7 @@ exports.ddCommand = function(filename, kilobytes) {
exports.spawnCat = function(options) {
var spawn = require('child_process').spawn;
if (process.platform === 'win32') {
if (exports.isWindows) {
return spawn('more', [], options);
} else {
return spawn('cat', [], options);
@ -207,7 +207,7 @@ exports.spawnCat = function(options) {
exports.spawnSyncCat = function(options) {
var spawnSync = require('child_process').spawnSync;
if (process.platform === 'win32') {
if (exports.isWindows) {
return spawnSync('more', [], options);
} else {
return spawnSync('cat', [], options);
@ -218,7 +218,7 @@ exports.spawnSyncCat = function(options) {
exports.spawnPwd = function(options) {
var spawn = require('child_process').spawn;
if (process.platform === 'win32') {
if (exports.isWindows) {
return spawn('cmd.exe', ['/c', 'cd'], options);
} else {
return spawn('pwd', [], options);
@ -374,7 +374,7 @@ exports.checkSpawnSyncRet = function(ret) {
};
var etcServicesFileName = path.join('/etc', 'services');
if (process.platform === 'win32') {
if (exports.isWindows) {
etcServicesFileName = path.join(process.env.SystemRoot, 'System32', 'drivers',
'etc', 'services');
}

View File

@ -30,7 +30,7 @@ assert.throws(function() {
// Windows doesn't usually have an entry for localhost 127.0.0.1 in
// C:\Windows\System32\drivers\etc\hosts
// so we disable this test on Windows.
if (process.platform != 'win32') {
if (!common.isWindows) {
dns.resolve('127.0.0.1', 'PTR', function(error, domains) {
if (error) throw error;
assert.ok(Array.isArray(domains));

View File

@ -38,7 +38,7 @@ function testCwd(options, forCode, forData) {
}
// Assume these exist, and 'pwd' gives us the right directory back
if (process.platform == 'win32') {
if (common.isWindows) {
testCwd({cwd: process.env.windir}, 0, process.env.windir);
testCwd({cwd: 'c:\\'}, 0, 'c:\\');
} else {

View File

@ -4,11 +4,9 @@ var assert = require('assert');
var spawn = require('child_process').spawn;
var isWindows = process.platform === 'win32';
process.env.HELLO = 'WORLD';
if (isWindows) {
if (common.isWindows) {
var child = spawn('cmd.exe', ['/c', 'set'], {});
} else {
var child = spawn('/usr/bin/env', [], {});

View File

@ -1,6 +1,4 @@
'use strict';
var is_windows = process.platform === 'win32';
var common = require('../common');
var assert = require('assert'),
os = require('os'),
@ -12,7 +10,7 @@ var assert = require('assert'),
var grep, sed, echo;
if (is_windows) {
if (common.isWindows) {
grep = spawn('grep', ['--binary', 'o']),
sed = spawn('sed', ['--binary', 's/o/O/']),
echo = spawn('cmd.exe',

View File

@ -4,8 +4,6 @@ var assert = require('assert');
var spawn = require('child_process').spawn;
var isWindows = process.platform === 'win32';
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});

View File

@ -1,5 +1,5 @@
'use strict';
require('../common');
const common = require('../common');
var assert = require('assert');
var exec = require('child_process').exec;
@ -8,7 +8,7 @@ var error_count = 0;
var pwdcommand, dir;
if (process.platform == 'win32') {
if (common.isWindows) {
pwdcommand = 'echo %cd%';
dir = 'c:\\windows';
} else {

View File

@ -20,7 +20,7 @@ function after(err, stdout, stderr) {
}
}
if (process.platform !== 'win32') {
if (!common.isWindows) {
child = exec('/usr/bin/env', { env: { 'HELLO': 'WORLD' } }, after);
} else {
child = exec('set', { env: { 'HELLO': 'WORLD' } }, after);

View File

@ -17,7 +17,7 @@ function test(fun, code) {
});
}
if (process.platform === 'win32') {
if (common.isWindows) {
test(child_process.exec, 1); // exit code of cmd.exe
} else {
test(child_process.exec, 127); // exit code of /bin/sh

View File

@ -18,7 +18,7 @@ var fork = require('child_process').fork;
var assert = require('assert');
var common = require('../common');
if (process.platform === 'win32') {
if (common.isWindows) {
console.error('Sending dgram sockets to child processes not supported');
process.exit(0);
}

View File

@ -4,14 +4,12 @@ var assert = require('assert');
var spawn = require('child_process').spawn;
var is_windows = process.platform === 'win32';
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() {

View File

@ -2,7 +2,7 @@
var assert = require('assert');
var child_process = require('child_process');
var spawn = child_process.spawn;
var cmd = (process.platform === 'win32') ? 'rundll32' : 'ls';
var cmd = require('../common').isWindows ? 'rundll32' : 'ls';
var invalidArgsMsg = /Incorrect value of args option/;
var invalidOptionsMsg = /options argument must be an object/;

View File

@ -38,7 +38,7 @@ assert.deepEqual(ret_err.spawnargs, ['bar']);
var response;
var cwd;
if (process.platform === 'win32') {
if (common.isWindows) {
cwd = 'c:\\';
response = spawnSync('cmd.exe', ['/c', 'cd'], {cwd: cwd});
} else {

View File

@ -3,9 +3,8 @@ var common = require('../common');
var assert = require('assert');
var spawn = require('child_process').spawn;
var is_windows = process.platform === 'win32';
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);

View File

@ -4,7 +4,7 @@ var assert = require('assert');
var cluster = require('cluster');
var net = require('net');
if (process.platform === 'win32') {
if (common.isWindows) {
console.log('1..0 # Skipped: not reliable on Windows.');
return;
}

View File

@ -8,7 +8,7 @@ var common = require('../common');
var dgram = require('dgram');
if (process.platform === 'win32') {
if (common.isWindows) {
console.warn('dgram clustering is currently not supported on windows.');
process.exit(0);
}

View File

@ -8,7 +8,7 @@ var common = require('../common');
var dgram = require('dgram');
if (process.platform === 'win32') {
if (common.isWindows) {
console.warn('dgram clustering is currently not supported on windows.');
process.exit(0);
}

View File

@ -1,5 +1,8 @@
'use strict';
if (process.platform === 'win32') {
const common = require('../common');
if (common.isWindows) {
console.log('1..0 # Skipped: on windows, because clustered dgram is ENOTSUP');
return;
}

View File

@ -1,14 +1,15 @@
'use strict';
const common = require('../common');
const assert = require('assert');
const cluster = require('cluster');
const http = require('http');
// It is not possible to send pipe handles over the IPC pipe on Windows.
if (process.platform === 'win32') {
if (common.isWindows) {
process.exit(0);
}
var common = require('../common');
var assert = require('assert');
var cluster = require('cluster');
var http = require('http');
if (cluster.isMaster) {
common.refreshTmpDir();
var ok = false;

View File

@ -4,7 +4,7 @@ var assert = require('assert');
var cluster = require('cluster');
var net = require('net');
if (process.platform === 'win32') {
if (common.isWindows) {
console.log('1..0 # Skipped: not reliable on Windows');
return;
}

View File

@ -5,7 +5,7 @@ var fs = require('fs');
var spawn = require('child_process').spawn;
// Fails with EINVAL on SmartOS, EBUSY on Windows.
if (process.platform === 'sunos' || process.platform === 'win32') {
if (process.platform === 'sunos' || common.isWindows) {
console.log('1..0 # Skipped: cannot rmdir current working directory');
return;
}

View File

@ -5,7 +5,7 @@ var fs = require('fs');
var spawn = require('child_process').spawn;
// Fails with EINVAL on SmartOS, EBUSY on Windows.
if (process.platform === 'sunos' || process.platform === 'win32') {
if (process.platform === 'sunos' || common.isWindows) {
console.log('1..0 # Skipped: cannot rmdir current working directory');
return;
}

View File

@ -39,8 +39,6 @@ var dgram = require('dgram');
// supported while using cluster, though servers still cause the master to error
// with ENOTSUP.
var windows = process.platform === 'win32';
if (cluster.isMaster) {
var pass;
var messages = 0;
@ -56,12 +54,12 @@ if (cluster.isMaster) {
messages++;
ports[rinfo.port] = true;
if (windows && messages === 2) {
if (common.isWindows && messages === 2) {
assert.equal(Object.keys(ports).length, 2);
done();
}
if (!windows && messages === 4) {
if (!common.isWindows && messages === 4) {
assert.equal(Object.keys(ports).length, 3);
done();
}
@ -76,7 +74,7 @@ if (cluster.isMaster) {
target.on('listening', function() {
cluster.fork();
cluster.fork();
if (!windows) {
if (!common.isWindows) {
cluster.fork({BOUND: 'y'});
cluster.fork({BOUND: 'y'});
}

View File

@ -49,7 +49,7 @@ createFileWithPerms(readWriteFile, 0o666);
* continuous integration platform to take care of that.
*/
var hasWriteAccessForReadonlyFile = false;
if (process.platform !== 'win32' && process.getuid() === 0) {
if (!common.isWindows && process.getuid() === 0) {
hasWriteAccessForReadonlyFile = true;
try {
process.setuid('nobody');

View File

@ -62,7 +62,7 @@ var m = 0o600;
fs.appendFileSync(filename4, num, { mode: m });
// windows permissions aren't unix
if (process.platform !== 'win32') {
if (!common.isWindows) {
var st = fs.statSync(filename4);
assert.equal(st.mode & 0o700, m);
}

View File

@ -91,7 +91,7 @@ fs.appendFile(filename4, n, { mode: m }, function(e) {
common.error('appended to file4');
// windows permissions aren't unix
if (process.platform !== 'win32') {
if (!common.isWindows) {
var st = fs.statSync(filename4);
assert.equal(st.mode & 0o700, m);
}

View File

@ -7,7 +7,6 @@ var got_error = false;
var success_count = 0;
var mode_async;
var mode_sync;
var is_windows = process.platform === 'win32';
// 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);

View File

@ -5,7 +5,7 @@ var path = require('path');
// simulate `cat readfile.js | node readfile.js`
if (process.platform === 'win32') {
if (common.isWindows) {
console.log('1..0 # Skipped: No /dev/stdin on windows.');
return;
}

View File

@ -4,7 +4,7 @@ var assert = require('assert');
// simulate `cat readfile.js | node readfile.js`
if (process.platform === 'win32') {
if (common.isWindows) {
console.log('1..0 # Skipped: No /dev/stdin on windows.');
return;
}

View File

@ -5,7 +5,7 @@ var path = require('path');
// simulate `cat readfile.js | node readfile.js`
if (process.platform === 'win32') {
if (common.isWindows) {
console.log('1..0 # Skipped: No /dev/stdin on windows.');
return;
}

View File

@ -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 = process.platform === 'win32';
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]);

View File

@ -9,8 +9,6 @@ var expected_async = 4;
var linkTime;
var fileTime;
var is_windows = process.platform === 'win32';
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) {

View File

@ -4,8 +4,6 @@ var assert = require('assert');
var util = require('util');
var fs = require('fs');
var is_windows = process.platform === 'win32';
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');

View File

@ -3,7 +3,6 @@ var common = require('../common');
var assert = require('assert');
var path = require('path');
var fs = require('fs');
var isWindows = process.platform === 'win32';
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;

View File

@ -63,7 +63,7 @@ fs.writeFile(filename3, n, { mode: m }, function(e) {
if (e) throw e;
// windows permissions aren't unix
if (process.platform !== 'win32') {
if (!common.isWindows) {
var st = fs.statSync(filename3);
assert.equal(st.mode & 0o700, m);
}

View File

@ -54,7 +54,7 @@ server.listen(common.PORT, function() {
'-key', join(common.fixturesDir, 'foafssl.key')];
// for the performance and stability issue in s_client on Windows
if (process.platform === 'win32')
if (common.isWindows)
args.push('-no_rand_screen');
var client = spawn(common.opensslCli, args);

View File

@ -9,7 +9,7 @@ var cluster = require('cluster');
console.error('Cluster listen fd test', process.argv.slice(2));
if (process.platform === 'win32') {
if (common.isWindows) {
console.log('1..0 # Skipped: This test is disabled on windows.');
return;
}

View File

@ -6,7 +6,7 @@ var net = require('net');
var PORT = common.PORT;
var spawn = require('child_process').spawn;
if (process.platform === 'win32') {
if (common.isWindows) {
console.log('1..0 # Skipped: This test is disabled on windows.');
return;
}

View File

@ -6,7 +6,7 @@ var net = require('net');
var PORT = common.PORT;
var spawn = require('child_process').spawn;
if (process.platform === 'win32') {
if (common.isWindows) {
console.log('1..0 # Skipped: This test is disabled on windows.');
return;
}

View File

@ -6,7 +6,7 @@ var net = require('net');
var PORT = common.PORT;
var spawn = require('child_process').spawn;
if (process.platform === 'win32') {
if (common.isWindows) {
console.log('1..0 # Skipped: This test is disabled on windows.');
return;
}

View File

@ -4,12 +4,10 @@ var assert = require('assert');
var module = require('module');
var isWindows = process.platform === 'win32';
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;

View File

@ -4,11 +4,9 @@ var assert = require('assert');
var module = require('module');
var isWindows = process.platform === 'win32';
var file, delimiter, paths;
if (isWindows) {
if (common.isWindows) {
file = 'C:\\Users\\Rocko Artischocko\\node_stuff\\foo';
delimiter = '\\';
} else {

View File

@ -14,7 +14,7 @@ var accessErrorFired = false;
var emptyTxt;
if (process.platform === 'win32') {
if (common.isWindows) {
// on Win, common.PIPE will be a named pipe, so we use an existing empty
// file instead
emptyTxt = path.join(common.fixturesDir, 'empty.txt');
@ -58,7 +58,7 @@ noEntSocketClient.on('error', function(err) {
// On Windows or when running as root, a chmod has no effect on named pipes
if (process.platform !== 'win32' && process.getuid() !== 0) {
if (!common.isWindows && process.getuid() !== 0) {
// Trying to connect to a socket one has no access to should result in EACCES
var accessServer = net.createServer(function() {
assert.ok(false);
@ -83,7 +83,7 @@ if (process.platform !== 'win32' && process.getuid() !== 0) {
process.on('exit', function() {
assert.ok(notSocketErrorFired);
assert.ok(noEntErrorFired);
if (process.platform !== 'win32' && process.getuid() !== 0) {
if (!common.isWindows && process.getuid() !== 0) {
assert.ok(accessErrorFired);
}
});

View File

@ -3,7 +3,7 @@ var assert = require('assert');
var path = require('path');
var common = require('../common');
if (process.platform === 'win32') {
if (common.isWindows) {
var file = path.join(common.fixturesDir, 'a.js');
var resolvedFile = path.resolve(file);

View File

@ -4,8 +4,6 @@ var assert = require('assert');
var path = require('path');
var isWindows = process.platform === 'win32';
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');

View File

@ -1,12 +1,15 @@
'use strict';
if (process.platform === 'win32') {
const assert = require('assert');
const spawn = require('child_process').spawn;
const common = require('../common');
if (common.isWindows) {
// Win32 doesn't have signals, just a kindof emulation, insufficient
// for this test to apply.
return;
}
var assert = require('assert');
var spawn = require('child_process').spawn;
var ok;
if (process.argv[2] !== '--do-test') {

View File

@ -1,12 +1,13 @@
'use strict';
const common = require('../common');
const assert = require('assert');
// SIGUSR1 and SIGHUP are not supported on Windows
if (process.platform === 'win32') {
if (common.isWindows) {
process.exit(0);
}
var common = require('../common');
var assert = require('assert');
console.log('process.pid: ' + process.pid);
var first = 0,

View File

@ -3,7 +3,7 @@ var common = require('../common');
var assert = require('assert');
var spawn = require('child_process').spawn;
if (process.platform === 'win32') {
if (common.isWindows) {
console.log('1..0 # Skipped: platform not supported.');
return;
}

View File

@ -35,7 +35,7 @@ var server = tls.Server({
'-connect', '127.0.0.1:' + common.PORT];
// for the performance and stability issue in s_client on Windows
if (process.platform === 'win32')
if (common.isWindows)
args.push('-no_rand_screen');
var client = spawn(common.opensslCli, args);

View File

@ -45,7 +45,7 @@ function test(keylen, expectedCipher, cb) {
'-cipher', ciphers];
// for the performance and stability issue in s_client on Windows
if (process.platform === 'win32')
if (common.isWindows)
args.push('-no_rand_screen');
var client = spawn(common.opensslCli, args);

View File

@ -34,7 +34,7 @@ server.listen(common.PORT, '127.0.0.1', function() {
' -connect 127.0.0.1:' + common.PORT;
// for the performance and stability issue in s_client on Windows
if (process.platform === 'win32')
if (common.isWindows)
cmd += ' -no_rand_screen';
exec(cmd, function(err, stdout, stderr) {

View File

@ -37,7 +37,7 @@ server.listen(common.PORT, '127.0.0.1', function() {
' -connect 127.0.0.1:' + common.PORT;
// for the performance and stability issue in s_client on Windows
if (process.platform === 'win32')
if (common.isWindows)
cmd += ' -no_rand_screen';
exec(cmd, function(err, stdout, stderr) {

View File

@ -31,7 +31,7 @@ server.listen(common.PORT, '127.0.0.1', function() {
'-connect', address];
// for the performance and stability issue in s_client on Windows
if (process.platform === 'win32')
if (common.isWindows)
args.push('-no_rand_screen');
var client = spawn(common.opensslCli, args, { stdio: 'inherit' });

View File

@ -97,7 +97,7 @@ server.listen(common.PORT, function() {
var args = ['s_client', '-connect', '127.0.0.1:' + common.PORT];
// for the performance and stability issue in s_client on Windows
if (process.platform === 'win32')
if (common.isWindows)
args.push('-no_rand_screen');
var client = spawn(common.opensslCli, args);

View File

@ -135,7 +135,7 @@ function runClient(prefix, port, options, cb) {
var args = ['s_client', '-connect', '127.0.0.1:' + port];
// for the performance issue in s_client on Windows
if (process.platform === 'win32')
if (common.isWindows)
args.push('-no_rand_screen');
console.log(prefix + ' connecting with', options.name);

View File

@ -82,7 +82,7 @@ function doTest(testOptions, callback) {
].concat(testOptions.tickets ? [] : '-no_ticket');
// for the performance and stability issue in s_client on Windows
if (process.platform === 'win32')
if (common.isWindows)
args.push('-no_rand_screen');
server.listen(common.PORT, function() {

View File

@ -41,7 +41,7 @@ server.listen(common.PORT, '127.0.0.1', function() {
' -connect 127.0.0.1:' + common.PORT;
// for the performance and stability issue in s_client on Windows
if (process.platform === 'win32')
if (common.isWindows)
cmd += ' -no_rand_screen';
exec(cmd, function(err, stdout, stderr) {

View File

@ -4,7 +4,7 @@ var assert = require('assert');
// Note in Windows one can only set the "user" bits.
var mask;
if (process.platform == 'win32') {
if (common.isWindows) {
mask = '0600';
} else {
mask = '0664';

View File

@ -2,7 +2,7 @@
var assert = require('assert');
var common = require('../common');
if (process.platform === 'win32') {
if (common.isWindows) {
console.log('1..0 # Skipped: no RLIMIT_NOFILE on Windows');
return;
}

View File

@ -4,8 +4,6 @@ var assert = require('assert');
var spawn = require('child_process').spawn;
var is_windows = process.platform === 'win32';
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 {

View File

@ -3,7 +3,7 @@ var common = require('../common');
var assert = require('assert');
var exec = require('child_process').exec;
if (process.platform !== 'win32') {
if (!common.isWindows) {
// Unix.
var SLEEP3_COMMAND = 'sleep 3';
} else {

View File

@ -1,5 +1,5 @@
'use strict';
if (process.platform === 'win32') {
if (common.isWindows) {
console.log('1..0 # Skipped: no `wrk` on windows');
return;
}

View File

@ -4,7 +4,7 @@ var assert = require('assert');
var spawn = require('child_process').spawn;
var fs = require('fs');
if (process.platform === 'win32') {
if (common.isWindows) {
console.log('1..0 # Skipped: no RLIMIT_NOFILE on Windows');
return;
}

View File

@ -67,7 +67,7 @@ assert.strictEqual(ret, msg + '\n',
var response;
var cwd;
if (process.platform === 'win32') {
if (common.isWindows) {
cwd = 'c:\\';
response = execSync('echo %cd%', {cwd: cwd});
} else {

View File

@ -4,7 +4,7 @@ var assert = require('assert');
var path = require('path');
var fs = require('fs');
var expectFilePath = process.platform === 'win32' ||
var expectFilePath = common.isWindows ||
process.platform === 'linux' ||
process.platform === 'darwin';

View File

@ -1,15 +1,15 @@
'use strict';
// This test is only relevant on Windows.
if (process.platform !== 'win32') {
return process.exit(0);
}
var common = require('../common'),
assert = require('assert'),
fs = require('fs'),
path = require('path'),
succeeded = 0;
// This test is only relevant on Windows.
if (!common.isWindows) {
return process.exit(0);
}
function test(p) {
var result = fs.realpathSync(p);
assert.strictEqual(result, path.resolve(p));