pkgsrc-Changes-HG archive

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

[.joined/pkgsrc/trunk]: .joined/pkgsrc/pkgtools/pkglint pkgtools/pkglint: upd...



details:   https://anonhg.NetBSD.org/.joined/pkgsrc/rev/4c58aa0d54a6
branches:  trunk
changeset: 370873:4c58aa0d54a6
user:      rillig <rillig%pkgsrc.org@localhost>
date:      Sat Jan 01 12:44:24 2022 +0000

description:
pkgtools/pkglint: update to 21.4.1

Changes since 21.4.0:

Running 'pkglint doc/CHANGES-2021' now warns about issues for this
single file.  Previously, it was necessary to specify '-Cglobal' as
well, but then pkglint also warned about issues in all other CHANGES
files.

Pkglint no longer warns about the characters '!' and '@' in
GO_MODULES_FILES, since these are legitimate.  Fixes PR pkg/56595.

Small cleanups in the pkglint testing infrastructure.

diffstat:

 pkgtools/pkglint/Makefile                    |   4 +-
 pkgtools/pkglint/files/autofix_test.go       |  14 +++----
 pkgtools/pkglint/files/check_test.go         |  38 ++++++++++++++++-----
 pkgtools/pkglint/files/files_test.go         |  22 +++++++-----
 pkgtools/pkglint/files/lineslexer_test.go    |   6 +-
 pkgtools/pkglint/files/mkassignchecker.go    |   7 ++-
 pkgtools/pkglint/files/mkline_test.go        |  12 +++---
 pkgtools/pkglint/files/mklinechecker_test.go |   2 +-
 pkgtools/pkglint/files/mklineparser_test.go  |   2 +-
 pkgtools/pkglint/files/mklines_test.go       |  10 ++--
 pkgtools/pkglint/files/mkparser_test.go      |   4 +-
 pkgtools/pkglint/files/mkshparser_test.go    |   4 +-
 pkgtools/pkglint/files/mkshwalker_test.go    |   2 +-
 pkgtools/pkglint/files/mktokenslexer_test.go |  10 ++--
 pkgtools/pkglint/files/package_test.go       |   2 +-
 pkgtools/pkglint/files/pkglint.go            |   2 +-
 pkgtools/pkglint/files/pkglint_test.go       |  22 +++++++-----
 pkgtools/pkglint/files/pkgsrc.go             |   8 ++--
 pkgtools/pkglint/files/pkgsrc_test.go        |  37 +++++++++-----------
 pkgtools/pkglint/files/plist_test.go         |  22 +++++++-----
 pkgtools/pkglint/files/scope_test.go         |  38 +++++++++++-----------
 pkgtools/pkglint/files/shell_test.go         |   2 +-
 pkgtools/pkglint/files/shtokenizer_test.go   |   2 +-
 pkgtools/pkglint/files/tools_test.go         |  12 +++---
 pkgtools/pkglint/files/util_test.go          |  48 ++++++++++++++--------------
 pkgtools/pkglint/files/var_test.go           |  10 ++--
 pkgtools/pkglint/files/varalignblock_test.go |   2 +-
 pkgtools/pkglint/files/vardefs.go            |   1 +
 pkgtools/pkglint/files/vartype.go            |   1 +
 pkgtools/pkglint/files/vartype_test.go       |   4 +-
 pkgtools/pkglint/files/vartypecheck.go       |  13 +++++++-
 pkgtools/pkglint/files/vartypecheck_test.go  |  12 +++++++
 32 files changed, 212 insertions(+), 163 deletions(-)

diffs (truncated from 1307 to 300 lines):

diff -r d13219392a1d -r 4c58aa0d54a6 pkgtools/pkglint/Makefile
--- a/pkgtools/pkglint/Makefile Sat Jan 01 12:42:38 2022 +0000
+++ b/pkgtools/pkglint/Makefile Sat Jan 01 12:44:24 2022 +0000
@@ -1,6 +1,6 @@
-# $NetBSD: Makefile,v 1.706 2021/12/26 16:56:47 rillig Exp $
+# $NetBSD: Makefile,v 1.707 2022/01/01 12:44:24 rillig Exp $
 
-PKGNAME=       pkglint-21.4.0
+PKGNAME=       pkglint-21.4.1
 CATEGORIES=    pkgtools
 DISTNAME=      tools
 MASTER_SITES=  ${MASTER_SITE_GITHUB:=golang/}
