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:

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.