pkgsrc-Changes-HG archive

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

[pkgsrc/trunk]: pkgsrc/pkgtools/pkglint Updated pkglint to 5.4.0.



details:   https://anonhg.NetBSD.org/pkgsrc/rev/c40674aa866b
branches:  trunk
changeset: 348009:c40674aa866b
user:      rillig <rillig%pkgsrc.org@localhost>
date:      Sun Jun 05 11:24:32 2016 +0000

description:
Updated pkglint to 5.4.0.

Changes since 5.3.7:

* Replaced the -D... debug options with a single -d
* Omitted duplicate diagnostics
* Marked the :Q operator unnecessary for some variables
* Improved detection of whether bsd.prefs.mk has been included,
  which fixed unwarranted warnings about load time evaluation of
  some variables like ${ECHO} and ${SED}
* Improved detection for $(VAR) with round parentheses
* Fixed allowed locations for several variables
* Improved detection for used variables (still not perfect)
* Added warning that MASTER_SITES should not be used in HOMEPAGE
* Fixed warning about manual patches not being in distinfo
* Added a check for missing MASTER_SITE_* variables
* Added a check for unfinished url2pkg work
* Fixed several wrong warnings

diffstat:

 pkgtools/pkglint/Makefile                   |    6 +-
 pkgtools/pkglint/files/buildlink3.go        |   10 +-
 pkgtools/pkglint/files/category.go          |    2 +-
 pkgtools/pkglint/files/check_test.go        |   42 +-
 pkgtools/pkglint/files/dir.go               |    8 +-
 pkgtools/pkglint/files/distinfo.go          |   14 +-
 pkgtools/pkglint/files/distinfo_test.go     |   14 +
 pkgtools/pkglint/files/expecter.go          |    6 +-
 pkgtools/pkglint/files/files.go             |   28 +-
 pkgtools/pkglint/files/files_test.go        |    2 +-
 pkgtools/pkglint/files/getopt.go            |    4 +-
 pkgtools/pkglint/files/getopt_test.go       |    4 +
 pkgtools/pkglint/files/globaldata.go        |  171 +++--
 pkgtools/pkglint/files/globaldata_test.go   |   54 +-
 pkgtools/pkglint/files/globalvars.go        |   31 +-
 pkgtools/pkglint/files/licenses.go          |    2 +-
 pkgtools/pkglint/files/line.go              |   55 +-
 pkgtools/pkglint/files/line_test.go         |   32 +-
 pkgtools/pkglint/files/logging.go           |   73 +-
 pkgtools/pkglint/files/main.go              |   15 +-
 pkgtools/pkglint/files/mkline.go            |  840 ++++++++++++++++++++-------
 pkgtools/pkglint/files/mkline_test.go       |  496 ++++++++++++---
 pkgtools/pkglint/files/mklines.go           |  257 +-------
 pkgtools/pkglint/files/mklines_test.go      |  187 ++++++
 pkgtools/pkglint/files/mkparser.go          |  346 +++++++++++
 pkgtools/pkglint/files/mkparser_test.go     |  207 ++++++
 pkgtools/pkglint/files/mkshparser.go        |  655 +++++++++++++++++++++
 pkgtools/pkglint/files/mkshparser_test.go   |  352 +++++++++++
 pkgtools/pkglint/files/mkshtypes.go         |  231 +++++++
 pkgtools/pkglint/files/mktypes.go           |   37 +
 pkgtools/pkglint/files/mktypes_test.go      |   11 +
 pkgtools/pkglint/files/package.go           |  104 ++-
 pkgtools/pkglint/files/package_test.go      |   76 ++
 pkgtools/pkglint/files/parser.go            |  331 +----------
 pkgtools/pkglint/files/parser_test.go       |  239 +------
 pkgtools/pkglint/files/patches.go           |   64 +-
 pkgtools/pkglint/files/patches_test.go      |   10 +-
 pkgtools/pkglint/files/pkglint.0            |   42 +-
 pkgtools/pkglint/files/pkglint.1            |   42 +-
 pkgtools/pkglint/files/pkglint.go           |   39 +-
 pkgtools/pkglint/files/plist.go             |    2 +-
 pkgtools/pkglint/files/shell.go             |  460 +++++++++------
 pkgtools/pkglint/files/shell_test.go        |  205 +++++-
 pkgtools/pkglint/files/shtokenizer.go       |  313 ++++++++++
 pkgtools/pkglint/files/shtokenizer_test.go  |  443 ++++++++++++++
 pkgtools/pkglint/files/shtypes.go           |  147 ++++
 pkgtools/pkglint/files/shtypes_test.go      |   13 +
 pkgtools/pkglint/files/toplevel.go          |    2 +-
 pkgtools/pkglint/files/util.go              |  200 ++---
 pkgtools/pkglint/files/vardefs.go           |   64 +-
 pkgtools/pkglint/files/vartype.go           |   62 ++-
 pkgtools/pkglint/files/vartypecheck.go      |  227 ++++++-
 pkgtools/pkglint/files/vartypecheck_test.go |   76 +-
 53 files changed, 5399 insertions(+), 1954 deletions(-)

