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