diff options
| author | William Woodruff | 2018-02-04 21:54:49 -0500 | 
|---|---|---|
| committer | William Woodruff | 2018-02-06 08:44:56 -0500 | 
| commit | 3f43f60a2a52617bfc906f6f08863fce774a8583 (patch) | |
| tree | d5b8cff68a38d35c50bdc7111d689c5522b4f3ef /Library/Homebrew/test/dev-cmd/audit_spec.rb | |
| parent | a44b21b2dfd229c10a0c748c4f06e8ab6520f898 (diff) | |
| download | brew-3f43f60a2a52617bfc906f6f08863fce774a8583.tar.bz2 | |
audit: Warn on new formulae containing binary URLs
Diffstat (limited to 'Library/Homebrew/test/dev-cmd/audit_spec.rb')
| -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 | 
