Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. =================================================================== RCS file: /ftp/cvs/cvsroot/pkgsrc/pkgtools/pkglint/files/Attic/licenses_test.go,v rcsdiff: /ftp/cvs/cvsroot/pkgsrc/pkgtools/pkglint/files/Attic/licenses_test.go,v: warning: Unknown phrases like `commitid ...;' are present. retrieving revision 1.1 retrieving revision 1.26 diff -u -p -r1.1 -r1.26 --- pkgsrc/pkgtools/pkglint/files/Attic/licenses_test.go 2015/11/25 13:29:07 1.1 +++ pkgsrc/pkgtools/pkglint/files/Attic/licenses_test.go 2019/11/27 22:10:07 1.26 @@ -1,10 +1,72 @@ -package main +package pkglint import ( - check "gopkg.in/check.v1" + "gopkg.in/check.v1" ) -func (s *Suite) TestParseLicenses(c *check.C) { - c.Check(parseLicenses("gnu-gpl-v2"), check.DeepEquals, []string{"gnu-gpl-v2"}) - c.Check(parseLicenses("AND artistic"), check.DeepEquals, []string{"artistic"}) +func (s *Suite) Test_LicenseChecker_Check(c *check.C) { + t := s.Init(c) + + t.CreateFileLines("licenses/gnu-gpl-v2", + "The licenses for most software are designed to take away ...") + + test := func(licenseValue string, diagnostics ...string) { + mklines := t.SetUpFileMkLines("Makefile", + "LICENSE=\t"+licenseValue) + + mklines.ForEach(func(mkline *MkLine) { + (&LicenseChecker{mklines, mkline}).Check(mkline.Value(), opAssign) + }) + + t.CheckOutput(diagnostics) + } + + test("gpl-v2", + "WARN: ~/Makefile:1: License file licenses/gpl-v2 does not exist.") + + test("no-profit shareware", + "ERROR: ~/Makefile:1: Parse error for license condition \"no-profit shareware\".") + + 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.") + + test("gnu-gpl-v2", + nil...) + + 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.") + + 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.") + + test("(gnu-gpl-v2 OR gnu-gpl-v2) AND gnu-gpl-v2", + nil...) + + test("gnu-gpl-v2 OR (gnu-gpl-v2 AND gnu-gpl-v2)", + nil...) +} + +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.") + + 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.") }