@@ -3,33 +3,23 @@ const { TASK_TEST_GET_TEST_FILES } = require('hardhat/builtin-tasks/task-names')
3
3
4
4
// Modifies `hardhat test` to skip the proxy tests after proxies are removed by the transpiler for upgradeability.
5
5
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 ) => {
12
7
const path = require ( 'path' ) ;
13
8
const { promises : fs } = require ( 'fs' ) ;
14
- const { promisify } = require ( 'util' ) ;
15
-
16
- const glob = promisify ( globAsync ) ;
17
9
18
10
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' ) )
20
12
. then ( ( ) => true )
21
13
. catch ( ( ) => false ) ;
22
14
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 ) ) ;
35
25
} ) ;
0 commit comments