mirror of
https://github.com/nodejs/node.git
synced 2025-08-15 13:48:44 +02:00
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: https://github.com/nodejs/node/pull/56712 Reviewed-By: Yagiz Nizipli <yagiz@nizipli.com> Reviewed-By: Matteo Collina <matteo.collina@gmail.com>
This commit is contained in:
parent
4a5d2c7538
commit
0713ee3a17
6 changed files with 19 additions and 28 deletions
|
@ -279,12 +279,6 @@ Platform check for IBMi.
|
||||||
|
|
||||||
Platform check for Linux.
|
Platform check for Linux.
|
||||||
|
|
||||||
### `isLinuxPPCBE`
|
|
||||||
|
|
||||||
* [\<boolean>][<boolean>]
|
|
||||||
|
|
||||||
Platform check for Linux on PowerPC.
|
|
||||||
|
|
||||||
### `isMacOS`
|
### `isMacOS`
|
||||||
|
|
||||||
* [\<boolean>][<boolean>]
|
* [\<boolean>][<boolean>]
|
||||||
|
|
|
@ -1034,11 +1034,6 @@ const common = {
|
||||||
return require('os').type() === 'OS400';
|
return require('os').type() === 'OS400';
|
||||||
},
|
},
|
||||||
|
|
||||||
get isLinuxPPCBE() {
|
|
||||||
return (process.platform === 'linux') && (process.arch === 'ppc64') &&
|
|
||||||
(require('os').endianness() === 'BE');
|
|
||||||
},
|
|
||||||
|
|
||||||
get localhostIPv4() {
|
get localhostIPv4() {
|
||||||
if (localhostIPv4 !== null) return localhostIPv4;
|
if (localhostIPv4 !== null) return localhostIPv4;
|
||||||
|
|
||||||
|
@ -1067,13 +1062,6 @@ const common = {
|
||||||
return +process.env.NODE_COMMON_PORT || 12346;
|
return +process.env.NODE_COMMON_PORT || 12346;
|
||||||
},
|
},
|
||||||
|
|
||||||
/**
|
|
||||||
* Returns the EOL character used by this Git checkout.
|
|
||||||
*/
|
|
||||||
get checkoutEOL() {
|
|
||||||
return fs.readFileSync(__filename).includes('\r\n') ? '\r\n' : '\n';
|
|
||||||
},
|
|
||||||
|
|
||||||
get isInsideDirWithUnusualChars() {
|
get isInsideDirWithUnusualChars() {
|
||||||
return __dirname.includes('%') ||
|
return __dirname.includes('%') ||
|
||||||
(!isWindows && __dirname.includes('\\')) ||
|
(!isWindows && __dirname.includes('\\')) ||
|
||||||
|
|
|
@ -7,7 +7,6 @@ const {
|
||||||
allowGlobals,
|
allowGlobals,
|
||||||
buildType,
|
buildType,
|
||||||
canCreateSymLink,
|
canCreateSymLink,
|
||||||
checkoutEOL,
|
|
||||||
childShouldThrowAndAbort,
|
childShouldThrowAndAbort,
|
||||||
createZeroFilledFile,
|
createZeroFilledFile,
|
||||||
enoughTestMem,
|
enoughTestMem,
|
||||||
|
@ -27,7 +26,6 @@ const {
|
||||||
isIBMi,
|
isIBMi,
|
||||||
isInsideDirWithUnusualChars,
|
isInsideDirWithUnusualChars,
|
||||||
isLinux,
|
isLinux,
|
||||||
isLinuxPPCBE,
|
|
||||||
isMainThread,
|
isMainThread,
|
||||||
isOpenBSD,
|
isOpenBSD,
|
||||||
isMacOS,
|
isMacOS,
|
||||||
|
@ -59,7 +57,6 @@ export {
|
||||||
allowGlobals,
|
allowGlobals,
|
||||||
buildType,
|
buildType,
|
||||||
canCreateSymLink,
|
canCreateSymLink,
|
||||||
checkoutEOL,
|
|
||||||
childShouldThrowAndAbort,
|
childShouldThrowAndAbort,
|
||||||
createRequire,
|
createRequire,
|
||||||
createZeroFilledFile,
|
createZeroFilledFile,
|
||||||
|
@ -81,7 +78,6 @@ export {
|
||||||
isIBMi,
|
isIBMi,
|
||||||
isInsideDirWithUnusualChars,
|
isInsideDirWithUnusualChars,
|
||||||
isLinux,
|
isLinux,
|
||||||
isLinuxPPCBE,
|
|
||||||
isMainThread,
|
isMainThread,
|
||||||
isOpenBSD,
|
isOpenBSD,
|
||||||
isMacOS,
|
isMacOS,
|
||||||
|
|
|
@ -242,6 +242,7 @@ function nextdir() {
|
||||||
|
|
||||||
// Persists line lengths for in-memory representation of source file.
|
// Persists line lengths for in-memory representation of source file.
|
||||||
{
|
{
|
||||||
|
const checkoutEOL = fs.readFileSync(__filename).includes('\r\n') ? '\r\n' : '\n';
|
||||||
const coverageDirectory = nextdir();
|
const coverageDirectory = nextdir();
|
||||||
spawnSync(process.execPath, [
|
spawnSync(process.execPath, [
|
||||||
require.resolve('../fixtures/source-map/istanbul-throw.js'),
|
require.resolve('../fixtures/source-map/istanbul-throw.js'),
|
||||||
|
@ -250,7 +251,7 @@ function nextdir() {
|
||||||
'istanbul-throw.js',
|
'istanbul-throw.js',
|
||||||
coverageDirectory
|
coverageDirectory
|
||||||
);
|
);
|
||||||
if (common.checkoutEOL === '\r\n') {
|
if (checkoutEOL === '\r\n') {
|
||||||
assert.deepStrictEqual(sourceMap.lineLengths, [1086, 31, 185, 649, 0]);
|
assert.deepStrictEqual(sourceMap.lineLengths, [1086, 31, 185, 649, 0]);
|
||||||
} else {
|
} else {
|
||||||
assert.deepStrictEqual(sourceMap.lineLengths, [1085, 30, 184, 648, 0]);
|
assert.deepStrictEqual(sourceMap.lineLengths, [1085, 30, 184, 648, 0]);
|
||||||
|
|
|
@ -5,14 +5,21 @@ const {
|
||||||
isWindows,
|
isWindows,
|
||||||
isSunOS,
|
isSunOS,
|
||||||
isAIX,
|
isAIX,
|
||||||
isLinuxPPCBE,
|
|
||||||
isFreeBSD,
|
isFreeBSD,
|
||||||
} = require('../common');
|
} = require('../common');
|
||||||
|
|
||||||
|
const { endianness } = require('os');
|
||||||
|
|
||||||
|
function isLinuxPPCBE() {
|
||||||
|
return (process.platform === 'linux') &&
|
||||||
|
(process.arch === 'ppc64') &&
|
||||||
|
(endianness() === 'BE');
|
||||||
|
}
|
||||||
|
|
||||||
module.exports = {
|
module.exports = {
|
||||||
isCPPSymbolsNotMapped: isWindows ||
|
isCPPSymbolsNotMapped: isWindows ||
|
||||||
isSunOS ||
|
isSunOS ||
|
||||||
isAIX ||
|
isAIX ||
|
||||||
isLinuxPPCBE ||
|
isLinuxPPCBE() ||
|
||||||
isFreeBSD,
|
isFreeBSD,
|
||||||
};
|
};
|
||||||
|
|
|
@ -1,14 +1,19 @@
|
||||||
'use strict';
|
'use strict';
|
||||||
const common = require('../common');
|
require('../common');
|
||||||
const { checkoutEOL } = common;
|
const { readFileSync } = require('fs');
|
||||||
const { testWasiPreview1 } = require('../common/wasi');
|
const { testWasiPreview1 } = require('../common/wasi');
|
||||||
|
|
||||||
|
const checkoutEOL = readFileSync(__filename).includes('\r\n') ? '\r\n' : '\n';
|
||||||
|
|
||||||
|
// TODO(@jasnell): It's not entirely clear what this test is asserting.
|
||||||
|
// More comments would be helpful.
|
||||||
|
|
||||||
testWasiPreview1(['freopen'], {}, { stdout: `hello from input2.txt${checkoutEOL}` });
|
testWasiPreview1(['freopen'], {}, { stdout: `hello from input2.txt${checkoutEOL}` });
|
||||||
testWasiPreview1(['read_file'], {}, { stdout: `hello from input.txt${checkoutEOL}` });
|
testWasiPreview1(['read_file'], {}, { stdout: `hello from input.txt${checkoutEOL}` });
|
||||||
testWasiPreview1(['read_file_twice'], {}, {
|
testWasiPreview1(['read_file_twice'], {}, {
|
||||||
stdout: `hello from input.txt${checkoutEOL}hello from input.txt${checkoutEOL}`,
|
stdout: `hello from input.txt${checkoutEOL}hello from input.txt${checkoutEOL}`,
|
||||||
});
|
});
|
||||||
// Tests that are currently unsupported on Windows.
|
// Tests that are currently unsupported on Windows.
|
||||||
if (!common.isWindows) {
|
if (process.platform !== 'win32') {
|
||||||
testWasiPreview1(['stdin'], { input: 'hello world' }, { stdout: 'hello world' });
|
testWasiPreview1(['stdin'], { input: 'hello world' }, { stdout: 'hello world' });
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue