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.5 retrieving revision 1.12 diff -u -p -r1.5 -r1.12 --- pkgsrc/pkgtools/pkglint/files/Attic/licenses_test.go 2016/07/10 21:24:47 1.5 +++ pkgsrc/pkgtools/pkglint/files/Attic/licenses_test.go 2018/04/28 23:32:52 1.12 @@ -1,46 +1,93 @@ package main import ( - check "gopkg.in/check.v1" + "gopkg.in/check.v1" ) -func (s *Suite) Test_parseLicenses(c *check.C) { - c.Check(parseLicenses("gnu-gpl-v2"), check.DeepEquals, &LicenseCondition{Name: "gnu-gpl-v2"}) - c.Check(parseLicenses("AND artistic"), check.IsNil) -} - func (s *Suite) Test_checklineLicense(c *check.C) { - s.CreateTmpFile(c, "licenses/gnu-gpl-v2", "Most software \u2026") - mkline := NewMkLine(NewLine("Makefile", 7, "LICENSE=dummy", nil)) - G.globalData.Pkgsrcdir = s.tmpdir - G.CurrentDir = s.tmpdir + t := s.Init(c) + + t.SetupFileLines("licenses/gnu-gpl-v2", + "Most software \u2026") + mkline := t.NewMkLine("Makefile", 7, "LICENSE=dummy") + G.CurrentDir = t.TmpDir() licenseChecker := &LicenseChecker{mkline} licenseChecker.Check("gpl-v2", opAssign) - c.Check(s.Output(), equals, "WARN: Makefile:7: License file ~/licenses/gpl-v2 does not exist.\n") + t.CheckOutputLines( + "WARN: Makefile:7: License file ~/licenses/gpl-v2 does not exist.") licenseChecker.Check("no-profit shareware", opAssign) - c.Check(s.Output(), equals, "ERROR: Makefile:7: Parse error for license condition \"no-profit shareware\".\n") + t.CheckOutputLines( + "ERROR: Makefile:7: Parse error for license condition \"no-profit shareware\".") licenseChecker.Check("no-profit AND shareware", opAssign) - c.Check(s.Output(), equals, ""+ - "WARN: Makefile:7: License file ~/licenses/no-profit does not exist.\n"+ - "ERROR: Makefile:7: License \"no-profit\" must not be used.\n"+ - "WARN: Makefile:7: License file ~/licenses/shareware does not exist.\n"+ - "ERROR: Makefile:7: License \"shareware\" must not be used.\n") + 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.") licenseChecker.Check("gnu-gpl-v2", opAssign) - c.Check(s.Output(), equals, "") + t.CheckOutputEmpty() licenseChecker.Check("gnu-gpl-v2 AND gnu-gpl-v2 OR gnu-gpl-v2", opAssign) - c.Check(s.Output(), equals, "ERROR: Makefile:7: AND and OR operators in license conditions can only be combined using parentheses.\n") + t.CheckOutputLines( + "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) - c.Check(s.Output(), equals, "") + t.CheckOutputEmpty() +} + +func (s *Suite) Test_checkToplevelUnusedLicenses(c *check.C) { + t := s.Init(c) + + t.SetupFileLines("mk/bsd.pkg.mk", "# dummy") + t.SetupFileLines("mk/fetch/sites.mk", "# dummy") + t.SetupFileLines("mk/defaults/options.description", "option\tdescription") + t.SetupFileLines("doc/TODO") + t.SetupFileLines("mk/defaults/mk.conf") + t.SetupFileLines("mk/tools/bsd.tools.mk", + ".include \"actual-tools.mk\"") + t.SetupFileLines("mk/tools/actual-tools.mk") + t.SetupFileLines("mk/tools/defaults.mk") + t.SetupFileLines("mk/bsd.prefs.mk") + t.SetupFileLines("mk/misc/category.mk") + t.SetupFileLines("licenses/2-clause-bsd") + t.SetupFileLines("licenses/gnu-gpl-v3") + + t.SetupFileLines("Makefile", + MkRcsID, + "SUBDIR+=\tcategory") + + t.SetupFileLines("category/Makefile", + MkRcsID, + "COMMENT=\tExample category", + "", + "SUBDIR+=\tpackage", + "", + ".include \"../mk/misc/category.mk\"") + + t.SetupFileLines("category/package/Makefile", + MkRcsID, + "CATEGORIES=\tcategory", + "", + "COMMENT=Example package", + "LICENSE=\t2-clause-bsd", + "NO_CHECKSUM=\tyes") + t.SetupFileLines("category/package/PLIST", + PlistRcsID, + "bin/program") + + G.Main("pkglint", "-r", "-Cglobal", t.TmpDir()) + + t.CheckOutputLines( + "WARN: ~/licenses/gnu-gpl-v3: This license seems to be unused.", + "0 errors and 1 warning found.") }