Skip to content

Commit e654c8b

Browse files
jasnelladuh95
authored andcommitted
test: simplify common/index.js
Move single or trivial and limited use things out of common/index.js for the purpose of simplifying and reducing common/index.js PR-URL: #56712 Reviewed-By: Yagiz Nizipli <[email protected]> Reviewed-By: Matteo Collina <[email protected]>
1 parent 58d2dad commit e654c8b

File tree

6 files changed

+19
-28
lines changed

6 files changed

+19
-28
lines changed

test/common/README.md

-6
Original file line numberDiff line numberDiff line change
@@ -279,12 +279,6 @@ Platform check for IBMi.
279279

280280
Platform check for Linux.
281281

282-
### `isLinuxPPCBE`
283-
284-
* [\<boolean>][<boolean>]
285-
286-
Platform check for Linux on PowerPC.
287-
288282
### `isMacOS`
289283

290284
* [\<boolean>][<boolean>]

test/common/index.js

-12
Original file line numberDiff line numberDiff line change
@@ -1034,11 +1034,6 @@ const common = {
10341034
return require('os').type() === 'OS400';
10351035
},
10361036

1037-
get isLinuxPPCBE() {
1038-
return (process.platform === 'linux') && (process.arch === 'ppc64') &&
1039-
(require('os').endianness() === 'BE');
1040-
},
1041-
10421037
get localhostIPv4() {
10431038
if (localhostIPv4 !== null) return localhostIPv4;
10441039

@@ -1067,13 +1062,6 @@ const common = {
10671062
return +process.env.NODE_COMMON_PORT || 12346;
10681063
},
10691064

1070-
/**
1071-
* Returns the EOL character used by this Git checkout.
1072-
*/
1073-
get checkoutEOL() {
1074-
return fs.readFileSync(__filename).includes('\r\n') ? '\r\n' : '\n';
1075-
},
1076-
10771065
get isInsideDirWithUnusualChars() {
10781066
return __dirname.includes('%') ||
10791067
(!isWindows && __dirname.includes('\\')) ||

test/common/index.mjs

-4
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,6 @@ const {
77
allowGlobals,
88
buildType,
99
canCreateSymLink,
10-
checkoutEOL,
1110
childShouldThrowAndAbort,
1211
createZeroFilledFile,
1312
enoughTestMem,
@@ -27,7 +26,6 @@ const {
2726
isIBMi,
2827
isInsideDirWithUnusualChars,
2928
isLinux,
30-
isLinuxPPCBE,
3129
isMainThread,
3230
isOpenBSD,
3331
isMacOS,
@@ -59,7 +57,6 @@ export {
5957
allowGlobals,
6058
buildType,
6159
canCreateSymLink,
62-
checkoutEOL,
6360
childShouldThrowAndAbort,
6461
createRequire,
6562
createZeroFilledFile,
@@ -81,7 +78,6 @@ export {
8178
isIBMi,
8279
isInsideDirWithUnusualChars,
8380
isLinux,
84-
isLinuxPPCBE,
8581
isMainThread,
8682
isOpenBSD,
8783
isMacOS,

test/parallel/test-source-map-enable.js

+2-1
Original file line numberDiff line numberDiff line change
@@ -242,6 +242,7 @@ function nextdir() {
242242

243243
// Persists line lengths for in-memory representation of source file.
244244
{
245+
const checkoutEOL = fs.readFileSync(__filename).includes('\r\n') ? '\r\n' : '\n';
245246
const coverageDirectory = nextdir();
246247
spawnSync(process.execPath, [
247248
require.resolve('../fixtures/source-map/istanbul-throw.js'),
@@ -250,7 +251,7 @@ function nextdir() {
250251
'istanbul-throw.js',
251252
coverageDirectory
252253
);
253-
if (common.checkoutEOL === '\r\n') {
254+
if (checkoutEOL === '\r\n') {
254255
assert.deepStrictEqual(sourceMap.lineLengths, [1086, 31, 185, 649, 0]);
255256
} else {
256257
assert.deepStrictEqual(sourceMap.lineLengths, [1085, 30, 184, 648, 0]);

test/tick-processor/util.js

+9-2
Original file line numberDiff line numberDiff line change
@@ -5,14 +5,21 @@ const {
55
isWindows,
66
isSunOS,
77
isAIX,
8-
isLinuxPPCBE,
98
isFreeBSD,
109
} = require('../common');
1110

11+
const { endianness } = require('os');
12+
13+
function isLinuxPPCBE() {
14+
return (process.platform === 'linux') &&
15+
(process.arch === 'ppc64') &&
16+
(endianness() === 'BE');
17+
}
18+
1219
module.exports = {
1320
isCPPSymbolsNotMapped: isWindows ||
1421
isSunOS ||
1522
isAIX ||
16-
isLinuxPPCBE ||
23+
isLinuxPPCBE() ||
1724
isFreeBSD,
1825
};

test/wasi/test-wasi-io.js

+8-3
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,19 @@
11
'use strict';
2-
const common = require('../common');
3-
const { checkoutEOL } = common;
2+
require('../common');
3+
const { readFileSync } = require('fs');
44
const { testWasiPreview1 } = require('../common/wasi');
55

6+
const checkoutEOL = readFileSync(__filename).includes('\r\n') ? '\r\n' : '\n';
7+
8+
// TODO(@jasnell): It's not entirely clear what this test is asserting.
9+
// More comments would be helpful.
10+
611
testWasiPreview1(['freopen'], {}, { stdout: `hello from input2.txt${checkoutEOL}` });
712
testWasiPreview1(['read_file'], {}, { stdout: `hello from input.txt${checkoutEOL}` });
813
testWasiPreview1(['read_file_twice'], {}, {
914
stdout: `hello from input.txt${checkoutEOL}hello from input.txt${checkoutEOL}`,
1015
});
1116
// Tests that are currently unsupported on Windows.
12-
if (!common.isWindows) {
17+
if (process.platform !== 'win32') {
1318
testWasiPreview1(['stdin'], { input: 'hello world' }, { stdout: 'hello world' });
1419
}

0 commit comments

Comments
 (0)