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

1.1       rillig      1: package main
                      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.10      rillig     11:                "Most software \u2026")
                     12:        mkline := t.NewMkLine("Makefile", 7, "LICENSE=dummy")
1.2       rillig     13:
1.5       rillig     14:        licenseChecker := &LicenseChecker{mkline}
                     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:
                     47: func (s *Suite) Test_checkToplevelUnusedLicenses(c *check.C) {
                     48:        t := s.Init(c)
                     49:
1.14      rillig     50:        t.SetupPkgsrc()
1.16    ! rillig     51:        t.CreateFileLines("mk/misc/category.mk")
        !            52:        t.CreateFileLines("licenses/2-clause-bsd")
        !            53:        t.CreateFileLines("licenses/gnu-gpl-v3")
1.12      rillig     54:
1.16    ! rillig     55:        t.CreateFileLines("Makefile",
1.12      rillig     56:                MkRcsID,
                     57:                "SUBDIR+=\tcategory")
                     58:
1.16    ! rillig     59:        t.CreateFileLines("category/Makefile",
1.12      rillig     60:                MkRcsID,
                     61:                "COMMENT=\tExample category",
                     62:                "",
                     63:                "SUBDIR+=\tpackage",
                     64:                "",
                     65:                ".include \"../mk/misc/category.mk\"")
                     66:
1.16    ! rillig     67:        t.CreateFileLines("category/package/Makefile",
1.12      rillig     68:                MkRcsID,
                     69:                "CATEGORIES=\tcategory",
                     70:                "",
                     71:                "COMMENT=Example package",
                     72:                "LICENSE=\t2-clause-bsd",
                     73:                "NO_CHECKSUM=\tyes")
1.16    ! rillig     74:        t.CreateFileLines("category/package/PLIST",
1.12      rillig     75:                PlistRcsID,
                     76:                "bin/program")
                     77:
1.13      rillig     78:        G.Main("pkglint", "-r", "-Cglobal", t.File("."))
1.12      rillig     79:
                     80:        t.CheckOutputLines(
1.15      rillig     81:                "WARN: ~/licenses/gnu-gpl-v2: This license seems to be unused.", // Added by Tester.SetupPkgsrc
1.12      rillig     82:                "WARN: ~/licenses/gnu-gpl-v3: This license seems to be unused.",
1.15      rillig     83:                "0 errors and 2 warnings found.")
1.12      rillig     84: }
1.14      rillig     85:
                     86: func (s *Suite) Test_LicenseChecker_checkLicenseName__LICENSE_FILE(c *check.C) {
                     87:        t := s.Init(c)
                     88:
                     89:        t.SetupPkgsrc()
                     90:        t.SetupCommandLine("-Wno-space")
1.16    ! rillig     91:        t.CreateFileLines("category/package/DESCR",
1.14      rillig     92:                "Package description")
1.16    ! rillig     93:        t.CreateFileLines("category/package/Makefile",
1.14      rillig     94:                MkRcsID,
                     95:                "",
                     96:                "CATEGORIES=     chinese",
                     97:                "",
                     98:                "COMMENT=        Useful tools",
                     99:                "LICENSE=        my-license",
                    100:                "",
                    101:                "LICENSE_FILE=   my-license",
                    102:                "NO_CHECKSUM=    yes",
                    103:                "",
                    104:                ".include \"../../mk/bsd.pkg.mk\"")
1.16    ! rillig    105:        t.CreateFileLines("category/package/PLIST",
1.14      rillig    106:                PlistRcsID,
                    107:                "bin/program")
1.16    ! rillig    108:        t.CreateFileLines("category/package/my-license",
1.14      rillig    109:                "An individual license file.")
                    110:
                    111:        G.Main("pkglint", t.File("category/package"))
                    112:
                    113:        // FIXME: It should be allowed to place a license file directly into
                    114:        // the package directory.
                    115:        t.CheckOutputLines(
1.16    ! rillig    116:                "WARN: ~/category/package/my-license: Unexpected file found.",
        !           117:                "0 errors and 1 warning found.")
1.14      rillig    118: }

CVSweb <webmaster@jp.NetBSD.org>