Skip to content

Commit

Permalink
more robust removal of test files in failure case on os specific tests
Browse files Browse the repository at this point in the history
  • Loading branch information
Byron committed May 8, 2022
1 parent 1f3a600 commit 3f6502d
Showing 1 changed file with 9 additions and 5 deletions.
14 changes: 9 additions & 5 deletions src/tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -172,7 +172,6 @@ mod os_limited {
missing.push(path);
}
}
// Good ol' remove to clean up
for path in names.iter() {
std::fs::remove_file(path).ok();
}
Expand Down Expand Up @@ -219,10 +218,15 @@ mod os_limited {
assert!(File::open(path).is_ok());
}
remaining_count = remaining_items.len();
},
_ => panic!(
}
_ => {
for path in names.iter() {
std::fs::remove_file(path).ok();
}
panic!(
"restore_all was expected to return `trash::ErrorKind::RestoreCollision` but did not."
),
);
}
}
let remaining = trash::os_limited::list()
.unwrap()
Expand All @@ -233,7 +237,7 @@ mod os_limited {
trash::os_limited::purge_all(remaining).unwrap();
for path in names.iter() {
// This will obviously fail on the items that both didn't collide and weren't restored.
let _ = std::fs::remove_file(path);
std::fs::remove_file(path).ok();
}
}

Expand Down

0 comments on commit 3f6502d

Please sign in to comment.