Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 3 additions & 6 deletions v-next/hardhat-mocha/src/task-action.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,7 @@ import { resolve as pathResolve } from "node:path";
import { HardhatError } from "@nomicfoundation/hardhat-errors";
import { setGlobalOptionsAsEnvVariables } from "@nomicfoundation/hardhat-utils/env";
import { getAllFilesMatching } from "@nomicfoundation/hardhat-utils/fs";
import {
markTestRunDone,
markTestRunStart,
markTestWorkerDone,
} from "hardhat/internal/coverage";
import { markTestRunDone, markTestWorkerDone } from "hardhat/internal/coverage";

interface TestActionArguments {
testFiles: string[];
Expand Down Expand Up @@ -120,7 +116,8 @@ const testWithHardhat: NewTaskActionFunction<TestActionArguments> = async (
// which supports both ESM and CJS
await mocha.loadFilesAsync();

await markTestRunStart("mocha");
// await markTestRunStart("mocha");
await hre.hooks.runParallelHandlers("test", "onTestRunStart", ["mocha"]);

const testFailures = await new Promise<number>((resolve) => {
mocha.run(resolve);
Expand Down
5 changes: 3 additions & 2 deletions v-next/hardhat-node-test-runner/src/task-action.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ import { hardhatTestReporter } from "@nomicfoundation/hardhat-node-test-reporter
import { setGlobalOptionsAsEnvVariables } from "@nomicfoundation/hardhat-utils/env";
import { getAllFilesMatching } from "@nomicfoundation/hardhat-utils/fs";
import { createNonClosingWriter } from "@nomicfoundation/hardhat-utils/stream";
import { markTestRunStart, markTestRunDone } from "hardhat/internal/coverage";
import { markTestRunDone } from "hardhat/internal/coverage";

interface TestActionArguments {
testFiles: string[];
Expand Down Expand Up @@ -130,7 +130,8 @@ const testWithHardhat: NewTaskActionFunction<TestActionArguments> = async (
return failures;
}

await markTestRunStart("nodejs");
// await markTestRunStart("nodejs");
await hre.hooks.runParallelHandlers("test", "onTestRunStart", ["nodejs"]);

const testFailures = await runTests();

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
import type { TestHooks } from "hardhat/types/hooks";

import { markTestRunStart } from "../helpers.js";

export default async (): Promise<Partial<TestHooks>> => {
const handlers: Partial<TestHooks> = {
onTestRunStart: async (_context, id) => {
console.log(`onTestRunStart coverage hook handler called with id: ${id}`);
await markTestRunStart(id);
},
};

return handlers;
};
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ const hardhatPlugin: HardhatPlugin = {
clean: () => import("./hook-handlers/clean.js"),
hre: () => import("./hook-handlers/hre.js"),
solidity: () => import("./hook-handlers/solidity.js"),
test: () => import("./hook-handlers/test.js"),
},
npmPackage: "hardhat",
};
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,11 +19,7 @@ import { createNonClosingWriter } from "@nomicfoundation/hardhat-utils/stream";
import { HardhatRuntimeEnvironmentImplementation } from "../../core/hre.js";
import { isSupportedChainType } from "../../edr/chain-type.js";
import { ArtifactManagerImplementation } from "../artifacts/artifact-manager.js";
import {
markTestRunDone,
markTestRunStart,
markTestWorkerDone,
} from "../coverage/helpers.js";
import { markTestRunDone, markTestWorkerDone } from "../coverage/helpers.js";

import { getEdrArtifacts, getBuildInfos } from "./edr-artifacts.js";
import {
Expand Down Expand Up @@ -148,7 +144,8 @@ const runSolidityTests: NewTaskActionFunction<TestActionArguments> = async (
const options: RunOptions =
solidityTestConfigToRunOptions(solidityTestConfig);

await markTestRunStart("solidity");
// await markTestRunStart("solidity");
await hre.hooks.runParallelHandlers("test", "onTestRunStart", ["solidity"]);

const runStream = run(
chainType,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,5 +39,7 @@ declare module "../../../types/hooks.js" {
filePath: string,
) => Promise<string | undefined>,
) => Promise<string | undefined>;

onTestRunStart(context: HookContext, id: string): Promise<void>;
}
}
Loading