[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.20

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.10      rillig     12:        mkline := t.NewMkLine("Makefile", 7, "LICENSE=dummy")
1.2       rillig     13:
1.18      rillig     14:        licenseChecker := LicenseChecker{mkline}
1.5       rillig     15:        licenseChecker.Check("gpl-v2", opAssign)
1.2       rillig     16:
1.10      rillig     17:        t.CheckOutputLines(
1.8       rillig     18:                "WARN: Makefile:7: License file ~/licenses/gpl-v2 does not exist.")
1.2       rillig     19:
1.5       rillig     20:        licenseChecker.Check("no-profit shareware", opAssign)
                     21:
1.10      rillig     22:        t.CheckOutputLines(
1.8       rillig     23:                "ERROR: Makefile:7: Parse error for license condition \"no-profit shareware\".")
1.5       rillig     24:
                     25:        licenseChecker.Check("no-profit AND shareware", opAssign)
1.2       rillig     26:
1.10      rillig     27:        t.CheckOutputLines(
1.8       rillig     28:                "WARN: Makefile:7: License file ~/licenses/no-profit does not exist.",
                     29:                "ERROR: Makefile:7: License \"no-profit\" must not be used.",
                     30:                "WARN: Makefile:7: License file ~/licenses/shareware does not exist.",
                     31:                "ERROR: Makefile:7: License \"shareware\" must not be used.")
1.5       rillig     32:
                     33:        licenseChecker.Check("gnu-gpl-v2", opAssign)
                     34:
1.10      rillig     35:        t.CheckOutputEmpty()
1.5       rillig     36:
                     37:        licenseChecker.Check("gnu-gpl-v2 AND gnu-gpl-v2 OR gnu-gpl-v2", opAssign)
                     38:
1.10      rillig     39:        t.CheckOutputLines(
1.8       rillig     40:                "ERROR: Makefile:7: AND and OR operators in license conditions can only be combined using parentheses.")
1.2       rillig     41:
1.5       rillig     42:        licenseChecker.Check("(gnu-gpl-v2 OR gnu-gpl-v2) AND gnu-gpl-v2", opAssign)
1.2       rillig     43:
1.10      rillig     44:        t.CheckOutputEmpty()
1.2       rillig     45: }
1.12      rillig     46:
1.18      rillig     47: func (s *Suite) Test_LicenseChecker_checkName__LICENSE_FILE(c *check.C) {
1.12      rillig     48:        t := s.Init(c)
                     49:
1.20    ! rillig     50:        t.SetUpPkgsrc()
        !            51:        t.SetUpPackage("category/package",
1.18      rillig     52:                "LICENSE=\tmy-license",
1.12      rillig     53:                "",
1.18      rillig     54:                "LICENSE_FILE=\tmy-license")
1.16      rillig     55:        t.CreateFileLines("category/package/my-license",
1.14      rillig     56:                "An individual license file.")
                     57:
                     58:        G.Main("pkglint", t.File("category/package"))
                     59:
                     60:        // FIXME: It should be allowed to place a license file directly into
                     61:        // the package directory.
                     62:        t.CheckOutputLines(
1.16      rillig     63:                "WARN: ~/category/package/my-license: Unexpected file found.",
                     64:                "0 errors and 1 warning found.")
1.14      rillig     65: }

CVSweb <webmaster@jp.NetBSD.org>