diff -r d13219392a1d -r 4c58aa0d54a6 pkgtools/pkglint/files/autofix_test.go
--- a/pkgtools/pkglint/files/autofix_test.go    Sat Jan 01 12:42:38 2022 +0000
+++ b/pkgtools/pkglint/files/autofix_test.go    Sat Jan 01 12:44:24 2022 +0000
@@ -84,7 +84,7 @@
 
        line := t.NewLine("filename", 1, "original")
 
-       c.Check(line.fix, check.IsNil)
+       t.CheckNil(line.fix)
        t.CheckDeepEquals(line.raw, newRawLines("original\n"))
 
        {
@@ -94,7 +94,6 @@
                fix.Apply()
        }
 
-       c.Check(line.fix, check.NotNil)
        t.CheckDeepEquals(line.raw, newRawLines("original\n"))
        t.CheckDeepEquals(line.fix.texts, []string{"lriginao\n"})
        t.CheckOutputLines(
@@ -107,7 +106,6 @@
                fix.Apply()
        }
 
-       c.Check(line.fix, check.NotNil)
        t.CheckDeepEquals(line.raw, newRawLines("original\n"))
        t.CheckDeepEquals(line.fix.texts, []string{"lruginao\n"})
        t.CheckEquals(line.RawText(0), "lruginao")
@@ -121,7 +119,6 @@
                fix.Apply()
        }
 
-       c.Check(line.fix, check.NotNil)
        t.CheckDeepEquals(line.raw, newRawLines("original\n"))
        t.CheckDeepEquals(line.fix.texts, []string{"middle\n"})
        t.CheckOutputLines(
@@ -362,7 +359,8 @@
        fix := NewAutofix(line)
        fix2 := NewAutofix(line)
 
-       t.Check(fix2, check.Not(check.Equals), fix)
+       t.CheckEquals(fix2 == fix, false)
+       t.CheckDeepEquals(fix2, fix)
 }
 
 func (s *Suite) Test_Autofix_Errorf(c *check.C) {
@@ -1380,7 +1378,7 @@
        // As long as the file is kept open, it cannot be overwritten or deleted.
        openFile, err := os.OpenFile(t.File("subdir/file.txt").String(), 0, 0666)
        defer func() { assertNil(openFile.Close(), "") }()
-       c.Check(err, check.IsNil)
+       t.CheckNil(err)
 
        fix := lines.Lines[0].Autofix()
        fix.Warnf("Should start with an uppercase letter.")
@@ -1406,8 +1404,8 @@
        lines := t.SetUpFileLines("file.txt",
                "line 1")
 
-       c.Check(os.RemoveAll(t.File("file.txt").String()), check.IsNil)
-       c.Check(os.MkdirAll(t.File("file.txt").String(), 0777), check.IsNil)
+       t.CheckNil(os.RemoveAll(t.File("file.txt").String()))
+       t.CheckNil(os.MkdirAll(t.File("file.txt").String(), 0777))
 
        fix := lines.Lines[0].Autofix()
        fix.Warnf("Should start with an uppercase letter.")
diff -r d13219392a1d -r 4c58aa0d54a6 pkgtools/pkglint/files/check_test.go
--- a/pkgtools/pkglint/files/check_test.go      Sat Jan 01 12:42:38 2022 +0000
+++ b/pkgtools/pkglint/files/check_test.go      Sat Jan 01 12:44:24 2022 +0000
@@ -272,7 +272,7 @@
        // Make sure that registering the type succeeds.
        // This is necessary for BtUnknown and guessed types.
        vartype := G.Pkgsrc.VariableType(nil, varname)
-       t.c.Assert(vartype.basicType, check.Equals, basicType)
+       t.AssertEquals(vartype.basicType, basicType)
 }
 
 // SetUpFileLines creates a temporary file and writes the given lines to it.
@@ -544,11 +544,8 @@
        }
 
        abs := t.File(filename)
-       err := os.MkdirAll(abs.Dir().String(), 0777)
-       t.c.Assert(err, check.IsNil)
-
-       err = abs.WriteString(content.String())
-       t.c.Assert(err, check.IsNil)
+       t.AssertNil(os.MkdirAll(abs.Dir().String(), 0777))
+       t.AssertNil(abs.WriteString(content.String()))
 
        G.fileCache.Evict(abs)
 
