Merge branch 'Homebrew:master' into mohammad
This commit is contained in:
commit
a91dbd4a96
@ -11,7 +11,7 @@ GEM
|
||||
public_suffix (>= 2.0.2, < 5.0)
|
||||
ast (2.4.2)
|
||||
bindata (2.4.10)
|
||||
bootsnap (1.12.0)
|
||||
bootsnap (1.13.0)
|
||||
msgpack (~> 1.2)
|
||||
byebug (11.1.3)
|
||||
coderay (1.1.3)
|
||||
|
||||
@ -556,6 +556,9 @@ EOS
|
||||
[[ -d "${DIR}/.git" ]] || continue
|
||||
cd "${DIR}" || continue
|
||||
|
||||
# Git's fsmonitor prevents the release of our locks
|
||||
git config --bool core.fsmonitor false
|
||||
|
||||
if ! git config --local --get remote.origin.url &>/dev/null
|
||||
then
|
||||
opoo "No remote 'origin' in ${DIR}, skipping update!"
|
||||
|
||||
@ -15,8 +15,7 @@ module OnSystem
|
||||
def arch_condition_met?(arch)
|
||||
raise ArgumentError, "Invalid arch condition: #{arch.inspect}" if ARCH_OPTIONS.exclude?(arch)
|
||||
|
||||
current_arch = Homebrew::SimulateSystem.arch || Hardware::CPU.type
|
||||
arch == current_arch
|
||||
arch == Homebrew::SimulateSystem.current_arch
|
||||
end
|
||||
|
||||
sig { params(os_name: Symbol, or_condition: T.nilable(Symbol)).returns(T::Boolean) }
|
||||
@ -26,14 +25,7 @@ module OnSystem
|
||||
return true if [:macos, *MacOSVersions::SYMBOLS.keys].include?(os_name)
|
||||
end
|
||||
|
||||
if BASE_OS_OPTIONS.include?(os_name)
|
||||
if Homebrew::SimulateSystem.none?
|
||||
return OS.linux? if os_name == :linux
|
||||
return OS.mac? if os_name == :macos
|
||||
end
|
||||
|
||||
return Homebrew::SimulateSystem.send("#{os_name}?")
|
||||
end
|
||||
return Homebrew::SimulateSystem.send("simulating_or_running_on_#{os_name}?") if BASE_OS_OPTIONS.include?(os_name)
|
||||
|
||||
raise ArgumentError, "Invalid OS condition: #{os_name.inspect}" unless MacOSVersions::SYMBOLS.key?(os_name)
|
||||
|
||||
@ -41,10 +33,10 @@ module OnSystem
|
||||
raise ArgumentError, "Invalid OS `or_*` condition: #{or_condition.inspect}"
|
||||
end
|
||||
|
||||
return false if Homebrew::SimulateSystem.linux? || (Homebrew::SimulateSystem.none? && OS.linux?)
|
||||
return false if Homebrew::SimulateSystem.simulating_or_running_on_linux?
|
||||
|
||||
base_os = MacOS::Version.from_symbol(os_name)
|
||||
current_os = MacOS::Version.from_symbol(Homebrew::SimulateSystem.os || MacOS.version.to_sym)
|
||||
current_os = MacOS::Version.from_symbol(Homebrew::SimulateSystem.current_os)
|
||||
|
||||
return current_os >= base_os if or_condition == :or_newer
|
||||
return current_os <= base_os if or_condition == :or_older
|
||||
|
||||
@ -23,17 +23,4 @@ class Formula
|
||||
|
||||
sig { params(targets: T.nilable(T.any(Pathname, String))).void }
|
||||
def deuniversalize_machos(*targets); end
|
||||
|
||||
class << self
|
||||
undef ignore_missing_libraries
|
||||
|
||||
def ignore_missing_libraries(*libs)
|
||||
libraries = libs.flatten
|
||||
if libraries.any? { |x| !x.is_a?(String) && !x.is_a?(Regexp) }
|
||||
raise FormulaSpecificationError, "#{__method__} can handle Strings and Regular Expressions only"
|
||||
end
|
||||
|
||||
allowed_missing_libraries.merge(libraries)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
@ -1,27 +0,0 @@
|
||||
# typed: true
|
||||
# frozen_string_literal: true
|
||||
|
||||
# The Library/Homebrew/extend/os/software_spec.rb conditional logic will need to be more nuanced
|
||||
# if this file ever includes more than `uses_from_macos`.
|
||||
class SoftwareSpec
|
||||
undef uses_from_macos
|
||||
|
||||
def uses_from_macos(deps, bounds = {})
|
||||
if deps.is_a?(Hash)
|
||||
bounds = deps.dup
|
||||
deps = [bounds.shift].to_h
|
||||
end
|
||||
|
||||
@uses_from_macos_elements << deps
|
||||
|
||||
bounds = bounds.transform_values { |v| MacOS::Version.from_symbol(v) }
|
||||
|
||||
# Linux simulating macOS. Assume oldest macOS version.
|
||||
return if Homebrew::EnvConfig.simulate_macos_on_linux? && !bounds.key?(:since)
|
||||
|
||||
# macOS new enough for dependency to not be required.
|
||||
return if MacOS.version >= bounds[:since]
|
||||
|
||||
depends_on deps
|
||||
end
|
||||
end
|
||||
@ -1,9 +1,4 @@
|
||||
# typed: strict
|
||||
# frozen_string_literal: true
|
||||
|
||||
# This logic will need to be more nuanced if this file includes more than `uses_from_macos`.
|
||||
if OS.mac? || Homebrew::EnvConfig.simulate_macos_on_linux?
|
||||
require "extend/os/mac/software_spec"
|
||||
elsif OS.linux?
|
||||
require "extend/os/linux/software_spec"
|
||||
end
|
||||
require "extend/os/linux/software_spec" if OS.linux?
|
||||
|
||||
@ -3214,12 +3214,19 @@ class Formula
|
||||
end
|
||||
|
||||
# Permit links to certain libraries that don't exist. Available on Linux only.
|
||||
def ignore_missing_libraries(*)
|
||||
return if Homebrew::SimulateSystem.linux?
|
||||
|
||||
def ignore_missing_libraries(*libs)
|
||||
unless Homebrew::SimulateSystem.simulating_or_running_on_linux?
|
||||
raise FormulaSpecificationError, "#{__method__} is available on Linux only"
|
||||
end
|
||||
|
||||
libraries = libs.flatten
|
||||
if libraries.any? { |x| !x.is_a?(String) && !x.is_a?(Regexp) }
|
||||
raise FormulaSpecificationError, "#{__method__} can handle Strings and Regular Expressions only"
|
||||
end
|
||||
|
||||
allowed_missing_libraries.merge(libraries)
|
||||
end
|
||||
|
||||
# @private
|
||||
def allowed_missing_libraries
|
||||
@allowed_missing_libraries ||= Set.new
|
||||
|
||||
@ -307,6 +307,13 @@ module Homebrew
|
||||
EOS
|
||||
end
|
||||
|
||||
if dep_f.deprecated? && !formula.deprecated? && !formula.disabled?
|
||||
problem <<~EOS
|
||||
Dependency '#{dep.name}' is deprecated but has un-deprecated dependents. Either
|
||||
un-deprecate '#{dep.name}' or deprecate it and all of its dependents.
|
||||
EOS
|
||||
end
|
||||
|
||||
# we want to allow uses_from_macos for aliases but not bare dependencies
|
||||
if self.class.aliases.include?(dep.name) && spec.uses_from_macos_names.exclude?(dep.name)
|
||||
problem "Dependency '#{dep.name}' is an alias; use the canonical name '#{dep.to_formula.full_name}'."
|
||||
@ -410,13 +417,11 @@ module Homebrew
|
||||
end
|
||||
|
||||
def audit_glibc
|
||||
return if formula.name != "glibc"
|
||||
return unless @core_tap
|
||||
return if formula.name != "glibc"
|
||||
return if [OS::CI_GLIBC_VERSION, "2.27", "2.31", "2.35"].include?(formula.version.to_s)
|
||||
|
||||
version = formula.version.to_s
|
||||
return if version == OS::CI_GLIBC_VERSION
|
||||
|
||||
problem "The glibc version must be #{version}, as this is the version used by our CI on Linux. " \
|
||||
problem "The glibc version must be #{OS::CI_GLIBC_VERSION}, as this is the version used by our CI on Linux. " \
|
||||
"Glibc is for users who have a system Glibc with a lower version, " \
|
||||
"which allows them to use our Linux bottles, which were compiled against system Glibc on CI."
|
||||
end
|
||||
|
||||
@ -136,6 +136,18 @@ module Formulary
|
||||
class_s = Formulary.class_s(name)
|
||||
json_formula = Homebrew::API::Formula.all_formulae[name]
|
||||
|
||||
if (bottle_tag = Utils::Bottles.tag.to_s.presence) &&
|
||||
(variations = json_formula["variations"].presence) &&
|
||||
(variation = variations[bottle_tag].presence)
|
||||
json_formula = json_formula.merge(variation)
|
||||
end
|
||||
|
||||
uses_from_macos_names = json_formula["uses_from_macos"].map do |dep|
|
||||
next dep unless dep.is_a? Hash
|
||||
|
||||
dep.keys.first
|
||||
end
|
||||
|
||||
klass = Class.new(::Formula) do
|
||||
desc json_formula["desc"]
|
||||
homepage json_formula["homepage"]
|
||||
@ -176,20 +188,18 @@ module Formulary
|
||||
disable! date: disable_date, because: reason
|
||||
end
|
||||
|
||||
json_formula["build_dependencies"].each do |dep|
|
||||
depends_on dep => :build
|
||||
end
|
||||
|
||||
json_formula["dependencies"].each do |dep|
|
||||
next if uses_from_macos_names.include? dep
|
||||
|
||||
depends_on dep
|
||||
end
|
||||
|
||||
json_formula["recommended_dependencies"].each do |dep|
|
||||
depends_on dep => :recommended
|
||||
end
|
||||
[:build, :recommended, :optional].each do |type|
|
||||
json_formula["#{type}_dependencies"].each do |dep|
|
||||
next if uses_from_macos_names.include? dep
|
||||
|
||||
json_formula["optional_dependencies"].each do |dep|
|
||||
depends_on dep => :optional
|
||||
depends_on dep => type
|
||||
end
|
||||
end
|
||||
|
||||
json_formula["uses_from_macos"].each do |dep|
|
||||
|
||||
@ -32,19 +32,31 @@ module Homebrew
|
||||
end
|
||||
|
||||
sig { returns(T::Boolean) }
|
||||
def none?
|
||||
@os.nil? && @arch.nil?
|
||||
end
|
||||
def simulating_or_running_on_macos?
|
||||
return OS.mac? if @os.blank?
|
||||
|
||||
sig { returns(T::Boolean) }
|
||||
def macos?
|
||||
[:macos, *MacOSVersions::SYMBOLS.keys].include?(@os)
|
||||
end
|
||||
|
||||
sig { returns(T::Boolean) }
|
||||
def linux?
|
||||
def simulating_or_running_on_linux?
|
||||
return OS.linux? if @os.blank?
|
||||
|
||||
@os == :linux
|
||||
end
|
||||
|
||||
sig { returns(Symbol) }
|
||||
def current_arch
|
||||
@arch || Hardware::CPU.type
|
||||
end
|
||||
|
||||
sig { returns(Symbol) }
|
||||
def current_os
|
||||
return @os if @os.present?
|
||||
return :linux if OS.linux?
|
||||
|
||||
MacOS.version.to_sym
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
@ -162,12 +162,25 @@ class SoftwareSpec
|
||||
add_dep_option(dep) if dep
|
||||
end
|
||||
|
||||
def uses_from_macos(spec, _bounds = {})
|
||||
spec = [spec.dup.shift].to_h if spec.is_a?(Hash)
|
||||
def uses_from_macos(deps, bounds = {})
|
||||
if deps.is_a?(Hash)
|
||||
bounds = deps.dup
|
||||
deps = [bounds.shift].to_h
|
||||
end
|
||||
|
||||
@uses_from_macos_elements << spec
|
||||
@uses_from_macos_elements << deps
|
||||
|
||||
depends_on(spec)
|
||||
# Linux simulating macOS. Assume oldest macOS version.
|
||||
return if Homebrew::EnvConfig.simulate_macos_on_linux? && !bounds.key?(:since)
|
||||
|
||||
# macOS new enough for dependency to not be required.
|
||||
if Homebrew::SimulateSystem.simulating_or_running_on_macos?
|
||||
current_os = MacOS::Version.from_symbol(Homebrew::SimulateSystem.current_os)
|
||||
since_os = MacOS::Version.from_symbol(bounds[:since]) if bounds.key?(:since)
|
||||
return if current_os >= since_os
|
||||
end
|
||||
|
||||
depends_on deps
|
||||
end
|
||||
|
||||
def uses_from_macos_names
|
||||
|
||||
@ -1845,4 +1845,52 @@ describe Formula do
|
||||
expect(f.test).to eq(2)
|
||||
end
|
||||
end
|
||||
|
||||
describe "#ignore_missing_libraries" do
|
||||
after do
|
||||
Homebrew::SimulateSystem.clear
|
||||
end
|
||||
|
||||
it "adds library to allowed_missing_libraries on Linux", :needs_linux do
|
||||
Homebrew::SimulateSystem.clear
|
||||
f = formula do
|
||||
url "foo-1.0"
|
||||
|
||||
ignore_missing_libraries "bar.so"
|
||||
end
|
||||
expect(f.class.allowed_missing_libraries.to_a).to eq(["bar.so"])
|
||||
end
|
||||
|
||||
it "adds library to allowed_missing_libraries on macOS when simulating Linux", :needs_macos do
|
||||
Homebrew::SimulateSystem.os = :linux
|
||||
f = formula do
|
||||
url "foo-1.0"
|
||||
|
||||
ignore_missing_libraries "bar.so"
|
||||
end
|
||||
expect(f.class.allowed_missing_libraries.to_a).to eq(["bar.so"])
|
||||
end
|
||||
|
||||
it "raises an error on macOS", :needs_macos do
|
||||
Homebrew::SimulateSystem.clear
|
||||
expect {
|
||||
formula do
|
||||
url "foo-1.0"
|
||||
|
||||
ignore_missing_libraries "bar.so"
|
||||
end
|
||||
}.to raise_error("ignore_missing_libraries is available on Linux only")
|
||||
end
|
||||
|
||||
it "raises an error on Linux when simulating macOS", :needs_linux do
|
||||
Homebrew::SimulateSystem.os = :macos
|
||||
expect {
|
||||
formula do
|
||||
url "foo-1.0"
|
||||
|
||||
ignore_missing_libraries "bar.so"
|
||||
end
|
||||
}.to raise_error("ignore_missing_libraries is available on Linux only")
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
@ -260,6 +260,26 @@ describe Formulary do
|
||||
}
|
||||
end
|
||||
|
||||
let(:variations_json) do
|
||||
{
|
||||
"variations" => {
|
||||
Utils::Bottles.tag.to_s => {
|
||||
"dependencies" => ["dep", "variations_dep"],
|
||||
},
|
||||
},
|
||||
}
|
||||
end
|
||||
|
||||
let(:linux_variations_json) do
|
||||
{
|
||||
"variations" => {
|
||||
"x86_64_linux" => {
|
||||
"dependencies" => ["dep", "uses_from_macos_dep"],
|
||||
},
|
||||
},
|
||||
}
|
||||
end
|
||||
|
||||
before do
|
||||
allow(described_class).to receive(:loader_for).and_return(described_class::FormulaAPILoader.new(formula_name))
|
||||
end
|
||||
@ -303,6 +323,25 @@ describe Formulary do
|
||||
formula.install
|
||||
}.to raise_error("Cannot build from source from abstract formula.")
|
||||
end
|
||||
|
||||
it "returns a Formula with variations when given a name", :needs_macos do
|
||||
allow(Homebrew::API::Formula).to receive(:all_formulae).and_return formula_json_contents(variations_json)
|
||||
|
||||
formula = described_class.factory(formula_name)
|
||||
expect(formula).to be_kind_of(Formula)
|
||||
expect(formula.deps.count).to eq 5
|
||||
expect(formula.deps.map(&:name).include?("variations_dep")).to be true
|
||||
end
|
||||
|
||||
it "returns a Formula without duplicated deps and uses_from_macos with variations on Linux", :needs_linux do
|
||||
allow(Homebrew::API::Formula)
|
||||
.to receive(:all_formulae).and_return formula_json_contents(linux_variations_json)
|
||||
|
||||
formula = described_class.factory(formula_name)
|
||||
expect(formula).to be_kind_of(Formula)
|
||||
expect(formula.deps.count).to eq 5
|
||||
expect(formula.deps.map(&:name).include?("uses_from_macos_dep")).to be true
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
@ -1,51 +0,0 @@
|
||||
# typed: false
|
||||
# frozen_string_literal: true
|
||||
|
||||
require "software_spec"
|
||||
|
||||
describe SoftwareSpec do
|
||||
subject(:spec) { described_class.new }
|
||||
|
||||
describe "#uses_from_macos" do
|
||||
before do
|
||||
allow(OS).to receive(:mac?).and_return(true)
|
||||
allow(OS::Mac).to receive(:version).and_return(OS::Mac::Version.from_symbol(:sierra))
|
||||
end
|
||||
|
||||
it "adds a macOS dependency if the OS version meets requirements" do
|
||||
spec.uses_from_macos("foo", since: :el_capitan)
|
||||
|
||||
expect(spec.deps).to be_empty
|
||||
expect(spec.uses_from_macos_elements.first).to eq("foo")
|
||||
end
|
||||
|
||||
it "doesn't add a macOS dependency if the OS version doesn't meet requirements" do
|
||||
spec.uses_from_macos("foo", since: :high_sierra)
|
||||
|
||||
expect(spec.deps.first.name).to eq("foo")
|
||||
expect(spec.uses_from_macos_elements).to eq(["foo"])
|
||||
end
|
||||
|
||||
it "works with tags" do
|
||||
spec.uses_from_macos("foo" => :build, :since => :high_sierra)
|
||||
|
||||
dep = spec.deps.first
|
||||
|
||||
expect(dep.name).to eq("foo")
|
||||
expect(dep.tags).to include(:build)
|
||||
end
|
||||
|
||||
it "doesn't add a dependency if no OS version is specified" do
|
||||
spec.uses_from_macos("foo")
|
||||
spec.uses_from_macos("bar" => :build)
|
||||
|
||||
expect(spec.deps).to be_empty
|
||||
end
|
||||
|
||||
it "raises an error if passing invalid OS versions" do
|
||||
expect {
|
||||
spec.uses_from_macos("foo", since: :bar)
|
||||
}.to raise_error(MacOSVersionError, "unknown or unsupported macOS version: :bar")
|
||||
end
|
||||
end
|
||||
end
|
||||
118
Library/Homebrew/test/simulate_system_spec.rb
Normal file
118
Library/Homebrew/test/simulate_system_spec.rb
Normal file
@ -0,0 +1,118 @@
|
||||
# typed: false
|
||||
# frozen_string_literal: true
|
||||
|
||||
require "settings"
|
||||
|
||||
describe Homebrew::SimulateSystem do
|
||||
after do
|
||||
described_class.clear
|
||||
end
|
||||
|
||||
describe "::simulating_or_running_on_macos?" do
|
||||
it "returns true on macOS", :needs_macos do
|
||||
described_class.clear
|
||||
expect(described_class.simulating_or_running_on_macos?).to be true
|
||||
end
|
||||
|
||||
it "returns false on Linux", :needs_linux do
|
||||
described_class.clear
|
||||
expect(described_class.simulating_or_running_on_macos?).to be false
|
||||
end
|
||||
|
||||
it "returns false on macOS when simulating Linux", :needs_macos do
|
||||
described_class.clear
|
||||
described_class.os = :linux
|
||||
expect(described_class.simulating_or_running_on_macos?).to be false
|
||||
end
|
||||
|
||||
it "returns true on Linux when simulating a generic macOS version", :needs_linux do
|
||||
described_class.clear
|
||||
described_class.os = :macos
|
||||
expect(described_class.simulating_or_running_on_macos?).to be true
|
||||
end
|
||||
|
||||
it "returns true on Linux when simulating a specific macOS version", :needs_linux do
|
||||
described_class.clear
|
||||
described_class.os = :monterey
|
||||
expect(described_class.simulating_or_running_on_macos?).to be true
|
||||
end
|
||||
end
|
||||
|
||||
describe "::simulating_or_running_on_linux?" do
|
||||
it "returns true on Linux", :needs_linux do
|
||||
described_class.clear
|
||||
expect(described_class.simulating_or_running_on_linux?).to be true
|
||||
end
|
||||
|
||||
it "returns false on macOS", :needs_macos do
|
||||
described_class.clear
|
||||
expect(described_class.simulating_or_running_on_linux?).to be false
|
||||
end
|
||||
|
||||
it "returns true on macOS when simulating Linux", :needs_macos do
|
||||
described_class.clear
|
||||
described_class.os = :linux
|
||||
expect(described_class.simulating_or_running_on_linux?).to be true
|
||||
end
|
||||
|
||||
it "returns false on Linux when simulating a generic macOS version", :needs_linux do
|
||||
described_class.clear
|
||||
described_class.os = :macos
|
||||
expect(described_class.simulating_or_running_on_linux?).to be false
|
||||
end
|
||||
|
||||
it "returns false on Linux when simulating a specific macOS version", :needs_linux do
|
||||
described_class.clear
|
||||
described_class.os = :monterey
|
||||
expect(described_class.simulating_or_running_on_linux?).to be false
|
||||
end
|
||||
end
|
||||
|
||||
describe "::current_arch" do
|
||||
it "returns the current architecture" do
|
||||
described_class.clear
|
||||
expect(described_class.current_arch).to eq Hardware::CPU.type
|
||||
end
|
||||
|
||||
it "returns the simulated architecture" do
|
||||
described_class.clear
|
||||
simulated_arch = if Hardware::CPU.arm?
|
||||
:intel
|
||||
else
|
||||
:arm
|
||||
end
|
||||
described_class.arch = simulated_arch
|
||||
expect(described_class.current_arch).to eq simulated_arch
|
||||
end
|
||||
end
|
||||
|
||||
describe "::current_os" do
|
||||
it "returns the current macOS version on macOS", :needs_macos do
|
||||
described_class.clear
|
||||
expect(described_class.current_os).to eq MacOS.version.to_sym
|
||||
end
|
||||
|
||||
it "returns `:linux` on Linux", :needs_linux do
|
||||
described_class.clear
|
||||
expect(described_class.current_os).to eq :linux
|
||||
end
|
||||
|
||||
it "returns `:linux` when simulating Linux on macOS", :needs_macos do
|
||||
described_class.clear
|
||||
described_class.os = :linux
|
||||
expect(described_class.current_os).to eq :linux
|
||||
end
|
||||
|
||||
it "returns `:macos` when simulating a generic macOS version on Linux", :needs_linux do
|
||||
described_class.clear
|
||||
described_class.os = :macos
|
||||
expect(described_class.current_os).to eq :macos
|
||||
end
|
||||
|
||||
it "returns `:macos` when simulating a specific macOS version on Linux", :needs_linux do
|
||||
described_class.clear
|
||||
described_class.os = :monterey
|
||||
expect(described_class.current_os).to eq :monterey
|
||||
end
|
||||
end
|
||||
end
|
||||
@ -135,21 +135,22 @@ describe SoftwareSpec do
|
||||
end
|
||||
end
|
||||
|
||||
describe "#uses_from_macos" do
|
||||
it "allows specifying dependencies", :needs_linux do
|
||||
describe "#uses_from_macos", :needs_linux do
|
||||
context "when running on Linux", :needs_linux do
|
||||
it "allows specifying dependencies" do
|
||||
spec.uses_from_macos("foo")
|
||||
|
||||
expect(spec.deps.first.name).to eq("foo")
|
||||
end
|
||||
|
||||
it "works with tags", :needs_linux do
|
||||
it "works with tags" do
|
||||
spec.uses_from_macos("foo" => :build)
|
||||
|
||||
expect(spec.deps.first.name).to eq("foo")
|
||||
expect(spec.deps.first.tags).to include(:build)
|
||||
end
|
||||
|
||||
it "ignores OS version specifications", :needs_linux do
|
||||
it "ignores OS version specifications" do
|
||||
spec.uses_from_macos("foo", since: :mojave)
|
||||
spec.uses_from_macos("bar" => :build, :since => :mojave)
|
||||
|
||||
@ -159,6 +160,50 @@ describe SoftwareSpec do
|
||||
end
|
||||
end
|
||||
|
||||
context "when running on macOS", :needs_macos do
|
||||
before do
|
||||
allow(OS).to receive(:mac?).and_return(true)
|
||||
allow(OS::Mac).to receive(:version).and_return(OS::Mac::Version.from_symbol(:sierra))
|
||||
end
|
||||
|
||||
it "adds a macOS dependency if the OS version meets requirements" do
|
||||
spec.uses_from_macos("foo", since: :el_capitan)
|
||||
|
||||
expect(spec.deps).to be_empty
|
||||
expect(spec.uses_from_macos_elements.first).to eq("foo")
|
||||
end
|
||||
|
||||
it "doesn't add a macOS dependency if the OS version doesn't meet requirements" do
|
||||
spec.uses_from_macos("foo", since: :high_sierra)
|
||||
|
||||
expect(spec.deps.first.name).to eq("foo")
|
||||
expect(spec.uses_from_macos_elements).to eq(["foo"])
|
||||
end
|
||||
|
||||
it "works with tags" do
|
||||
spec.uses_from_macos("foo" => :build, :since => :high_sierra)
|
||||
|
||||
dep = spec.deps.first
|
||||
|
||||
expect(dep.name).to eq("foo")
|
||||
expect(dep.tags).to include(:build)
|
||||
end
|
||||
|
||||
it "doesn't add a dependency if no OS version is specified" do
|
||||
spec.uses_from_macos("foo")
|
||||
spec.uses_from_macos("bar" => :build)
|
||||
|
||||
expect(spec.deps).to be_empty
|
||||
end
|
||||
|
||||
it "raises an error if passing invalid OS versions" do
|
||||
expect {
|
||||
spec.uses_from_macos("foo", since: :bar)
|
||||
}.to raise_error(MacOSVersionError, "unknown or unsupported macOS version: :bar")
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
specify "explicit options override defaupt depends_on option description" do
|
||||
spec.option("with-foo", "blah")
|
||||
spec.depends_on("foo" => :optional)
|
||||
|
||||
@ -15,8 +15,8 @@ $:.unshift "#{path}/../#{ruby_engine}/#{ruby_version}/gems/ast-2.4.2/lib"
|
||||
$:.unshift "#{path}/../#{ruby_engine}/#{ruby_version}/gems/bindata-2.4.10/lib"
|
||||
$:.unshift "#{path}/../#{ruby_engine}/#{ruby_version}/extensions/x86_64-darwin-15/2.6.0-static/msgpack-1.5.4"
|
||||
$:.unshift "#{path}/../#{ruby_engine}/#{ruby_version}/gems/msgpack-1.5.4/lib"
|
||||
$:.unshift "#{path}/../#{ruby_engine}/#{ruby_version}/extensions/x86_64-darwin-15/2.6.0-static/bootsnap-1.12.0"
|
||||
$:.unshift "#{path}/../#{ruby_engine}/#{ruby_version}/gems/bootsnap-1.12.0/lib"
|
||||
$:.unshift "#{path}/../#{ruby_engine}/#{ruby_version}/extensions/x86_64-darwin-15/2.6.0-static/bootsnap-1.13.0"
|
||||
$:.unshift "#{path}/../#{ruby_engine}/#{ruby_version}/gems/bootsnap-1.13.0/lib"
|
||||
$:.unshift "#{path}/"
|
||||
$:.unshift "#{path}/../#{ruby_engine}/#{ruby_version}/extensions/x86_64-darwin-15/2.6.0-static/byebug-11.1.3"
|
||||
$:.unshift "#{path}/../#{ruby_engine}/#{ruby_version}/gems/byebug-11.1.3/lib"
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user