From fa384b03faac221d9a98a64a5d998c652fc45aca Mon Sep 17 00:00:00 2001 From: Rylan Polster Date: Sat, 23 Jul 2022 02:00:28 +0200 Subject: [PATCH 1/4] Simplify `SimulateSystem` usage --- Library/Homebrew/extend/on_system.rb | 16 +-- Library/Homebrew/simulate_system.rb | 24 +++- Library/Homebrew/test/simulate_system_spec.rb | 118 ++++++++++++++++++ 3 files changed, 140 insertions(+), 18 deletions(-) create mode 100644 Library/Homebrew/test/simulate_system_spec.rb diff --git a/Library/Homebrew/extend/on_system.rb b/Library/Homebrew/extend/on_system.rb index 5ec59cbdfa6a4..d151e26dddc8a 100644 --- a/Library/Homebrew/extend/on_system.rb +++ b/Library/Homebrew/extend/on_system.rb @@ -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 @@ def os_condition_met?(os_name, or_condition = nil) 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("treat_as_#{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 @@ def os_condition_met?(os_name, or_condition = nil) 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.treat_as_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 diff --git a/Library/Homebrew/simulate_system.rb b/Library/Homebrew/simulate_system.rb index d52a2af752733..c93791afb9400 100644 --- a/Library/Homebrew/simulate_system.rb +++ b/Library/Homebrew/simulate_system.rb @@ -32,19 +32,31 @@ def clear end sig { returns(T::Boolean) } - def none? - @os.nil? && @arch.nil? - end + def treat_as_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 treat_as_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 diff --git a/Library/Homebrew/test/simulate_system_spec.rb b/Library/Homebrew/test/simulate_system_spec.rb new file mode 100644 index 0000000000000..9994b71feac32 --- /dev/null +++ b/Library/Homebrew/test/simulate_system_spec.rb @@ -0,0 +1,118 @@ +# typed: false +# frozen_string_literal: true + +require "settings" + +describe Homebrew::SimulateSystem do + after do + described_class.clear + end + + describe "::treat_as_macos?" do + it "returns true on macOS", :needs_macos do + described_class.clear + expect(described_class.treat_as_macos?).to be true + end + + it "returns false on Linux", :needs_linux do + described_class.clear + expect(described_class.treat_as_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.treat_as_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.treat_as_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.treat_as_macos?).to be true + end + end + + describe "::treat_as_linux?" do + it "returns true on Linux", :needs_linux do + described_class.clear + expect(described_class.treat_as_linux?).to be true + end + + it "returns false on macOS", :needs_macos do + described_class.clear + expect(described_class.treat_as_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.treat_as_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.treat_as_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.treat_as_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 From 34a1bc66188f94caeb830a282b78a0ac7132f098 Mon Sep 17 00:00:00 2001 From: Rylan Polster Date: Sat, 23 Jul 2022 02:58:50 +0200 Subject: [PATCH 2/4] Use `SimulateSystem` for `ignore_missing_libraries` --- Library/Homebrew/extend/os/linux/formula.rb | 13 ------ Library/Homebrew/formula.rb | 13 ++++-- Library/Homebrew/test/formula_spec.rb | 48 +++++++++++++++++++++ 3 files changed, 58 insertions(+), 16 deletions(-) diff --git a/Library/Homebrew/extend/os/linux/formula.rb b/Library/Homebrew/extend/os/linux/formula.rb index da2d162bdfabe..f3586103bcfd6 100644 --- a/Library/Homebrew/extend/os/linux/formula.rb +++ b/Library/Homebrew/extend/os/linux/formula.rb @@ -23,17 +23,4 @@ def rpath 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 diff --git a/Library/Homebrew/formula.rb b/Library/Homebrew/formula.rb index f52caa36508c8..1f842d6aaaf3f 100644 --- a/Library/Homebrew/formula.rb +++ b/Library/Homebrew/formula.rb @@ -3214,10 +3214,17 @@ def link_overwrite_paths 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.treat_as_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 - raise FormulaSpecificationError, "#{__method__} is available on Linux only" + allowed_missing_libraries.merge(libraries) end # @private diff --git a/Library/Homebrew/test/formula_spec.rb b/Library/Homebrew/test/formula_spec.rb index d4680abd7f252..0883985623555 100644 --- a/Library/Homebrew/test/formula_spec.rb +++ b/Library/Homebrew/test/formula_spec.rb @@ -1845,4 +1845,52 @@ def install 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 From 91cf9f2ad8daabb1dbe845341350c8aae5c141a4 Mon Sep 17 00:00:00 2001 From: Rylan Polster Date: Sat, 23 Jul 2022 02:47:22 +0200 Subject: [PATCH 3/4] Use `SimulateSystem` for `uses_from_macos` deps --- .../Homebrew/extend/os/mac/software_spec.rb | 27 ------- Library/Homebrew/extend/os/software_spec.rb | 7 +- Library/Homebrew/software_spec.rb | 21 +++++- .../test/os/mac/software_spec_spec.rb | 51 ------------- Library/Homebrew/test/software_spec_spec.rb | 75 +++++++++++++++---- 5 files changed, 78 insertions(+), 103 deletions(-) delete mode 100644 Library/Homebrew/extend/os/mac/software_spec.rb delete mode 100644 Library/Homebrew/test/os/mac/software_spec_spec.rb diff --git a/Library/Homebrew/extend/os/mac/software_spec.rb b/Library/Homebrew/extend/os/mac/software_spec.rb deleted file mode 100644 index 1be80083e286e..0000000000000 --- a/Library/Homebrew/extend/os/mac/software_spec.rb +++ /dev/null @@ -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 diff --git a/Library/Homebrew/extend/os/software_spec.rb b/Library/Homebrew/extend/os/software_spec.rb index 32f46468f7d89..1e6f8f529c6aa 100644 --- a/Library/Homebrew/extend/os/software_spec.rb +++ b/Library/Homebrew/extend/os/software_spec.rb @@ -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? diff --git a/Library/Homebrew/software_spec.rb b/Library/Homebrew/software_spec.rb index c27f124aa6dc9..14825ce16870f 100644 --- a/Library/Homebrew/software_spec.rb +++ b/Library/Homebrew/software_spec.rb @@ -162,12 +162,25 @@ def depends_on(spec) 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 << deps - @uses_from_macos_elements << 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.treat_as_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(spec) + depends_on deps end def uses_from_macos_names diff --git a/Library/Homebrew/test/os/mac/software_spec_spec.rb b/Library/Homebrew/test/os/mac/software_spec_spec.rb deleted file mode 100644 index c6a72db7350b2..0000000000000 --- a/Library/Homebrew/test/os/mac/software_spec_spec.rb +++ /dev/null @@ -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 diff --git a/Library/Homebrew/test/software_spec_spec.rb b/Library/Homebrew/test/software_spec_spec.rb index 284cf2211a7e4..a737088803742 100644 --- a/Library/Homebrew/test/software_spec_spec.rb +++ b/Library/Homebrew/test/software_spec_spec.rb @@ -135,27 +135,72 @@ end end - describe "#uses_from_macos" do - it "allows specifying dependencies", :needs_linux do - spec.uses_from_macos("foo") + 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 + expect(spec.deps.first.name).to eq("foo") + end - it "works with tags", :needs_linux do - spec.uses_from_macos("foo" => :build) + 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) + expect(spec.deps.first.name).to eq("foo") + expect(spec.deps.first.tags).to include(:build) + end + + it "ignores OS version specifications" do + spec.uses_from_macos("foo", since: :mojave) + spec.uses_from_macos("bar" => :build, :since => :mojave) + + expect(spec.deps.first.name).to eq("foo") + expect(spec.deps.last.name).to eq("bar") + expect(spec.deps.last.tags).to include(:build) + end end - it "ignores OS version specifications", :needs_linux do - spec.uses_from_macos("foo", since: :mojave) - spec.uses_from_macos("bar" => :build, :since => :mojave) + 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.first.name).to eq("foo") - expect(spec.deps.last.name).to eq("bar") - expect(spec.deps.last.tags).to include(:build) + 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 From 4cc0e854ce98950cb75815dbf1813cfd8684195b Mon Sep 17 00:00:00 2001 From: Rylan Polster Date: Thu, 28 Jul 2022 09:18:16 -0400 Subject: [PATCH 4/4] Rename `treat_as_*?` to `simulating_or_running_on_*?` --- Library/Homebrew/extend/on_system.rb | 4 ++-- Library/Homebrew/formula.rb | 2 +- Library/Homebrew/simulate_system.rb | 4 ++-- Library/Homebrew/software_spec.rb | 2 +- Library/Homebrew/test/simulate_system_spec.rb | 24 +++++++++---------- 5 files changed, 18 insertions(+), 18 deletions(-) diff --git a/Library/Homebrew/extend/on_system.rb b/Library/Homebrew/extend/on_system.rb index d151e26dddc8a..a7f7b3744f51f 100644 --- a/Library/Homebrew/extend/on_system.rb +++ b/Library/Homebrew/extend/on_system.rb @@ -25,7 +25,7 @@ def os_condition_met?(os_name, or_condition = nil) return true if [:macos, *MacOSVersions::SYMBOLS.keys].include?(os_name) end - return Homebrew::SimulateSystem.send("treat_as_#{os_name}?") if BASE_OS_OPTIONS.include?(os_name) + 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) @@ -33,7 +33,7 @@ def os_condition_met?(os_name, or_condition = nil) raise ArgumentError, "Invalid OS `or_*` condition: #{or_condition.inspect}" end - return false if Homebrew::SimulateSystem.treat_as_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.current_os) diff --git a/Library/Homebrew/formula.rb b/Library/Homebrew/formula.rb index 1f842d6aaaf3f..d2f9ea56f2530 100644 --- a/Library/Homebrew/formula.rb +++ b/Library/Homebrew/formula.rb @@ -3215,7 +3215,7 @@ def link_overwrite_paths # Permit links to certain libraries that don't exist. Available on Linux only. def ignore_missing_libraries(*libs) - unless Homebrew::SimulateSystem.treat_as_linux? + unless Homebrew::SimulateSystem.simulating_or_running_on_linux? raise FormulaSpecificationError, "#{__method__} is available on Linux only" end diff --git a/Library/Homebrew/simulate_system.rb b/Library/Homebrew/simulate_system.rb index c93791afb9400..de61eabef70ee 100644 --- a/Library/Homebrew/simulate_system.rb +++ b/Library/Homebrew/simulate_system.rb @@ -32,14 +32,14 @@ def clear end sig { returns(T::Boolean) } - def treat_as_macos? + def simulating_or_running_on_macos? return OS.mac? if @os.blank? [:macos, *MacOSVersions::SYMBOLS.keys].include?(@os) end sig { returns(T::Boolean) } - def treat_as_linux? + def simulating_or_running_on_linux? return OS.linux? if @os.blank? @os == :linux diff --git a/Library/Homebrew/software_spec.rb b/Library/Homebrew/software_spec.rb index 14825ce16870f..30e9856d837c5 100644 --- a/Library/Homebrew/software_spec.rb +++ b/Library/Homebrew/software_spec.rb @@ -174,7 +174,7 @@ def uses_from_macos(deps, bounds = {}) return if Homebrew::EnvConfig.simulate_macos_on_linux? && !bounds.key?(:since) # macOS new enough for dependency to not be required. - if Homebrew::SimulateSystem.treat_as_macos? + 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 diff --git a/Library/Homebrew/test/simulate_system_spec.rb b/Library/Homebrew/test/simulate_system_spec.rb index 9994b71feac32..0b72700d9f313 100644 --- a/Library/Homebrew/test/simulate_system_spec.rb +++ b/Library/Homebrew/test/simulate_system_spec.rb @@ -8,63 +8,63 @@ described_class.clear end - describe "::treat_as_macos?" do + describe "::simulating_or_running_on_macos?" do it "returns true on macOS", :needs_macos do described_class.clear - expect(described_class.treat_as_macos?).to be true + 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.treat_as_macos?).to be false + 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.treat_as_macos?).to be false + 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.treat_as_macos?).to be true + 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.treat_as_macos?).to be true + expect(described_class.simulating_or_running_on_macos?).to be true end end - describe "::treat_as_linux?" do + describe "::simulating_or_running_on_linux?" do it "returns true on Linux", :needs_linux do described_class.clear - expect(described_class.treat_as_linux?).to be true + 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.treat_as_linux?).to be false + 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.treat_as_linux?).to be true + 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.treat_as_linux?).to be false + 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.treat_as_linux?).to be false + expect(described_class.simulating_or_running_on_linux?).to be false end end