Skip to content

Conversation

wellnana
Copy link
Contributor

Add a log if evm_version is not compatible with the solc version, to avoid the confusion of the user.

@wellnana wellnana requested a review from zerosnacks August 25, 2025 15:40
@wellnana wellnana requested a review from zerosnacks August 25, 2025 15:48
@zerosnacks
Copy link
Member

Thanks! Would you mind adding a unit test for this?

For reference:

#[test]
fn test_normalize_defaults() {
figment::Jail::expect_with(|jail| {
jail.create_file(
"foundry.toml",
r"
[default]
solc = '0.8.13'
",
)?;
let loaded = Config::load().unwrap().sanitized();
assert_eq!(loaded.evm_version, EvmVersion::London);
Ok(())
});
}

This shows how to use Snapbox's .stderr_eq to assert the warning:

// Sets up a debuggable test case.
// Run with `cargo test-debugger`.
forgetest!(
#[ignore = "ran manually"]
manual_debug_setup,
|prj, cmd| {
cmd.args(["init", "--force"])
.arg(prj.root())
.assert_success()
.stdout_eq(str![[r#"
Initializing [..]...
Installing forge-std in [..] (url: Some("https://github.com/foundry-rs/forge-std"), tag: None)
Installed forge-std[..]
Initialized forge project
"#]])
.stderr_eq(str![[r#"
Warning: Target directory is not empty, but `--force` was specified
...
"#]]);

Thanks!

@wellnana
Copy link
Contributor Author

Thanks! Would you mind adding a unit test for this?

For reference:

#[test]
fn test_normalize_defaults() {
figment::Jail::expect_with(|jail| {
jail.create_file(
"foundry.toml",
r"
[default]
solc = '0.8.13'
",
)?;
let loaded = Config::load().unwrap().sanitized();
assert_eq!(loaded.evm_version, EvmVersion::London);
Ok(())
});
}

This shows how to use Snapbox's .stderr_eq to assert the warning:

// Sets up a debuggable test case.
// Run with `cargo test-debugger`.
forgetest!(
#[ignore = "ran manually"]
manual_debug_setup,
|prj, cmd| {
cmd.args(["init", "--force"])
.arg(prj.root())
.assert_success()
.stdout_eq(str![[r#"
Initializing [..]...
Installing forge-std in [..] (url: Some("https://github.com/foundry-rs/forge-std"), tag: None)
Installed forge-std[..]
Initialized forge project
"#]])
.stderr_eq(str![[r#"
Warning: Target directory is not empty, but `--force` was specified
...
"#]]);

Thanks!

Thanks for the suggestion! I've implemented the unit test and it passes locally.

However, I'm running into an issue where the test doesn't work properly within the forgetest integration test framework. There seems to be an integration problem that I need to investigate.

I'll need some time to figure this out.

@wellnana
Copy link
Contributor Author

@zerosnacks

  1. Add a cli test for the mismatch of evm_version and solc version
  2. use eprintln instead of warn!, warn! was not printing the message to stderr even with RUST_LOG=warn set, but println! works.

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.

3 participants