[BACK]Return to licenses_test.go CVS log [TXT][DIR] Up to [cvs.NetBSD.org] / pkgsrc / pkgtools / pkglint / files

File: [cvs.NetBSD.org] / pkgsrc / pkgtools / pkglint / files / licenses_test.go (download)

Revision 1.6, Tue Dec 13 00:58:07 2016 UTC (3 years, 3 months ago) by rillig
Branch: MAIN
CVS Tags: pkgsrc-2016Q4-base, pkgsrc-2016Q4
Changes since 1.5: +2 -1 lines

Updated pkglint to 5.4.13.

Changes since 5.4.12:

* Added check for unintended # comments, especially in HOMEPAGE
* Added check for quotes in COMMENT
* Fixed hardcoded package versions for PHP, Python, Lua, etc.
* Code cleanup in the tests

package main

import (
	check "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.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}
	licenseChecker.Check("gpl-v2", opAssign)

	c.Check(s.Output(), equals, "WARN: Makefile:7: License file ~/licenses/gpl-v2 does not exist.\n")

	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"+
		"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")

	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")

	licenseChecker.Check("(gnu-gpl-v2 OR gnu-gpl-v2) AND gnu-gpl-v2", opAssign)

	c.Check(s.Output(), equals, "")
}