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 5.6.0



details:   https://anonhg.NetBSD.org/pkgsrc/rev/bf10861c9961
branches:  trunk
changeset: 383874:bf10861c9961
user:      rillig <rillig%pkgsrc.org@localhost>
date:      Sun Aug 12 16:31:56 2018 +0000

description:
pkgtools/pkglint: update to 5.6.0

Changes since 5.5.16:

* Check for negated shell commands (if ! test -z "foo"); they are not
  supported by Solaris.

* Don't check variable permissions for infrastructure files. A warning
  like "may not be set by any package" doesn't make sense for them.

* Check that PLIST_VARS matches PLIST.*, which is especially useful in
  options.mk files.

* Improve checks for options.mk files (for PKG_OPTIONS_SET).

* Prefer options handling with !empty() over checking empty() first.

* Prefer ${MACHINE_ARCH} == i386 over !empty(MACHINE_ARCH:Mi386), for
  single-valued variables.

diffstat:

 pkgtools/pkglint/Makefile                     |    4 +-
 pkgtools/pkglint/files/alternatives.go        |   22 +-
 pkgtools/pkglint/files/alternatives_test.go   |    2 +-
 pkgtools/pkglint/files/autofix_test.go        |   49 ++++-
 pkgtools/pkglint/files/buildlink3_test.go     |   20 +-
 pkgtools/pkglint/files/category.go            |   10 +-
 pkgtools/pkglint/files/category_test.go       |    7 +-
 pkgtools/pkglint/files/check_test.go          |   84 ++++++--
 pkgtools/pkglint/files/codewalk.md            |   63 ++++++
 pkgtools/pkglint/files/distinfo.go            |  117 ++++++-----
 pkgtools/pkglint/files/distinfo_test.go       |  117 ++++++++++--
 pkgtools/pkglint/files/files.go               |    4 +
 pkgtools/pkglint/files/histogram/histogram.go |    2 +-
 pkgtools/pkglint/files/licenses.go            |    2 +-
 pkgtools/pkglint/files/licenses_test.go       |    3 +-
 pkgtools/pkglint/files/mkline.go              |  123 +++++++++---
 pkgtools/pkglint/files/mkline_test.go         |   10 +-
 pkgtools/pkglint/files/mklinechecker.go       |   56 ++++--
 pkgtools/pkglint/files/mklinechecker_test.go  |   37 +++-
 pkgtools/pkglint/files/mklines.go             |   79 +++++++-
 pkgtools/pkglint/files/mklines_test.go        |  179 ++++++++++++++++++-
 pkgtools/pkglint/files/mkparser.go            |  132 ++++++++++++--
 pkgtools/pkglint/files/mkparser_test.go       |   89 +++++----
 pkgtools/pkglint/files/mkshwalker.go          |  238 ++++++++++++++++---------
 pkgtools/pkglint/files/mkshwalker_test.go     |  154 +++++++++++++++-
 pkgtools/pkglint/files/options.go             |   41 +++-
 pkgtools/pkglint/files/options_test.go        |   63 +++++-
 pkgtools/pkglint/files/package.go             |   59 ++++--
 pkgtools/pkglint/files/package_test.go        |   68 ++-----
 pkgtools/pkglint/files/patches_test.go        |   47 +++++-
 pkgtools/pkglint/files/pkglint.go             |   24 +-
 pkgtools/pkglint/files/pkglint_test.go        |   97 ++++-----
 pkgtools/pkglint/files/pkgsrc.go              |    2 +-
 pkgtools/pkglint/files/pkgsrc_test.go         |    6 +-
 pkgtools/pkglint/files/pkgver/vercmp_test.go  |   31 +-
 pkgtools/pkglint/files/shell.go               |   67 ++++---
 pkgtools/pkglint/files/shell_test.go          |   30 +++
 pkgtools/pkglint/files/tools_test.go          |    3 +-
 pkgtools/pkglint/files/toplevel.go            |   13 +-
 pkgtools/pkglint/files/toplevel_test.go       |    3 +-
 pkgtools/pkglint/files/util.go                |   16 +-
 pkgtools/pkglint/files/util_test.go           |   24 +-
 pkgtools/pkglint/files/vardefs_test.go        |   21 ++
 pkgtools/pkglint/files/vartypecheck.go        |    5 +-
 pkgtools/pkglint/files/vartypecheck_test.go   |   71 +++++--
 45 files changed, 1647 insertions(+), 647 deletions(-)

