Skip to content

Commit 7326b79

Browse files
mattsseampcode-com
andauthored
fix: bind TempDir guard in clone test to prevent premature cleanup (#13471)
Amp-Thread-ID: https://ampcode.com/threads/T-019c6840-d225-723a-bf92-46e4e29c7ad1 Co-authored-by: Amp <amp@ampcode.com>
1 parent 662b35a commit 7326b79

1 file changed

Lines changed: 2 additions & 2 deletions

File tree

crates/forge/src/cmd/clone.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1090,7 +1090,8 @@ mod tests {
10901090

10911091
/// Run the clone command with the specified contract address and assert the compilation.
10921092
async fn one_test_case(address: Address, check_compilation_result: bool) {
1093-
let mut project_root = tempfile::tempdir().unwrap().path().to_path_buf();
1093+
let temp_dir = tempfile::tempdir().unwrap();
1094+
let mut project_root = temp_dir.path().to_path_buf();
10941095
let client = mock_etherscan(address);
10951096
let meta = CloneArgs::collect_metadata_from_client(address, &client).await.unwrap();
10961097
CloneArgs::init_an_empty_project(&project_root, DependencyInstallOpts::default())
@@ -1115,7 +1116,6 @@ mod tests {
11151116
pick_creation_info(&address.to_string()).expect("creation code not found");
11161117
assert_compilation_result(rv, contract_name, stripped_creation_code);
11171118
}
1118-
std::fs::remove_dir_all(project_root).unwrap();
11191119
}
11201120

11211121
#[tokio::test(flavor = "multi_thread")]

0 commit comments

Comments
 (0)