diffs (truncated from 10217 to 300 lines):

diff -r 9c0c7215ecd1 -r c40674aa866b pkgtools/pkglint/Makefile
--- a/pkgtools/pkglint/Makefile Sun Jun 05 10:12:13 2016 +0000
+++ b/pkgtools/pkglint/Makefile Sun Jun 05 11:24:32 2016 +0000
@@ -1,6 +1,6 @@
-# $NetBSD: Makefile,v 1.484 2016/04/10 16:59:37 joerg Exp $
+# $NetBSD: Makefile,v 1.485 2016/06/05 11:24:32 rillig Exp $
 
-PKGNAME=       pkglint-5.3.7
+PKGNAME=       pkglint-5.4.0
 DISTFILES=     # none
 CATEGORIES=    pkgtools
 
@@ -19,7 +19,7 @@
 
 SUBST_CLASSES+=                pkglint
 SUBST_STAGE.pkglint=   post-configure
-SUBST_FILES.pkglint+=  main.go
+SUBST_FILES.pkglint+=  main.go package_test.go
 SUBST_SED.pkglint+=    -e s\|@VERSION@\|${PKGNAME:S/pkglint-//}\|g
 SUBST_SED.pkglint+=    -e s\|@BMAKE@\|${MAKE:Q}\|g
 
diff -r 9c0c7215ecd1 -r c40674aa866b pkgtools/pkglint/files/buildlink3.go
--- a/pkgtools/pkglint/files/buildlink3.go      Sun Jun 05 10:12:13 2016 +0000
+++ b/pkgtools/pkglint/files/buildlink3.go      Sun Jun 05 11:24:32 2016 +0000
@@ -5,7 +5,7 @@
 )
 
 func ChecklinesBuildlink3Mk(mklines *MkLines) {
-       if G.opts.DebugTrace {
+       if G.opts.Debug {
                defer tracecall1(mklines.lines[0].Fname)()
        }
 
@@ -118,7 +118,7 @@
 
                        if varname == "BUILDLINK_ABI_DEPENDS."+pkgbase {
                                abiLine = line
-                               parser := NewParser(line, value)
+                               parser := NewParser(line, value, false)
                                if dp := parser.Dependency(); dp != nil && parser.EOF() {
                                        abi = dp
                                }
@@ -126,7 +126,7 @@
                        }
                        if varname == "BUILDLINK_API_DEPENDS."+pkgbase {
                                apiLine = line
-                               parser := NewParser(line, value)
+                               parser := NewParser(line, value, false)
                                if dp := parser.Dependency(); dp != nil && parser.EOF() {
                                        api = dp
                                }
@@ -174,8 +174,8 @@
                        }
 
                } else {
-                       if G.opts.DebugUnchecked {
-                               exp.CurrentLine().Debugf("Unchecked line in third paragraph.")
+                       if G.opts.Debug {
+                               traceStep1("Unchecked line %s in third paragraph.", exp.CurrentLine().linenos())
                        }
                        exp.Advance()
                }
diff -r 9c0c7215ecd1 -r c40674aa866b pkgtools/pkglint/files/category.go
--- a/pkgtools/pkglint/files/category.go        Sun Jun 05 10:12:13 2016 +0000
+++ b/pkgtools/pkglint/files/category.go        Sun Jun 05 11:24:32 2016 +0000
@@ -5,7 +5,7 @@
 )
 
 func CheckdirCategory() {
-       if G.opts.DebugTrace {
+       if G.opts.Debug {
                defer tracecall1(G.CurrentDir)()
        }
 
diff -r 9c0c7215ecd1 -r c40674aa866b pkgtools/pkglint/files/check_test.go
--- a/pkgtools/pkglint/files/check_test.go      Sun Jun 05 10:12:13 2016 +0000
+++ b/pkgtools/pkglint/files/check_test.go      Sun Jun 05 11:24:32 2016 +0000
@@ -77,7 +77,8 @@
 
 func (s *Suite) DebugToStdout() {
        G.debugOut = os.Stdout
-       G.opts.DebugTrace = true
+       G.logOut = os.Stdout
+       G.opts.Debug = true
 }
 
 func (s *Suite) UseCommandLine(c *check.C, args ...string) {
@@ -85,21 +86,35 @@
        if exitcode != nil && *exitcode != 0 {
                c.Fatalf("Cannot parse command line: %#v", args)
        }
+       G.opts.LogVerbose = true // See SetUpTest
 }
 
-func (s *Suite) RegisterTool(toolname, varname string, varRequired bool) {
-       if G.globalData.Tools == nil {
-               G.globalData.Tools = make(map[string]bool)
-               G.globalData.Vartools = make(map[string]string)
-               G.globalData.toolsVarRequired = make(map[string]bool)
-               G.globalData.PredefinedTools = make(map[string]bool)
+func (s *Suite) RegisterMasterSite(varname string, urls ...string) {
+       name2url := &G.globalData.MasterSiteVarToURL
+       url2name := &G.globalData.MasterSiteURLToVar
+       if *name2url == nil {
+               *name2url = make(map[string]string)
+               *url2name = make(map[string]string)
+       }
+       (*name2url)[varname] = urls[0]
+       for _, url := range urls {
+               (*url2name)[url] = varname
        }
-       G.globalData.Tools[toolname] = true
-       G.globalData.Vartools[toolname] = varname
-       if varRequired {
-               G.globalData.toolsVarRequired[toolname] = true
+}
+
+func (s *Suite) RegisterTool(tool *Tool) {
+       reg := G.globalData.Tools
+
+       if len(reg.byName) == 0 && len(reg.byVarname) == 0 {
+               reg = NewToolRegistry()
+               G.globalData.Tools = reg
        }
-       G.globalData.PredefinedTools[toolname] = true
+       if tool.Name != "" {
+               reg.byName[tool.Name] = tool
+       }
+       if tool.Varname != "" {
+               reg.byVarname[tool.Varname] = tool
+       }
 }
 
 func (s *Suite) CreateTmpFile(c *check.C, relFname, content string) (absFname string) {
@@ -140,9 +155,10 @@
 }
 
 func (s *Suite) SetUpTest(c *check.C) {
-       G = GlobalVars{TestingData: &TestingData{VerifiedBits: make(map[string]bool)}}
+       G = GlobalVars{Testing: true}
        G.logOut, G.logErr, G.debugOut = &s.stdout, &s.stderr, &s.stdout
        s.UseCommandLine(c /* no arguments */)
+       G.opts.LogVerbose = true // To detect duplicate work being done
 }
 
 func (s *Suite) TearDownTest(c *check.C) {
diff -r 9c0c7215ecd1 -r c40674aa866b pkgtools/pkglint/files/dir.go
--- a/pkgtools/pkglint/files/dir.go     Sun Jun 05 10:12:13 2016 +0000
+++ b/pkgtools/pkglint/files/dir.go     Sun Jun 05 11:24:32 2016 +0000
@@ -6,13 +6,13 @@
 )
 
 func CheckDirent(fname string) {
-       if G.opts.DebugTrace {
+       if G.opts.Debug {
                defer tracecall1(fname)()
        }
 
        st, err := os.Lstat(fname)
        if err != nil || !st.Mode().IsDir() && !st.Mode().IsRegular() {
-               Errorf(fname, noLines, "No such file or directory.")
+               NewLineWhole(fname).Errorf("No such file or directory.")
                return
        }
        isDir := st.Mode().IsDir()
@@ -24,7 +24,7 @@
        G.Infrastructure = matches(absCurrentDir, `/mk/|/mk$`)
        G.CurPkgsrcdir = findPkgsrcTopdir(G.CurrentDir)
        if G.CurPkgsrcdir == "" {
-               Errorf(fname, noLines, "Cannot determine the pkgsrc root directory for %q.", G.CurrentDir)
+               NewLineWhole(fname).Error1("Cannot determine the pkgsrc root directory for %q.", G.CurrentDir)
                return
        }
 
@@ -44,6 +44,6 @@
        case ".":
                CheckdirToplevel()
        default:
-               Errorf(fname, noLines, "Cannot check directories outside a pkgsrc tree.")
+               NewLineWhole(fname).Error0("Cannot check directories outside a pkgsrc tree.")
        }
 }
diff -r 9c0c7215ecd1 -r c40674aa866b pkgtools/pkglint/files/distinfo.go
--- a/pkgtools/pkglint/files/distinfo.go        Sun Jun 05 10:12:13 2016 +0000
+++ b/pkgtools/pkglint/files/distinfo.go        Sun Jun 05 11:24:32 2016 +0000
@@ -9,7 +9,7 @@
 )
 
 func ChecklinesDistinfo(lines []*Line) {
-       if G.opts.DebugTrace {
+       if G.opts.Debug {
                defer tracecall1(lines[0].Fname)()
        }
 
@@ -20,8 +20,8 @@
        } else if G.Pkg != nil && dirExists(G.CurrentDir+"/"+G.Pkg.Patchdir) {
                patchesDir = G.Pkg.Patchdir
        }
-       if G.opts.DebugMisc {
-               Debugf(fname, noLines, "patchesDir=%q", patchesDir)
+       if G.opts.Debug {
+               traceStep1("patchesDir=%q", patchesDir)
        }
 
        ck := &distinfoLinesChecker{
@@ -124,16 +124,16 @@
 func (ck *distinfoLinesChecker) checkUnrecordedPatches() {
        files, err := ioutil.ReadDir(G.CurrentDir + "/" + ck.patchdir)
        if err != nil {
-               if G.opts.DebugUnchecked {
-                       Debugf(ck.distinfoFilename, noLines, "Cannot read patchesDir %q: %s", ck.patchdir, err)
+               if G.opts.Debug {
+                       traceStep("Cannot read patchesDir %q: %s", ck.patchdir, err)
                }
                return
        }
 
        for _, file := range files {
                patch := file.Name()
-               if file.Mode().IsRegular() && !ck.patches[patch] {
-                       Errorf(ck.distinfoFilename, noLines, "patch %q is not recorded. Run \"%s makepatchsum\".", ck.patchdir+"/"+patch, confMake)
+               if file.Mode().IsRegular() && !ck.patches[patch] && hasPrefix(patch, "patch-") {
+                       NewLineWhole(ck.distinfoFilename).Errorf("patch %q is not recorded. Run \"%s makepatchsum\".", ck.patchdir+"/"+patch, confMake)
                }
        }
 }
diff -r 9c0c7215ecd1 -r c40674aa866b pkgtools/pkglint/files/distinfo_test.go
--- a/pkgtools/pkglint/files/distinfo_test.go   Sun Jun 05 10:12:13 2016 +0000
+++ b/pkgtools/pkglint/files/distinfo_test.go   Sun Jun 05 11:24:32 2016 +0000
@@ -83,3 +83,17 @@
                "ERROR: ~/distinfo: patch \"patches/patch-aa\" is not recorded. Run \""+confMake+" makepatchsum\".\n"+
                "ERROR: ~/distinfo: patch \"patches/patch-src-Makefile\" is not recorded. Run \""+confMake+" makepatchsum\".\n")
 }
+
+func (s *Suite) TestChecklinesDistinfo_ManualPatches(c *check.C) {
+       s.CreateTmpFile(c, "patches/manual-libtool.m4",
+               "")
+       G.CurrentDir = s.tmpdir
+
+       ChecklinesDistinfo(s.NewLines(s.tmpdir+"/distinfo",
+               "$"+"NetBSD$",
+               "",
+               "SHA1 (patch-aa) = ..."))
+
+       c.Check(s.Output(), equals, ""+
+               "WARN: ~/distinfo:3: Patch file \"patch-aa\" does not exist in directory \"patches\".\n")
+}
diff -r 9c0c7215ecd1 -r c40674aa866b pkgtools/pkglint/files/expecter.go
--- a/pkgtools/pkglint/files/expecter.go        Sun Jun 05 10:12:13 2016 +0000
+++ b/pkgtools/pkglint/files/expecter.go        Sun Jun 05 11:24:32 2016 +0000
@@ -38,7 +38,7 @@
 }
 
 func (exp *Expecter) AdvanceIfMatches(re string) bool {
-       if G.opts.DebugTrace {
+       if G.opts.Debug {
                defer tracecall2(exp.CurrentLine().Text, re)()
        }
 
@@ -53,7 +53,7 @@
 }
 
 func (exp *Expecter) AdvanceIfPrefix(prefix string) bool {
-       if G.opts.DebugTrace {
+       if G.opts.Debug {
                defer tracecall2(exp.CurrentLine().Text, prefix)()
        }
 
@@ -61,7 +61,7 @@
 }
 
 func (exp *Expecter) AdvanceIfEquals(text string) bool {
-       if G.opts.DebugTrace {
+       if G.opts.Debug {
                defer tracecall2(exp.CurrentLine().Text, text)()
        }
 
diff -r 9c0c7215ecd1 -r c40674aa866b pkgtools/pkglint/files/files.go
--- a/pkgtools/pkglint/files/files.go   Sun Jun 05 10:12:13 2016 +0000
+++ b/pkgtools/pkglint/files/files.go   Sun Jun 05 11:24:32 2016 +0000
@@ -3,18 +3,17 @@
 import (
        "io/ioutil"
        "os"
-       "strconv"
        "strings"
 )
 
 func LoadNonemptyLines(fname string, joinContinuationLines bool) []*Line {
        lines, err := readLines(fname, joinContinuationLines)
        if err != nil {
-               Errorf(fname, noLines, "Cannot be read.")
+               NewLineWhole(fname).Error0("Cannot be read.")
                return nil
        }
        if len(lines) == 0 {
-               Errorf(fname, noLines, "Must not be empty.")
+               NewLineWhole(fname).Error0("Must not be empty.")
                return nil
        }



Home | Main Index | Thread Index | Old Index