Class: Homebrew::TestBot::FormulaeDependents Private

Inherits:
TestFormulae show all
Defined in:
test_bot/formulae_dependents.rb

This class is part of a private API. This class may only be used in the Homebrew/brew repository. Third parties should avoid using this class if possible, as it may be removed or changed without warning.

Instance Attribute Summary collapse

Attributes inherited from TestFormulae

#artifact_cache, #skipped_or_failed_formulae

Attributes inherited from Test

#steps

Instance Method Summary collapse

Methods inherited from Test

#failed_steps, #ignored_steps

Methods included from Utils::Output::Mixin

#odebug, #odeprecated, #odie, #odisabled, #ofail, #oh1, #oh1_title, #ohai, #ohai_title, #onoe, #opoo, #opoo_outside_github_actions, #pretty_deprecated, #pretty_disabled, #pretty_duration, #pretty_installed, #pretty_outdated, #pretty_uninstalled

Constructor Details

#initialize(tap:, git:, dry_run:, fail_fast:, verbose:) ⇒ void

This method is part of a private API. This method may only be used in the Homebrew/brew repository. Third parties should avoid using this method if possible, as it may be removed or changed without warning.

Parameters:

  • tap (Tap, nil)
  • git (String, nil)
  • dry_run (Boolean)
  • fail_fast (Boolean)
  • verbose (Boolean)


22
23
24
25
26
27
# File 'test_bot/formulae_dependents.rb', line 22

def initialize(tap:, git:, dry_run:, fail_fast:, verbose:)
  super
  @testing_formulae_with_tested_dependents = T.let([], T::Array[String])
  @tested_dependents_list = T.let(nil, T.nilable(Pathname))
  @dependent_testing_formulae = T.let([], T::Array[String])
end

Instance Attribute Details

#tested_formulae=(value) ⇒ Array<String> (writeonly)

This method is part of a private API. This method may only be used in the Homebrew/brew repository. Third parties should avoid using this method if possible, as it may be removed or changed without warning.

Returns:



11
12
13
# File 'test_bot/formulae_dependents.rb', line 11

def tested_formulae=(value)
  @tested_formulae = value
end

#testing_formulae=(value) ⇒ Array<String> (writeonly)

This method is part of a private API. This method may only be used in the Homebrew/brew repository. Third parties should avoid using this method if possible, as it may be removed or changed without warning.

Returns:



8
9
10
# File 'test_bot/formulae_dependents.rb', line 8

def testing_formulae=(value)
  @testing_formulae = value
end

Instance Method Details

#run!(args:) ⇒ void

This method is part of a private API. This method may only be used in the Homebrew/brew repository. Third parties should avoid using this method if possible, as it may be removed or changed without warning.

This method returns an undefined value.

Parameters:



30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
# File 'test_bot/formulae_dependents.rb', line 30

def run!(args:)
  test "brew", "untap", "--force", "homebrew/cask" if !tap&.core_cask_tap? && CoreCaskTap.instance.installed?

  installable_bottles = @tested_formulae - @skipped_or_failed_formulae
  unneeded_formulae = @tested_formulae - @testing_formulae
  @skipped_or_failed_formulae += unneeded_formulae

  info_header "Skipped or failed formulae:"
  puts skipped_or_failed_formulae

  @testing_formulae_with_tested_dependents = []
  @tested_dependents_list = Pathname("tested-dependents-#{Utils::Bottles.tag}.txt")

  @dependent_testing_formulae = sorted_formulae - skipped_or_failed_formulae

  install_formulae_if_needed_from_bottles!(installable_bottles, args:)

  # TODO: move to extend/os
  # rubocop:todo Homebrew/MoveToExtendOS
  artifact_specifier = if OS.linux?
    "{linux,ubuntu}"
  else
    "{macos-#{MacOS.version},#{MacOS.version}-#{Hardware::CPU.arch}}"
  end
  # rubocop:enable Homebrew/MoveToExtendOS

  download_artifacts_from_previous_run!("dependents{,_#{artifact_specifier}*}", dry_run: args.dry_run?)
  @skip_candidates = T.let(
    if (tested_dependents_cache = artifact_cache/@tested_dependents_list).exist?
      tested_dependents_cache.read.split("\n")
    else
      []
    end,
    T.nilable(T::Array[String]),
  )

  @dependent_testing_formulae.each do |formula_name|
    dependent_formulae!(formula_name, args:)
    puts
  end

  return unless GitHub::Actions.env_set?

  # Remove `bash` after it is tested, since leaving a broken `bash`
  # installation in the environment can cause issues with subsequent
  # GitHub Actions steps.
  return unless @dependent_testing_formulae.include?("bash")

  test "brew", "uninstall", "--formula", "--force", "bash"
end