Skip to content

Commit

Permalink
formulae_dependents: build more dependents from source
Browse files Browse the repository at this point in the history
If the `--build-dependents-from-source` flag is passed, then all
dependents are built from source. This is the current behaviour.

We change behaviour in two ways:
1. Build unbottled dependents from source if all its dependencies are
   either bottled, or were built earlier in the `test-bot` run.
2. Build Linux-only formulae from source too (either with the
   appropriate flag or when the above condition is true) instead of
   always skipping source builds on Linux.

Building unbottled dependents will be useful for detecting dependents
which should be bottled after Homebrew#714.

This change should also allow us to clean up a bit of code in the
`#dependent_formulae!` method. I've omitted that for now since I have a
pending PR (Homebrew#717) which introduces conflicting changes.
  • Loading branch information
carlocab committed Nov 18, 2021
1 parent 7e3c529 commit 0144acc
Showing 1 changed file with 10 additions and 10 deletions.
20 changes: 10 additions & 10 deletions lib/tests/formulae_dependents.rb
Original file line number Diff line number Diff line change
Expand Up @@ -48,8 +48,6 @@ def dependent_formulae!(formula_name, args:)
def dependents_for_formula(formula, formula_name, args:)
info_header "Determining dependents..."

build_dependents_from_source_disabled = OS.linux? && tap.present? && tap.full_name == "Homebrew/homebrew-core"

uses_args = %w[--formula --include-build --include-test]
uses_args << "--recursive" unless args.skip_recursive_dependents?
dependents = with_env(HOMEBREW_STDERR: "1") do
Expand All @@ -76,15 +74,17 @@ def dependents_for_formula(formula, formula_name, args:)
end)

# Split into dependents that we could potentially be building from source and those
# we should not. The criteria is that it depends on a formula in the allowlist and
# that formula has been, or will be, built in this test run.
source_dependents, dependents = dependents.partition do |_, deps|
deps.any? do |d|
full_name = d.to_formula.full_name

next false if !args.build_dependents_from_source? || build_dependents_from_source_disabled
# we should not. The criteria is that either the `--build-dependents-from-source` flag
# was passed or a dependent has no bottle but has useable dependencies.
source_dependents, dependents = dependents.partition do |dependent, deps|
next false if OS.linux? && dependent.requirements.exclude?(LinuxRequirement.new)
next true if args.build_dependents_from_source?

!bottled?(dependent, no_older_versions: true) && deps.all? do |dep|
f = dep.to_formula
built_formulae = @testing_formulae - skipped_or_failed_formulae

@testing_formulae.include?(full_name)
bottled?(f) || built_formulae.include?(f.full_name)
end
end

Expand Down

0 comments on commit 0144acc

Please sign in to comment.