Pass args to ENV instead of using global args.
This commit is contained in:
parent
e669949659
commit
25b3632c4c
@ -83,20 +83,20 @@ class Build
|
|||||||
fixopt(dep) unless dep.opt_prefix.directory?
|
fixopt(dep) unless dep.opt_prefix.directory?
|
||||||
end
|
end
|
||||||
|
|
||||||
ENV.activate_extensions!
|
ENV.activate_extensions!(args: args)
|
||||||
|
|
||||||
if superenv?
|
if superenv?(args: args)
|
||||||
ENV.keg_only_deps = keg_only_deps
|
ENV.keg_only_deps = keg_only_deps
|
||||||
ENV.deps = formula_deps
|
ENV.deps = formula_deps
|
||||||
ENV.run_time_deps = run_time_deps
|
ENV.run_time_deps = run_time_deps
|
||||||
ENV.x11 = reqs.any? { |rq| rq.is_a?(X11Requirement) }
|
ENV.x11 = reqs.any? { |rq| rq.is_a?(X11Requirement) }
|
||||||
ENV.setup_build_environment(formula)
|
ENV.setup_build_environment(formula, args: args)
|
||||||
post_superenv_hacks
|
post_superenv_hacks
|
||||||
reqs.each(&:modify_build_environment)
|
reqs.each { |req| req.modify_build_environment(args: args) }
|
||||||
deps.each(&:modify_build_environment)
|
deps.each(&:modify_build_environment)
|
||||||
else
|
else
|
||||||
ENV.setup_build_environment(formula)
|
ENV.setup_build_environment(formula, args: args)
|
||||||
reqs.each(&:modify_build_environment)
|
reqs.each { |req| req.modify_build_environment(args: args) }
|
||||||
deps.each(&:modify_build_environment)
|
deps.each(&:modify_build_environment)
|
||||||
|
|
||||||
keg_only_deps.each do |dep|
|
keg_only_deps.each do |dep|
|
||||||
|
|||||||
@ -27,11 +27,11 @@ module Homebrew
|
|||||||
end
|
end
|
||||||
|
|
||||||
def __env
|
def __env
|
||||||
__env_args.parse
|
args = __env_args.parse
|
||||||
|
|
||||||
ENV.activate_extensions!
|
ENV.activate_extensions!(args: args)
|
||||||
ENV.deps = args.formulae if superenv?
|
ENV.deps = args.formulae if superenv?(args: args)
|
||||||
ENV.setup_build_environment
|
ENV.setup_build_environment(args: args)
|
||||||
|
|
||||||
shell = if args.plain?
|
shell = if args.plain?
|
||||||
nil
|
nil
|
||||||
|
|||||||
@ -256,7 +256,7 @@ module Homebrew
|
|||||||
def decorate_requirements(requirements)
|
def decorate_requirements(requirements)
|
||||||
req_status = requirements.map do |req|
|
req_status = requirements.map do |req|
|
||||||
req_s = req.display_s
|
req_s = req.display_s
|
||||||
req.satisfied? ? pretty_installed(req_s) : pretty_uninstalled(req_s)
|
req.satisfied?(args: args) ? pretty_installed(req_s) : pretty_uninstalled(req_s)
|
||||||
end
|
end
|
||||||
req_status.join(", ")
|
req_status.join(", ")
|
||||||
end
|
end
|
||||||
|
|||||||
@ -73,7 +73,7 @@ module Homebrew
|
|||||||
end
|
end
|
||||||
|
|
||||||
def audit
|
def audit
|
||||||
audit_args.parse
|
args = audit_args.parse
|
||||||
|
|
||||||
Homebrew.auditing = true
|
Homebrew.auditing = true
|
||||||
inject_dump_stats!(FormulaAuditor, /^audit_/) if args.audit_debug?
|
inject_dump_stats!(FormulaAuditor, /^audit_/) if args.audit_debug?
|
||||||
@ -88,8 +88,8 @@ module Homebrew
|
|||||||
git = args.git?
|
git = args.git?
|
||||||
skip_style = args.skip_style? || args.no_named?
|
skip_style = args.skip_style? || args.no_named?
|
||||||
|
|
||||||
ENV.activate_extensions!
|
ENV.activate_extensions!(args: args)
|
||||||
ENV.setup_build_environment
|
ENV.setup_build_environment(args: args)
|
||||||
|
|
||||||
audit_formulae = args.no_named? ? Formula : args.resolved_formulae
|
audit_formulae = args.no_named? ? Formula : args.resolved_formulae
|
||||||
style_files = args.formulae_paths unless skip_style
|
style_files = args.formulae_paths unless skip_style
|
||||||
|
|||||||
@ -27,16 +27,16 @@ module Homebrew
|
|||||||
end
|
end
|
||||||
|
|
||||||
def sh
|
def sh
|
||||||
sh_args.parse
|
args = sh_args.parse
|
||||||
|
|
||||||
ENV.activate_extensions!
|
ENV.activate_extensions!(args: args)
|
||||||
|
|
||||||
if superenv?
|
if superenv?(args: args)
|
||||||
ENV.set_x11_env_if_installed
|
ENV.set_x11_env_if_installed
|
||||||
ENV.deps = Formula.installed.select { |f| f.keg_only? && f.opt_prefix.directory? }
|
ENV.deps = Formula.installed.select { |f| f.keg_only? && f.opt_prefix.directory? }
|
||||||
end
|
end
|
||||||
ENV.setup_build_environment
|
ENV.setup_build_environment(args: args)
|
||||||
if superenv?
|
if superenv?(args: args)
|
||||||
# superenv stopped adding brew's bin but generally users will want it
|
# superenv stopped adding brew's bin but generally users will want it
|
||||||
ENV["PATH"] = PATH.new(ENV["PATH"]).insert(1, HOMEBREW_PREFIX/"bin")
|
ENV["PATH"] = PATH.new(ENV["PATH"]).insert(1, HOMEBREW_PREFIX/"bin")
|
||||||
end
|
end
|
||||||
|
|||||||
@ -5,24 +5,24 @@ require "extend/ENV/shared"
|
|||||||
require "extend/ENV/std"
|
require "extend/ENV/std"
|
||||||
require "extend/ENV/super"
|
require "extend/ENV/super"
|
||||||
|
|
||||||
def superenv?
|
def superenv?(args:)
|
||||||
Homebrew.args.env != "std" && Superenv.bin
|
args&.env != "std" && Superenv.bin
|
||||||
end
|
end
|
||||||
|
|
||||||
module EnvActivation
|
module EnvActivation
|
||||||
def activate_extensions!
|
def activate_extensions!(args:)
|
||||||
if superenv?
|
if superenv?(args: args)
|
||||||
extend(Superenv)
|
extend(Superenv)
|
||||||
else
|
else
|
||||||
extend(Stdenv)
|
extend(Stdenv)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
def with_build_environment
|
def with_build_environment(args:)
|
||||||
old_env = to_hash.dup
|
old_env = to_hash.dup
|
||||||
tmp_env = to_hash.dup.extend(EnvActivation)
|
tmp_env = to_hash.dup.extend(EnvActivation)
|
||||||
tmp_env.activate_extensions!
|
tmp_env.activate_extensions!(args: args)
|
||||||
tmp_env.setup_build_environment
|
tmp_env.setup_build_environment(args: args)
|
||||||
replace(tmp_env)
|
replace(tmp_env)
|
||||||
yield
|
yield
|
||||||
ensure
|
ensure
|
||||||
|
|||||||
@ -29,8 +29,9 @@ module SharedEnvExtension
|
|||||||
].freeze
|
].freeze
|
||||||
|
|
||||||
# @private
|
# @private
|
||||||
def setup_build_environment(formula = nil)
|
def setup_build_environment(formula = nil, args: nil)
|
||||||
@formula = formula
|
@formula = formula
|
||||||
|
@args = args
|
||||||
reset
|
reset
|
||||||
end
|
end
|
||||||
|
|
||||||
@ -162,7 +163,7 @@ module SharedEnvExtension
|
|||||||
# ENV.append_to_cflags "-I ./missing/includes"
|
# ENV.append_to_cflags "-I ./missing/includes"
|
||||||
# end</pre>
|
# end</pre>
|
||||||
def compiler
|
def compiler
|
||||||
@compiler ||= if (cc = Homebrew.args.cc)
|
@compiler ||= if (cc = @args.cc)
|
||||||
warn_about_non_apple_gcc($&) if cc =~ GNU_GCC_REGEXP
|
warn_about_non_apple_gcc($&) if cc =~ GNU_GCC_REGEXP
|
||||||
fetch_compiler(cc, "--cc")
|
fetch_compiler(cc, "--cc")
|
||||||
elsif (cc = homebrew_cc)
|
elsif (cc = homebrew_cc)
|
||||||
@ -254,8 +255,8 @@ module SharedEnvExtension
|
|||||||
|
|
||||||
# @private
|
# @private
|
||||||
def effective_arch
|
def effective_arch
|
||||||
if Homebrew.args.build_bottle? && Homebrew.args.bottle_arch
|
if @args&.build_bottle? && @args&.bottle_arch
|
||||||
Homebrew.args.bottle_arch.to_sym
|
@args.bottle_arch.to_sym
|
||||||
else
|
else
|
||||||
Hardware.oldest_cpu
|
Hardware.oldest_cpu
|
||||||
end
|
end
|
||||||
|
|||||||
@ -11,7 +11,7 @@ module Stdenv
|
|||||||
SAFE_CFLAGS_FLAGS = "-w -pipe"
|
SAFE_CFLAGS_FLAGS = "-w -pipe"
|
||||||
|
|
||||||
# @private
|
# @private
|
||||||
def setup_build_environment(formula = nil)
|
def setup_build_environment(formula = nil, args: nil)
|
||||||
super
|
super
|
||||||
|
|
||||||
self["HOMEBREW_ENV"] = "std"
|
self["HOMEBREW_ENV"] = "std"
|
||||||
@ -110,14 +110,14 @@ module Stdenv
|
|||||||
end
|
end
|
||||||
|
|
||||||
def clang
|
def clang
|
||||||
super
|
super()
|
||||||
replace_in_cflags(/-Xarch_#{Hardware::CPU.arch_32_bit} (-march=\S*)/, '\1')
|
replace_in_cflags(/-Xarch_#{Hardware::CPU.arch_32_bit} (-march=\S*)/, '\1')
|
||||||
map = Hardware::CPU.optimization_flags.dup
|
map = Hardware::CPU.optimization_flags.dup
|
||||||
if DevelopmentTools.clang_build_version < 700
|
if DevelopmentTools.clang_build_version < 700
|
||||||
# Clang mistakenly enables AES-NI on plain Nehalem
|
# Clang mistakenly enables AES-NI on plain Nehalem
|
||||||
map[:nehalem] = "-march=nehalem -Xclang -target-feature -Xclang -aes"
|
map[:nehalem] = "-march=nehalem -Xclang -target-feature -Xclang -aes"
|
||||||
end
|
end
|
||||||
set_cpu_cflags map
|
set_cpu_cflags(map)
|
||||||
end
|
end
|
||||||
|
|
||||||
def m64
|
def m64
|
||||||
@ -186,7 +186,7 @@ module Stdenv
|
|||||||
|
|
||||||
# @private
|
# @private
|
||||||
def set_cpu_cflags(map = Hardware::CPU.optimization_flags) # rubocop:disable Naming/AccessorMethodName
|
def set_cpu_cflags(map = Hardware::CPU.optimization_flags) # rubocop:disable Naming/AccessorMethodName
|
||||||
set_cpu_flags CC_FLAG_VARS, map
|
set_cpu_flags(CC_FLAG_VARS, map)
|
||||||
end
|
end
|
||||||
|
|
||||||
def make_jobs
|
def make_jobs
|
||||||
|
|||||||
@ -36,7 +36,7 @@ module Superenv
|
|||||||
end
|
end
|
||||||
|
|
||||||
# @private
|
# @private
|
||||||
def setup_build_environment(formula = nil)
|
def setup_build_environment(formula = nil, args: nil)
|
||||||
super
|
super
|
||||||
send(compiler)
|
send(compiler)
|
||||||
|
|
||||||
|
|||||||
@ -3,9 +3,9 @@
|
|||||||
module SharedEnvExtension
|
module SharedEnvExtension
|
||||||
# @private
|
# @private
|
||||||
def effective_arch
|
def effective_arch
|
||||||
if Homebrew.args.build_bottle? && Homebrew.args.bottle_arch
|
if @args&.build_bottle? && @args&.bottle_arch
|
||||||
Homebrew.args.bottle_arch.to_sym
|
@args.bottle_arch.to_sym
|
||||||
elsif Homebrew.args.build_bottle?
|
elsif @args&.build_bottle?
|
||||||
Hardware.oldest_cpu
|
Hardware.oldest_cpu
|
||||||
else
|
else
|
||||||
:native
|
:native
|
||||||
|
|||||||
@ -1,8 +1,8 @@
|
|||||||
# frozen_string_literal: true
|
# frozen_string_literal: true
|
||||||
|
|
||||||
module Stdenv
|
module Stdenv
|
||||||
def setup_build_environment(formula = nil)
|
def setup_build_environment(formula = nil, args: nil)
|
||||||
generic_setup_build_environment(formula)
|
generic_setup_build_environment(formula, args: args)
|
||||||
|
|
||||||
prepend_path "CPATH", HOMEBREW_PREFIX/"include"
|
prepend_path "CPATH", HOMEBREW_PREFIX/"include"
|
||||||
prepend_path "LIBRARY_PATH", HOMEBREW_PREFIX/"lib"
|
prepend_path "LIBRARY_PATH", HOMEBREW_PREFIX/"lib"
|
||||||
|
|||||||
@ -7,8 +7,8 @@ module Superenv
|
|||||||
end
|
end
|
||||||
|
|
||||||
# @private
|
# @private
|
||||||
def setup_build_environment(formula = nil)
|
def setup_build_environment(formula = nil, args: nil)
|
||||||
generic_setup_build_environment(formula)
|
generic_setup_build_environment(formula, args: args)
|
||||||
self["HOMEBREW_OPTIMIZATION_LEVEL"] = "O2"
|
self["HOMEBREW_OPTIMIZATION_LEVEL"] = "O2"
|
||||||
self["HOMEBREW_DYNAMIC_LINKER"] = determine_dynamic_linker_path
|
self["HOMEBREW_DYNAMIC_LINKER"] = determine_dynamic_linker_path
|
||||||
self["HOMEBREW_RPATH_PATHS"] = determine_rpath_paths(formula)
|
self["HOMEBREW_RPATH_PATHS"] = determine_rpath_paths(formula)
|
||||||
|
|||||||
@ -32,8 +32,8 @@ module Stdenv
|
|||||||
append "CFLAGS", "-I#{MacOS::X11.include}" unless MacOS::CLT.installed?
|
append "CFLAGS", "-I#{MacOS::X11.include}" unless MacOS::CLT.installed?
|
||||||
end
|
end
|
||||||
|
|
||||||
def setup_build_environment(formula = nil)
|
def setup_build_environment(formula = nil, args: nil)
|
||||||
generic_setup_build_environment formula
|
generic_setup_build_environment(formula, args: args)
|
||||||
|
|
||||||
# sed is strict, and errors out when it encounters files with
|
# sed is strict, and errors out when it encounters files with
|
||||||
# mixed character sets
|
# mixed character sets
|
||||||
|
|||||||
@ -106,7 +106,7 @@ module Superenv
|
|||||||
end
|
end
|
||||||
|
|
||||||
# @private
|
# @private
|
||||||
def setup_build_environment(formula = nil)
|
def setup_build_environment(formula = nil, args: nil)
|
||||||
sdk = formula ? MacOS.sdk_for_formula(formula) : MacOS.sdk
|
sdk = formula ? MacOS.sdk_for_formula(formula) : MacOS.sdk
|
||||||
if MacOS.sdk_root_needed? || sdk&.source == :xcode
|
if MacOS.sdk_root_needed? || sdk&.source == :xcode
|
||||||
self["HOMEBREW_SDKROOT"] = sdk.path
|
self["HOMEBREW_SDKROOT"] = sdk.path
|
||||||
@ -119,7 +119,7 @@ module Superenv
|
|||||||
self["HOMEBREW_SDKROOT"] = nil
|
self["HOMEBREW_SDKROOT"] = nil
|
||||||
self["HOMEBREW_DEVELOPER_DIR"] = nil
|
self["HOMEBREW_DEVELOPER_DIR"] = nil
|
||||||
end
|
end
|
||||||
generic_setup_build_environment(formula)
|
generic_setup_build_environment(formula, args: args)
|
||||||
|
|
||||||
# Filter out symbols known not to be defined since GNU Autotools can't
|
# Filter out symbols known not to be defined since GNU Autotools can't
|
||||||
# reliably figure this out with Xcode 8 and above.
|
# reliably figure this out with Xcode 8 and above.
|
||||||
|
|||||||
@ -469,7 +469,7 @@ class FormulaInstaller
|
|||||||
|
|
||||||
if req.prune_from_option?(build)
|
if req.prune_from_option?(build)
|
||||||
Requirement.prune
|
Requirement.prune
|
||||||
elsif req.satisfied?
|
elsif req.satisfied?(args: Homebrew.args)
|
||||||
Requirement.prune
|
Requirement.prune
|
||||||
elsif (req.build? || req.test?) && !keep_build_test
|
elsif (req.build? || req.test?) && !keep_build_test
|
||||||
Requirement.prune
|
Requirement.prune
|
||||||
|
|||||||
@ -53,16 +53,15 @@ class Requirement
|
|||||||
|
|
||||||
# Overriding {#satisfied?} is unsupported.
|
# Overriding {#satisfied?} is unsupported.
|
||||||
# Pass a block or boolean to the satisfy DSL method instead.
|
# Pass a block or boolean to the satisfy DSL method instead.
|
||||||
def satisfied?
|
def satisfied?(args: nil)
|
||||||
satisfy = self.class.satisfy
|
satisfy = self.class.satisfy
|
||||||
return true unless satisfy
|
return true unless satisfy
|
||||||
|
|
||||||
@satisfied_result = satisfy.yielder { |p| instance_eval(&p) }
|
@satisfied_result = satisfy.yielder(args: args) { |p| instance_eval(&p) }
|
||||||
return false unless @satisfied_result
|
return false unless @satisfied_result
|
||||||
|
|
||||||
true
|
true
|
||||||
end
|
end
|
||||||
alias installed? satisfied?
|
|
||||||
|
|
||||||
# Overriding {#fatal?} is unsupported.
|
# Overriding {#fatal?} is unsupported.
|
||||||
# Pass a boolean to the fatal DSL method instead.
|
# Pass a boolean to the fatal DSL method instead.
|
||||||
@ -82,8 +81,8 @@ class Requirement
|
|||||||
|
|
||||||
# Overriding {#modify_build_environment} is unsupported.
|
# Overriding {#modify_build_environment} is unsupported.
|
||||||
# Pass a block to the env DSL method instead.
|
# Pass a block to the env DSL method instead.
|
||||||
def modify_build_environment
|
def modify_build_environment(args:)
|
||||||
satisfied?
|
satisfied?(args: args)
|
||||||
instance_eval(&env_proc) if env_proc
|
instance_eval(&env_proc) if env_proc
|
||||||
|
|
||||||
# XXX If the satisfy block returns a Pathname, then make sure that it
|
# XXX If the satisfy block returns a Pathname, then make sure that it
|
||||||
@ -182,12 +181,12 @@ class Requirement
|
|||||||
@proc = block
|
@proc = block
|
||||||
end
|
end
|
||||||
|
|
||||||
def yielder
|
def yielder(args:)
|
||||||
if instance_variable_defined?(:@satisfied)
|
if instance_variable_defined?(:@satisfied)
|
||||||
@satisfied
|
@satisfied
|
||||||
elsif @options[:build_env]
|
elsif @options[:build_env]
|
||||||
require "extend/ENV"
|
require "extend/ENV"
|
||||||
ENV.with_build_environment { yield @proc }
|
ENV.with_build_environment(args: args) { yield @proc }
|
||||||
else
|
else
|
||||||
yield @proc
|
yield @proc
|
||||||
end
|
end
|
||||||
|
|||||||
@ -28,7 +28,7 @@ begin
|
|||||||
formula.extend(Debrew::Formula) if Homebrew.args.debug?
|
formula.extend(Debrew::Formula) if Homebrew.args.debug?
|
||||||
|
|
||||||
ENV.extend(Stdenv)
|
ENV.extend(Stdenv)
|
||||||
ENV.setup_build_environment(formula)
|
ENV.setup_build_environment(formula, args: args)
|
||||||
|
|
||||||
# tests can also return false to indicate failure
|
# tests can also return false to indicate failure
|
||||||
Timeout.timeout TEST_TIMEOUT_SECONDS do
|
Timeout.timeout TEST_TIMEOUT_SECONDS do
|
||||||
|
|||||||
@ -1,5 +1,6 @@
|
|||||||
# frozen_string_literal: true
|
# frozen_string_literal: true
|
||||||
|
|
||||||
|
require "cli/args"
|
||||||
require "extend/ENV"
|
require "extend/ENV"
|
||||||
|
|
||||||
shared_examples EnvActivation do
|
shared_examples EnvActivation do
|
||||||
@ -14,10 +15,12 @@ shared_examples EnvActivation do
|
|||||||
end
|
end
|
||||||
|
|
||||||
describe "#with_build_environment" do
|
describe "#with_build_environment" do
|
||||||
|
let(:args) { Homebrew::CLI::Args.new }
|
||||||
|
|
||||||
it "restores the environment" do
|
it "restores the environment" do
|
||||||
before = subject.dup
|
before = subject.dup
|
||||||
|
|
||||||
subject.with_build_environment do
|
subject.with_build_environment(args: args) do
|
||||||
subject["foo"] = "bar"
|
subject["foo"] = "bar"
|
||||||
end
|
end
|
||||||
|
|
||||||
@ -29,7 +32,7 @@ shared_examples EnvActivation do
|
|||||||
before = subject.dup
|
before = subject.dup
|
||||||
|
|
||||||
expect {
|
expect {
|
||||||
subject.with_build_environment do
|
subject.with_build_environment(args: args) do
|
||||||
subject["foo"] = "bar"
|
subject["foo"] = "bar"
|
||||||
raise StandardError
|
raise StandardError
|
||||||
end
|
end
|
||||||
@ -40,13 +43,13 @@ shared_examples EnvActivation do
|
|||||||
end
|
end
|
||||||
|
|
||||||
it "returns the value of the block" do
|
it "returns the value of the block" do
|
||||||
expect(subject.with_build_environment { 1 }).to eq(1)
|
expect(subject.with_build_environment(args: args) { 1 }).to eq(1)
|
||||||
end
|
end
|
||||||
|
|
||||||
it "does not mutate the interface" do
|
it "does not mutate the interface" do
|
||||||
expected = subject.methods
|
expected = subject.methods
|
||||||
|
|
||||||
subject.with_build_environment do
|
subject.with_build_environment(args: args) do
|
||||||
expect(subject.methods).to eq(expected)
|
expect(subject.methods).to eq(expected)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|||||||
@ -1,5 +1,6 @@
|
|||||||
# frozen_string_literal: true
|
# frozen_string_literal: true
|
||||||
|
|
||||||
|
require "cli/args"
|
||||||
require "requirements/java_requirement"
|
require "requirements/java_requirement"
|
||||||
|
|
||||||
describe JavaRequirement do
|
describe JavaRequirement do
|
||||||
@ -40,14 +41,16 @@ describe JavaRequirement do
|
|||||||
describe "#satisfied?" do
|
describe "#satisfied?" do
|
||||||
subject { described_class.new(%w[1.8]) }
|
subject { described_class.new(%w[1.8]) }
|
||||||
|
|
||||||
|
let(:args) { Homebrew::CLI::Args.new }
|
||||||
|
|
||||||
it "returns false if no `java` executable can be found" do
|
it "returns false if no `java` executable can be found" do
|
||||||
allow(File).to receive(:executable?).and_return(false)
|
allow(File).to receive(:executable?).and_return(false)
|
||||||
expect(subject).not_to be_satisfied
|
expect(subject).not_to be_satisfied(args: args)
|
||||||
end
|
end
|
||||||
|
|
||||||
it "returns true if #preferred_java returns a path" do
|
it "returns true if #preferred_java returns a path" do
|
||||||
allow(subject).to receive(:preferred_java).and_return(Pathname.new("/usr/bin/java"))
|
allow(subject).to receive(:preferred_java).and_return(Pathname.new("/usr/bin/java"))
|
||||||
expect(subject).to be_satisfied
|
expect(subject).to be_satisfied(args: args)
|
||||||
end
|
end
|
||||||
|
|
||||||
context "when #possible_javas contains paths" do
|
context "when #possible_javas contains paths" do
|
||||||
@ -71,17 +74,17 @@ describe JavaRequirement do
|
|||||||
|
|
||||||
it "returns false if all are lower" do
|
it "returns false if all are lower" do
|
||||||
setup_java_with_version "1.6.0_5"
|
setup_java_with_version "1.6.0_5"
|
||||||
expect(subject).not_to be_satisfied
|
expect(subject).not_to be_satisfied(args: args)
|
||||||
end
|
end
|
||||||
|
|
||||||
it "returns true if one is equal" do
|
it "returns true if one is equal" do
|
||||||
setup_java_with_version "1.7.0_5"
|
setup_java_with_version "1.7.0_5"
|
||||||
expect(subject).to be_satisfied
|
expect(subject).to be_satisfied(args: args)
|
||||||
end
|
end
|
||||||
|
|
||||||
it "returns false if all are higher" do
|
it "returns false if all are higher" do
|
||||||
setup_java_with_version "1.8.0_5"
|
setup_java_with_version "1.8.0_5"
|
||||||
expect(subject).not_to be_satisfied
|
expect(subject).not_to be_satisfied(args: args)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
@ -90,17 +93,17 @@ describe JavaRequirement do
|
|||||||
|
|
||||||
it "returns false if all are lower" do
|
it "returns false if all are lower" do
|
||||||
setup_java_with_version "1.6.0_5"
|
setup_java_with_version "1.6.0_5"
|
||||||
expect(subject).not_to be_satisfied
|
expect(subject).not_to be_satisfied(args: args)
|
||||||
end
|
end
|
||||||
|
|
||||||
it "returns true if one is equal" do
|
it "returns true if one is equal" do
|
||||||
setup_java_with_version "1.7.0_5"
|
setup_java_with_version "1.7.0_5"
|
||||||
expect(subject).to be_satisfied
|
expect(subject).to be_satisfied(args: args)
|
||||||
end
|
end
|
||||||
|
|
||||||
it "returns true if one is higher" do
|
it "returns true if one is higher" do
|
||||||
setup_java_with_version "1.8.0_5"
|
setup_java_with_version "1.8.0_5"
|
||||||
expect(subject).to be_satisfied
|
expect(subject).to be_satisfied(args: args)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|||||||
@ -1,5 +1,6 @@
|
|||||||
# frozen_string_literal: true
|
# frozen_string_literal: true
|
||||||
|
|
||||||
|
require "cli/args"
|
||||||
require "requirements/java_requirement"
|
require "requirements/java_requirement"
|
||||||
require "fileutils"
|
require "fileutils"
|
||||||
|
|
||||||
@ -8,6 +9,8 @@ describe JavaRequirement do
|
|||||||
|
|
||||||
let(:java_home) { mktmpdir }
|
let(:java_home) { mktmpdir }
|
||||||
|
|
||||||
|
let(:args) { Homebrew::CLI::Args.new }
|
||||||
|
|
||||||
before do
|
before do
|
||||||
FileUtils.mkdir java_home/"bin"
|
FileUtils.mkdir java_home/"bin"
|
||||||
FileUtils.touch java_home/"bin/java"
|
FileUtils.touch java_home/"bin/java"
|
||||||
@ -15,23 +18,23 @@ describe JavaRequirement do
|
|||||||
end
|
end
|
||||||
|
|
||||||
specify "Apple Java environment" do
|
specify "Apple Java environment" do
|
||||||
expect(subject).to be_satisfied
|
expect(subject).to be_satisfied(args: args)
|
||||||
|
|
||||||
expect(ENV).to receive(:prepend_path)
|
expect(ENV).to receive(:prepend_path)
|
||||||
expect(ENV).to receive(:append_to_cflags)
|
expect(ENV).to receive(:append_to_cflags)
|
||||||
|
|
||||||
subject.modify_build_environment
|
subject.modify_build_environment(args: args)
|
||||||
expect(ENV["JAVA_HOME"]).to eq(java_home.to_s)
|
expect(ENV["JAVA_HOME"]).to eq(java_home.to_s)
|
||||||
end
|
end
|
||||||
|
|
||||||
specify "Oracle Java environment" do
|
specify "Oracle Java environment" do
|
||||||
expect(subject).to be_satisfied
|
expect(subject).to be_satisfied(args: args)
|
||||||
|
|
||||||
FileUtils.mkdir java_home/"include"
|
FileUtils.mkdir java_home/"include"
|
||||||
expect(ENV).to receive(:prepend_path)
|
expect(ENV).to receive(:prepend_path)
|
||||||
expect(ENV).to receive(:append_to_cflags).twice
|
expect(ENV).to receive(:append_to_cflags).twice
|
||||||
|
|
||||||
subject.modify_build_environment
|
subject.modify_build_environment(args: args)
|
||||||
expect(ENV["JAVA_HOME"]).to eq(java_home.to_s)
|
expect(ENV["JAVA_HOME"]).to eq(java_home.to_s)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|||||||
@ -1,5 +1,6 @@
|
|||||||
# frozen_string_literal: true
|
# frozen_string_literal: true
|
||||||
|
|
||||||
|
require "cli/args"
|
||||||
require "extend/ENV"
|
require "extend/ENV"
|
||||||
require "requirement"
|
require "requirement"
|
||||||
|
|
||||||
@ -10,6 +11,8 @@ describe Requirement do
|
|||||||
|
|
||||||
let(:klass) { Class.new(described_class) }
|
let(:klass) { Class.new(described_class) }
|
||||||
|
|
||||||
|
let(:args) { Homebrew::CLI::Args.new }
|
||||||
|
|
||||||
describe "#tags" do
|
describe "#tags" do
|
||||||
subject { described_class.new(tags) }
|
subject { described_class.new(tags) }
|
||||||
|
|
||||||
@ -64,7 +67,7 @@ describe Requirement do
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
it { is_expected.to be_satisfied }
|
it { is_expected.to be_satisfied(args: args) }
|
||||||
end
|
end
|
||||||
|
|
||||||
describe "#satisfy with block and build_env returns false" do
|
describe "#satisfy with block and build_env returns false" do
|
||||||
@ -76,7 +79,7 @@ describe Requirement do
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
it { is_expected.not_to be_satisfied }
|
it { is_expected.not_to be_satisfied(args: args) }
|
||||||
end
|
end
|
||||||
|
|
||||||
describe "#satisfy returns true" do
|
describe "#satisfy returns true" do
|
||||||
@ -86,7 +89,7 @@ describe Requirement do
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
it { is_expected.to be_satisfied }
|
it { is_expected.to be_satisfied(args: args) }
|
||||||
end
|
end
|
||||||
|
|
||||||
describe "#satisfy returns false" do
|
describe "#satisfy returns false" do
|
||||||
@ -96,7 +99,7 @@ describe Requirement do
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
it { is_expected.not_to be_satisfied }
|
it { is_expected.not_to be_satisfied(args: args) }
|
||||||
end
|
end
|
||||||
|
|
||||||
describe "#satisfy with block returning true and without :build_env" do
|
describe "#satisfy with block returning true and without :build_env" do
|
||||||
@ -110,7 +113,7 @@ describe Requirement do
|
|||||||
|
|
||||||
it "sets up build environment" do
|
it "sets up build environment" do
|
||||||
expect(ENV).to receive(:with_build_environment).and_call_original
|
expect(ENV).to receive(:with_build_environment).and_call_original
|
||||||
subject.satisfied?
|
subject.satisfied?(args: args)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
@ -125,7 +128,7 @@ describe Requirement do
|
|||||||
|
|
||||||
it "skips setting up build environment" do
|
it "skips setting up build environment" do
|
||||||
expect(ENV).not_to receive(:with_build_environment)
|
expect(ENV).not_to receive(:with_build_environment)
|
||||||
subject.satisfied?
|
subject.satisfied?(args: args)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
@ -140,8 +143,8 @@ describe Requirement do
|
|||||||
|
|
||||||
it "infers path from #satisfy result" do
|
it "infers path from #satisfy result" do
|
||||||
expect(ENV).to receive(:prepend_path).with("PATH", Pathname.new("/foo/bar"))
|
expect(ENV).to receive(:prepend_path).with("PATH", Pathname.new("/foo/bar"))
|
||||||
subject.satisfied?
|
subject.satisfied?(args: args)
|
||||||
subject.modify_build_environment
|
subject.modify_build_environment(args: args)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
@ -179,7 +182,7 @@ describe Requirement do
|
|||||||
let(:klass) { Class.new(described_class) }
|
let(:klass) { Class.new(described_class) }
|
||||||
|
|
||||||
it "returns nil" do
|
it "returns nil" do
|
||||||
expect(subject.modify_build_environment).to be nil
|
expect(subject.modify_build_environment(args: args)).to be nil
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|||||||
@ -1,13 +1,16 @@
|
|||||||
# frozen_string_literal: true
|
# frozen_string_literal: true
|
||||||
|
|
||||||
|
require "cli/args"
|
||||||
require "requirements/linux_requirement"
|
require "requirements/linux_requirement"
|
||||||
|
|
||||||
describe LinuxRequirement do
|
describe LinuxRequirement do
|
||||||
subject(:requirement) { described_class.new }
|
subject(:requirement) { described_class.new }
|
||||||
|
|
||||||
describe "#satisfied?" do
|
describe "#satisfied?" do
|
||||||
|
let(:args) { Homebrew::CLI::Args.new }
|
||||||
|
|
||||||
it "returns true on Linux" do
|
it "returns true on Linux" do
|
||||||
expect(requirement.satisfied?).to eq(OS.linux?)
|
expect(requirement.satisfied?(args: args)).to eq(OS.linux?)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|||||||
@ -1,23 +1,26 @@
|
|||||||
# frozen_string_literal: true
|
# frozen_string_literal: true
|
||||||
|
|
||||||
|
require "cli/args"
|
||||||
require "requirements/macos_requirement"
|
require "requirements/macos_requirement"
|
||||||
|
|
||||||
describe MacOSRequirement do
|
describe MacOSRequirement do
|
||||||
subject(:requirement) { described_class.new }
|
subject(:requirement) { described_class.new }
|
||||||
|
|
||||||
describe "#satisfied?" do
|
describe "#satisfied?" do
|
||||||
|
let(:args) { Homebrew::CLI::Args.new }
|
||||||
|
|
||||||
it "returns true on macOS" do
|
it "returns true on macOS" do
|
||||||
expect(requirement.satisfied?).to eq OS.mac?
|
expect(requirement.satisfied?(args: args)).to eq OS.mac?
|
||||||
end
|
end
|
||||||
|
|
||||||
it "supports version symbols", :needs_macos do
|
it "supports version symbols", :needs_macos do
|
||||||
requirement = described_class.new([MacOS.version.to_sym])
|
requirement = described_class.new([MacOS.version.to_sym])
|
||||||
expect(requirement).to be_satisfied
|
expect(requirement).to be_satisfied(args: args)
|
||||||
end
|
end
|
||||||
|
|
||||||
it "supports maximum versions", :needs_macos do
|
it "supports maximum versions", :needs_macos do
|
||||||
requirement = described_class.new([:catalina], comparator: "<=")
|
requirement = described_class.new([:catalina], comparator: "<=")
|
||||||
expect(requirement.satisfied?).to eq MacOS.version <= :catalina
|
expect(requirement.satisfied?(args: args)).to eq MacOS.version <= :catalina
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|||||||
@ -1,5 +1,6 @@
|
|||||||
# frozen_string_literal: true
|
# frozen_string_literal: true
|
||||||
|
|
||||||
|
require "cli/args"
|
||||||
require "requirements/osxfuse_requirement"
|
require "requirements/osxfuse_requirement"
|
||||||
|
|
||||||
describe OsxfuseRequirement do
|
describe OsxfuseRequirement do
|
||||||
@ -21,21 +22,23 @@ describe OsxfuseRequirement do
|
|||||||
end
|
end
|
||||||
|
|
||||||
describe "#modify_build_environment", :needs_macos do
|
describe "#modify_build_environment", :needs_macos do
|
||||||
|
let(:args) { Homebrew::CLI::Args.new }
|
||||||
|
|
||||||
it "adds the fuse directories to PKG_CONFIG_PATH" do
|
it "adds the fuse directories to PKG_CONFIG_PATH" do
|
||||||
allow(ENV).to receive(:append_path)
|
allow(ENV).to receive(:append_path)
|
||||||
requirement.modify_build_environment
|
requirement.modify_build_environment(args: args)
|
||||||
expect(ENV).to have_received(:append_path).with("PKG_CONFIG_PATH", any_args)
|
expect(ENV).to have_received(:append_path).with("PKG_CONFIG_PATH", any_args)
|
||||||
end
|
end
|
||||||
|
|
||||||
it "adds the fuse directories to HOMEBREW_LIBRARY_PATHS" do
|
it "adds the fuse directories to HOMEBREW_LIBRARY_PATHS" do
|
||||||
allow(ENV).to receive(:append_path)
|
allow(ENV).to receive(:append_path)
|
||||||
requirement.modify_build_environment
|
requirement.modify_build_environment(args: args)
|
||||||
expect(ENV).to have_received(:append_path).with("HOMEBREW_LIBRARY_PATHS", any_args)
|
expect(ENV).to have_received(:append_path).with("HOMEBREW_LIBRARY_PATHS", any_args)
|
||||||
end
|
end
|
||||||
|
|
||||||
it "adds the fuse directories to HOMEBREW_INCLUDE_PATHS" do
|
it "adds the fuse directories to HOMEBREW_INCLUDE_PATHS" do
|
||||||
allow(ENV).to receive(:append_path)
|
allow(ENV).to receive(:append_path)
|
||||||
requirement.modify_build_environment
|
requirement.modify_build_environment(args: args)
|
||||||
expect(ENV).to have_received(:append_path).with("HOMEBREW_INCLUDE_PATHS", any_args)
|
expect(ENV).to have_received(:append_path).with("HOMEBREW_INCLUDE_PATHS", any_args)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|||||||
@ -1,10 +1,13 @@
|
|||||||
# frozen_string_literal: true
|
# frozen_string_literal: true
|
||||||
|
|
||||||
|
require "cli/args"
|
||||||
require "requirements/x11_requirement"
|
require "requirements/x11_requirement"
|
||||||
|
|
||||||
describe X11Requirement do
|
describe X11Requirement do
|
||||||
let(:default_name) { "x11" }
|
let(:default_name) { "x11" }
|
||||||
|
|
||||||
|
let(:args) { Homebrew::CLI::Args.new }
|
||||||
|
|
||||||
describe "#name" do
|
describe "#name" do
|
||||||
it "defaults to x11" do
|
it "defaults to x11" do
|
||||||
expect(subject.name).to eq(default_name)
|
expect(subject.name).to eq(default_name)
|
||||||
@ -22,7 +25,7 @@ describe X11Requirement do
|
|||||||
it "calls ENV#x11" do
|
it "calls ENV#x11" do
|
||||||
allow(subject).to receive(:satisfied?).and_return(true)
|
allow(subject).to receive(:satisfied?).and_return(true)
|
||||||
expect(ENV).to receive(:x11)
|
expect(ENV).to receive(:x11)
|
||||||
subject.modify_build_environment
|
subject.modify_build_environment(args: args)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
@ -30,12 +33,12 @@ describe X11Requirement do
|
|||||||
it "returns true if X11 is installed" do
|
it "returns true if X11 is installed" do
|
||||||
expect(MacOS::XQuartz).to receive(:version).and_return("2.7.5")
|
expect(MacOS::XQuartz).to receive(:version).and_return("2.7.5")
|
||||||
expect(MacOS::XQuartz).to receive(:installed?).and_return(true)
|
expect(MacOS::XQuartz).to receive(:installed?).and_return(true)
|
||||||
expect(subject).to be_satisfied
|
expect(subject).to be_satisfied(args: args)
|
||||||
end
|
end
|
||||||
|
|
||||||
it "returns false if X11 is not installed" do
|
it "returns false if X11 is not installed" do
|
||||||
expect(MacOS::XQuartz).to receive(:installed?).and_return(false)
|
expect(MacOS::XQuartz).to receive(:installed?).and_return(false)
|
||||||
expect(subject).not_to be_satisfied
|
expect(subject).not_to be_satisfied(args: args)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user