pkgsrc-Changes-HG archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

[pkgsrc/trunk]: pkgsrc/pkgtools/pkglint pkgtools/pkglint: update to 22.2.5



details:   https://anonhg.NetBSD.org/pkgsrc/rev/5dc945422715
branches:  trunk
changeset: 383334:5dc945422715
user:      rillig <rillig%pkgsrc.org@localhost>
date:      Wed Aug 17 20:41:51 2022 +0000

description:
pkgtools/pkglint: update to 22.2.5

Changes since 22.2.4:

Makefiles in wip/mk may use internal variables (starting with '_'), just
like their counterparts in main mk/.

Package versions containing letters are now parsed like in pkg_install.

diffstat:

 pkgtools/pkglint/Makefile                      |   5 +-
 pkgtools/pkglint/files/mkassignchecker_test.go |   7 +-
 pkgtools/pkglint/files/pkglint.go              |   3 +-
 pkgtools/pkglint/files/pkgver/vercmp.go        |   1 +
 pkgtools/pkglint/files/pkgver/vercmp_test.go   |  94 +++++++++++++------------
 5 files changed, 61 insertions(+), 49 deletions(-)

diffs (179 lines):

diff -r 680b8133bce3 -r 5dc945422715 pkgtools/pkglint/Makefile
--- a/pkgtools/pkglint/Makefile Wed Aug 17 20:28:37 2022 +0000
+++ b/pkgtools/pkglint/Makefile Wed Aug 17 20:41:51 2022 +0000
@@ -1,7 +1,6 @@
-# $NetBSD: Makefile,v 1.725 2022/08/12 20:38:07 bsiegert Exp $
+# $NetBSD: Makefile,v 1.726 2022/08/17 20:41:51 rillig Exp $
 
-PKGNAME=       pkglint-22.2.4
-PKGREVISION=   1
+PKGNAME=       pkglint-22.2.5
 CATEGORIES=    pkgtools
 DISTNAME=      tools
 MASTER_SITES=  ${MASTER_SITE_GITHUB:=golang/}
diff -r 680b8133bce3 -r 5dc945422715 pkgtools/pkglint/files/mkassignchecker_test.go
--- a/pkgtools/pkglint/files/mkassignchecker_test.go    Wed Aug 17 20:28:37 2022 +0000
+++ b/pkgtools/pkglint/files/mkassignchecker_test.go    Wed Aug 17 20:41:51 2022 +0000
@@ -108,12 +108,17 @@
                MkCvsID,
                "_VARNAME=\t\tvalue",
                "_SORTED_VARS.group=\tVARNAME")
+       t.CreateFileLines("wip/mk/infra.mk",
+               MkCvsID,
+               "_CVS_ENV+=\t\tCVS_RSH=ssh")
        t.FinishSetUp()
 
        G.Check(t.File("mk/infra.mk"))
