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: updated to 5.7.13



details:   https://anonhg.NetBSD.org/pkgsrc/rev/08d809a845e5
branches:  trunk
changeset: 396829:08d809a845e5
user:      rillig <rillig%pkgsrc.org@localhost>
date:      Mon Jun 10 19:51:57 2019 +0000

description:
pkgtools/pkglint: updated to 5.7.13

Changes since 5.7.12:

* Fixed a warning in the variable permissions that previously said "this
  variable should not be used at load time in this file, it would be ok
  in .", with an empty list of alternative files.

* Lots of refactoring and new tests.

diffstat:

 pkgtools/pkglint/Makefile                       |     5 +-
 pkgtools/pkglint/PLIST                          |     4 +-
 pkgtools/pkglint/files/autofix.go               |    18 +-
 pkgtools/pkglint/files/check_test.go            |    33 +-
 pkgtools/pkglint/files/distinfo.go              |    10 +-
 pkgtools/pkglint/files/line.go                  |     2 +-
 pkgtools/pkglint/files/logging.go               |     4 +-
 pkgtools/pkglint/files/mkline.go                |    81 +-
 pkgtools/pkglint/files/mkline_test.go           |   100 +-
 pkgtools/pkglint/files/mklinechecker.go         |   158 +-
 pkgtools/pkglint/files/mklinechecker_test.go    |   349 ++-
 pkgtools/pkglint/files/mklines.go               |     3 +
 pkgtools/pkglint/files/mklines_test.go          |    16 +
 pkgtools/pkglint/files/mklines_varalign_test.go |    45 +
 pkgtools/pkglint/files/mkparser.go              |     2 +-
 pkgtools/pkglint/files/mkshparser_test.go       |     2 +-
 pkgtools/pkglint/files/mkshwalker.go            |     2 +-
 pkgtools/pkglint/files/mktypes.go               |    14 +-
 pkgtools/pkglint/files/mktypes_test.go          |    12 +
 pkgtools/pkglint/files/options_test.go          |    60 +
 pkgtools/pkglint/files/package.go               |     5 +-
 pkgtools/pkglint/files/package_test.go          |   115 +-
 pkgtools/pkglint/files/paragraph.go             |    72 +
 pkgtools/pkglint/files/paragraph_test.go        |   153 +
 pkgtools/pkglint/files/patches_test.go          |    23 +
 pkgtools/pkglint/files/pkglint.go               |    40 +-
 pkgtools/pkglint/files/pkglint_test.go          |    66 +-
 pkgtools/pkglint/files/pkgsrc.go                |     6 +-
 pkgtools/pkglint/files/shell.go                 |     2 +-
 pkgtools/pkglint/files/shell_test.go            |   267 +-
 pkgtools/pkglint/files/shtokenizer.go           |     2 +-
 pkgtools/pkglint/files/shtypes.go               |     8 +-
 pkgtools/pkglint/files/substcontext.go          |    82 +-
 pkgtools/pkglint/files/substcontext_test.go     |    64 +-
 pkgtools/pkglint/files/tools.go                 |    11 +-
 pkgtools/pkglint/files/tools_test.go            |    77 +-
 pkgtools/pkglint/files/toplevel_test.go         |   102 +-
 pkgtools/pkglint/files/trace/tracing.go         |     2 +-
 pkgtools/pkglint/files/util.go                  |    90 +-
 pkgtools/pkglint/files/util_test.go             |    84 +
 pkgtools/pkglint/files/var.go                   |     6 +-
 pkgtools/pkglint/files/var_test.go              |    11 +
 pkgtools/pkglint/files/vardefs.go               |  2620 +++++++++++-----------
 pkgtools/pkglint/files/vardefs_test.go          |    24 +-
 pkgtools/pkglint/files/vartype.go               |    11 +-
 pkgtools/pkglint/files/vartypecheck.go          |     4 +-
 pkgtools/pkglint/files/vartypecheck_test.go     |    27 +-
 47 files changed, 3086 insertions(+), 1808 deletions(-)

diffs (truncated from 6875 to 300 lines):

diff -r 64bce6c7fd54 -r 08d809a845e5 pkgtools/pkglint/Makefile
--- a/pkgtools/pkglint/Makefile Mon Jun 10 19:08:54 2019 +0000
+++ b/pkgtools/pkglint/Makefile Mon Jun 10 19:51:57 2019 +0000
@@ -1,7 +1,6 @@
-# $NetBSD: Makefile,v 1.584 2019/05/27 15:18:29 bsiegert Exp $
+# $NetBSD: Makefile,v 1.585 2019/06/10 19:51:57 rillig Exp $
 
-PKGNAME=       pkglint-5.7.12
-PKGREVISION=   1
+PKGNAME=       pkglint-5.7.13
 CATEGORIES=    pkgtools
 DISTNAME=      tools
 MASTER_SITES=  ${MASTER_SITE_GITHUB:=golang/}
