aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMike McQuaid2017-11-10 13:34:56 +0000
committerGitHub2017-11-10 13:34:56 +0000
commit219f9691ef6ece820c528dc280d1b253c2a40412 (patch)
treeb2a3d19334eae04d627f0854afe7408b9e56330a
parent934480ca44b292cb6a50b2fc4a6aa78e065c1e47 (diff)
parente0bb978cc93ab81ffeaa15656fe74384cf7982fc (diff)
downloadbrew-219f9691ef6ece820c528dc280d1b253c2a40412.tar.bz2
Merge pull request #3292 from claui/add-audit-test-cases
Add tests for `FormulaAuditor#audit_deps`
-rw-r--r--Library/Homebrew/test/dev-cmd/audit_spec.rb68
1 files changed, 68 insertions, 0 deletions
diff --git a/Library/Homebrew/test/dev-cmd/audit_spec.rb b/Library/Homebrew/test/dev-cmd/audit_spec.rb
index 8dd3aee72..857b69c07 100644
--- a/Library/Homebrew/test/dev-cmd/audit_spec.rb
+++ b/Library/Homebrew/test/dev-cmd/audit_spec.rb
@@ -217,6 +217,74 @@ describe FormulaAuditor do
end
end
+ describe "#audit_deps" do
+ describe "a dependency on a macOS-provided keg-only formula" do
+ describe "which is whitelisted" do
+ let(:fa) do
+ formula_auditor "foo", <<-EOS.undent, new_formula: true
+ class Foo < Formula
+ url "http://example.com/foo-1.0.tgz"
+ homepage "http://example.com"
+
+ depends_on "openssl"
+ end
+ EOS
+ end
+
+ let(:f_openssl) do
+ formula do
+ url "http://example.com/openssl-1.0.tgz"
+ homepage "http://example.com"
+
+ keg_only :provided_by_macos
+ end
+ end
+
+ before do
+ allow(fa.formula.deps.first)
+ .to receive(:to_formula).and_return(f_openssl)
+ fa.audit_deps
+ end
+
+ subject { fa }
+
+ its(:problems) { are_expected.to be_empty }
+ end
+
+ describe "which is not whitelisted" do
+ let(:fa) do
+ formula_auditor "foo", <<-EOS.undent, new_formula: true
+ class Foo < Formula
+ url "http://example.com/foo-1.0.tgz"
+ homepage "http://example.com"
+
+ depends_on "bc"
+ end
+ EOS
+ end
+
+ let(:f_bc) do
+ formula do
+ url "http://example.com/bc-1.0.tgz"
+ homepage "http://example.com"
+
+ keg_only :provided_by_macos
+ end
+ end
+
+ before do
+ allow(fa.formula.deps.first)
+ .to receive(:to_formula).and_return(f_bc)
+ fa.audit_deps
+ end
+
+ subject { fa }
+
+ its(:problems) { are_expected.to match([/unnecessary/]) }
+ end
+ end
+ end
+
describe "#audit_keg_only_style" do
specify "keg_only_needs_downcasing" do
fa = formula_auditor "foo", <<~EOS, strict: true