license: update tests and license checking logic
This commit is contained in:
parent
e4e55c5cb3
commit
127d67e745
@ -350,7 +350,7 @@ module Homebrew
|
|||||||
|
|
||||||
def audit_license
|
def audit_license
|
||||||
if formula.license.present?
|
if formula.license.present?
|
||||||
if @spdx_data.key?(formula.license)
|
if @spdx_data["licenses"].any?{|lic| lic["licenseId"] == formula.license}
|
||||||
return unless @online
|
return unless @online
|
||||||
|
|
||||||
user, repo = get_repo_data(%r{https?://github\.com/([^/]+)/([^/]+)/?.*})
|
user, repo = get_repo_data(%r{https?://github\.com/([^/]+)/([^/]+)/?.*})
|
||||||
|
|||||||
@ -96,7 +96,7 @@ module Homebrew
|
|||||||
end
|
end
|
||||||
|
|
||||||
describe "#audit_license" do
|
describe "#audit_license" do
|
||||||
let(:spdx_ids) {
|
let(:spdx_data) {
|
||||||
full_path = File.join(File.dirname(__FILE__), "../../data/spdx.json")
|
full_path = File.join(File.dirname(__FILE__), "../../data/spdx.json")
|
||||||
File.open(full_path, "r") do |f|
|
File.open(full_path, "r") do |f|
|
||||||
JSON.parse(f.read)
|
JSON.parse(f.read)
|
||||||
@ -107,7 +107,7 @@ module Homebrew
|
|||||||
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
|
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
|
fa = formula_auditor "foo", <<~RUBY, spdx_data: spdx_data, new_formula: false
|
||||||
class Foo < Formula
|
class Foo < Formula
|
||||||
url "https://brew.sh/foo-1.0.tgz"
|
url "https://brew.sh/foo-1.0.tgz"
|
||||||
license ""
|
license ""
|
||||||
@ -119,7 +119,7 @@ module Homebrew
|
|||||||
end
|
end
|
||||||
|
|
||||||
it "detects no license info" do
|
it "detects no license info" do
|
||||||
fa = formula_auditor "foo", <<~RUBY, spdx_ids: spdx_ids, new_formula: true
|
fa = formula_auditor "foo", <<~RUBY, spdx_data: spdx_data, 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 ""
|
||||||
@ -132,7 +132,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, new_formula: true
|
fa = formula_auditor "foo", <<~RUBY, spdx_data: spdx_data, 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}"
|
||||||
@ -144,7 +144,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, new_formula: true
|
fa = formula_auditor "foo", <<~RUBY, spdx_data: spdx_data, 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"
|
||||||
@ -157,7 +157,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, new_formula: true
|
fa = formula_auditor "cask", <<~RUBY, spdx_data: spdx_data, 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"
|
||||||
@ -166,12 +166,12 @@ module Homebrew
|
|||||||
RUBY
|
RUBY
|
||||||
|
|
||||||
fa.audit_license
|
fa.audit_license
|
||||||
expect(fa.problems).to be_empty
|
expect(fa.problems).to be_empty
|
||||||
end
|
end
|
||||||
|
|
||||||
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, new_formula: true
|
fa = formula_auditor "cask", <<~RUBY, online: true, spdx_data: spdx_data, 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"
|
||||||
|
|||||||
@ -1,9 +1,7 @@
|
|||||||
require 'rspec'
|
# frozen_string_literal: true
|
||||||
|
|
||||||
describe 'My behaviour' do
|
require "cmd/shared_examples/args_parse"
|
||||||
|
|
||||||
it 'should do something' do
|
describe "Homebrew.update_license_data_args" do
|
||||||
|
it_behaves_like "parseable arguments"
|
||||||
true.should == false
|
end
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user