From 84e3e0a6b87229067041da4e947ee4f352892b62 Mon Sep 17 00:00:00 2001 From: Alexander Bayandin Date: Tue, 15 Jun 2021 13:25:26 +0100 Subject: [PATCH] audit_spec: add tests for audit_conflicts --- Library/Homebrew/test/dev-cmd/audit_spec.rb | 53 +++++++++++++++++++++ 1 file changed, 53 insertions(+) diff --git a/Library/Homebrew/test/dev-cmd/audit_spec.rb b/Library/Homebrew/test/dev-cmd/audit_spec.rb index 92dcb75377..259e6bd2c1 100644 --- a/Library/Homebrew/test/dev-cmd/audit_spec.rb +++ b/Library/Homebrew/test/dev-cmd/audit_spec.rb @@ -1139,5 +1139,58 @@ module Homebrew expect(fa.problems).to be_empty end end + + describe "#audit_conflicts" do + specify "it warns when conflicting with non-existing formula" do + fa = formula_auditor "foo", <<~RUBY + class Foo < Formula + url "https://brew.sh/foo-1.0.tgz" + + conflicts_with "bar" + end + RUBY + + fa.audit_conflicts + + expect(fa.problems.first[:message]) + .to match("Can't find conflicting formula \"bar\"") + end + + specify "it warns when conflicting with itself" do + fa = formula_auditor "foo", <<~RUBY + class Foo < Formula + url "https://brew.sh/foo-1.0.tgz" + + conflicts_with "#{dir}/foo.rb" + end + RUBY + + fa.audit_conflicts + + expect(fa.problems.first[:message]) + .to match("Formula should not conflict with itself") + end + + specify "it warns when another formula does not have a symmetric conflict" do + formula_auditor "bar", <<~RUBY + class Bar < Formula + url "https://brew.sh/foo-1.0.tgz" + end + RUBY + + fa = formula_auditor "foo", <<~RUBY + class Foo < Formula + url "https://brew.sh/foo-1.0.tgz" + + conflicts_with "#{dir}/bar.rb" + end + RUBY + + fa.audit_conflicts + + expect(fa.problems.first[:message]) + .to match("Formula bar should also have a conflict declared with foo") + end + end end end