version 1.8, 2017/01/29 14:27:48 |
version 1.18, 2018/12/02 01:57:48 |
|
|
package main |
package main |
|
|
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 := NewMkLine(NewLine("Makefile", 7, "LICENSE=dummy", nil)) |
|
G.globalData.Pkgsrcdir = s.tmpdir |
|
G.CurrentDir = s.tmpdir |
|
|
|
licenseChecker := &LicenseChecker{mkline} |
t.CreateFileLines("licenses/gnu-gpl-v2", |
|
"The licenses for most software are designed to take away ...") |
|
mkline := t.NewMkLine("Makefile", 7, "LICENSE=dummy") |
|
|
|
licenseChecker := LicenseChecker{mkline} |
licenseChecker.Check("gpl-v2", opAssign) |
licenseChecker.Check("gpl-v2", opAssign) |
|
|
s.CheckOutputLines( |
t.CheckOutputLines( |
"WARN: Makefile:7: License file ~/licenses/gpl-v2 does not exist.") |
"WARN: Makefile:7: License file ~/licenses/gpl-v2 does not exist.") |
|
|
licenseChecker.Check("no-profit shareware", opAssign) |
licenseChecker.Check("no-profit shareware", opAssign) |
|
|
s.CheckOutputLines( |
t.CheckOutputLines( |
"ERROR: Makefile:7: Parse error for license condition \"no-profit shareware\".") |
"ERROR: Makefile:7: Parse error for license condition \"no-profit shareware\".") |
|
|
licenseChecker.Check("no-profit AND shareware", opAssign) |
licenseChecker.Check("no-profit AND shareware", opAssign) |
|
|
s.CheckOutputLines( |
t.CheckOutputLines( |
"WARN: Makefile:7: License file ~/licenses/no-profit does not exist.", |
"WARN: Makefile:7: License file ~/licenses/no-profit does not exist.", |
"ERROR: Makefile:7: License \"no-profit\" must not be used.", |
"ERROR: Makefile:7: License \"no-profit\" must not be used.", |
"WARN: Makefile:7: License file ~/licenses/shareware does not exist.", |
"WARN: Makefile:7: License file ~/licenses/shareware does not exist.", |
Line 32 func (s *Suite) Test_checklineLicense(c |
|
Line 32 func (s *Suite) Test_checklineLicense(c |
|
|
|
licenseChecker.Check("gnu-gpl-v2", opAssign) |
licenseChecker.Check("gnu-gpl-v2", opAssign) |
|
|
s.CheckOutputEmpty() |
t.CheckOutputEmpty() |
|
|
licenseChecker.Check("gnu-gpl-v2 AND gnu-gpl-v2 OR gnu-gpl-v2", opAssign) |
licenseChecker.Check("gnu-gpl-v2 AND gnu-gpl-v2 OR gnu-gpl-v2", opAssign) |
|
|
s.CheckOutputLines( |
t.CheckOutputLines( |
"ERROR: Makefile:7: AND and OR operators in license conditions can only be combined using parentheses.") |
"ERROR: Makefile:7: AND and OR operators in license conditions can only be combined using parentheses.") |
|
|
licenseChecker.Check("(gnu-gpl-v2 OR gnu-gpl-v2) AND gnu-gpl-v2", opAssign) |
licenseChecker.Check("(gnu-gpl-v2 OR gnu-gpl-v2) AND gnu-gpl-v2", opAssign) |
|
|
s.CheckOutputEmpty() |
t.CheckOutputEmpty() |
|
} |
|
|
|
func (s *Suite) Test_LicenseChecker_checkName__LICENSE_FILE(c *check.C) { |
|
t := s.Init(c) |
|
|
|
t.SetupPkgsrc() |
|
t.SetupPackage("category/package", |
|
"LICENSE=\tmy-license", |
|
"", |
|
"LICENSE_FILE=\tmy-license") |
|
t.CreateFileLines("category/package/my-license", |
|
"An individual license file.") |
|
|
|
G.Main("pkglint", t.File("category/package")) |
|
|
|
// FIXME: It should be allowed to place a license file directly into |
|
// the package directory. |
|
t.CheckOutputLines( |
|
"WARN: ~/category/package/my-license: Unexpected file found.", |
|
"0 errors and 1 warning found.") |
} |
} |