test: use module.exports consistently
PR-URL: https://github.com/nodejs/node/pull/22557 Reviewed-By: Anna Henningsen <anna@addaleax.net> Reviewed-By: Colin Ihrig <cjihrig@gmail.com> Reviewed-By: Weijia Wang <starkwang@126.com> Reviewed-By: Luigi Pinca <luigipinca@gmail.com> Reviewed-By: Ruben Bridgewater <ruben@bridgewater.de>
This commit is contained in:
parent
b797103e26
commit
25d29da10a
@ -2,10 +2,14 @@
|
|||||||
const common = require('../common');
|
const common = require('../common');
|
||||||
const path = require('path');
|
const path = require('path');
|
||||||
|
|
||||||
|
const kNodeShared = Boolean(process.config.variables.node_shared);
|
||||||
|
const kShlibSuffix = process.config.variables.shlib_suffix;
|
||||||
|
const kExecPath = path.dirname(process.execPath);
|
||||||
|
|
||||||
// If node executable is linked to shared lib, need to take care about the
|
// If node executable is linked to shared lib, need to take care about the
|
||||||
// shared lib path.
|
// shared lib path.
|
||||||
exports.addLibraryPath = function(env) {
|
function addLibraryPath(env) {
|
||||||
if (!process.config.variables.node_shared) {
|
if (!kNodeShared) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -13,37 +17,37 @@ exports.addLibraryPath = function(env) {
|
|||||||
|
|
||||||
env.LD_LIBRARY_PATH =
|
env.LD_LIBRARY_PATH =
|
||||||
(env.LD_LIBRARY_PATH ? env.LD_LIBRARY_PATH + path.delimiter : '') +
|
(env.LD_LIBRARY_PATH ? env.LD_LIBRARY_PATH + path.delimiter : '') +
|
||||||
path.join(path.dirname(process.execPath), 'lib.target');
|
path.join(kExecPath, 'lib.target');
|
||||||
// For AIX.
|
// For AIX.
|
||||||
env.LIBPATH =
|
env.LIBPATH =
|
||||||
(env.LIBPATH ? env.LIBPATH + path.delimiter : '') +
|
(env.LIBPATH ? env.LIBPATH + path.delimiter : '') +
|
||||||
path.join(path.dirname(process.execPath), 'lib.target');
|
path.join(kExecPath, 'lib.target');
|
||||||
// For Mac OSX.
|
// For Mac OSX.
|
||||||
env.DYLD_LIBRARY_PATH =
|
env.DYLD_LIBRARY_PATH =
|
||||||
(env.DYLD_LIBRARY_PATH ? env.DYLD_LIBRARY_PATH + path.delimiter : '') +
|
(env.DYLD_LIBRARY_PATH ? env.DYLD_LIBRARY_PATH + path.delimiter : '') +
|
||||||
path.dirname(process.execPath);
|
kExecPath;
|
||||||
// For Windows.
|
// For Windows.
|
||||||
env.PATH =
|
env.PATH = (env.PATH ? env.PATH + path.delimiter : '') + kExecPath;
|
||||||
(env.PATH ? env.PATH + path.delimiter : '') +
|
}
|
||||||
path.dirname(process.execPath);
|
|
||||||
};
|
|
||||||
|
|
||||||
// Get the full path of shared lib.
|
// Get the full path of shared lib.
|
||||||
exports.getSharedLibPath = function() {
|
function getSharedLibPath() {
|
||||||
if (common.isWindows) {
|
if (common.isWindows) {
|
||||||
return path.join(path.dirname(process.execPath), 'node.dll');
|
return path.join(kExecPath, 'node.dll');
|
||||||
} else if (common.isOSX) {
|
} else if (common.isOSX) {
|
||||||
return path.join(path.dirname(process.execPath),
|
return path.join(kExecPath, `libnode.${kShlibSuffix}`);
|
||||||
`libnode.${process.config.variables.shlib_suffix}`);
|
|
||||||
} else {
|
} else {
|
||||||
return path.join(path.dirname(process.execPath),
|
return path.join(kExecPath, 'lib.target', `libnode.${kShlibSuffix}`);
|
||||||
'lib.target',
|
}
|
||||||
`libnode.${process.config.variables.shlib_suffix}`);
|
|
||||||
}
|
}
|
||||||
};
|
|
||||||
|
|
||||||
// Get the binary path of stack frames.
|
// Get the binary path of stack frames.
|
||||||
exports.getBinaryPath = function() {
|
function getBinaryPath() {
|
||||||
return process.config.variables.node_shared ?
|
return kNodeShared ? getSharedLibPath() : process.execPath;
|
||||||
exports.getSharedLibPath() : process.execPath;
|
}
|
||||||
|
|
||||||
|
module.exports = {
|
||||||
|
addLibraryPath,
|
||||||
|
getBinaryPath,
|
||||||
|
getSharedLibPath
|
||||||
};
|
};
|
||||||
|
@ -59,9 +59,15 @@ let tmpdirName = '.tmp';
|
|||||||
if (process.env.TEST_THREAD_ID) {
|
if (process.env.TEST_THREAD_ID) {
|
||||||
tmpdirName += `.${process.env.TEST_THREAD_ID}`;
|
tmpdirName += `.${process.env.TEST_THREAD_ID}`;
|
||||||
}
|
}
|
||||||
exports.path = path.join(testRoot, tmpdirName);
|
|
||||||
|
|
||||||
exports.refresh = () => {
|
const tmpPath = path.join(testRoot, tmpdirName);
|
||||||
rimrafSync(exports.path);
|
|
||||||
fs.mkdirSync(exports.path);
|
function refresh() {
|
||||||
|
rimrafSync(this.path);
|
||||||
|
fs.mkdirSync(this.path);
|
||||||
|
}
|
||||||
|
|
||||||
|
module.exports = {
|
||||||
|
path: tmpPath,
|
||||||
|
refresh
|
||||||
};
|
};
|
||||||
|
Loading…
x
Reference in New Issue
Block a user