diff -r 64bce6c7fd54 -r 08d809a845e5 pkgtools/pkglint/PLIST
--- a/pkgtools/pkglint/PLIST    Mon Jun 10 19:08:54 2019 +0000
+++ b/pkgtools/pkglint/PLIST    Mon Jun 10 19:51:57 2019 +0000
@@ -1,4 +1,4 @@
-@comment $NetBSD: PLIST,v 1.11 2019/03/10 19:01:50 rillig Exp $
+@comment $NetBSD: PLIST,v 1.12 2019/06/10 19:51:57 rillig Exp $
 bin/pkglint
 gopkg/pkg/${GO_PLATFORM}/netbsd.org/pkglint.a
 gopkg/pkg/${GO_PLATFORM}/netbsd.org/pkglint/getopt.a
@@ -71,6 +71,8 @@
 gopkg/src/netbsd.org/pkglint/options_test.go
 gopkg/src/netbsd.org/pkglint/package.go
 gopkg/src/netbsd.org/pkglint/package_test.go
+gopkg/src/netbsd.org/pkglint/paragraph.go
+gopkg/src/netbsd.org/pkglint/paragraph_test.go
 gopkg/src/netbsd.org/pkglint/patches.go
 gopkg/src/netbsd.org/pkglint/patches_test.go
 gopkg/src/netbsd.org/pkglint/pkglint.0
diff -r 64bce6c7fd54 -r 08d809a845e5 pkgtools/pkglint/files/autofix.go
--- a/pkgtools/pkglint/files/autofix.go Mon Jun 10 19:08:54 2019 +0000
+++ b/pkgtools/pkglint/files/autofix.go Mon Jun 10 19:51:57 2019 +0000
@@ -75,7 +75,7 @@
        // Since a silent fix doesn't have a diagnostic, its explanation would
        // not provide any clue as to what diagnostic it belongs. That would
        // be confusing, therefore this case is not allowed.
