Skip to content

Commit dbc5caa

Browse files
committed
use defer to make dmg unmounting more reliable
1 parent 886e26e commit dbc5caa

File tree

3 files changed

+18
-1
lines changed

3 files changed

+18
-1
lines changed

Cargo.lock

Lines changed: 7 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

git-discover/Cargo.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,4 +27,5 @@ git-testtools = { path = "../tests/tools" }
2727
is_ci = "1.1.1"
2828

2929
[target.'cfg(target_os = "macos")'.dev-dependencies]
30+
defer = "0.1.0"
3031
tempfile = "3.2.0"

git-discover/tests/upwards/mod.rs

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -220,6 +220,15 @@ fn cross_fs() -> crate::Result {
220220
.arg(&dmg_file)
221221
.status()?;
222222

223+
// Ensure that the mount point is always cleaned up
224+
let defer_detach = defer::defer(|| {
225+
Command::new("hdiutil")
226+
.arg("detach")
227+
.arg(mount_point.path())
228+
.status()
229+
.expect("detach temporary test dmg filesystem successfully");
230+
});
231+
223232
// Symlink the mount point into the repo
224233
symlink(mount_point.path(), top_level_repo.path().join("remote"))?;
225234

@@ -250,7 +259,7 @@ fn cross_fs() -> crate::Result {
250259
);
251260

252261
// Cleanup
253-
Command::new("hdiutil").arg("detach").arg(mount_point.path()).status()?;
262+
drop(defer_detach);
254263

255264
Ok(())
256265
}

0 commit comments

Comments
 (0)