diff --git a/Library/Homebrew/test/cask/installer_spec.rb b/Library/Homebrew/test/cask/installer_spec.rb index 00411028f6..e9da105157 100644 --- a/Library/Homebrew/test/cask/installer_spec.rb +++ b/Library/Homebrew/test/cask/installer_spec.rb @@ -16,27 +16,31 @@ describe Cask::Installer, :cask do expect(caffeine.config.appdir.join("Caffeine.app")).to be_a_directory end - [ - ["HFS+", "container-dmg"], - ["APFS", "container-apfs-dmg"], - ].each do |filesystem, cask| - it "works with #{filesystem} dmg-based Casks" do - asset = Cask::CaskLoader.load(cask_path(cask)) - diskutil_list_command = "diskutil list | grep '/dev'" + it "works with HFS+ dmg-based Casks" do + asset = Cask::CaskLoader.load(cask_path("container-dmg")) - sleep(1) - original_diskutil_list = `#{diskutil_list_command}` + described_class.new(asset).install - described_class.new(asset).install + expect(Cask::Caskroom.path.join("container-dmg", asset.version)).to be_a_directory + expect(asset.config.appdir.join("container")).to be_a_file + end - expect(Cask::Caskroom.path.join(cask, asset.version)).to be_a_directory - expect(asset.config.appdir.join("container")).to be_a_file + it "works with APFS dmg-based Casks" do + asset = Cask::CaskLoader.load(cask_path("container-apfs-dmg")) + diskutil_list_command = "diskutil list | grep '/dev'" - sleep(2) - expect { system diskutil_list_command } - .to output(original_diskutil_list) - .to_stdout_from_any_process - end + sleep 5 + original_diskutil_list = `#{diskutil_list_command}` + + described_class.new(asset).install + + expect(Cask::Caskroom.path.join("container-apfs-dmg", asset.version)).to be_a_directory + expect(asset.config.appdir.join("container")).to be_a_file + + sleep 5 + expect { system diskutil_list_command } + .to output(original_diskutil_list) + .to_stdout_from_any_process end it "works with tar-gz-based Casks" do diff --git a/Library/Homebrew/unpack_strategy/dmg.rb b/Library/Homebrew/unpack_strategy/dmg.rb index 866d18208e..f758c1a78c 100644 --- a/Library/Homebrew/unpack_strategy/dmg.rb +++ b/Library/Homebrew/unpack_strategy/dmg.rb @@ -96,15 +96,11 @@ module UnpackStrategy # For HFS, just use # For APFS, find the corresponding to - eject_paths = if disk_info.success? - disk_info.plist - .fetch("APFSPhysicalStores", []) - .map { |store| store["APFSPhysicalStore"] } - .compact - .presence || [path] - else - [path] - end + eject_paths = disk_info.plist + .fetch("APFSPhysicalStores", []) + .map { |store| store["APFSPhysicalStore"] } + .compact + .presence || [path] eject_paths.each do |eject_path| system_command! "diskutil",