Added tests for plist_caveats
This commit is contained in:
parent
5fba0c4776
commit
9218d3014d
@ -165,7 +165,6 @@ class Caveats
|
|||||||
s = []
|
s = []
|
||||||
if f.plist || (keg && keg.plist_installed?)
|
if f.plist || (keg && keg.plist_installed?)
|
||||||
plist_domain = f.plist_path.basename(".plist")
|
plist_domain = f.plist_path.basename(".plist")
|
||||||
plist_path = plist_complete_path
|
|
||||||
|
|
||||||
# we readlink because this path probably doesn't exist since caveats
|
# we readlink because this path probably doesn't exist since caveats
|
||||||
# occurs before the link step of installation
|
# occurs before the link step of installation
|
||||||
@ -197,8 +196,8 @@ class Caveats
|
|||||||
s << " #{f.plist_manual}"
|
s << " #{f.plist_manual}"
|
||||||
end
|
end
|
||||||
|
|
||||||
# pbpaste is a system clipboard tool for OSX that doesn't work well with tmux
|
# pbpaste pastes the system clipboard tool on macOS and fails with `tmux` by default
|
||||||
# This checks if tmux is being used and warns about brew failure
|
# check if this is being run under `tmux` to avoid failing
|
||||||
if ENV["TMUX"] && !quiet_system("/usr/bin/pbpaste")
|
if ENV["TMUX"] && !quiet_system("/usr/bin/pbpaste")
|
||||||
s << "" << "WARNING: brew services will fail when run under tmux."
|
s << "" << "WARNING: brew services will fail when run under tmux."
|
||||||
end
|
end
|
||||||
@ -206,7 +205,7 @@ class Caveats
|
|||||||
s.join("\n") + "\n" unless s.empty?
|
s.join("\n") + "\n" unless s.empty?
|
||||||
end
|
end
|
||||||
|
|
||||||
def plist_complete_path
|
def plist_path
|
||||||
destination = if f.plist_startup
|
destination = if f.plist_startup
|
||||||
"/Library/LaunchDaemons"
|
"/Library/LaunchDaemons"
|
||||||
else
|
else
|
||||||
@ -218,8 +217,8 @@ class Caveats
|
|||||||
else
|
else
|
||||||
File.basename Dir["#{keg}/*.plist"].first
|
File.basename Dir["#{keg}/*.plist"].first
|
||||||
end
|
end
|
||||||
destination_path = Pathname.new File.expand_path destination
|
destination_path = Pathname.new(File.expand_path(destination))
|
||||||
|
|
||||||
return destination_path/plist_filename
|
destination_path/plist_filename
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|||||||
@ -1,6 +1,5 @@
|
|||||||
require "formula"
|
require "formula"
|
||||||
require "caveats"
|
require "caveats"
|
||||||
require "pathname"
|
|
||||||
|
|
||||||
describe Caveats do
|
describe Caveats do
|
||||||
subject { described_class.new(f) }
|
subject { described_class.new(f) }
|
||||||
@ -50,6 +49,81 @@ describe Caveats do
|
|||||||
end
|
end
|
||||||
expect(described_class.new(f).caveats).to include("login")
|
expect(described_class.new(f).caveats).to include("login")
|
||||||
end
|
end
|
||||||
|
|
||||||
|
it "gives information about restarting services after upgrade" do
|
||||||
|
f = formula do
|
||||||
|
url "foo-1.0"
|
||||||
|
def plist
|
||||||
|
"plist_test.plist"
|
||||||
|
end
|
||||||
|
plist_options startup: true
|
||||||
|
end
|
||||||
|
f_obj = described_class.new(f)
|
||||||
|
plist_path = Pathname.new("plist")
|
||||||
|
FileUtils.touch plist_path
|
||||||
|
allow(f_obj).to receive(:plist_path).and_return(plist_path)
|
||||||
|
allow(plist_path).to receive(:symlink?).and_return(true)
|
||||||
|
expect(f_obj.caveats).to include("restart #{f.full_name}")
|
||||||
|
expect(f_obj.caveats).to include("sudo")
|
||||||
|
end
|
||||||
|
|
||||||
|
context "when plist_path is not a file nor symlinked and plist_startup is false" do
|
||||||
|
let(:f) {
|
||||||
|
formula do
|
||||||
|
url "foo-1.0"
|
||||||
|
def plist
|
||||||
|
"plist_test.plist"
|
||||||
|
end
|
||||||
|
end
|
||||||
|
}
|
||||||
|
let(:f_obj) { described_class.new(f) }
|
||||||
|
let(:caveats) { f_obj.caveats }
|
||||||
|
let(:plist_path) { Pathname.new("plist") }
|
||||||
|
|
||||||
|
before do
|
||||||
|
FileUtils.touch plist_path
|
||||||
|
allow(f_obj).to receive(:plist_path).and_return(plist_path)
|
||||||
|
allow(plist_path).to receive(:symlink?).and_return(true)
|
||||||
|
end
|
||||||
|
|
||||||
|
it "tells command to run after upgrade" do
|
||||||
|
allow(Kernel).to receive(:system).with(any_args).and_return(true)
|
||||||
|
expect(caveats).to include("restart #{f.full_name} after an upgrade")
|
||||||
|
end
|
||||||
|
|
||||||
|
it "tells command to run to start formula" do
|
||||||
|
expect(caveats).to include("To start #{f.full_name}:")
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
it "gives information about plist_manual" do
|
||||||
|
f = formula do
|
||||||
|
url "foo-1.0"
|
||||||
|
def plist
|
||||||
|
"plist_test.plist"
|
||||||
|
end
|
||||||
|
plist_options manual: "foo"
|
||||||
|
end
|
||||||
|
caveats = described_class.new(f).caveats
|
||||||
|
|
||||||
|
expect(caveats).to include("background service")
|
||||||
|
expect(caveats).to include(f.plist_manual)
|
||||||
|
end
|
||||||
|
|
||||||
|
it "warns about brew failing under tmux" do
|
||||||
|
f = formula do
|
||||||
|
url "foo-1.0"
|
||||||
|
def plist
|
||||||
|
"plist_test.plist"
|
||||||
|
end
|
||||||
|
end
|
||||||
|
allow(ENV).to receive(:[]).with("TMUX").and_return(true)
|
||||||
|
allow(Homebrew).to receive(:_system).with("/usr/bin/pbpaste").and_return(false)
|
||||||
|
caveats = described_class.new(f).caveats
|
||||||
|
|
||||||
|
expect(caveats).to include("WARNING:")
|
||||||
|
expect(caveats).to include("tmux")
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
context "when f.keg_only is not nil" do
|
context "when f.keg_only is not nil" do
|
||||||
@ -127,53 +201,5 @@ describe Caveats do
|
|||||||
expect(caveats).to include(HOMEBREW_PREFIX/"share/fish/vendor_completions.d")
|
expect(caveats).to include(HOMEBREW_PREFIX/"share/fish/vendor_completions.d")
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
context "when plist_caveats are given" do
|
|
||||||
it "gives information about plist_manual" do
|
|
||||||
f = formula do
|
|
||||||
url "foo-1.0"
|
|
||||||
def plist
|
|
||||||
"plist_test.plist"
|
|
||||||
end
|
|
||||||
plist_options manual: "foo"
|
|
||||||
end
|
|
||||||
caveats = described_class.new(f).caveats
|
|
||||||
|
|
||||||
expect(caveats).to include("background service")
|
|
||||||
expect(caveats).to include(f.plist_manual)
|
|
||||||
end
|
|
||||||
|
|
||||||
it "warns about brew failing under tmux" do
|
|
||||||
f = formula do
|
|
||||||
url "foo-1.0"
|
|
||||||
def plist
|
|
||||||
"plist_test.plist"
|
|
||||||
end
|
|
||||||
end
|
|
||||||
allow(ENV).to receive(:[]).with("TMUX").and_return(true)
|
|
||||||
allow(Homebrew).to receive(:_system).with("/usr/bin/pbpaste").and_return(false)
|
|
||||||
caveats = described_class.new(f).caveats
|
|
||||||
|
|
||||||
expect(caveats).to include("WARNING:")
|
|
||||||
expect(caveats).to include("tmux")
|
|
||||||
end
|
|
||||||
|
|
||||||
it "gives information about restarting services after upgrade" do
|
|
||||||
f = formula do
|
|
||||||
url "foo-1.0"
|
|
||||||
def plist
|
|
||||||
"plist_test.plist"
|
|
||||||
end
|
|
||||||
plist_options startup: true
|
|
||||||
end
|
|
||||||
f_obj = described_class.new(f)
|
|
||||||
plist_path = Pathname.new("plist")
|
|
||||||
FileUtils.touch plist_path
|
|
||||||
allow(f_obj).to receive(:plist_complete_path).and_return(plist_path)
|
|
||||||
allow(plist_path).to receive(:symlink?).and_return(true)
|
|
||||||
expect(f_obj.caveats).to include("restart #{f.full_name}")
|
|
||||||
expect(f_obj.caveats).to include("sudo")
|
|
||||||
end
|
|
||||||
end
|
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user