summaryrefslogtreecommitdiff
path: root/pkgtools/pkglint/files/licenses_test.go
diff options
context:
space:
mode:
Diffstat (limited to 'pkgtools/pkglint/files/licenses_test.go')
-rw-r--r--pkgtools/pkglint/files/licenses_test.go27
1 files changed, 20 insertions, 7 deletions
diff --git a/pkgtools/pkglint/files/licenses_test.go b/pkgtools/pkglint/files/licenses_test.go
index ca2f360b477..8129dbae86d 100644
--- a/pkgtools/pkglint/files/licenses_test.go
+++ b/pkgtools/pkglint/files/licenses_test.go
@@ -5,8 +5,8 @@ import (
)
func (s *Suite) Test_parseLicenses(c *check.C) {
- c.Check(parseLicenses("gnu-gpl-v2"), check.DeepEquals, []string{"gnu-gpl-v2"})
- c.Check(parseLicenses("AND artistic"), check.DeepEquals, []string{"artistic"})
+ 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) {
@@ -15,19 +15,32 @@ func (s *Suite) Test_checklineLicense(c *check.C) {
G.globalData.Pkgsrcdir = s.tmpdir
G.CurrentDir = s.tmpdir
- checklineLicense(mkline, "gpl-v2")
+ 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")
- checklineLicense(mkline, "no-profit shareware")
+ licenseChecker.Check("no-profit shareware", opAssign)
+
+ c.Check(s.Output(), equals, "ERROR: Makefile:7: Parse error for license condition \"no-profit shareware\".\n")
+
+ licenseChecker.Check("no-profit AND shareware", opAssign)
c.Check(s.Output(), equals, ""+
"WARN: Makefile:7: License file ~/licenses/no-profit does not exist.\n"+
- "WARN: Makefile:7: License \"no-profit\" is deprecated.\n"+
+ "ERROR: Makefile:7: License \"no-profit\" must not be used.\n"+
"WARN: Makefile:7: License file ~/licenses/shareware does not exist.\n"+
- "WARN: Makefile:7: License \"shareware\" is deprecated.\n")
+ "ERROR: Makefile:7: License \"shareware\" must not be used.\n")
+
+ licenseChecker.Check("gnu-gpl-v2", opAssign)
+
+ c.Check(s.Output(), equals, "")
+
+ 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")
- checklineLicense(mkline, "gnu-gpl-v2")
+ licenseChecker.Check("(gnu-gpl-v2 OR gnu-gpl-v2) AND gnu-gpl-v2", opAssign)
c.Check(s.Output(), equals, "")
}