@@ -681,8 +678,7 @@
 // The file or directory must exist.
 func (t *Tester) Remove(filename RelPath) {
        abs := t.File(filename)
-       err := os.Remove(abs.String())
-       t.c.Assert(err, check.IsNil)
+       t.AssertNil(os.Remove(abs.String()))
        G.fileCache.Evict(abs)
 }
 
@@ -859,6 +855,18 @@
        return G.Main(&t.stdout, &t.stderr, argv)
 }
 
+func (t *Tester) AssertNil(obj interface{}) {
+       t.c.Assert(obj, check.IsNil)
+}
+
+func (t *Tester) AssertNotNil(obj interface{}) {
+       t.c.Assert(obj, check.NotNil)
+}
+
+func (t *Tester) AssertEquals(actual, expected interface{}) {
+       t.c.Assert(actual, check.Equals, expected)
+}
+
 // Check delegates a check to the check.Check function.
 // Thereby, there is no need to distinguish between c.Check and t.Check
 // in the test code.
@@ -866,6 +874,14 @@
        return t.c.Check(obj, checker, args...)
 }
 
+func (t *Tester) CheckNil(obj interface{}) bool {
+       return t.c.Check(obj, check.IsNil)
+}
+
+func (t *Tester) CheckNotNil(obj interface{}) bool {
+       return t.c.Check(obj, check.NotNil)
+}
+
 func (t *Tester) CheckEquals(actual interface{}, expected interface{}) bool {
        return t.c.Check(actual, check.Equals, expected)
 }
@@ -884,6 +900,10 @@
                check.Commentf(format, args...))
 }
 
