Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
formulae_dependents: apply some optimisations
1. Doing `brew install --only-dependencies` and `brew postinstall` can be quite expensive. Let's defer this to when we're sure we have dependents to test. 2. Calling `brew uses` is slow, because this requires traversing the dependency tree. [*] Let's avoid doing this unless we know we really need to. Here, we test for "needing to" by checking if another `.rb` file in the tap that might be a formula contains a `depends_on` line declaring a dependency on the formula being tested. 3. Restrict the second `brew uses` call to when we are building dependents from source, since that is the only instance where we are interested in the build dependents. While we're here, make sure to call `brew postinstall` on all dependencies that were rebuilt, and not just the one being tested currently. This may address Homebrew#805. Locally, this results in the following speed up for a formula with no dependents: Before ( brew test-bot --only-formulae-dependents --testing-formulae=hello --dry-run) 28.95s user 6.70s system 76% cpu 46.875 total After ( brew test-bot --only-formulae-dependents --testing-formulae=hello --dry-run) 0.91s user 1.02s system 51% cpu 3.738 total This makes testing formulae with dependents slightly slower. However, the vast majority of formulae in Homebrew/core have no dependents (on macOS, at least), so this is likely a net win for the average workflow. [*] Potential future optimisation: calling `Dependency.expand` directly might give us better opportunities to exploit caching.
- Loading branch information