You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
the env var FORGE_SNAPSHOT_CHECK is available to enable checking section snapshots (those snapshots defined with vm.startSnapshotGas). but its use is not consistent with other configuration.
// 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(){
problems
there is no equivalent command-line flag
configuration is not located with other env var access. a call to std::env::var appears directly in the conditional
the value of the env var is not parsed (so FORGE_SNAPSHOT_CHECK="false" or even FORGE_SNAPSHOT_CHECK="" creates the same behavior as FORGE_SNAPSHOT_CHECK="true")
consistency
it seems like figment is intended to provide access to configuration, but it is inconsistently used across the project. there are other examples of configuration that does not arrive via figment.
in this case, the forge test command uses clap arg macros for command-line arguments, and some of the arg identify env variables as sources of argument values. the defined clap args are then merged into figment with merge_impl_figment_convert
however, FORGE_SNAPSHOT_CHECK has no associated arg, because it is accessed directly, and is not merged.
suggestions
access to env should be collected in one location
a command-line option should be available to override any env configuration
env booleans should be parsed for value instead of a simple presence condition
defining clap args for snapshot check could achieve the suggestions.
The text was updated successfully, but these errors were encountered:
zerosnacks
changed the title
improve forge test configuration for checking gas section snapshots
feat: improve forge test configuration for checking gas section snapshots
Jan 22, 2025
Component
Forge
Have you ensured that all of these are up to date?
What version of Foundry are you on?
forge Version: 0.3.1-nightly Commit SHA: fea3885 Build Timestamp: 2025-01-21T16:53:17.552998000Z (1737478397) Build Profile: release
What version of Foundryup are you on?
No response
What command(s) is the bug in?
forge
Operating System
macOS (Apple Silicon)
Describe the bug
the env var
FORGE_SNAPSHOT_CHECK
is available to enable checking section snapshots (those snapshots defined withvm.startSnapshotGas
). but its use is not consistent with other configuration.foundry/crates/forge/bin/cmd/test/mod.rs
Lines 665 to 667 in 5993795
problems
std::env::var
appears directly in the conditionalFORGE_SNAPSHOT_CHECK="false"
or evenFORGE_SNAPSHOT_CHECK=""
creates the same behavior asFORGE_SNAPSHOT_CHECK="true"
)consistency
it seems like
figment
is intended to provide access to configuration, but it is inconsistently used across the project. there are other examples of configuration that does not arrive viafigment
.in this case, the
forge test
command uses claparg
macros for command-line arguments, and some of thearg
identify env variables as sources of argument values. the defined clap args are then merged into figment withmerge_impl_figment_convert
however,
FORGE_SNAPSHOT_CHECK
has no associatedarg
, because it is accessed directly, and is not merged.suggestions
defining clap
arg
s for snapshot check could achieve the suggestions.The text was updated successfully, but these errors were encountered: