Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: forge test snapshot flags #9710

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

turbocrime
Copy link

@turbocrime turbocrime commented Jan 18, 2025

Motivation

fixes #9697

Solution

i've added command-line flags and an environment variable FORGE_SNAPSHOT_EMIT which allow a user to control snapshot generation.

i also slightly refactored the use of environment variable FORGE_SNAPSHOT_CHECK.

existing default behaviors are maintained.

Comment on lines +126 to +127
#[arg(long, env = "FORGE_SNAPSHOT_EMIT", action = ArgAction::Set, default_value="true", default_missing_value = "true", require_equals=true, num_args = 0..=1)]
snapshot_emit: bool,
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this is a little strange but it's the only way to get decent behavior out of clap

@@ -662,7 +670,7 @@ impl TestArgs {
if !gas_snapshots.is_empty() {
// Check for differences in gas snapshots if `FORGE_SNAPSHOT_CHECK` is set.
// Exiting early with code 1 if differences are found.
if std::env::var("FORGE_SNAPSHOT_CHECK").is_ok() {
if self.snapshot_check {
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

direct env var access is now moved to another clap flag.

the behavior now supports 'false' values as well, instead of just conditioning on presence.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
Status: No status
Development

Successfully merging this pull request may close these issues.

feat: provide some way to disable generation of section snapshots by the snapshot cheatcodes
1 participant