diffs (truncated from 4024 to 300 lines):

diff -r 16d1898ae679 -r bf10861c9961 pkgtools/pkglint/Makefile
--- a/pkgtools/pkglint/Makefile Sun Aug 12 16:14:38 2018 +0000
+++ b/pkgtools/pkglint/Makefile Sun Aug 12 16:31:56 2018 +0000
@@ -1,6 +1,6 @@
-# $NetBSD: Makefile,v 1.545 2018/08/09 20:21:42 rillig Exp $
+# $NetBSD: Makefile,v 1.546 2018/08/12 16:31:56 rillig Exp $
 
-PKGNAME=       pkglint-5.5.16
+PKGNAME=       pkglint-5.6.0
 DISTFILES=     # none
 CATEGORIES=    pkgtools
 
diff -r 16d1898ae679 -r bf10861c9961 pkgtools/pkglint/files/alternatives.go
--- a/pkgtools/pkglint/files/alternatives.go    Sun Aug 12 16:14:38 2018 +0000
+++ b/pkgtools/pkglint/files/alternatives.go    Sun Aug 12 16:31:56 2018 +0000
@@ -13,17 +13,19 @@
 
        for _, line := range lines {
                if m, wrapper, space, implementation := match3(line.Text, `^(\S+)([ \t]+)(\S+)`); m {
-                       if plistFiles[wrapper] {
-                               line.Errorf("Alternative wrapper %q must not appear in the PLIST.", wrapper)
-                       }
+                       if plistFiles != nil {
+                               if plistFiles[wrapper] {
+                                       line.Errorf("Alternative wrapper %q must not appear in the PLIST.", wrapper)
+                               }
 
-                       relImplementation := strings.Replace(implementation, "@PREFIX@/", "", 1)
-                       plistName := regex.Compile(`@(\w+)@`).ReplaceAllString(relImplementation, "${$1}")
-                       if !plistFiles[plistName] && !G.Pkg.vars.Defined("ALTERNATIVES_SRC") {
-                               if plistName != implementation {
-                                       line.Errorf("Alternative implementation %q must appear in the PLIST as %q.", implementation, plistName)
-                               } else {
-                                       line.Errorf("Alternative implementation %q must appear in the PLIST.", implementation)
+                               relImplementation := strings.Replace(implementation, "@PREFIX@/", "", 1)
+                               plistName := regex.Compile(`@(\w+)@`).ReplaceAllString(relImplementation, "${$1}")
+                               if !plistFiles[plistName] && !G.Pkg.vars.Defined("ALTERNATIVES_SRC") {
+                                       if plistName != implementation {
+                                               line.Errorf("Alternative implementation %q must appear in the PLIST as %q.", implementation, plistName)
+                                       } else {
+                                               line.Errorf("Alternative implementation %q must appear in the PLIST.", implementation)
+                                       }
                                }
                        }
 
diff -r 16d1898ae679 -r bf10861c9961 pkgtools/pkglint/files/alternatives_test.go
--- a/pkgtools/pkglint/files/alternatives_test.go       Sun Aug 12 16:14:38 2018 +0000
+++ b/pkgtools/pkglint/files/alternatives_test.go       Sun Aug 12 16:31:56 2018 +0000
@@ -16,7 +16,7 @@
        G.Pkg.PlistFiles["bin/vim"] = true
        G.Pkg.PlistFiles["sbin/sendmail.exim${EXIMVER}"] = true
 
-       CheckfileAlternatives(t.TempFilename("ALTERNATIVES"), G.Pkg.PlistFiles)
+       CheckfileAlternatives(t.File("ALTERNATIVES"), G.Pkg.PlistFiles)
 
        t.CheckOutputLines(
                "ERROR: ~/ALTERNATIVES:1: Alternative implementation \"@PREFIX@/sbin/sendmail.postfix@POSTFIXVER@\" must appear in the PLIST as \"sbin/sendmail.postfix${POSTFIXVER}\".",
diff -r 16d1898ae679 -r bf10861c9961 pkgtools/pkglint/files/autofix_test.go
--- a/pkgtools/pkglint/files/autofix_test.go    Sun Aug 12 16:14:38 2018 +0000
+++ b/pkgtools/pkglint/files/autofix_test.go    Sun Aug 12 16:31:56 2018 +0000
@@ -113,13 +113,13 @@
        t := s.Init(c)
 
        t.SetupCommandLine("--autofix")
-       t.SetupFileLines("Makefile",
+       t.SetupFileLines("category/basename/Makefile",
                "line1 := value1",
                "line2 := value2",
                "line3 := value3")
        pkg := NewPackage("category/basename")
        G.Pkg = pkg
-       mklines := pkg.loadPackageMakefile(t.TempFilename("Makefile"))
+       mklines := pkg.loadPackageMakefile()
        G.Pkg = nil
 
        fix := mklines.mklines[1].Autofix()
@@ -135,19 +135,19 @@
        SaveAutofixChanges(mklines.lines)
 
        t.CheckOutputLines(
-               "AUTOFIX: ~/Makefile:2: Replacing \"lin\" with \"XXX\".",
-               "AUTOFIX: ~/Makefile:2: Replacing \"e2 \" with \"XXX\".",
-               "AUTOFIX: ~/Makefile:2: Replacing \":= \" with \"XXX\".",
-               "AUTOFIX: ~/Makefile:2: Replacing \"val\" with \"XXX\".",
-               "AUTOFIX: ~/Makefile:2: Replacing \"ue2\" with \"XXX\".",
-               "AUTOFIX: ~/Makefile:3: Replacing \"lin\" with \"XXX\".")
-       t.CheckFileLines("Makefile",
+               "AUTOFIX: ~/category/basename/Makefile:2: Replacing \"lin\" with \"XXX\".",
+               "AUTOFIX: ~/category/basename/Makefile:2: Replacing \"e2 \" with \"XXX\".",
+               "AUTOFIX: ~/category/basename/Makefile:2: Replacing \":= \" with \"XXX\".",
+               "AUTOFIX: ~/category/basename/Makefile:2: Replacing \"val\" with \"XXX\".",
+               "AUTOFIX: ~/category/basename/Makefile:2: Replacing \"ue2\" with \"XXX\".",
+               "AUTOFIX: ~/category/basename/Makefile:3: Replacing \"lin\" with \"XXX\".")
+       t.CheckFileLines("category/basename/Makefile",
                "line1 := value1",
                "XXXXXXXXXXXXXXX",
                "XXXe3 := value3")
 }
 
-func (s *Suite) Test_Autofix_multiple_modifications(c *check.C) {
+func (s *Suite) Test_Autofix__multiple_modifications(c *check.C) {
        t := s.Init(c)
 
        t.SetupCommandLine("--show-autofix", "--explain")
@@ -449,3 +449,32 @@
                "WARN: Makefile:74: Please write row instead of line.")
        c.Check(G.explanationsAvailable, equals, true)
 }
+
+// Since the diagnostic doesn't contain the string "few", nothing happens.
+func (s *Suite) Test_Autofix__skip(c *check.C) {
+       t := s.Init(c)
+
+       t.SetupCommandLine("--only", "few", "--autofix")
+
+       lines := t.SetupFileLines("fname",
+               "111 222 333 444 555")
+
+       fix := lines[0].Autofix()
+       fix.Warnf("Many.")
+       fix.Explain(
+               "Explanation.")
+       fix.Replace("111", "___")
+       fix.ReplaceAfter(" ", "222", "___")
+       fix.ReplaceRegex(`\d+`, "___", 1)
+       fix.InsertBefore("before")
+       fix.InsertAfter("after")
+       fix.Delete()
+       fix.Apply()
+
+       SaveAutofixChanges(lines)
+
+       t.CheckOutputEmpty()
+       t.CheckFileLines("fname",
+               "111 222 333 444 555")
+       c.Check(lines[0].raw[0].textnl, equals, "111 222 333 444 555\n")
+}
diff -r 16d1898ae679 -r bf10861c9961 pkgtools/pkglint/files/buildlink3_test.go
--- a/pkgtools/pkglint/files/buildlink3_test.go Sun Aug 12 16:14:38 2018 +0000
+++ b/pkgtools/pkglint/files/buildlink3_test.go Sun Aug 12 16:31:56 2018 +0000
@@ -6,7 +6,7 @@
        t := s.Init(c)
 
        t.SetupVartypes()
-       mklines := t.NewMkLines("buildlink3.mk",
+       mklines := t.SetupFileMkLines("buildlink3.mk",
                MkRcsID,
                "# XXX This file was created automatically using createbuildlink-@PKGVERSION@",
                "",
@@ -28,10 +28,10 @@
        ChecklinesBuildlink3Mk(mklines)
 
        t.CheckOutputLines(
-               "ERROR: buildlink3.mk:12: \"/x11/Xbae\" does not exist.",
-               "ERROR: buildlink3.mk:12: There is no package in \"x11/Xbae\".",
-               "ERROR: buildlink3.mk:14: \"/mk/motif.buildlink3.mk\" does not exist.",
-               "ERROR: buildlink3.mk:2: This comment indicates unfinished work (url2pkg).")
+               "ERROR: ~/buildlink3.mk:12: \"x11/Xbae\" does not exist.",
+               "ERROR: ~/buildlink3.mk:12: There is no package in \"x11/Xbae\".",
+               "ERROR: ~/buildlink3.mk:14: \"mk/motif.buildlink3.mk\" does not exist.",
+               "ERROR: ~/buildlink3.mk:2: This comment indicates unfinished work (url2pkg).")
 }
 
 // Before version 5.3, pkglint wrongly warned here.
@@ -315,7 +315,7 @@
 
        t.SetupCommandLine("-Wall")
        t.SetupVartypes()
-       mklines := t.NewMkLines("buildlink3.mk",
+       mklines := t.SetupFileMkLines("buildlink3.mk",
                MkRcsID,
                "",
                ".if ${VAAPI_AVAILABLE} == \"yes\"",
@@ -340,8 +340,8 @@
 
        // No warning about the indentation of the .include lines.
        t.CheckOutputLines(
-               "ERROR: buildlink3.mk:11: \"/multimedia/libva\" does not exist.",
-               "ERROR: buildlink3.mk:11: There is no package in \"multimedia/libva\".",
-               "ERROR: buildlink3.mk:13: \"/x11/libX11/buildlink3.mk\" does not exist.",
-               "WARN: buildlink3.mk:3: Expected a BUILDLINK_TREE line.")
+               "ERROR: ~/buildlink3.mk:11: \"multimedia/libva\" does not exist.",
+               "ERROR: ~/buildlink3.mk:11: There is no package in \"multimedia/libva\".",
+               "ERROR: ~/buildlink3.mk:13: \"x11/libX11/buildlink3.mk\" does not exist.",
+               "WARN: ~/buildlink3.mk:3: Expected a BUILDLINK_TREE line.")
 }
diff -r 16d1898ae679 -r bf10861c9961 pkgtools/pkglint/files/category.go
--- a/pkgtools/pkglint/files/category.go        Sun Aug 12 16:14:38 2018 +0000
+++ b/pkgtools/pkglint/files/category.go        Sun Aug 12 16:31:56 2018 +0000
@@ -5,12 +5,12 @@
        "sort"
 )
 
-func CheckdirCategory() {
+func CheckdirCategory(dir string) {
        if trace.Tracing {
-               defer trace.Call1(G.CurrentDir)()
+               defer trace.Call1(dir)()
        }
 
-       lines := LoadNonemptyLines(G.CurrentDir+"/Makefile", true)
+       lines := LoadNonemptyLines(dir+"/Makefile", true)
        if lines == nil {
                return
        }
@@ -40,7 +40,7 @@
        // the (hopefully) sorted list of SUBDIRs. The first step is to
        // collect the SUBDIRs in the Makefile and in the file system.
 
-       fSubdirs := getSubdirs(G.CurrentDir)
+       fSubdirs := getSubdirs(dir)
        sort.Strings(fSubdirs)
        var mSubdirs []subdir
 
@@ -147,7 +147,7 @@
                        fNeednext = true
                        mNeednext = true
                        if mActive {
-                               subdirs = append(subdirs, G.CurrentDir+"/"+mCurrent)
+                               subdirs = append(subdirs, dir+"/"+mCurrent)
                        }
                }
        }
diff -r 16d1898ae679 -r bf10861c9961 pkgtools/pkglint/files/category_test.go
--- a/pkgtools/pkglint/files/category_test.go   Sun Aug 12 16:14:38 2018 +0000
+++ b/pkgtools/pkglint/files/category_test.go   Sun Aug 12 16:31:56 2018 +0000
@@ -13,9 +13,8 @@
                "SUBDIR-=unknown #doesn\u2019t work",
                "",
                ".include \"../mk/category.mk\"")
-       G.CurrentDir = t.TempFilename("archivers")
 
-       CheckdirCategory()
+       CheckdirCategory(t.File("archivers"))
 
        t.CheckOutputLines(
                "ERROR: ~/archivers/Makefile:1: Expected \"# $"+"NetBSD$\".",
@@ -48,10 +47,8 @@
                "# dummy")
        t.SetupFileLines("mk/misc/category.mk",
                "# dummy")
-       G.CurrentDir = t.TempFilename("archivers")
-       G.CurPkgsrcdir = ".."
 
-       CheckdirCategory()
+       CheckdirCategory(t.File("archivers"))
 
        t.CheckOutputLines(
                "WARN: ~/archivers/Makefile:2: COMMENT contains invalid characters (U+005C U+0024 U+0024 U+0024 U+0024 U+0022).")
diff -r 16d1898ae679 -r bf10861c9961 pkgtools/pkglint/files/check_test.go
--- a/pkgtools/pkglint/files/check_test.go      Sun Aug 12 16:14:38 2018 +0000
+++ b/pkgtools/pkglint/files/check_test.go      Sun Aug 12 16:31:56 2018 +0000
@@ -51,7 +51,7 @@
        G.logOut = NewSeparatorWriter(&t.stdout)
        G.logErr = NewSeparatorWriter(&t.stderr)
        trace.Out = &t.stdout
-       G.Pkgsrc = NewPkgsrc(t.TmpDir())
+       G.Pkgsrc = NewPkgsrc(t.File("."))
 
        t.checkC = c
        t.SetupCommandLine( /* no arguments */ )
@@ -160,13 +160,57 @@
        return NewMkLines(plainLines)
 }
 
+// SetupPkgsrc sets up a minimal but complete pkgsrc installation in the
+// temporary folder, so that pkglint runs without any errors.
+// Individual files may be overwritten by calling other Setup* methods.
+// This setup is especially interesting for testing Pkglint.Main.
+func (t *Tester) SetupPkgsrc() {
+
+       // This file is needed to locate the pkgsrc root directory.
+       // See findPkgsrcTopdir.
+       t.CreateFileLines("mk/bsd.pkg.mk",
+               MkRcsID)
+
+       // See Pkgsrc.loadDocChanges.
+       t.CreateFileLines("doc/CHANGES-2018",
+               RcsID)
+
+       // See Pkgsrc.loadSuggestedUpdates.
+       t.CreateFileLines("doc/TODO",
+               RcsID)
+
+       // The MASTER_SITES in the package Makefile are searched here.
+       // See Pkgsrc.loadMasterSites.
+       t.CreateFileLines("mk/fetch/sites.mk",
+               MkRcsID)
+
+       // The options for the PKG_OPTIONS framework must be readable.
+       // See Pkgsrc.loadPkgOptions.
+       t.CreateFileLines("mk/defaults/options.description")
+
+       // The user-defined variables are read in to check for missing
+       // BUILD_DEFS declarations in the package Makefile.
+       t.CreateFileLines("mk/defaults/mk.conf",
+               MkRcsID)
+
+       // The tool definitions are read in to check for missing
+       // USE_TOOLS declarations in the package Makefile.



Home | Main Index | Thread Index | Old Index