Rename Override module to SimulateSystem
This commit is contained in:
parent
d96a8fd35e
commit
5ec19adf58
@ -255,8 +255,8 @@ module Cask
|
||||
# Big Sur is the first version of macOS that supports arm
|
||||
next if arch == :arm && MacOS::Version.from_symbol(os_name) < MacOS::Version.from_symbol(:big_sur)
|
||||
|
||||
Homebrew::Override.os = os_name
|
||||
Homebrew::Override.arch = arch
|
||||
Homebrew::SimulateSystem.os = os_name
|
||||
Homebrew::SimulateSystem.arch = arch
|
||||
|
||||
refresh
|
||||
|
||||
@ -272,7 +272,7 @@ module Cask
|
||||
end
|
||||
end
|
||||
|
||||
Homebrew::Override.clear
|
||||
Homebrew::SimulateSystem.clear
|
||||
refresh
|
||||
|
||||
hash["variations"] = variations
|
||||
|
||||
@ -4,7 +4,6 @@
|
||||
require "locale"
|
||||
require "lazy_object"
|
||||
require "livecheck"
|
||||
require "override"
|
||||
|
||||
require "cask/artifact"
|
||||
|
||||
|
||||
@ -1,7 +1,7 @@
|
||||
# typed: false
|
||||
# frozen_string_literal: true
|
||||
|
||||
require "override"
|
||||
require "simulate_system"
|
||||
|
||||
module OnSystem
|
||||
extend T::Sig
|
||||
@ -13,9 +13,9 @@ module OnSystem
|
||||
|
||||
sig { params(arch: Symbol).returns(T::Boolean) }
|
||||
def arch_condition_met?(arch)
|
||||
raise ArgumentError, "Invalid arch condition: #{arch.inspect}" unless ARCH_OPTIONS.include?(arch)
|
||||
raise ArgumentError, "Invalid arch condition: #{arch.inspect}" if ARCH_OPTIONS.exclude?(arch)
|
||||
|
||||
current_arch = Homebrew::Override.arch || Hardware::CPU.type
|
||||
current_arch = Homebrew::SimulateSystem.arch || Hardware::CPU.type
|
||||
arch == current_arch
|
||||
end
|
||||
|
||||
@ -27,12 +27,12 @@ module OnSystem
|
||||
end
|
||||
|
||||
if BASE_OS_OPTIONS.include?(os_name)
|
||||
if Homebrew::Override.none?
|
||||
if Homebrew::SimulateSystem.none?
|
||||
return OS.linux? if os_name == :linux
|
||||
return OS.mac? if os_name == :macos
|
||||
end
|
||||
|
||||
return Homebrew::Override.send("#{os_name}?")
|
||||
return Homebrew::SimulateSystem.send("#{os_name}?")
|
||||
end
|
||||
|
||||
raise ArgumentError, "Invalid OS condition: #{os_name.inspect}" unless MacOS::Version::SYMBOLS.key?(os_name)
|
||||
@ -42,7 +42,7 @@ module OnSystem
|
||||
end
|
||||
|
||||
base_os = MacOS::Version.from_symbol(os_name)
|
||||
current_os = MacOS::Version.from_symbol(Homebrew::Override.os || MacOS.version.to_sym)
|
||||
current_os = MacOS::Version.from_symbol(Homebrew::SimulateSystem.os || MacOS.version.to_sym)
|
||||
|
||||
return current_os >= base_os if or_condition == :or_newer
|
||||
return current_os <= base_os if or_condition == :or_older
|
||||
|
||||
@ -2,16 +2,13 @@
|
||||
# frozen_string_literal: true
|
||||
|
||||
module Homebrew
|
||||
# Helper module for overriding machine-specific methods.
|
||||
# Helper module for simulating different system condfigurations.
|
||||
#
|
||||
# @api private
|
||||
class Override
|
||||
class SimulateSystem
|
||||
class << self
|
||||
extend T::Sig
|
||||
|
||||
ARCH_OPTIONS = [:intel, :arm64].freeze
|
||||
OS_OPTIONS = [:macos, :linux].freeze
|
||||
|
||||
attr_reader :os, :arch
|
||||
|
||||
sig { params(new_os: Symbol).void }
|
||||
@ -1583,11 +1583,11 @@ describe Formula do
|
||||
|
||||
describe "on_{os_version} blocks", :needs_macos do
|
||||
before do
|
||||
Homebrew::Override.os = :monterey
|
||||
Homebrew::SimulateSystem.os = :monterey
|
||||
end
|
||||
|
||||
after do
|
||||
Homebrew::Override.clear
|
||||
Homebrew::SimulateSystem.clear
|
||||
end
|
||||
|
||||
let(:f) do
|
||||
@ -1610,31 +1610,31 @@ describe Formula do
|
||||
end
|
||||
|
||||
it "only calls code within `on_monterey`" do
|
||||
Homebrew::Override.os = :monterey
|
||||
Homebrew::SimulateSystem.os = :monterey
|
||||
f.brew { f.install }
|
||||
expect(f.test).to eq(1)
|
||||
end
|
||||
|
||||
it "only calls code within `on_monterey :or_newer`" do
|
||||
Homebrew::Override.os = :ventura
|
||||
Homebrew::SimulateSystem.os = :ventura
|
||||
f.brew { f.install }
|
||||
expect(f.test).to eq(1)
|
||||
end
|
||||
|
||||
it "only calls code within `on_big_sur`" do
|
||||
Homebrew::Override.os = :big_sur
|
||||
Homebrew::SimulateSystem.os = :big_sur
|
||||
f.brew { f.install }
|
||||
expect(f.test).to eq(2)
|
||||
end
|
||||
|
||||
it "only calls code within `on_catalina`" do
|
||||
Homebrew::Override.os = :catalina
|
||||
Homebrew::SimulateSystem.os = :catalina
|
||||
f.brew { f.install }
|
||||
expect(f.test).to eq(3)
|
||||
end
|
||||
|
||||
it "only calls code within `on_catalina :or_older`" do
|
||||
Homebrew::Override.os = :mojave
|
||||
Homebrew::SimulateSystem.os = :mojave
|
||||
f.brew { f.install }
|
||||
expect(f.test).to eq(3)
|
||||
end
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user