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

Annotation of pkgsrc/pkgtools/pkglint/files/licenses_test.go, Revision 1.25

1.19      rillig      1: package pkglint
1.1       rillig      2:
                      3: import (
1.12      rillig      4:        "gopkg.in/check.v1"
1.1       rillig      5: )
                      6:
1.16      rillig      7: func (s *Suite) Test_LicenseChecker_Check(c *check.C) {
1.10      rillig      8:        t := s.Init(c)
                      9:
1.16      rillig     10:        t.CreateFileLines("licenses/gnu-gpl-v2",
1.18      rillig     11:                "The licenses for most software are designed to take away ...")
1.2       rillig     12:
1.24      rillig     13:        test := func(licenseValue string, diagnostics ...string) {
                     14:                mklines := t.NewMkLines("Makefile",
                     15:                        "LICENSE=\t"+licenseValue)
1.2       rillig     16:
1.24      rillig     17:                mklines.ForEach(func(mkline *MkLine) {
                     18:                        (&LicenseChecker{mklines, mkline}).Check(mkline.Value(), opAssign)
                     19:                })
1.5       rillig     20:
1.24      rillig     21:                t.CheckOutput(diagnostics)
                     22:        }
1.5       rillig     23:
1.24      rillig     24:        test("gpl-v2",
                     25:                "WARN: Makefile:1: License file ~/licenses/gpl-v2 does not exist.")
1.2       rillig     26:
1.24      rillig     27:        test("no-profit shareware",
                     28:                "ERROR: Makefile:1: Parse error for license condition \"no-profit shareware\".")
1.5       rillig     29:
1.24      rillig     30:        test("no-profit AND shareware",
                     31:                "WARN: Makefile:1: License file ~/licenses/no-profit does not exist.",
                     32:                "ERROR: Makefile:1: License \"no-profit\" must not be used.",
                     33:                "WARN: Makefile:1: License file ~/licenses/shareware does not exist.",
                     34:                "ERROR: Makefile:1: License \"shareware\" must not be used.")
1.5       rillig     35:
1.24      rillig     36:        test("gnu-gpl-v2",
                     37:                nil...)
1.2       rillig     38:
1.24      rillig     39:        test("gnu-gpl-v2 AND gnu-gpl-v2 OR gnu-gpl-v2",
                     40:                "ERROR: Makefile:1: AND and OR operators in license conditions can only be combined using parentheses.")
1.2       rillig     41:
1.24      rillig     42:        test("(gnu-gpl-v2 OR gnu-gpl-v2) AND gnu-gpl-v2",
                     43:                nil...)
1.2       rillig     44: }
1.12      rillig     45:
1.18      rillig     46: func (s *Suite) Test_LicenseChecker_checkName__LICENSE_FILE(c *check.C) {
1.12      rillig     47:        t := s.Init(c)
                     48:
1.20      rillig     49:        t.SetUpPkgsrc()
                     50:        t.SetUpPackage("category/package",
1.18      rillig     51:                "LICENSE=\tmy-license",
1.12      rillig     52:                "",
1.18      rillig     53:                "LICENSE_FILE=\tmy-license")
1.16      rillig     54:        t.CreateFileLines("category/package/my-license",
1.14      rillig     55:                "An individual license file.")
                     56:
1.25    ! rillig     57:        t.Main("category/package")
1.14      rillig     58:
1.21      rillig     59:        // There is no warning about the unusual file name in the package directory.
                     60:        // If it were not mentioned in LICENSE_FILE, the file named my-license
                     61:        // would be warned about.
1.14      rillig     62:        t.CheckOutputLines(
1.21      rillig     63:                "Looks fine.")
1.14      rillig     64: }

CVSweb <webmaster@jp.NetBSD.org>