Aggregate --gas-stats output for multi-runner test execution#8036
Aggregate --gas-stats output for multi-runner test execution#8036
--gas-stats output for multi-runner test execution#8036Conversation
🦋 Changeset detectedLatest commit: 126259a The changes in this PR will be included in the next version bump. This PR includes changesets to release 1 package
Not sure what this means? Click here to learn what changesets are. Click here if you're a maintainer who wants to add another changeset to this PR |
There was a problem hiding this comment.
Pull request overview
Updates Hardhat’s --gas-stats behavior to produce a single consolidated gas statistics report when multiple test runners are executed in one test invocation, matching the aggregation approach already used by the coverage plugin. It also refactors internal access to _coverage and _gasAnalytics to go through helper functions instead of direct property access.
Changes:
- Aggregate gas measurements across multiple runner IDs and print one final gas stats table at the end of the overall
testtask. - Add
enableReport/disableReportsupport to gas analytics to suppress per-runner reporting during multi-runner execution. - Introduce/get/use
get*/set*helper functions for coverage and gas analytics managers across tasks and hook handlers; update tests accordingly.
Reviewed changes
Copilot reviewed 9 out of 14 changed files in this pull request and generated no comments.
Show a summary per file
| File | Description |
|---|---|
| v-next/hardhat/src/internal/builtin-plugins/test/task-action.ts | Disables per-runner reporting and prints a single aggregated coverage + gas stats report at the end using runner IDs. |
| v-next/hardhat/src/internal/builtin-plugins/solidity-test/task-action.ts | Routes coverage collection and gas measurement recording through the new manager helpers. |
| v-next/hardhat/src/internal/builtin-plugins/gas-analytics/gas-analytics-manager.ts | Adds report enable/disable gating and supports loading measurements from multiple runner IDs. |
| v-next/hardhat/src/internal/builtin-plugins/gas-analytics/types.ts | Extends the manager interface with enableReport() / disableReport(). |
| v-next/hardhat/src/internal/builtin-plugins/gas-analytics/helpers.ts | Adds getGasAnalyticsManager/setGasAnalyticsManager helpers and keeps backward-compatible exported test hooks. |
| v-next/hardhat/src/internal/builtin-plugins/gas-analytics/hook-handlers/test.ts | Uses getGasAnalyticsManager instead of direct _gasAnalytics access. |
| v-next/hardhat/src/internal/builtin-plugins/gas-analytics/hook-handlers/hre.ts | Uses setGasAnalyticsManager to attach the manager to the HRE. |
| v-next/hardhat/src/internal/builtin-plugins/coverage/helpers.ts | Adds getCoverageManager/setCoverageManager helpers and keeps backward-compatible exported test hooks. |
| v-next/hardhat/src/internal/builtin-plugins/coverage/hook-handlers/test.ts | Uses getCoverageManager instead of direct _coverage access. |
| v-next/hardhat/src/internal/builtin-plugins/coverage/hook-handlers/solidity.ts | Uses getCoverageManager when recording metadata during Solidity preprocessing. |
| v-next/hardhat/src/internal/builtin-plugins/coverage/hook-handlers/hre.ts | Uses setCoverageManager to attach the manager to the HRE. |
| v-next/hardhat/test/internal/builtin-plugins/gas-analytics/gas-analytics-manager.ts | Adds tests for multi-ID loading and aggregated reporting behavior (including report enable/disable). |
| v-next/hardhat/test/internal/builtin-plugins/coverage/coverage-manager.ts | Updates tests to use setCoverageManager helper and adjusts console suppression/comment formatting. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
--gas-stats output for multi-runner test execution
eec7cb6 to
e62d33c
Compare
alcuadrado
left a comment
There was a problem hiding this comment.
Left a tiny comment, but LGTM
…o encapsulate internal _coverage/_gasAnalytics access
…o encapsulate internal _coverage/_gasAnalytics writes
…-analytics-manager.ts Co-authored-by: Patricio Palladino <email@patriciopalladino.com>
8ab302f to
126259a
Compare
When multiple test runners (e.g.,
solidity+nodejs) are used together,--gas-statsnow aggregates gas measurements across all runners and prints a single consolidated table at the end, instead of printing separate tables per runner. Follows the same approach used in thecoverageplugin.Also includes minor refactors to encapsulate internal
_coverage/_gasAnalyticsproperty access behind helper functions (getCoverageManager,setCoverageManager,getGasAnalyticsManager,setGasAnalyticsManager).This PR can be reviewed one commit at a time.
Closes #7500