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.17 retrieving revision 1.27 diff -u -p -r1.17 -r1.27 --- pkgsrc/pkgtools/pkglint/files/Attic/licenses_test.go 2018/11/07 20:58:23 1.17 +++ pkgsrc/pkgtools/pkglint/files/Attic/licenses_test.go 2019/12/08 00:06:38 1.27 @@ -1,4 +1,4 @@ -package main +package pkglint import ( "gopkg.in/check.v1" @@ -8,111 +8,63 @@ func (s *Suite) Test_LicenseChecker_Chec t := s.Init(c) t.CreateFileLines("licenses/gnu-gpl-v2", - "Most software \u2026") - mkline := t.NewMkLine("Makefile", 7, "LICENSE=dummy") + "The licenses for most software are designed to take away ...") - licenseChecker := &LicenseChecker{mkline} - licenseChecker.Check("gpl-v2", opAssign) + test := func(licenseValue string, diagnostics ...string) { + mklines := t.SetUpFileMkLines("Makefile", + "LICENSE=\t"+licenseValue) - t.CheckOutputLines( - "WARN: Makefile:7: License file ~/licenses/gpl-v2 does not exist.") + mklines.ForEach(func(mkline *MkLine) { + (&LicenseChecker{mklines, mkline}).Check(mkline.Value(), opAssign) + }) - licenseChecker.Check("no-profit shareware", opAssign) + t.CheckOutput(diagnostics) + } - t.CheckOutputLines( - "ERROR: Makefile:7: Parse error for license condition \"no-profit shareware\".") + test("gpl-v2", + "ERROR: ~/Makefile:1: License file licenses/gpl-v2 does not exist.") - licenseChecker.Check("no-profit AND shareware", opAssign) + test("no-profit shareware", + "ERROR: ~/Makefile:1: Parse error for license condition \"no-profit shareware\".") - t.CheckOutputLines( - "WARN: Makefile:7: License file ~/licenses/no-profit does not exist.", - "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.") + test("no-profit AND shareware", + "ERROR: ~/Makefile:1: License file licenses/no-profit does not exist.", + "ERROR: ~/Makefile:1: License file licenses/shareware does not exist.") - licenseChecker.Check("gnu-gpl-v2", opAssign) + test("gnu-gpl-v2", + nil...) - t.CheckOutputEmpty() + 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.") - licenseChecker.Check("gnu-gpl-v2 AND gnu-gpl-v2 OR gnu-gpl-v2", opAssign) - - t.CheckOutputLines( - "ERROR: Makefile:7: 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.") - licenseChecker.Check("(gnu-gpl-v2 OR gnu-gpl-v2) AND gnu-gpl-v2", opAssign) + test("(gnu-gpl-v2 OR gnu-gpl-v2) AND gnu-gpl-v2", + nil...) - t.CheckOutputEmpty() + test("gnu-gpl-v2 OR (gnu-gpl-v2 AND gnu-gpl-v2)", + nil...) } -func (s *Suite) Test_Pkgsrc_checkToplevelUnusedLicenses(c *check.C) { +func (s *Suite) Test_LicenseChecker_checkName__LICENSE_FILE(c *check.C) { t := s.Init(c) - t.SetupPkgsrc() - t.CreateFileLines("mk/misc/category.mk") - t.CreateFileLines("licenses/2-clause-bsd") - t.CreateFileLines("licenses/gnu-gpl-v3") - - t.CreateFileLines("Makefile", - MkRcsID, - "SUBDIR+=\tcategory") - - t.CreateFileLines("category/Makefile", - MkRcsID, - "COMMENT=\tExample category", - "", - "SUBDIR+=\tpackage", - "", - ".include \"../mk/misc/category.mk\"") - - t.CreateFileLines("category/package/Makefile", - MkRcsID, - "CATEGORIES=\tcategory", - "", - "COMMENT=Example package", - "LICENSE=\t2-clause-bsd", - "NO_CHECKSUM=\tyes") - t.CreateFileLines("category/package/PLIST", - PlistRcsID, - "bin/program") - - G.Main("pkglint", "-r", "-Cglobal", t.File(".")) - - t.CheckOutputLines( - "WARN: ~/licenses/gnu-gpl-v2: This license seems to be unused.", // Added by Tester.SetupPkgsrc - "WARN: ~/licenses/gnu-gpl-v3: This license seems to be unused.", - "0 errors and 2 warnings found.") -} - -func (s *Suite) Test_LicenseChecker_checkLicenseName__LICENSE_FILE(c *check.C) { - t := s.Init(c) - - t.SetupPkgsrc() - t.SetupCommandLine("-Wno-space") - t.CreateFileLines("category/package/DESCR", - "Package description") - t.CreateFileLines("category/package/Makefile", - MkRcsID, - "", - "CATEGORIES= chinese", - "", - "COMMENT= Useful tools", - "LICENSE= my-license", - "", - "LICENSE_FILE= my-license", - "NO_CHECKSUM= yes", + t.SetUpPkgsrc() + t.SetUpPackage("category/package", + "LICENSE=\tmy-license", "", - ".include \"../../mk/bsd.pkg.mk\"") - t.CreateFileLines("category/package/PLIST", - PlistRcsID, - "bin/program") + "LICENSE_FILE=\tmy-license") t.CreateFileLines("category/package/my-license", "An individual license file.") - G.Main("pkglint", t.File("category/package")) + t.Main("category/package") - // FIXME: It should be allowed to place a license file directly into - // the package directory. + // 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( - "WARN: ~/category/package/my-license: Unexpected file found.", - "0 errors and 1 warning found.") + "Looks fine.") }