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

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")
                     13:        G.CurrentDir = t.TmpDir()
1.2       rillig     14:
1.5       rillig     15:        licenseChecker := &LicenseChecker{mkline}
                     16:        licenseChecker.Check("gpl-v2", opAssign)
1.2       rillig     17:
1.10      rillig     18:        t.CheckOutputLines(
1.8       rillig     19:                "WARN: Makefile:7: License file ~/licenses/gpl-v2 does not exist.")
1.2       rillig     20:
1.5       rillig     21:        licenseChecker.Check("no-profit shareware", opAssign)
                     22:
1.10      rillig     23:        t.CheckOutputLines(
1.8       rillig     24:                "ERROR: Makefile:7: Parse error for license condition \"no-profit shareware\".")
1.5       rillig     25:
                     26:        licenseChecker.Check("no-profit AND shareware", opAssign)
1.2       rillig     27:
1.10      rillig     28:        t.CheckOutputLines(
1.8       rillig     29:                "WARN: Makefile:7: License file ~/licenses/no-profit does not exist.",
                     30:                "ERROR: Makefile:7: License \"no-profit\" must not be used.",
                     31:                "WARN: Makefile:7: License file ~/licenses/shareware does not exist.",
                     32:                "ERROR: Makefile:7: License \"shareware\" must not be used.")
1.5       rillig     33:
                     34:        licenseChecker.Check("gnu-gpl-v2", opAssign)
                     35:
1.10      rillig     36:        t.CheckOutputEmpty()
1.5       rillig     37:
                     38:        licenseChecker.Check("gnu-gpl-v2 AND gnu-gpl-v2 OR gnu-gpl-v2", opAssign)
                     39:
1.10      rillig     40:        t.CheckOutputLines(
1.8       rillig     41:                "ERROR: Makefile:7: AND and OR operators in license conditions can only be combined using parentheses.")
1.2       rillig     42:
1.5       rillig     43:        licenseChecker.Check("(gnu-gpl-v2 OR gnu-gpl-v2) AND gnu-gpl-v2", opAssign)
1.2       rillig     44:
1.10      rillig     45:        t.CheckOutputEmpty()
1.2       rillig     46: }
1.12    ! rillig     47:
        !            48: func (s *Suite) Test_checkToplevelUnusedLicenses(c *check.C) {
        !            49:        t := s.Init(c)
        !            50:
        !            51:        t.SetupFileLines("mk/bsd.pkg.mk", "# dummy")
        !            52:        t.SetupFileLines("mk/fetch/sites.mk", "# dummy")
        !            53:        t.SetupFileLines("mk/defaults/options.description", "option\tdescription")
        !            54:        t.SetupFileLines("doc/TODO")
        !            55:        t.SetupFileLines("mk/defaults/mk.conf")
        !            56:        t.SetupFileLines("mk/tools/bsd.tools.mk",
        !            57:                ".include \"actual-tools.mk\"")
        !            58:        t.SetupFileLines("mk/tools/actual-tools.mk")
        !            59:        t.SetupFileLines("mk/tools/defaults.mk")
        !            60:        t.SetupFileLines("mk/bsd.prefs.mk")
        !            61:        t.SetupFileLines("mk/misc/category.mk")
        !            62:        t.SetupFileLines("licenses/2-clause-bsd")
        !            63:        t.SetupFileLines("licenses/gnu-gpl-v3")
        !            64:
        !            65:        t.SetupFileLines("Makefile",
        !            66:                MkRcsID,
        !            67:                "SUBDIR+=\tcategory")
        !            68:
        !            69:        t.SetupFileLines("category/Makefile",
        !            70:                MkRcsID,
        !            71:                "COMMENT=\tExample category",
        !            72:                "",
        !            73:                "SUBDIR+=\tpackage",
        !            74:                "",
        !            75:                ".include \"../mk/misc/category.mk\"")
        !            76:
        !            77:        t.SetupFileLines("category/package/Makefile",
        !            78:                MkRcsID,
        !            79:                "CATEGORIES=\tcategory",
        !            80:                "",
        !            81:                "COMMENT=Example package",
        !            82:                "LICENSE=\t2-clause-bsd",
        !            83:                "NO_CHECKSUM=\tyes")
        !            84:        t.SetupFileLines("category/package/PLIST",
        !            85:                PlistRcsID,
        !            86:                "bin/program")
        !            87:
        !            88:        G.Main("pkglint", "-r", "-Cglobal", t.TmpDir())
        !            89:
        !            90:        t.CheckOutputLines(
        !            91:                "WARN: ~/licenses/gnu-gpl-v3: This license seems to be unused.",
        !            92:                "0 errors and 1 warning found.")
        !            93: }

CVSweb <webmaster@jp.NetBSD.org>