-       G.Assertf(
+       assertf(
                fix.diagFormat != SilentAutofixFormat,
                "Autofix: Silent fixes cannot have an explanation.")
 
@@ -276,7 +276,7 @@
 
        // To fix this assertion, call one of Autofix.Errorf, Autofix.Warnf
        // or Autofix.Notef before calling Apply.
-       G.Assertf(
+       assertf(
                fix.level != nil,
                "Each autofix must have a log level and a diagnostic.")
 
@@ -345,8 +345,8 @@
        // This complicated code should not be in the Autofix type.
 
        fix.assertRealLine()
-       G.Assertf(mkline.IsMultiline(), "Line must be a multiline.")
-       G.Assertf(mkline.IsVarassign() || mkline.IsCommentedVarassign(), "Line must be a variable assignment.")
+       assertf(mkline.IsMultiline(), "Line must be a multiline.")
+       assertf(mkline.IsVarassign() || mkline.IsCommentedVarassign(), "Line must be a variable assignment.")
 
        if fix.skip() {
                return
@@ -404,13 +404,13 @@
 
 func (fix *Autofix) setDiag(level *LogLevel, format string, args []interface{}) {
        if G.Testing && format != SilentAutofixFormat {
-               G.Assertf(
+               assertf(
                        hasSuffix(format, "."),
                        "Autofix: format %q must end with a period.",
                        format)
        }
-       G.Assertf(fix.level == nil, "Autofix can only have a single diagnostic.")
-       G.Assertf(fix.diagFormat == "", "Autofix can only have a single diagnostic.")
+       assertf(fix.level == nil, "Autofix can only have a single diagnostic.")
+       assertf(fix.diagFormat == "", "Autofix can only have a single diagnostic.")
 
        fix.level = level
        fix.diagFormat = format
@@ -418,7 +418,7 @@
 }
 
 func (fix *Autofix) skip() bool {
-       G.Assertf(
+       assertf(
                fix.diagFormat != "",
                "Autofix: The diagnostic must be given before the action.")
        // This check is necessary for the --only command line option.
@@ -426,7 +426,7 @@
 }
 
 func (fix *Autofix) assertRealLine() {
-       G.Assertf(fix.line.firstLine >= 1, "Cannot autofix this line since it is not a real line.")
+       assertf(fix.line.firstLine >= 1, "Cannot autofix this line since it is not a real line.")
 }
 
 // SaveAutofixChanges writes the given lines back into their files,
diff -r 64bce6c7fd54 -r 08d809a845e5 pkgtools/pkglint/files/check_test.go
--- a/pkgtools/pkglint/files/check_test.go      Mon Jun 10 19:08:54 2019 +0000
+++ b/pkgtools/pkglint/files/check_test.go      Mon Jun 10 19:51:57 2019 +0000
@@ -189,7 +189,7 @@
        }
 }
 
-// SetUpOption pretends that the package option is defined in mk/defaults/options.description.
+// SetUpOption pretends that the given package option is defined in mk/defaults/options.description.
 func (t *Tester) SetUpOption(name, description string) {
        G.Pkgsrc.PkgOptions[name] = description
 }
@@ -321,7 +321,7 @@
 // SetUpCategory makes the given category valid by creating a dummy Makefile.
 // After that, it can be mentioned in the CATEGORIES variable of a package.
 func (t *Tester) SetUpCategory(name string) {
-       G.Assertf(!contains(name, "/"), "Category must not contain a slash.")
+       assertf(!contains(name, "/"), "Category must not contain a slash.")
 
        if _, err := os.Stat(t.File(name + "/Makefile")); os.IsNotExist(err) {
                t.CreateFileLines(name+"/Makefile",
@@ -509,9 +509,9 @@
 // Copy copies a file inside the temporary directory.
 func (t *Tester) Copy(relativeSrc, relativeDst string) {
        data, err := ioutil.ReadFile(t.File(relativeSrc))
-       G.AssertNil(err, "Copy.Read")
+       assertNil(err, "Copy.Read")
        err = ioutil.WriteFile(t.File(relativeDst), data, 0777)
-       G.AssertNil(err, "Copy.Write")
+       assertNil(err, "Copy.Write")
 }
 
 // Chdir changes the current working directory to the given subdirectory
@@ -605,13 +605,13 @@
                }
 
                mklines := NewMkLines(NewLines(filename, lines))
-               G.Assertf(files[filename] == nil, "MkLines with name %q already exists.", filename)
+               assertf(files[filename] == nil, "MkLines with name %q already exists.", filename)
                files[filename] = mklines
                return mklines
        }
 
        get = func(filename string) MkLines {
-               G.Assertf(files[filename] != nil, "MkLines with name %q doesn't exist.", filename)
+               assertf(files[filename] != nil, "MkLines with name %q doesn't exist.", filename)
                return files[filename]
        }
 
@@ -797,7 +797,7 @@
 // NewMkLine creates an in-memory line in the Makefile format with the given text.
 func (t *Tester) NewMkLine(filename string, lineno int, text string) MkLine {
        basename := path.Base(filename)
-       G.Assertf(
+       assertf(
                hasSuffix(basename, ".mk") ||
                        basename == "Makefile" ||
                        hasPrefix(basename, "Makefile.") ||
@@ -807,8 +807,9 @@
        return MkLineParser{}.Parse(t.NewLine(filename, lineno, text))
 }
 
-func (t *Tester) NewShellLineChecker(mklines MkLines, filename string, lineno int, text string) *ShellLineChecker {
-       return NewShellLineChecker(mklines, t.NewMkLine(filename, lineno, text))
+func (t *Tester) NewShellLineChecker(text string) *ShellLineChecker {
+       mklines := t.NewMkLines("filename.mk", text)
+       return NewShellLineChecker(mklines, mklines.mklines[0])
 }
 
 // NewLines returns a list of simple lines that belong together.
@@ -837,7 +838,7 @@
 // see SetUpFileMkLines for loading Makefile fragments with line continuations.
 func (t *Tester) NewMkLines(filename string, lines ...string) MkLines {
        basename := path.Base(filename)
-       G.Assertf(
+       assertf(
                hasSuffix(basename, ".mk") || basename == "Makefile" || hasPrefix(basename, "Makefile."),
                "filename %q must be realistic, otherwise the variable permissions are wrong", filename)
 
@@ -857,7 +858,7 @@
 
        t.stdout.Reset()
        t.stderr.Reset()
-       if G.Usable() {
+       if G.usable() {
                G.Logger.logged = Once{}
                if G.Logger.out != nil { // Necessary because Main resets the G variable.
                        G.Logger.out.state = 0 // Prevent an empty line at the beginning of the next output.
@@ -865,7 +866,7 @@
                }
        }
 
-       G.Assertf(t.tmpdir != "", "Tester must be initialized before checking the output.")
+       assertf(t.tmpdir != "", "Tester must be initialized before checking the output.")
        return strings.Replace(stdout+stderr, t.tmpdir, "~", -1)
 }
 
@@ -883,7 +884,7 @@
 //
 // See CheckOutputEmpty, CheckOutputLinesIgnoreSpace.
 func (t *Tester) CheckOutputLines(expectedLines ...string) {
-       G.Assertf(len(expectedLines) > 0, "To check empty lines, use CheckLinesEmpty instead.")
+       assertf(len(expectedLines) > 0, "To check empty lines, use CheckOutputEmpty instead.")
        t.CheckOutput(expectedLines)
 }
 
@@ -896,8 +897,8 @@
 //
 // See CheckOutputEmpty, CheckOutputLines.
 func (t *Tester) CheckOutputLinesIgnoreSpace(expectedLines ...string) {
-       G.Assertf(len(expectedLines) > 0, "To check empty lines, use CheckLinesEmpty instead.")
-       G.Assertf(t.tmpdir != "", "Tester must be initialized before checking the output.")
+       assertf(len(expectedLines) > 0, "To check empty lines, use CheckOutputEmpty instead.")
+       assertf(t.tmpdir != "", "Tester must be initialized before checking the output.")
 
        rawOutput := t.stdout.String() + t.stderr.String()
        _ = t.Output() // Just to consume the output
@@ -1055,7 +1056,7 @@
 // The diagnostics go to the in-memory buffer again,
 // ready to be checked with CheckOutputLines.
 func (t *Tester) DisableTracing() {
-       if G.Usable() {
+       if G.usable() {
                G.Logger.out = NewSeparatorWriter(&t.stdout)
        }
        trace.Tracing = false
diff -r 64bce6c7fd54 -r 08d809a845e5 pkgtools/pkglint/files/distinfo.go
--- a/pkgtools/pkglint/files/distinfo.go        Mon Jun 10 19:08:54 2019 +0000
+++ b/pkgtools/pkglint/files/distinfo.go        Mon Jun 10 19:51:57 2019 +0000
@@ -226,17 +226,17 @@
 
        computeHash := func(hasher hash.Hash) string {
                f, err := os.Open(distfile)
-               G.AssertNil(err, "Opening distfile")
+               assertNil(err, "Opening distfile")
 
                // Don't load the distfile into memory since some of them
                // are hundreds of MB in size.
                _, err = io.Copy(hasher, f)
-               G.AssertNil(err, "Computing hash of distfile")
+               assertNil(err, "Computing hash of distfile")
 
                hexHash := hex.EncodeToString(hasher.Sum(nil))
 
                err = f.Close()
-               G.AssertNil(err, "Closing distfile")
+               assertNil(err, "Closing distfile")
 
                return hexHash
        }
@@ -251,7 +251,7 @@
                        return computeHash(sha512.New())
                default:
                        fileInfo, err := os.Lstat(distfile)
-                       G.AssertNil(err, "Inaccessible distfile info")
+                       assertNil(err, "Inaccessible distfile info")
                        return sprintf("%d bytes", fileInfo.Size())
                }
        }
@@ -436,7 +436,7 @@
        skipText := []byte("$" + "NetBSD")
        for _, patchLine := range bytes.SplitAfter(patchBytes, []byte("\n")) {
                if !bytes.Contains(patchLine, skipText) {
-                       hasher.Write(patchLine)
+                       _, _ = hasher.Write(patchLine)
                }
        }
        return sprintf("%x", hasher.Sum(nil)), nil
diff -r 64bce6c7fd54 -r 08d809a845e5 pkgtools/pkglint/files/line.go
--- a/pkgtools/pkglint/files/line.go    Mon Jun 10 19:08:54 2019 +0000
+++ b/pkgtools/pkglint/files/line.go    Mon Jun 10 19:51:57 2019 +0000
@@ -83,7 +83,7 @@
 }
 
 func NewLine(filename string, lineno int, text string, rawLine *RawLine) Line {
-       G.Assertf(rawLine != nil, "use NewLineMulti for creating a Line with no RawLine attached to it")
+       assertf(rawLine != nil, "use NewLineMulti for creating a Line with no RawLine attached to it")
        return NewLineMulti(filename, lineno, lineno, text, []*RawLine{rawLine})
 }
 
diff -r 64bce6c7fd54 -r 08d809a845e5 pkgtools/pkglint/files/logging.go
--- a/pkgtools/pkglint/files/logging.go Mon Jun 10 19:08:54 2019 +0000
+++ b/pkgtools/pkglint/files/logging.go Mon Jun 10 19:51:57 2019 +0000
@@ -190,14 +190,14 @@
 
        if G.Testing && format != AutofixFormat {
                if textproc.Alpha.Contains(format[0]) {
-                       G.Assertf(
+                       assertf(
                                textproc.Upper.Contains(format[0]),
                                "Diagnostic %q must start with an uppercase letter.",
                                format)
                }
 
                if !hasSuffix(format, ": %s") && !hasSuffix(format, ". %s") {
-                       G.Assertf(hasSuffix(format, "."), "Diagnostic format %q must end in a period.", format)
+                       assertf(hasSuffix(format, "."), "Diagnostic format %q must end in a period.", format)
                }
        }
 
diff -r 64bce6c7fd54 -r 08d809a845e5 pkgtools/pkglint/files/mkline.go
--- a/pkgtools/pkglint/files/mkline.go  Mon Jun 10 19:08:54 2019 +0000



Home | Main Index | Thread Index | Old Index