diff options
Diffstat (limited to 'Library/Homebrew/test')
| -rw-r--r-- | Library/Homebrew/test/dev-cmd/audit_spec.rb | 78 |
1 files changed, 78 insertions, 0 deletions
diff --git a/Library/Homebrew/test/dev-cmd/audit_spec.rb b/Library/Homebrew/test/dev-cmd/audit_spec.rb index 2381ff1f5..38884222d 100644 --- a/Library/Homebrew/test/dev-cmd/audit_spec.rb +++ b/Library/Homebrew/test/dev-cmd/audit_spec.rb @@ -522,4 +522,82 @@ describe FormulaAuditor do end end end + + describe "#audit_url_is_not_binary" do + specify "it detects a url containing darwin and x86_64" do + fa = formula_auditor "foo", <<~EOS, official_tap: true + class Foo < Formula + url "https://example.com/example-darwin.x86_64.tar.gz" + end + EOS + + fa.audit_url_is_not_binary + + expect(fa.problems.first) + .to match("looks like a binary package, not a source archive. Official taps are source-only.") + end + + specify "it detects a url containing darwin and amd64" do + fa = formula_auditor "foo", <<~EOS, official_tap: true + class Foo < Formula + url "https://example.com/example-darwin.amd64.tar.gz" + end + EOS + + fa.audit_url_is_not_binary + + expect(fa.problems.first) + .to match("looks like a binary package, not a source archive. Official taps are source-only.") + end + + specify "it works on the devel spec" do + fa = formula_auditor "foo", <<~EOS, official_tap: true + class Foo < Formula + url "https://example.com/valid-1.0.tar.gz" + + devel do + url "https://example.com/example-darwin.x86_64.tar.gz" + end + end + EOS + + fa.audit_url_is_not_binary + + expect(fa.problems.first) + .to match("looks like a binary package, not a source archive. Official taps are source-only.") + end + + specify "it works on the head spec" do + fa = formula_auditor "foo", <<~EOS, official_tap: true + class Foo < Formula + url "https://example.com/valid-1.0.tar.gz" + + head do + url "https://example.com/example-darwin.x86_64.tar.gz" + end + end + EOS + + fa.audit_url_is_not_binary + + expect(fa.problems.first) + .to match("looks like a binary package, not a source archive. Official taps are source-only.") + end + + specify "it ignores resource urls" do + fa = formula_auditor "foo", <<~EOS, official_tap: true + class Foo < Formula + url "https://example.com/valid-1.0.tar.gz" + + resource "binary_res" do + url "https://example.com/example-darwin.x86_64.tar.gz" + end + end + EOS + + fa.audit_url_is_not_binary + + expect(fa.problems).to eq([]) + end + end end |
