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

1.1       rillig      1: package main
                      2:
                      3: import (
1.12      rillig      4:        "gopkg.in/check.v1"
1.1       rillig      5: )
                      6:
1.4       rillig      7: func (s *Suite) Test_checklineLicense(c *check.C) {
1.10      rillig      8:        t := s.Init(c)
                      9:
                     10:        t.SetupFileLines("licenses/gnu-gpl-v2",
                     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:
                     50:        t.SetupFileLines("mk/bsd.pkg.mk", "# dummy")
                     51:        t.SetupFileLines("mk/fetch/sites.mk", "# dummy")
                     52:        t.SetupFileLines("mk/defaults/options.description", "option\tdescription")
                     53:        t.SetupFileLines("doc/TODO")
                     54:        t.SetupFileLines("mk/defaults/mk.conf")
                     55:        t.SetupFileLines("mk/tools/bsd.tools.mk",
                     56:                ".include \"actual-tools.mk\"")
                     57:        t.SetupFileLines("mk/tools/actual-tools.mk")
                     58:        t.SetupFileLines("mk/tools/defaults.mk")
                     59:        t.SetupFileLines("mk/bsd.prefs.mk")
                     60:        t.SetupFileLines("mk/misc/category.mk")
                     61:        t.SetupFileLines("licenses/2-clause-bsd")
                     62:        t.SetupFileLines("licenses/gnu-gpl-v3")
                     63:
                     64:        t.SetupFileLines("Makefile",
                     65:                MkRcsID,
                     66:                "SUBDIR+=\tcategory")
                     67:
                     68:        t.SetupFileLines("category/Makefile",
                     69:                MkRcsID,
                     70:                "COMMENT=\tExample category",
                     71:                "",
                     72:                "SUBDIR+=\tpackage",
                     73:                "",
                     74:                ".include \"../mk/misc/category.mk\"")
                     75:
                     76:        t.SetupFileLines("category/package/Makefile",
                     77:                MkRcsID,
                     78:                "CATEGORIES=\tcategory",
                     79:                "",
                     80:                "COMMENT=Example package",
                     81:                "LICENSE=\t2-clause-bsd",
                     82:                "NO_CHECKSUM=\tyes")
                     83:        t.SetupFileLines("category/package/PLIST",
                     84:                PlistRcsID,
                     85:                "bin/program")
                     86:
1.13    ! rillig     87:        G.Main("pkglint", "-r", "-Cglobal", t.File("."))
1.12      rillig     88:
                     89:        t.CheckOutputLines(
                     90:                "WARN: ~/licenses/gnu-gpl-v3: This license seems to be unused.",
                     91:                "0 errors and 1 warning found.")
                     92: }

CVSweb <webmaster@jp.NetBSD.org>