Skip to content

Commit dd2bb0a

Browse files
committed
chore: restore the --no-compile flag in the test solidity task
1 parent 34e9feb commit dd2bb0a

File tree

2 files changed

+25
-3
lines changed

2 files changed

+25
-3
lines changed

v-next/hardhat/src/internal/builtin-plugins/solidity-test/index.ts

+4
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,10 @@ const hardhatPlugin: HardhatPlugin = {
1111
},
1212
tasks: [
1313
task(["test", "solidity"], "Run the Solidity tests")
14+
.addFlag({
15+
name: "noCompile",
16+
description: "Don't compile the project before running the test",
17+
})
1418
.setAction(import.meta.resolve("./task-action.js"))
1519
.build(),
1620
],

v-next/hardhat/src/internal/builtin-plugins/solidity-test/task-action.ts

+21-3
Original file line numberDiff line numberDiff line change
@@ -21,12 +21,14 @@ import {
2121
} from "./helpers.js";
2222
import { testReporter } from "./reporter.js";
2323
import { run } from "./runner.js";
24+
import chalk from "chalk";
2425

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+
noCompile: boolean;
28+
}
2729

2830
const runSolidityTests: NewTaskActionFunction<TestActionArguments> = async (
29-
{},
31+
{ noCompile },
3032
hre,
3133
) => {
3234
// NOTE: A test file is either a file with a `.sol` extension in the `tests.solidity`
@@ -42,6 +44,22 @@ const runSolidityTests: NewTaskActionFunction<TestActionArguments> = async (
4244
])
4345
).flat(1);
4446

47+
// TODO: Decide either how to support or remove this flag from this task.
48+
//
49+
// One option for supporting it would be to iterate over
50+
// hre.artifacts.getArtifactPaths() (or hre.artifacts.getBuildInfoPaths())
51+
// and find the artifacts matching the rootFilePaths.
52+
//
53+
// However, we currently don't store fsPaths neither in artifacts nor in
54+
// buildInfo, which makes the "matching" operation a bit more complicated.
55+
if (noCompile) {
56+
console.warn(
57+
chalk.yellow(
58+
"The --no-compile flag is currently not supported by the test solidity task. The task will always compile all the test contracts before running them.",
59+
),
60+
);
61+
}
62+
4563
const buildOptions: BuildOptions = {
4664
force: false,
4765
buildProfile: hre.globalOptions.buildProfile,

0 commit comments

Comments
 (0)