* Write failing tests for issue #18638
* Fix `Hbc::SystemCommand` to avoid deadlocks; ref #18638
The current implementation of `Hbc::SystemCommand` uses the `Open3` library in a way that causes a deadlock in cases where `STDERR` grows beyond a certain size.
This commit fixes the issue by following the practice suggested in the Ruby documentation, i. e. choosing a stream selection method that avoids deadlocks.
* Change app artifact to move instead of link
First step towards change in installation behavior mentioned in [13201]
* Fix handling of binaries linked from inside of app bundles
Also adds `appdir` method for interpolation in stanzas
* Change appdir to root Applications directory
* Update 2-app tests
* Refactor: add options, ivars to `Installer`, `Download`
In preparation for upcoming changes, this commit cleans up some code. The commit includes:
- In order to reduce unnecessary object passing, make both the `force` and `skip_cask_deps` option into instance variables of the `Installer` class
- Introduce options hashes to initializers of both the `Installer` and `Download` class
- When the `install --force` command enters the fetch phase, make it explicit in the code that fetching is never enforced in that case.
- Update tests
* Force overwrite artifacts on `--force` reinstall
This commit changes the behavior of a `Moved` artifact such that if the target already exists, `brew cask install --force` will remove the existing target before moving the staged artifact.
In that case, the warning message will say *overwriting* instead of *not moving*.
The behavior of plain `brew cask install` remains unchanged; the same goes for the warning message for that case.
* Change remaining artifacts to move instead of symlink
* Update casks to use appdir in binary paths
* Forcibly overwrite artifacts, modifying flags and using `sudo` if needed
- This commit implements [the proposed behavior for `install --force`](https://github.com/caskroom/homebrew-cask/pull/13966#issuecomment-220830387) when a target already exists and has either permission problems or is not owned by the user.
- The changes apply only when the `force` option is given.
- Reused the existing safeguard from the `.pkg` artifact to prevent deleting important directories by bug or mistake
- The two existing blacklists `SYSTEM_DIRS` and `UNDELETABLE_DIRS` have been consolidated into the `Hbc::MacOS` module.
- `UNDELETABLE_DIRS` now also contains all the entries from `SYSTEM_DIRS` which was a to-do anyway.
- The two blacklists are now also frozen for good measure.
- The utility method `permissions_rmtree` was moved to `Hbc::Utils`.
- The `tried_permissions` part in `Utils` now falls back correctly when there are also ownership issues at the same time.
- Introduced a separate `current_user` method for mocking.
- Added an optional feature to `FakeSystemCommand` so it can now act as a proxy to `SystemCommand`.
- Added tests for various `permissions_rmtree` cases.
* Place argument separator '--' before all arguments to chmod where it had
been incorrectly placed after the permissions argument.
* The separator should be after any options (like '-R' or '-N') but before
any permissions, even when they look like options, like '-r'.
* Add '--' to calls to chmod where it was missing for consistency.