Don't remove cask directories when upgrading. by JBYoshi · Pull Request #15138 · Homebrew/brew (original) (raw)
That's the gist of it.
I haven't figured out an automated test case yet since I don't know of any APIs that Apple exposes for the dock / Launchpad. However, I have been manually testing using the 1password
cask. Here's my current procedure:
- Add a
sleep(10)
call to the end ofCask::Artifact::Moved::delete()
. (This accounts for the timing sensitivity discussed in the original issue.) - Install an old version of the
1password
cask (I used 8.10.1). - Pin the 1Password app to the dock and/or add it to a folder in Launchpad.
- Change the cask file to a newer version (I used 8.10.3).
- Run
brew upgrade
.
With the original code, the 1Password app will disappear from the dock and will be moved out of the folder in Launchpad. With this code, the app remains in the dock and the Launchpad folder.
One possible automated test case could be making sure the inode number stays the same before and after the upgrade. That wouldn't check Launchpad or the dock directly but it will ensure the directory isn't deleted.