[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.3, Wed Jan 27 21:55:50 2016 UTC (4 years, 2 months ago) by rillig
Branch: MAIN
CVS Tags: pkgsrc-2016Q2-base, pkgsrc-2016Q2, pkgsrc-2016Q1-base, pkgsrc-2016Q1
Changes since 1.2: +2 -2 lines

Updated pkglint to 5.3.4

Changes since 5.3.3:

* Added some unit tests
* Fixed the Makefile parser to recognize seldomly-used variable modifiers
  like :S///S/// without intermediate colon or :ts\n
* Cleaned up some unit tests
* Combined diagnostics that span multiple lines into single-line ones

package main

import (
	check "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) TestChecklineLicense(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

	checklineLicense(mkline, "gpl-v2")

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

	checklineLicense(mkline, "no-profit shareware")

	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"+
		"WARN: Makefile:7: License file ~/licenses/shareware does not exist.\n"+
		"WARN: Makefile:7: License \"shareware\" is deprecated.\n")

	checklineLicense(mkline, "gnu-gpl-v2")

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