Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit 8f51e36

Browse filesBrowse files
santigimenocjihrig
authored andcommitted
test: use common platform helpers everywhere
Use the common.isWindows, common.isFreeBSD and common.isSunOS where possible. Add common.isOSX and common.isLinux. Fix `test-fs-read-file-sync-hostname` as in its current form was not being run anywhere. PR-URL: #7845 Reviewed-By: Colin Ihrig <cjihrig@gmail.com> Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl> Reviewed-By: James M Snell <jasnell@gmail.com>
1 parent e6887e2 commit 8f51e36
Copy full SHA for 8f51e36
Expand file treeCollapse file tree

26 files changed

+46
-40
lines changed
Open diff view settings
Collapse file

‎test/common.js‎

Copy file name to clipboardExpand all lines: test/common.js
+6-4Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,8 @@ exports.isLinuxPPCBE = (process.platform === 'linux') &&
2626
(os.endianness() === 'BE');
2727
exports.isSunOS = process.platform === 'sunos';
2828
exports.isFreeBSD = process.platform === 'freebsd';
29+
exports.isLinux = process.platform === 'linux';
30+
exports.isOSX = process.platform === 'darwin';
2931

3032
exports.enoughTestMem = os.totalmem() > 0x40000000; /* 1 Gb */
3133
exports.rootDir = exports.isWindows ? 'c:\\' : '/';
@@ -61,7 +63,7 @@ function rmdirSync(p, originalEr) {
6163
if (e.code === 'ENOTDIR')
6264
throw originalEr;
6365
if (e.code === 'ENOTEMPTY' || e.code === 'EEXIST' || e.code === 'EPERM') {
64-
const enc = process.platform === 'linux' ? 'buffer' : 'utf8';
66+
const enc = exports.isLinux ? 'buffer' : 'utf8';
6567
fs.readdirSync(p, enc).forEach((f) => {
6668
if (f instanceof Buffer) {
6769
const buf = Buffer.concat([Buffer.from(p), Buffer.from(path.sep), f]);
@@ -91,7 +93,7 @@ var inFreeBSDJail = null;
9193
var localhostIPv4 = null;
9294

9395
exports.localIPv6Hosts = ['localhost'];
94-
if (process.platform === 'linux') {
96+
if (exports.isLinux) {
9597
exports.localIPv6Hosts = [
9698
// Debian/Ubuntu
9799
'ip6-localhost',
@@ -110,7 +112,7 @@ Object.defineProperty(exports, 'inFreeBSDJail', {
110112
get: function() {
111113
if (inFreeBSDJail !== null) return inFreeBSDJail;
112114

113-
if (process.platform === 'freebsd' &&
115+
if (exports.isFreeBSD &&
114116
child_process.execSync('sysctl -n security.jail.jailed').toString() ===
115117
'1\n') {
116118
inFreeBSDJail = true;
@@ -469,7 +471,7 @@ exports.nodeProcessAborted = function nodeProcessAborted(exitCode, signal) {
469471

470472
// On Windows, v8's base::OS::Abort triggers an access violation,
471473
// which corresponds to exit code 3221225477 (0xC0000005)
472-
if (process.platform === 'win32')
474+
if (exports.isWindows)
473475
expectedExitCodes = [3221225477];
474476

475477
// When using --abort-on-uncaught-exception, V8 will use
Collapse file

‎test/internet/test-dns-ipv6.js‎

Copy file name to clipboardExpand all lines: test/internet/test-dns-ipv6.js
+1-1Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -123,7 +123,7 @@ TEST(function test_lookup_ipv6_hint(done) {
123123
}, function(err, ip, family) {
124124
if (err) {
125125
// FreeBSD does not support V4MAPPED
126-
if (process.platform === 'freebsd') {
126+
if (common.isFreeBSD) {
127127
assert(err instanceof Error);
128128
assert.strictEqual(err.code, 'EAI_BADFLAGS');
129129
assert.strictEqual(err.hostname, 'www.google.com');
Collapse file

‎test/parallel/test-cwd-enoent-preload.js‎

Copy file name to clipboardExpand all lines: test/parallel/test-cwd-enoent-preload.js
+1-1Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ const fs = require('fs');
55
const spawn = require('child_process').spawn;
66

77
// Fails with EINVAL on SmartOS, EBUSY on Windows, EBUSY on AIX.
8-
if (process.platform === 'sunos' || common.isWindows || common.isAix) {
8+
if (common.isSunOS || common.isWindows || common.isAix) {
99
common.skip('cannot rmdir current working directory');
1010
return;
1111
}
Collapse file

‎test/parallel/test-cwd-enoent-repl.js‎

Copy file name to clipboardExpand all lines: test/parallel/test-cwd-enoent-repl.js
+1-1Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ var fs = require('fs');
55
var spawn = require('child_process').spawn;
66

77
// Fails with EINVAL on SmartOS, EBUSY on Windows, EBUSY on AIX.
8-
if (process.platform === 'sunos' || common.isWindows || common.isAix) {
8+
if (common.isSunOS || common.isWindows || common.isAix) {
99
common.skip('cannot rmdir current working directory');
1010
return;
1111
}
Collapse file

‎test/parallel/test-cwd-enoent.js‎

Copy file name to clipboardExpand all lines: test/parallel/test-cwd-enoent.js
+1-1Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ var fs = require('fs');
55
var spawn = require('child_process').spawn;
66

77
// Fails with EINVAL on SmartOS, EBUSY on Windows, EBUSY on AIX.
8-
if (process.platform === 'sunos' || common.isWindows || common.isAix) {
8+
if (common.isSunOS || common.isWindows || common.isAix) {
99
common.skip('cannot rmdir current working directory');
1010
return;
1111
}
Collapse file

‎test/parallel/test-dgram-empty-packet.js‎

Copy file name to clipboardExpand all lines: test/parallel/test-dgram-empty-packet.js
+1-1Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ var callbacks = 0;
66
var client;
77
var timer;
88

9-
if (process.platform === 'darwin') {
9+
if (common.isOSX) {
1010
common.skip('because of 17894467 Apple bug');
1111
return;
1212
}
Collapse file

‎test/parallel/test-dgram-send-empty-array.js‎

Copy file name to clipboardExpand all lines: test/parallel/test-dgram-send-empty-array.js
+1-1Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ const common = require('../common');
44
const assert = require('assert');
55
const dgram = require('dgram');
66

7-
if (process.platform === 'darwin') {
7+
if (common.isOSX) {
88
common.skip('because of 17894467 Apple bug');
99
return;
1010
}
Collapse file

‎test/parallel/test-dgram-send-empty-buffer.js‎

Copy file name to clipboardExpand all lines: test/parallel/test-dgram-send-empty-buffer.js
+1-1Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
const common = require('../common');
33
const dgram = require('dgram');
44

5-
if (process.platform === 'darwin') {
5+
if (common.isOSX) {
66
common.skip('because of 17894467 Apple bug');
77
return;
88
}
Collapse file

‎test/parallel/test-domain-abort-on-uncaught.js‎

Copy file name to clipboardExpand all lines: test/parallel/test-domain-abort-on-uncaught.js
+1-1Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -233,7 +233,7 @@ if (process.argv[2] === 'child') {
233233

234234
tests.forEach(function(test, testIndex) {
235235
var testCmd = '';
236-
if (process.platform !== 'win32') {
236+
if (!common.isWindows) {
237237
// Do not create core files, as it can take a lot of disk space on
238238
// continuous testing and developers' machines
239239
testCmd += 'ulimit -c 0 && ';
Collapse file

‎test/parallel/test-domain-no-error-handler-abort-on-uncaught.js‎

Copy file name to clipboardExpand all lines: test/parallel/test-domain-no-error-handler-abort-on-uncaught.js
+1-1Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -144,7 +144,7 @@ if (process.argv[2] === 'child') {
144144

145145
tests.forEach(function(test, testIndex) {
146146
var testCmd = '';
147-
if (process.platform !== 'win32') {
147+
if (!common.isWindows) {
148148
// Do not create core files, as it can take a lot of disk space on
149149
// continuous testing and developers' machines
150150
testCmd += 'ulimit -c 0 && ';

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.