audit spec: include cases for new formula

This commit is contained in:
Lionell 2020-06-18 00:45:13 +08:00
parent 610dfe0fc2
commit f78d4f41a0

View File

@ -106,8 +106,21 @@ module Homebrew
let(:custom_spdx_id) { "zzz" } let(:custom_spdx_id) { "zzz" }
let(:standard_mismatch_spdx_id) { "0BSD" } let(:standard_mismatch_spdx_id) { "0BSD" }
it "does not check if the formula is not a new formula" do
fa = formula_auditor "foo", <<~RUBY, spdx_ids: spdx_ids, new_formula: false
class Foo < Formula
url "https://brew.sh/foo-1.0.tgz"
license ""
end
RUBY
fa.audit_license
p fa.problems
expect(fa.problems).to be_empty
end
it "detects no license info" do it "detects no license info" do
fa = formula_auditor "foo", <<~RUBY, spdx_ids: spdx_ids fa = formula_auditor "foo", <<~RUBY, spdx_ids: spdx_ids, new_formula: true
class Foo < Formula class Foo < Formula
url "https://brew.sh/foo-1.0.tgz" url "https://brew.sh/foo-1.0.tgz"
license "" license ""
@ -120,7 +133,7 @@ module Homebrew
end end
it "detects if license is not a standard spdx-id" do it "detects if license is not a standard spdx-id" do
fa = formula_auditor "foo", <<~RUBY, spdx_ids: spdx_ids fa = formula_auditor "foo", <<~RUBY, spdx_ids: spdx_ids, new_formula: true
class Foo < Formula class Foo < Formula
url "https://brew.sh/foo-1.0.tgz" url "https://brew.sh/foo-1.0.tgz"
license "#{custom_spdx_id}" license "#{custom_spdx_id}"
@ -132,7 +145,7 @@ module Homebrew
end end
it "verifies that a license info is a standard spdx id" do it "verifies that a license info is a standard spdx id" do
fa = formula_auditor "foo", <<~RUBY, spdx_ids: spdx_ids fa = formula_auditor "foo", <<~RUBY, spdx_ids: spdx_ids, new_formula: true
class Foo < Formula class Foo < Formula
url "https://brew.sh/foo-1.0.tgz" url "https://brew.sh/foo-1.0.tgz"
license "0BSD" license "0BSD"
@ -145,7 +158,7 @@ module Homebrew
it "checks online and verifies that a standard license id is the same "\ it "checks online and verifies that a standard license id is the same "\
"as what is indicated on its Github repo" do "as what is indicated on its Github repo" do
fa = formula_auditor "cask", <<~RUBY, spdx_ids: spdx_ids, online: true, core_tap: true fa = formula_auditor "cask", <<~RUBY, spdx_ids: spdx_ids, online: true, core_tap: true, new_formula: true
class Cask < Formula class Cask < Formula
url "https://github.com/cask/cask/archive/v0.8.4.tar.gz" url "https://github.com/cask/cask/archive/v0.8.4.tar.gz"
head "https://github.com/cask/cask.git" head "https://github.com/cask/cask.git"
@ -159,7 +172,7 @@ module Homebrew
it "checks online and detects that a formula-specified license is not "\ it "checks online and detects that a formula-specified license is not "\
"the same as what is indicated on its Github repository" do "the same as what is indicated on its Github repository" do
fa = formula_auditor "cask", <<~RUBY, online: true, spdx_ids: spdx_ids, core_tap: true fa = formula_auditor "cask", <<~RUBY, online: true, spdx_ids: spdx_ids, core_tap: true, new_formula: true
class Cask < Formula class Cask < Formula
url "https://github.com/cask/cask/archive/v0.8.4.tar.gz" url "https://github.com/cask/cask/archive/v0.8.4.tar.gz"
head "https://github.com/cask/cask.git" head "https://github.com/cask/cask.git"