mirror of openzeppelin-contracts
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
openzeppelin-contracts/hardhat/task-test-get-files.js

36 lines
1.2 KiB

const { internalTask } = require('hardhat/config');
const { TASK_TEST_GET_TEST_FILES } = require('hardhat/builtin-tasks/task-names');
// Modifies `hardhat test` to skip the proxy tests after proxies are removed by the transpiler for upgradeability.
internalTask(TASK_TEST_GET_TEST_FILES).setAction(async ({ testFiles }, { config }) => {
if (testFiles.length !== 0) {
return testFiles;
}
const globAsync = require('glob');
const path = require('path');
const { promises: fs } = require('fs');
const { promisify } = require('util');
const glob = promisify(globAsync);
const hasProxies = await fs
.access(path.join(config.paths.sources, 'proxy/Proxy.sol'))
.then(() => true)
.catch(() => false);
return await glob(path.join(config.paths.tests, '**/*.js'), {
ignore: hasProxies
? []
: [
'proxy/beacon/BeaconProxy.test.js',
'proxy/beacon/UpgradeableBeacon.test.js',
'proxy/ERC1967/ERC1967Proxy.test.js',
'proxy/transparent/ProxyAdmin.test.js',
'proxy/transparent/TransparentUpgradeableProxy.test.js',
'proxy/utils/UUPSUpgradeable.test.js',
].map(p => path.join(config.paths.tests, p)),
});
});