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.
|
||||
|
||||
### `isLinuxPPCBE`
|
||||
|
||||
* [\<boolean>][<boolean>]
|
||||
|
||||
Platform check for Linux on PowerPC.
|
||||
|
||||
### `isMacOS`
|
||||
|
||||
* [\<boolean>][<boolean>]
|
||||
|
|
|
@ -1034,11 +1034,6 @@ const common = {
|
|||
return require('os').type() === 'OS400';
|
||||
},
|
||||
|
||||
get isLinuxPPCBE() {
|
||||
return (process.platform === 'linux') && (process.arch === 'ppc64') &&
|
||||
(require('os').endianness() === 'BE');
|
||||
},
|
||||
|
||||
get localhostIPv4() {
|
||||
if (localhostIPv4 !== null) return localhostIPv4;
|
||||
|
||||
|
@ -1067,13 +1062,6 @@ const common = {
|
|||
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() {
|
||||
return __dirname.includes('%') ||
|
||||
(!isWindows && __dirname.includes('\\')) ||
|
||||
|
|
|
@ -7,7 +7,6 @@ const {
|
|||
allowGlobals,
|
||||
buildType,
|
||||
canCreateSymLink,
|
||||
checkoutEOL,
|
||||
childShouldThrowAndAbort,
|
||||
createZeroFilledFile,
|
||||
enoughTestMem,
|
||||
|
@ -27,7 +26,6 @@ const {
|
|||
isIBMi,
|
||||
isInsideDirWithUnusualChars,
|
||||
isLinux,
|
||||
isLinuxPPCBE,
|
||||
isMainThread,
|
||||
isOpenBSD,
|
||||
isMacOS,
|
||||
|
@ -59,7 +57,6 @@ export {
|
|||
allowGlobals,
|
||||
buildType,
|
||||
canCreateSymLink,
|
||||
checkoutEOL,
|
||||
childShouldThrowAndAbort,
|
||||
createRequire,
|
||||
createZeroFilledFile,
|
||||
|
@ -81,7 +78,6 @@ export {
|
|||
isIBMi,
|
||||
isInsideDirWithUnusualChars,
|
||||
isLinux,
|
||||
isLinuxPPCBE,
|
||||
isMainThread,
|
||||
isOpenBSD,
|
||||
isMacOS,
|
||||
|
|
|
@ -242,6 +242,7 @@ function nextdir() {
|
|||
|
||||
// Persists line lengths for in-memory representation of source file.
|
||||
{
|
||||
const checkoutEOL = fs.readFileSync(__filename).includes('\r\n') ? '\r\n' : '\n';
|
||||
const coverageDirectory = nextdir();
|
||||
spawnSync(process.execPath, [
|
||||
require.resolve('../fixtures/source-map/istanbul-throw.js'),
|
||||
|
@ -250,7 +251,7 @@ function nextdir() {
|
|||
'istanbul-throw.js',
|
||||
coverageDirectory
|
||||
);
|
||||
if (common.checkoutEOL === '\r\n') {
|
||||
if (checkoutEOL === '\r\n') {
|
||||
assert.deepStrictEqual(sourceMap.lineLengths, [1086, 31, 185, 649, 0]);
|
||||
} else {
|
||||
assert.deepStrictEqual(sourceMap.lineLengths, [1085, 30, 184, 648, 0]);
|
||||
|
|
|
@ -5,14 +5,21 @@ const {
|
|||
isWindows,
|
||||
isSunOS,
|
||||
isAIX,
|
||||
isLinuxPPCBE,
|
||||
isFreeBSD,
|
||||
} = require('../common');
|
||||
|
||||
const { endianness } = require('os');
|
||||
|
||||
function isLinuxPPCBE() {
|
||||
return (process.platform === 'linux') &&
|
||||
(process.arch === 'ppc64') &&
|
||||
(endianness() === 'BE');
|
||||
}
|
||||
|
||||
module.exports = {
|
||||
isCPPSymbolsNotMapped: isWindows ||
|
||||
isSunOS ||
|
||||
isAIX ||
|
||||
isLinuxPPCBE ||
|
||||
isLinuxPPCBE() ||
|
||||
isFreeBSD,
|
||||
};
|
||||
|
|
|
@ -1,14 +1,19 @@
|
|||
'use strict';
|
||||
const common = require('../common');
|
||||
const { checkoutEOL } = common;
|
||||
require('../common');
|
||||
const { readFileSync } = require('fs');
|
||||
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(['read_file'], {}, { stdout: `hello from input.txt${checkoutEOL}` });
|
||||
testWasiPreview1(['read_file_twice'], {}, {
|
||||
stdout: `hello from input.txt${checkoutEOL}hello from input.txt${checkoutEOL}`,
|
||||
});
|
||||
// Tests that are currently unsupported on Windows.
|
||||
if (!common.isWindows) {
|
||||
if (process.platform !== 'win32') {
|
||||
testWasiPreview1(['stdin'], { input: 'hello world' }, { stdout: 'hello world' });
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue