Skip to content

Commit

Permalink
Merge pull request #5877 from NomicFoundation/alternative-test-messages
Browse files Browse the repository at this point in the history
Change how we print the titles of the test tasks
  • Loading branch information
alcuadrado authored Oct 29, 2024
2 parents 2ebd3c9 + 4c4234e commit b7fb81b
Show file tree
Hide file tree
Showing 5 changed files with 23 additions and 8 deletions.
6 changes: 6 additions & 0 deletions v-next/hardhat-mocha-test-runner/src/task-action.ts
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,10 @@ const testWithHardhat: NewTaskActionFunction<TestActionArguments> = async (

const files = await getTestFiles(testFiles, hre.config);

if (files.length === 0) {
return;
}

const tsx = fileURLToPath(import.meta.resolve("tsx/esm"));
process.env.NODE_OPTIONS = `--import ${tsx}`;

Expand Down Expand Up @@ -81,6 +85,8 @@ const testWithHardhat: NewTaskActionFunction<TestActionArguments> = async (
}
testsAlreadyRun = true;

console.log("Running Mocha tests");

// This instructs Mocha to use the more verbose file loading infrastructure
// which supports both ESM and CJS
await mocha.loadFilesAsync();
Expand Down
7 changes: 7 additions & 0 deletions v-next/hardhat-node-test-runner/src/task-action.ts
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,10 @@ const testWithHardhat: NewTaskActionFunction<TestActionArguments> = async (

const files = await getTestFiles(testFiles, hre.config);

if (files.length === 0) {
return 0;
}

const tsx = fileURLToPath(import.meta.resolve("tsx/esm"));
process.env.NODE_OPTIONS = `--import ${tsx}`;

Expand All @@ -79,6 +83,9 @@ const testWithHardhat: NewTaskActionFunction<TestActionArguments> = async (
testOnlyMessage,
});

console.log("Running node:test tests");
console.log();

const reporterStream = run(nodeTestOptions)
.on("test:fail", (event) => {
if (event.details.type === "suite") {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,13 @@ const runSolidityTests: NewTaskActionFunction<TestActionArguments> = async (
)
).filter((artifact) => artifact !== undefined);

if (testSuiteIds.length === 0) {
return;
}

console.log("Running Solidity tests");
console.log();

const config = {
projectRoot: hre.config.paths.root,
};
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -570,6 +570,8 @@ export class SolidityBuildSystemImplementation implements SolidityBuildSystem {
}

async #downloadConfiguredCompilers(quiet = false): Promise<void> {
// TODO: For the alpha release, we always print this message
quiet = false;
if (this.#downloadedCompilers) {
return;
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,9 +1,5 @@
import type { NewTaskActionFunction } from "../../../types/tasks.js";

import chalk from "chalk";

import { formatTaskId } from "../../core/tasks/utils.js";

interface TestActionArguments {
noCompile: boolean;
}
Expand All @@ -19,14 +15,11 @@ const runAllTests: NewTaskActionFunction<TestActionArguments> = async (
}

for (const subtask of thisTask.subtasks.values()) {
console.log(
chalk.bold(`Running the subtask "${formatTaskId(subtask.id)}"`),
);
await subtask.run({ noCompile: true });
console.log();
}

if (process.exitCode !== 0) {
if (process.exitCode !== undefined && process.exitCode !== 0) {
console.error("Test run failed");
}
};
Expand Down

0 comments on commit b7fb81b

Please sign in to comment.