Skip to content

Commit

Permalink
Merge pull request #718 from carlocab/more-source-dependents
Browse files Browse the repository at this point in the history
formulae_dependents: build more dependents from source
  • Loading branch information
carlocab authored Nov 24, 2021
2 parents 65bf48f + c26b3d0 commit 9b5f583
Showing 1 changed file with 13 additions and 17 deletions.
30 changes: 13 additions & 17 deletions lib/tests/formulae_dependents.rb
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,11 @@ def run!(args:)

private

def bottled_or_built?(formula)
built_formulae = @testing_formulae - skipped_or_failed_formulae
bottled?(formula) || built_formulae.include?(formula.full_name)
end

def dependent_formulae!(formula_name, args:)
cleanup_during!(args: args)

Expand All @@ -30,13 +35,6 @@ def dependent_formulae!(formula_name, args:)
dependents_for_formula(formula, formula_name, args: args)

source_dependents.each do |dependent|
next if dependent.deps.any? do |d|
f = d.to_formula
built_formulae = @testing_formulae - skipped_or_failed_formulae

!bottled?(f) && built_formulae.exclude?(f.full_name)
end

install_dependent(dependent, testable_dependents, build_from_source: true, args: args)
install_dependent(dependent, testable_dependents, args: args) if bottled?(dependent)
end
Expand All @@ -49,8 +47,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 @@ -77,16 +73,16 @@ 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
# we should not. The criteria is that a dependent must have bottled dependencies, and
# either the `--build-dependents-from-source` flag was passed or a dependent has no
# bottle on the current OS.
source_dependents, dependents = dependents.partition do |dependent, deps|
next false if OS.linux? && dependent.requirements.exclude?(LinuxRequirement.new)

next false if !args.build_dependents_from_source? || build_dependents_from_source_disabled
all_deps_bottled_or_built = deps.all? { |d| bottled_or_built?(d.to_formula) }
next all_deps_bottled_or_built if args.build_dependents_from_source?

@testing_formulae.include?(full_name)
end
all_deps_bottled_or_built && !bottled?(dependent, no_older_versions: true)
end

# From the non-source list, get rid of any dependents we are only a build dependency to
Expand Down

0 comments on commit 9b5f583

Please sign in to comment.