version 1.9, 2018/01/13 23:56:14 |
version 1.25, 2019/11/23 23:35:56 |
|
|
package main |
package pkglint |
|
|
import ( |
import ( |
check "gopkg.in/check.v1" |
"gopkg.in/check.v1" |
) |
) |
|
|
func (s *Suite) Test_checklineLicense(c *check.C) { |
func (s *Suite) Test_LicenseChecker_Check(c *check.C) { |
s.Init(c) |
t := s.Init(c) |
s.CreateTmpFile("licenses/gnu-gpl-v2", "Most software \u2026") |
|
mkline := T.NewMkLine("Makefile", 7, "LICENSE=dummy") |
|
G.globalData.Pkgsrcdir = s.tmpdir |
|
G.CurrentDir = s.tmpdir |
|
|
|
licenseChecker := &LicenseChecker{mkline} |
t.CreateFileLines("licenses/gnu-gpl-v2", |
licenseChecker.Check("gpl-v2", opAssign) |
"The licenses for most software are designed to take away ...") |
|
|
s.CheckOutputLines( |
test := func(licenseValue string, diagnostics ...string) { |
"WARN: Makefile:7: License file ~/licenses/gpl-v2 does not exist.") |
mklines := t.NewMkLines("Makefile", |
|
"LICENSE=\t"+licenseValue) |
|
|
licenseChecker.Check("no-profit shareware", opAssign) |
mklines.ForEach(func(mkline *MkLine) { |
|
(&LicenseChecker{mklines, mkline}).Check(mkline.Value(), opAssign) |
|
}) |
|
|
s.CheckOutputLines( |
t.CheckOutput(diagnostics) |
"ERROR: Makefile:7: Parse error for license condition \"no-profit shareware\".") |
} |
|
|
licenseChecker.Check("no-profit AND shareware", opAssign) |
test("gpl-v2", |
|
"WARN: Makefile:1: License file ~/licenses/gpl-v2 does not exist.") |
|
|
s.CheckOutputLines( |
test("no-profit shareware", |
"WARN: Makefile:7: License file ~/licenses/no-profit does not exist.", |
"ERROR: Makefile:1: Parse error for license condition \"no-profit shareware\".") |
"ERROR: Makefile:7: License \"no-profit\" must not be used.", |
|
"WARN: Makefile:7: License file ~/licenses/shareware does not exist.", |
|
"ERROR: Makefile:7: License \"shareware\" must not be used.") |
|
|
|
licenseChecker.Check("gnu-gpl-v2", opAssign) |
test("no-profit AND shareware", |
|
"WARN: Makefile:1: License file ~/licenses/no-profit does not exist.", |
|
"ERROR: Makefile:1: License \"no-profit\" must not be used.", |
|
"WARN: Makefile:1: License file ~/licenses/shareware does not exist.", |
|
"ERROR: Makefile:1: License \"shareware\" must not be used.") |
|
|
s.CheckOutputEmpty() |
test("gnu-gpl-v2", |
|
nil...) |
|
|
licenseChecker.Check("gnu-gpl-v2 AND gnu-gpl-v2 OR gnu-gpl-v2", opAssign) |
test("gnu-gpl-v2 AND gnu-gpl-v2 OR gnu-gpl-v2", |
|
"ERROR: Makefile:1: AND and OR operators in license conditions can only be combined using parentheses.") |
|
|
s.CheckOutputLines( |
test("(gnu-gpl-v2 OR gnu-gpl-v2) AND gnu-gpl-v2", |
"ERROR: Makefile:7: AND and OR operators in license conditions can only be combined using parentheses.") |
nil...) |
|
} |
|
|
licenseChecker.Check("(gnu-gpl-v2 OR gnu-gpl-v2) AND gnu-gpl-v2", opAssign) |
func (s *Suite) Test_LicenseChecker_checkName__LICENSE_FILE(c *check.C) { |
|
t := s.Init(c) |
|
|
s.CheckOutputEmpty() |
t.SetUpPkgsrc() |
|
t.SetUpPackage("category/package", |
|
"LICENSE=\tmy-license", |
|
"", |
|
"LICENSE_FILE=\tmy-license") |
|
t.CreateFileLines("category/package/my-license", |
|
"An individual license file.") |
|
|
|
t.Main("category/package") |
|
|
|
// There is no warning about the unusual file name in the package directory. |
|
// If it were not mentioned in LICENSE_FILE, the file named my-license |
|
// would be warned about. |
|
t.CheckOutputLines( |
|
"Looks fine.") |
} |
} |