summaryrefslogtreecommitdiff
path: root/pkgtools/pkglint/files/licenses_test.go
blob: ca2f360b477dc6191538f3e16b96c103ab48e790 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
package main

import (
	check "gopkg.in/check.v1"
)

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

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

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