+       G.Check(t.File("wip/mk/infra.mk"))
 
        t.CheckOutputLines(
-               "WARN: ~/mk/infra.mk:2: _VARNAME is defined but not used.")
+               "WARN: ~/mk/infra.mk:2: _VARNAME is defined but not used.",
+               "WARN: ~/wip/mk/infra.mk:2: _CVS_ENV is defined but not used.")
 }
 
 func (s *Suite) Test_MkAssignChecker_checkLeft__documented_underscore(c *check.C) {
diff -r 680b8133bce3 -r 5dc945422715 pkgtools/pkglint/files/pkglint.go
--- a/pkgtools/pkglint/files/pkglint.go Wed Aug 17 20:28:37 2022 +0000
+++ b/pkgtools/pkglint/files/pkglint.go Wed Aug 17 20:41:51 2022 +0000
@@ -311,7 +311,8 @@
        pkgsrcRel := p.Pkgsrc.Rel(dirent)
 
        p.Wip = pkgsrcRel.HasPrefixPath("wip")
-       p.Infrastructure = pkgsrcRel.HasPrefixPath("mk")
+       p.Infrastructure = pkgsrcRel.HasPrefixPath("mk") ||
+               pkgsrcRel.HasPrefixPath("wip/mk")
        pkgsrcdir := p.findPkgsrcTopdir(dir)
        if pkgsrcdir.IsEmpty() {
                G.Logger.TechErrorf("",
diff -r 680b8133bce3 -r 5dc945422715 pkgtools/pkglint/files/pkgver/vercmp.go
--- a/pkgtools/pkglint/files/pkgver/vercmp.go   Wed Aug 17 20:28:37 2022 +0000
+++ b/pkgtools/pkglint/files/pkgver/vercmp.go   Wed Aug 17 20:41:51 2022 +0000
@@ -69,6 +69,7 @@
                        num := lex.NextBytesSet(textproc.Digit)
                        v.nb, _ = strconv.Atoi(num)
                case lex.TestByteSet(textproc.Lower):
+                       v.add(0)
                        v.add(int(lex.Rest()[0] - 'a' + 1))
                        lex.Skip(1)
                default:
diff -r 680b8133bce3 -r 5dc945422715 pkgtools/pkglint/files/pkgver/vercmp_test.go
--- a/pkgtools/pkglint/files/pkgver/vercmp_test.go      Wed Aug 17 20:28:37 2022 +0000
+++ b/pkgtools/pkglint/files/pkgver/vercmp_test.go      Wed Aug 17 20:41:51 2022 +0000
@@ -3,6 +3,7 @@
 import (
        "gopkg.in/check.v1"
        "netbsd.org/pkglint/intqa"
+       "reflect"
        "testing"
 )
 
@@ -24,9 +25,12 @@
                {"1", "1.0", "1.0.0"},
                {"1.0nb1"},
                {"1.0nb2", "1_0nb2"},
-               {"1.0.1a", "1.0.a1", "1.0.aa"},
+               {"1.0.aa"},
+               {"1.0.a1"},
+               {"1.0.k"},
+               {"1.0.1a"},
                {"1.0.1z"},
-               {"1.0.11", "1.0.k"},
+               {"1.0.11", "1.0k"},
                {"2.0pre", "2.0rc"},
                {"2.0", "2.0pl"},
                {"2.0.1nb4"},
@@ -66,49 +70,51 @@
        }
 }
 
+func Test_newVersion(t *testing.T) {
+       tests := []struct {
+               name string
+               v    version
+       }{
+               {"5.0", version{[]int{5, 0, 0}, 0}},
+               {"5.0nb5", version{[]int{5, 0, 0}, 5}},
+               {"0.0.1-SNAP", version{[]int{0, 0, 0, 0, 1, 0, 19, 0, 14, 0, 1, 0, 16}, 0}},
+               {"1.0alpha3", version{[]int{1, 0, 0, -3, 3}, 0}},
+               {"1_0alpha3", version{[]int{1, 0, 0, -3, 3}, 0}},
+               {"2.5beta", version{[]int{2, 0, 5, -2}, 0}},
+               {"20151110", version{[]int{20151110}, 0}},
+               {"0", version{[]int{0}, 0}},
+               {"nb1", version{nil, 1}},
+               {"1.0.1a", version{[]int{1, 0, 0, 0, 1, 0, 1}, 0}},
+               {"1.1.1dnb2", version{[]int{1, 0, 1, 0, 1, 0, 4}, 2}},
+               {"1.0.1z", version{[]int{1, 0, 0, 0, 1, 0, 26}, 0}},
+               {"0pre20160620", version{[]int{0, -1, 20160620}, 0}},
+               {"3.5.DEV1710", version{[]int{3, 0, 5, 0, 0, 4, 0, 5, 0, 22, 1710}, 0}},
+
+               // In the following edge case, the "nb" and "beta" overlap.
+               // All the digits after the "nb" (which in this case are none at all)
+               // end up in the nb version part, and parsing continues with the next
+               // letter.
+               //
+               // Luckily this will not happen in practice since most version numbers
+               // are completely numeric, and those that aren't might have suffixes
+               // like "alpha", "beta", "public beta", "GA" (general availability),
+               // "final", "snapshot". The word "nonbeta" is purely hypothetical, and
+               // I didn't find any other word that would contain "nbeta". Commit
+               // hashes are also safe since their hex encoding cannot contain "n".
+               {"1.0nonbeta", version{[]int{1, 0, 0, 0, 14, 0, 15, 0, 5, 0, 20, 0, 1}, 0}},
+       }
+       for _, test := range tests {
+               t.Run(test.name, func(t *testing.T) {
+                       actual := *newVersion(test.name)
+                       if !reflect.DeepEqual(actual, test.v) {
+                               t.Errorf("expected %#v for %q, got %#v", test.v, test.name, actual)
+                       }
+               })
+       }
+}
+
 func (s *Suite) Test_newVersion(c *check.C) {
-       c.Check(newVersion("5.0"), check.DeepEquals,
-               &version{[]int{5, 0, 0}, 0})
-       c.Check(newVersion("5.0nb5"), check.DeepEquals,
-               &version{[]int{5, 0, 0}, 5})
-       c.Check(newVersion("0.0.1-SNAPSHOT"), check.DeepEquals,
-               &version{[]int{0, 0, 0, 0, 1, 19, 14, 1, 16, 19, 8, 15, 20}, 0})
-       c.Check(newVersion("1.0alpha3"), check.DeepEquals,
-               &version{[]int{1, 0, 0, -3, 3}, 0})
-       c.Check(newVersion("1_0alpha3"), check.DeepEquals,
-               &version{[]int{1, 0, 0, -3, 3}, 0})
-       c.Check(newVersion("2.5beta"), check.DeepEquals,
-               &version{[]int{2, 0, 5, -2}, 0})
-       c.Check(newVersion("20151110"), check.DeepEquals,
-               &version{[]int{20151110}, 0})
-       c.Check(newVersion("0"), check.DeepEquals,
-               &version{[]int{0}, 0})
-       c.Check(newVersion("nb1"), check.DeepEquals,
-               &version{nil, 1})
-       c.Check(newVersion("1.0.1a"), check.DeepEquals,
-               &version{[]int{1, 0, 0, 0, 1, 1}, 0})
-       c.Check(newVersion("1.1.1dnb2"), check.DeepEquals,
-               &version{[]int{1, 0, 1, 0, 1, 4}, 2})
-       c.Check(newVersion("1.0.1z"), check.DeepEquals,
-               &version{[]int{1, 0, 0, 0, 1, 26}, 0})
-       c.Check(newVersion("0pre20160620"), check.DeepEquals,
-               &version{[]int{0, -1, 20160620}, 0})
-       c.Check(newVersion("3.5.DEV1710"), check.DeepEquals,
-               &version{[]int{3, 0, 5, 0, 4, 5, 22, 1710}, 0})
-
-       // In the following edge case, the "nb" and "beta" overlap.
-       // All the digits after the "nb" (which in this case are none at all)
-       // end up in the nb version part, and parsing continues with the next
-       // letter.
-       //
-       // Luckily this will not happen in practice since most version numbers
-       // are completely numeric, and those that aren't might have suffixes
-       // like "alpha", "beta", "public beta", "GA" (general availability),
-       // "final", "snapshot". The word "nonbeta" is purely hypothetical, and
-       // I didn't find any other word that would contain "nbeta". Commit
-       // hashes are also safe since their hex encoding cannot contain "n".
-       c.Check(newVersion("1.0nonbeta"), check.DeepEquals,
-               &version{[]int{1, 0, 0, 14, 15, 5, 20, 1}, 0})
+       // See Test_newVersion.
 }
 
 func (s *Suite) Test__qa(c *check.C) {



Home | Main Index | Thread Index | Old Index