@@ -7,6 +7,7 @@ import type { SolidityTestRunnerConfigArgs } from "@ignored/edr";
7
7
import { finished } from "node:stream/promises" ;
8
8
9
9
import { getAllFilesMatching } from "@ignored/hardhat-vnext-utils/fs" ;
10
+ import { resolveFromRoot } from "@ignored/hardhat-vnext-utils/path" ;
10
11
import { createNonClosingWriter } from "@ignored/hardhat-vnext-utils/stream" ;
11
12
12
13
import { shouldMergeCompilationJobs } from "../solidity/build-profiles.js" ;
@@ -22,25 +23,34 @@ import {
22
23
import { testReporter } from "./reporter.js" ;
23
24
import { run } from "./runner.js" ;
24
25
25
- // eslint-disable-next-line @typescript-eslint/no-empty-interface -- the interface is expected to be expanded in the future
26
- interface TestActionArguments { }
26
+ interface TestActionArguments {
27
+ testFiles : string [ ] ;
28
+ }
27
29
28
30
const runSolidityTests : NewTaskActionFunction < TestActionArguments > = async (
29
- { } ,
31
+ { testFiles } ,
30
32
hre ,
31
33
) => {
32
- // NOTE: A test file is either a file with a `.sol` extension in the `tests.solidity`
33
- // directory or a file with a `.t.sol` extension in the `sources.solidity` directory
34
- const rootFilePaths = (
35
- await Promise . all ( [
36
- getAllFilesMatching ( hre . config . paths . tests . solidity , ( f ) =>
37
- f . endsWith ( ".sol" ) ,
38
- ) ,
39
- ...hre . config . paths . sources . solidity . map ( async ( dir ) => {
40
- return getAllFilesMatching ( dir , ( f ) => f . endsWith ( ".t.sol" ) ) ;
41
- } ) ,
42
- ] )
43
- ) . flat ( 1 ) ;
34
+ let rootFilePaths : string [ ] ;
35
+
36
+ if ( testFiles . length > 0 ) {
37
+ rootFilePaths = testFiles . map ( ( f ) =>
38
+ resolveFromRoot ( hre . config . paths . root , f ) ,
39
+ ) ;
40
+ } else {
41
+ // NOTE: A test file is either a file with a `.sol` extension in the `tests.solidity`
42
+ // directory or a file with a `.t.sol` extension in the `sources.solidity` directory
43
+ rootFilePaths = (
44
+ await Promise . all ( [
45
+ getAllFilesMatching ( hre . config . paths . tests . solidity , ( f ) =>
46
+ f . endsWith ( ".sol" ) ,
47
+ ) ,
48
+ ...hre . config . paths . sources . solidity . map ( async ( dir ) => {
49
+ return getAllFilesMatching ( dir , ( f ) => f . endsWith ( ".t.sol" ) ) ;
50
+ } ) ,
51
+ ] )
52
+ ) . flat ( 1 ) ;
53
+ }
44
54
45
55
const buildOptions : BuildOptions = {
46
56
force : false ,
0 commit comments