Class: Homebrew::DevCmd::Test Private

Inherits:
AbstractCommand show all
Defined in:
sorbet/rbi/dsl/homebrew/dev_cmd/test.rbi,
dev-cmd/test.rb

Overview

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.

DO NOT EDIT MANUALLY This is an autogenerated file for dynamic methods in Homebrew::DevCmd::Test. Please instead update this file by running bin/tapioca dsl Homebrew::DevCmd::Test.

Defined Under Namespace

Classes: Args

Instance Method Summary collapse

Methods inherited from AbstractCommand

command, command_name, dev_cmd?, #initialize, parser

Constructor Details

This class inherits a constructor from Homebrew::AbstractCommand

Instance Method Details

#argsHomebrew::DevCmd::Test::Args

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.



9
# File 'sorbet/rbi/dsl/homebrew/dev_cmd/test.rbi', line 9

def args; end

#runvoid

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.



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
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
# File 'dev-cmd/test.rb', line 33

def run
  Homebrew.install_bundler_gems!(groups: ["formula_test"], setup_path: false)

  require "formula_assertions"
  require "formula_free_port"

  args.named.to_resolved_formulae.each do |f|
    # Cannot test uninstalled formulae
    unless f.latest_version_installed?
      ofail "Testing requires the latest version of #{f.full_name}"
      next
    end

    # Cannot test formulae without a test method
    unless f.test_defined?
      ofail "#{f.full_name} defines no test"
      next
    end

    # Don't test unlinked formulae
    if !args.force? && !f.keg_only? && !f.linked?
      ofail "#{f.full_name} is not linked"
      next
    end

    # Don't test formulae missing test dependencies
    missing_test_deps = f.recursive_dependencies do |dependent, dependency|
      Dependency.prune if dependency.installed?
      next if dependency.test? && dependent == f

      Dependency.prune unless dependency.required?
    end.map(&:to_s)
    unless missing_test_deps.empty?
      ofail "#{f.full_name} is missing test dependencies: #{missing_test_deps.join(" ")}"
      next
    end

    oh1 "Testing #{f.full_name}"

    env = ENV.to_hash

    begin
      exec_args = HOMEBREW_RUBY_EXEC_ARGS + %W[
        --
        #{HOMEBREW_LIBRARY_PATH}/test.rb
        #{f.path}
      ].concat(args.options_only)

      exec_args << "--HEAD" if f.head?

      Utils.safe_fork do |error_pipe|
        if Sandbox.available?
          sandbox = Sandbox.new
          f.logs.mkpath
          sandbox.record_log(f.logs/"test.sandbox.log")
          sandbox.allow_write_temp_and_cache
          sandbox.allow_write_log(f)
          sandbox.allow_write_xcode
          sandbox.allow_write_path(HOMEBREW_PREFIX/"var/cache")
          sandbox.allow_write_path(HOMEBREW_PREFIX/"var/homebrew/locks")
          sandbox.allow_write_path(HOMEBREW_PREFIX/"var/log")
          sandbox.allow_write_path(HOMEBREW_PREFIX/"var/run")
          sandbox.deny_all_network_except_pipe(error_pipe) unless f.class.network_access_allowed?(:test)
          sandbox.exec(*exec_args)
        else
          exec(*exec_args)
        end
      end
    rescue Exception => e # rubocop:disable Lint/RescueException
      retry if retry_test?(f)
      ofail "#{f.full_name}: failed"
      $stderr.puts e, Utils::Backtrace.clean(e)
    ensure
      ENV.replace(env)
    end
  end
end