From 06c9bae613b392087bf0df0a38823f5984111669 Mon Sep 17 00:00:00 2001 From: Roland Walker Date: Wed, 18 Jun 2014 21:32:04 -0400 Subject: [PATCH] don't check error code of `diskutil eject` nstead, determine success by directly testing the intended effect: does the mount path still exist? Also: - retry once on failure. - silent success if the given mount point did not exist. These changes are intended to help with unpredictable problems with the test suite that manifest frequently on Travis. References: #4975, #4900, #4857 --- lib/cask/container/dmg.rb | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/lib/cask/container/dmg.rb b/lib/cask/container/dmg.rb index a76914476d..6e970ab37b 100644 --- a/lib/cask/container/dmg.rb +++ b/lib/cask/container/dmg.rb @@ -45,7 +45,18 @@ class Cask::Container::Dmg < Cask::Container::Base def eject! @mounts.each do |mount| # realpath is a failsafe against unusual filenames - @command.run!('/usr/sbin/diskutil', :args => ['eject', Pathname.new(mount).realpath]) + mountpath = Pathname.new(mount).realpath + next unless mountpath.exist? + @command.run('/usr/sbin/diskutil', + :args => ['eject', mountpath], + :stderr => :silence) + next unless mountpath.exist? + sleep 1 + @command.run('/usr/sbin/diskutil', + :args => ['eject', mountpath], + :stderr => :silence) + next unless mountpath.exist? + raise CaskError.new "Failed to eject #{mountpath}" end end end