diff options
| author | Claudia | 2017-10-09 02:32:44 +0200 |
|---|---|---|
| committer | Claudia | 2017-10-20 14:08:22 +0200 |
| commit | e0bb978cc93ab81ffeaa15656fe74384cf7982fc (patch) | |
| tree | 46dbe76ff7863f3bfaced48190dc60b6c4c5556a /Library | |
| parent | a2374cba6cf9a56897f5feeab7f4add661d3c287 (diff) | |
| download | brew-e0bb978cc93ab81ffeaa15656fe74384cf7982fc.tar.bz2 | |
Add tests for `FormulaAuditor#audit_deps`
These tests cover a few aspects of the `FormulaAuditor#audit_deps`
method. The main focus is the part where FormulaAuditor checks for
dependencies on formulas which are tagged `keg_only` with the
`:provided_by_macos` reason.
For this particular kind of `keg_only` formulas, we expect
`brew audit --new-formula` to fail with a problem message like:
> Dependency 'bc' may be unnecessary as it is provided by
> macOS; try to build this formula without it.
For more details, see the relevant discussion:
[1] https://github.com/Homebrew/homebrew-core/pull/14067#issuecomment-335046151
[2] https://github.com/Homebrew/brew/pull/3290#issuecomment-335052140
Diffstat (limited to 'Library')
| -rw-r--r-- | Library/Homebrew/test/dev-cmd/audit_spec.rb | 68 |
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 3e99bd06b..cea8daf6b 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.undent, strict: true |