+func (t *Tester) CheckLen(obj interface{}, expected int) bool {
+       return t.c.Check(obj, check.HasLen, expected)
+}
+
 // InternalErrorf reports a consistency error in the tests.
 func (t *Tester) InternalErrorf(format string, args ...interface{}) {
        // It is not possible to panic here since check.v1 would then
@@ -1284,7 +1304,7 @@
 // they equal the given lines.
 func (t *Tester) CheckFileLines(filename RelPath, lines ...string) {
        content, err := t.File(filename).ReadString()
-       t.c.Assert(err, check.IsNil)
+       t.AssertNil(err)
        actualLines := strings.Split(content, "\n")
        actualLines = actualLines[:len(actualLines)-1]
        t.CheckDeepEquals(emptyToNil(actualLines), emptyToNil(lines))
diff -r d13219392a1d -r 4c58aa0d54a6 pkgtools/pkglint/files/files_test.go
--- a/pkgtools/pkglint/files/files_test.go      Sat Jan 01 12:42:38 2022 +0000
+++ b/pkgtools/pkglint/files/files_test.go      Sat Jan 01 12:44:24 2022 +0000
@@ -25,31 +25,35 @@
        t := s.Init(c)
 
        nonexistent := t.File("nonexistent")
-       empty := t.CreateFileLines("empty")
+       empty := t.CreateFileLines("empty",
+               nil...)
        oneLiner := t.CreateFileLines("one-liner",
                "hello, world")
 
-       t.Check(Load(nonexistent, 0), check.IsNil)
-       t.Check(Load(empty, 0).Lines, check.HasLen, 0)
+       t.CheckNil(Load(nonexistent, 0))
+       t.CheckLen(Load(empty, 0).Lines, 0)
        t.CheckEquals(Load(oneLiner, 0).Lines[0].Text, "hello, world")
 
        t.CheckOutputEmpty()
 
-       t.Check(Load(nonexistent, LogErrors), check.IsNil)
-       t.Check(Load(empty, LogErrors).Lines, check.HasLen, 0)
+       t.CheckNil(Load(nonexistent, LogErrors))
+       t.CheckLen(Load(empty, LogErrors).Lines, 0)
        t.CheckEquals(Load(oneLiner, LogErrors).Lines[0].Text, "hello, world")
 
        t.CheckOutputLines(
                "ERROR: ~/nonexistent: Cannot be read.")
 
-       t.Check(Load(nonexistent, NotEmpty), check.IsNil)
-       t.Check(Load(empty, NotEmpty), check.IsNil)
+       t.CheckNil(Load(nonexistent, NotEmpty))
+       t.CheckNil(Load(empty, NotEmpty))
        t.CheckEquals(Load(oneLiner, NotEmpty).Lines[0].Text, "hello, world")
 
+       // Specifying NotEmpty only makes sense when combined with LogErrors
+       // or with MustSucceed.  On its own, NotEmpty returns nil in error
+       // cases, which is indistinguishable from an empty slice.
        t.CheckOutputEmpty()
 
-       t.Check(Load(nonexistent, NotEmpty|LogErrors), check.IsNil)
-       t.Check(Load(empty, NotEmpty|LogErrors), check.IsNil)
+       t.CheckNil(Load(nonexistent, NotEmpty|LogErrors))
+       t.CheckNil(Load(empty, NotEmpty|LogErrors))
        t.CheckEquals(Load(oneLiner, NotEmpty|LogErrors).Lines[0].Text, "hello, world")
 
        t.CheckOutputLines(
diff -r d13219392a1d -r 4c58aa0d54a6 pkgtools/pkglint/files/lineslexer_test.go
--- a/pkgtools/pkglint/files/lineslexer_test.go Sat Jan 01 12:42:38 2022 +0000
+++ b/pkgtools/pkglint/files/lineslexer_test.go Sat Jan 01 12:44:24 2022 +0000
@@ -95,12 +95,12 @@
 
        llex := NewLinesLexer(lines)
 
-       t.Check(llex.NextRegexp(`not found`), check.IsNil)
+       t.CheckNil(llex.NextRegexp(`not found`))
        t.CheckDeepEquals(llex.NextRegexp(`ne..`), []string{"ne 1"})
 
        t.CheckEquals(llex.EOF(), true)
 
-       t.Check(llex.NextRegexp(`^`), check.IsNil)
+       t.CheckNil(llex.NextRegexp(`^`))
 }
 
 func (s *Suite) Test_LinesLexer_SkipRegexp(c *check.C) {
@@ -235,7 +235,7 @@
 
        llex.next()
 
-       t.Check(llex.line, check.IsNil)
+       t.CheckNil(llex.line)
 }
 
 func (s *Suite) Test_NewMkLinesLexer(c *check.C) {
diff -r d13219392a1d -r 4c58aa0d54a6 pkgtools/pkglint/files/mkassignchecker.go
--- a/pkgtools/pkglint/files/mkassignchecker.go Sat Jan 01 12:42:38 2022 +0000
+++ b/pkgtools/pkglint/files/mkassignchecker.go Sat Jan 01 12:44:24 2022 +0000
@@ -645,8 +645,11 @@
        }
 }
 
-// checkVaruseShell is very similar to checkRightVaruse, they just differ
-// in the way they determine isWordPart.
+// checkVaruseShell checks that in a variable assignment, each variable
+// expression on the right-hand side of the assignment operator has the
+// correct data type and quoting.
+//
+// See checkRightVaruse for non-shell variables.
 func (ck *MkAssignChecker) checkVaruseShell(vartype *Vartype, time VucTime) {
        if trace.Tracing {
                defer trace.Call(vartype, time)()
diff -r d13219392a1d -r 4c58aa0d54a6 pkgtools/pkglint/files/mkline_test.go
--- a/pkgtools/pkglint/files/mkline_test.go     Sat Jan 01 12:42:38 2022 +0000
+++ b/pkgtools/pkglint/files/mkline_test.go     Sat Jan 01 12:44:24 2022 +0000
@@ -154,7 +154,7 @@
 
        mkline := t.NewMkLine("Makefile", 45, ".include \"../../category/package/buildlink3.mk\"")
 
-       c.Check(mkline.ConditionalVars(), check.HasLen, 0)
+       t.CheckLen(mkline.ConditionalVars(), 0)
 
        mkline.SetConditionalVars([]string{"OPSYS"})
 
@@ -166,7 +166,7 @@
 
        mkline := t.NewMkLine("filename.mk", 123, "#VAR=\tvalue ${VAR} suffix text")
 
-       t.Check(mkline.Tokenize(mkline.Value(), false), check.HasLen, 3)
+       t.CheckLen(mkline.Tokenize(mkline.Value(), false), 3)
 }
 
 func (s *Suite) Test_MkLine_ValueSplit(c *check.C) {
@@ -380,13 +380,13 @@
 
        tokens, rest := mkline.ValueTokens()
 
-       t.Check(tokens, check.IsNil)
+       t.CheckNil(tokens)
        t.CheckEquals(rest, "$")
 
        // Returns the same values, this time from the cache.
        tokens, rest = mkline.ValueTokens()
 
-       t.Check(tokens, check.IsNil)
+       t.CheckNil(tokens)
        t.CheckEquals(rest, "$")
 }
 
@@ -1410,7 +1410,7 @@
 
        ind.Pop()



Home | Main Index | Thread Index | Old Index