Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Revert "formula: remove OnOS." #12925

Merged
merged 2 commits into from
Feb 24, 2022
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
12 changes: 0 additions & 12 deletions Library/Homebrew/compat/formula.rb
Original file line number Diff line number Diff line change
Expand Up @@ -2,18 +2,6 @@
# 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)
Expand Down
1 change: 1 addition & 0 deletions Library/Homebrew/formula.rb
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,7 @@ class Formula
include Utils::Shebang
include Utils::Shell
include Context
include OnOS # TODO: 3.4.0: odeprecate OnOS usage in instance methods.
MikeMcQuaid marked this conversation as resolved.
Show resolved Hide resolved
extend Forwardable
extend Cachable
extend Predicable
Expand Down
46 changes: 46 additions & 0 deletions Library/Homebrew/test/formula_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -1534,4 +1534,50 @@ def setup_tab_for_prefix(prefix, options = {})
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