Skip to content

bug: forge test deletes any existing snapshots directory by design #9477

Closed
@smartcontracts

Description

Component

Forge

Have you ensured that all of these are up to date?

  • Foundry
  • Foundryup

What version of Foundry are you on?

forge 0.2.0 (e5dbb7a 2024-12-03T00:25:01.006590000Z)

What command(s) is the bug in?

forge test

Operating System

macOS (Apple Silicon)

Describe the bug

Running forge test in our repository seems to delete any existing "snapshots" folder if it already exists. We use a folder called "snapshots" to contain all of our snapshots, so this folder isn't exclusive to forge things. I've gotten around this for now by changing our foundry.toml to set the configured snapshots folder to a fake directory.

From a quick glance it looks like this is the source of the issue:

// Remove snapshot directory.
let snapshot_dir = project.root().join(&self.snapshots);
if snapshot_dir.exists() {
let _ = fs::remove_dir_all(&snapshot_dir);
}

I haven't checked what this is actually being used for but if I have some time later I might take a stab at a fix.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Assignees

Labels

Type

No type

Projects

  • Status

    Done

Relationships

None yet

Development

No branches or pull requests

Issue actions