Skip to content

Commit d26025b

Browse files
Amxxfrangio
authored andcommitted
Fix error when running hardhat test with parameters (#4265)
(cherry picked from commit dfef6a6)
1 parent a54f639 commit d26025b

File tree

1 file changed

+12
-22
lines changed

1 file changed

+12
-22
lines changed

hardhat/task-test-get-files.js

Lines changed: 12 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -3,33 +3,23 @@ const { TASK_TEST_GET_TEST_FILES } = require('hardhat/builtin-tasks/task-names')
33

44
// Modifies `hardhat test` to skip the proxy tests after proxies are removed by the transpiler for upgradeability.
55

6-
internalTask(TASK_TEST_GET_TEST_FILES).setAction(async ({ testFiles }, { config }) => {
7-
if (testFiles.length !== 0) {
8-
return testFiles;
9-
}
10-
11-
const globAsync = require('glob');
6+
internalTask(TASK_TEST_GET_TEST_FILES).setAction(async (args, hre, runSuper) => {
127
const path = require('path');
138
const { promises: fs } = require('fs');
14-
const { promisify } = require('util');
15-
16-
const glob = promisify(globAsync);
179

1810
const hasProxies = await fs
19-
.access(path.join(config.paths.sources, 'proxy/Proxy.sol'))
11+
.access(path.join(hre.config.paths.sources, 'proxy/Proxy.sol'))
2012
.then(() => true)
2113
.catch(() => false);
2214

23-
return await glob(path.join(config.paths.tests, '**/*.js'), {
24-
ignore: hasProxies
25-
? []
26-
: [
27-
'proxy/beacon/BeaconProxy.test.js',
28-
'proxy/beacon/UpgradeableBeacon.test.js',
29-
'proxy/ERC1967/ERC1967Proxy.test.js',
30-
'proxy/transparent/ProxyAdmin.test.js',
31-
'proxy/transparent/TransparentUpgradeableProxy.test.js',
32-
'proxy/utils/UUPSUpgradeable.test.js',
33-
].map(p => path.join(config.paths.tests, p)),
34-
});
15+
const ignoredIfProxy = [
16+
'proxy/beacon/BeaconProxy.test.js',
17+
'proxy/beacon/UpgradeableBeacon.test.js',
18+
'proxy/ERC1967/ERC1967Proxy.test.js',
19+
'proxy/transparent/ProxyAdmin.test.js',
20+
'proxy/transparent/TransparentUpgradeableProxy.test.js',
21+
'proxy/utils/UUPSUpgradeable.test.js',
22+
].map(p => path.join(hre.config.paths.tests, p));
23+
24+
return (await runSuper(args)).filter(file => hasProxies || !ignoredIfProxy.includes(file));
3525
});

0 commit comments

Comments
 (0)