Pass keep_tmp? and interactive? instead of using global args.
This commit is contained in:
parent
a6bc9e155a
commit
6b0b25cd00
@ -121,12 +121,11 @@ class Build
|
||||
|
||||
formula.update_head_version
|
||||
|
||||
formula.brew(fetch: false) do |_formula, staging|
|
||||
formula.brew(fetch: false, keep_tmp: args.keep_tmp?, interactive: args.interactive?) do |_formula, _staging|
|
||||
# For head builds, HOMEBREW_FORMULA_PREFIX should include the commit,
|
||||
# which is not known until after the formula has been staged.
|
||||
ENV["HOMEBREW_FORMULA_PREFIX"] = formula.prefix
|
||||
|
||||
staging.retain! if args.keep_tmp?
|
||||
formula.patch
|
||||
|
||||
if args.git?
|
||||
|
||||
@ -123,6 +123,6 @@ module Homebrew
|
||||
end
|
||||
end
|
||||
ensure
|
||||
FileUtils.rm_rf "update-test" unless Homebrew.args.keep_tmp?
|
||||
FileUtils.rm_rf "update-test" unless args.keep_tmp?
|
||||
end
|
||||
end
|
||||
|
||||
@ -1163,11 +1163,11 @@ class Formula
|
||||
# yields |self,staging| with current working directory set to the uncompressed tarball
|
||||
# where staging is a Mktemp staging context
|
||||
# @private
|
||||
def brew(fetch: true)
|
||||
def brew(fetch: true, keep_tmp: false, interactive: false)
|
||||
@prefix_returns_versioned_prefix = true
|
||||
active_spec.fetch if fetch
|
||||
stage do |staging|
|
||||
staging.retain! if Homebrew.args.keep_tmp?
|
||||
stage(interactive: interactive) do |staging|
|
||||
staging.retain! if keep_tmp
|
||||
|
||||
prepare_patches
|
||||
fetch_patches if fetch
|
||||
@ -1175,7 +1175,7 @@ class Formula
|
||||
begin
|
||||
yield self, staging
|
||||
rescue
|
||||
staging.retain! if Homebrew.args.interactive? || Homebrew.args.debug?
|
||||
staging.retain! if interactive || Homebrew.args.debug?
|
||||
raise
|
||||
ensure
|
||||
cp Dir["config.log", "CMakeCache.txt"], logs
|
||||
@ -1792,7 +1792,7 @@ class Formula
|
||||
end
|
||||
|
||||
# @private
|
||||
def run_test
|
||||
def run_test(keep_tmp: false)
|
||||
@prefix_returns_versioned_prefix = true
|
||||
|
||||
test_env = {
|
||||
@ -1808,7 +1808,7 @@ class Formula
|
||||
Utils.set_git_name_email!
|
||||
|
||||
mktemp("#{name}-test") do |staging|
|
||||
staging.retain! if Homebrew.args.keep_tmp?
|
||||
staging.retain! if keep_tmp
|
||||
@testpath = staging.tmpdir
|
||||
test_env[:HOME] = @testpath
|
||||
setup_home @testpath
|
||||
@ -2134,7 +2134,7 @@ class Formula
|
||||
}
|
||||
end
|
||||
|
||||
def stage
|
||||
def stage(interactive: false)
|
||||
active_spec.stage do |staging|
|
||||
@source_modified_time = active_spec.source_modified_time
|
||||
@buildpath = Pathname.pwd
|
||||
@ -2145,7 +2145,7 @@ class Formula
|
||||
HOMEBREW_PATH: nil,
|
||||
}
|
||||
|
||||
unless Homebrew.args.interactive?
|
||||
unless interactive
|
||||
stage_env[:HOME] = env_home
|
||||
stage_env.merge!(common_stage_test_env)
|
||||
end
|
||||
|
||||
@ -16,13 +16,13 @@ require "dev-cmd/test"
|
||||
TEST_TIMEOUT_SECONDS = 5 * 60
|
||||
|
||||
begin
|
||||
Homebrew.test_args.parse
|
||||
args = Homebrew.test_args.parse
|
||||
error_pipe = UNIXSocket.open(ENV["HOMEBREW_ERROR_PIPE"], &:recv_io)
|
||||
error_pipe.fcntl(Fcntl::F_SETFD, Fcntl::FD_CLOEXEC)
|
||||
|
||||
trap("INT", old_trap)
|
||||
|
||||
formula = Homebrew.args.resolved_formulae.first
|
||||
formula = args.resolved_formulae.first
|
||||
formula.extend(Homebrew::Assertions)
|
||||
formula.extend(Homebrew::FreePort)
|
||||
formula.extend(Debrew::Formula) if Homebrew.args.debug?
|
||||
@ -32,7 +32,7 @@ begin
|
||||
|
||||
# tests can also return false to indicate failure
|
||||
Timeout.timeout TEST_TIMEOUT_SECONDS do
|
||||
raise "test returned false" if formula.run_test == false
|
||||
raise "test returned false" if formula.run_test(keep_tmp: args.keep_tmp?) == false
|
||||
end
|
||||
rescue Exception => e # rubocop:disable Lint/RescueException
|
||||
error_pipe.puts e.to_json
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user