Merge pull request #12912 from Homebrew/formula_remove_include_on_os

formula: remove `OnOS`.
This commit is contained in:
Mike McQuaid 2022-02-24 08:44:30 +00:00 committed by GitHub
commit a92b86de0f
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 12 additions and 47 deletions

View File

@ -2,6 +2,18 @@
# frozen_string_literal: true
class Formula
extend OnOS
def on_macos(&block)
odeprecated "`on_macos do` inside `Formula` methods", "`if OS.mac?`"
super
end
def on_linux(&block)
odeprecated "`on_linux do` inside `Formula` methods", "`if OS.linux?`"
super
end
extend Enumerable
def self.each(&_block)

View File

@ -64,7 +64,6 @@ class Formula
include Utils::Shebang
include Utils::Shell
include Context
include OnOS # TODO: 3.4.0: odeprecate OnOS usage in instance methods.
extend Forwardable
extend Cachable
extend Predicable

View File

@ -1534,50 +1534,4 @@ describe Formula do
expect(f.any_installed_version).to eq(PkgVersion.parse("1.0_1"))
end
end
describe "#on_macos", :needs_macos do
let(:f) do
Class.new(Testball) do
@test = 0
attr_reader :test
def install
on_macos do
@test = 1
end
on_linux do
@test = 2
end
end
end.new
end
it "only calls code within on_macos" do
f.brew { f.install }
expect(f.test).to eq(1)
end
end
describe "#on_linux", :needs_linux do
let(:f) do
Class.new(Testball) do
@test = 0
attr_reader :test
def install
on_macos do
@test = 1
end
on_linux do
@test = 2
end
end
end.new
end
it "only calls code within on_linux" do
f.brew { f.install }
expect(f.test).to eq(2)
end
end
end