task-test-get-files.js 1008 B

12345678910111213141516171819202122232425
  1. const { internalTask } = require('hardhat/config');
  2. const { TASK_TEST_GET_TEST_FILES } = require('hardhat/builtin-tasks/task-names');
  3. // Modifies `hardhat test` to skip the proxy tests after proxies are removed by the transpiler for upgradeability.
  4. internalTask(TASK_TEST_GET_TEST_FILES).setAction(async (args, hre, runSuper) => {
  5. const path = require('path');
  6. const { promises: fs } = require('fs');
  7. const hasProxies = await fs
  8. .access(path.join(hre.config.paths.sources, 'proxy/Proxy.sol'))
  9. .then(() => true)
  10. .catch(() => false);
  11. const ignoredIfProxy = [
  12. 'proxy/beacon/BeaconProxy.test.js',
  13. 'proxy/beacon/UpgradeableBeacon.test.js',
  14. 'proxy/ERC1967/ERC1967Proxy.test.js',
  15. 'proxy/transparent/ProxyAdmin.test.js',
  16. 'proxy/transparent/TransparentUpgradeableProxy.test.js',
  17. 'proxy/utils/UUPSUpgradeable.test.js',
  18. ].map(p => path.join(hre.config.paths.tests, p));
  19. return (await runSuper(args)).filter(file => hasProxies || !ignoredIfProxy.includes(file));
  20. });