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.7.15



details:   https://anonhg.NetBSD.org/pkgsrc/rev/e3b0fe3d8b18
branches:  trunk
changeset: 397671:e3b0fe3d8b18
user:      rillig <rillig%pkgsrc.org@localhost>
date:      Mon Jul 01 22:25:52 2019 +0000

description:
pkgtools/pkglint: update to 5.7.15

Changes since 5.7.14:

* Added a check for packages that have been removed from the file system
  but not been recorded in doc/CHANGES. This will help produce more
  accurate release statistics.

* Small refactorings, as usual.

diffstat:

 pkgtools/pkglint/Makefile                   |   4 +-
 pkgtools/pkglint/files/autofix.go           |   3 -
 pkgtools/pkglint/files/autofix_test.go      |  25 ++++++++++++++
 pkgtools/pkglint/files/linelexer.go         |   2 +-
 pkgtools/pkglint/files/mklines.go           |   2 +-
 pkgtools/pkglint/files/mkparser.go          |  26 +++++++-------
 pkgtools/pkglint/files/package.go           |   4 +-
 pkgtools/pkglint/files/package_test.go      |   4 +-
 pkgtools/pkglint/files/pkglint_test.go      |   2 +-
 pkgtools/pkglint/files/pkgsrc.go            |  49 ++++++++++++++++++++++++++--
 pkgtools/pkglint/files/pkgsrc_test.go       |  46 +++++++++++++++++++++++++-
 pkgtools/pkglint/files/shtokenizer.go       |  20 +++++-----
 pkgtools/pkglint/files/substcontext_test.go |   8 ++--
 pkgtools/pkglint/files/util.go              |   6 +++
 14 files changed, 154 insertions(+), 47 deletions(-)

diffs (truncated from 537 to 300 lines):

diff -r 90024aad8fe9 -r e3b0fe3d8b18 pkgtools/pkglint/Makefile
--- a/pkgtools/pkglint/Makefile Mon Jul 01 22:13:09 2019 +0000
+++ b/pkgtools/pkglint/Makefile Mon Jul 01 22:25:52 2019 +0000
@@ -1,6 +1,6 @@
-# $NetBSD: Makefile,v 1.586 2019/06/30 20:56:18 rillig Exp $
+# $NetBSD: Makefile,v 1.587 2019/07/01 22:25:52 rillig Exp $
 
-PKGNAME=       pkglint-5.7.14
+PKGNAME=       pkglint-5.7.15
 CATEGORIES=    pkgtools
 DISTNAME=      tools
 MASTER_SITES=  ${MASTER_SITE_GITHUB:=golang/}
diff -r 90024aad8fe9 -r e3b0fe3d8b18 pkgtools/pkglint/files/autofix.go
--- a/pkgtools/pkglint/files/autofix.go Mon Jul 01 22:13:09 2019 +0000
+++ b/pkgtools/pkglint/files/autofix.go Mon Jul 01 22:25:52 2019 +0000
@@ -52,9 +52,6 @@
 const AutofixFormat = "AutofixFormat"
 
 func NewAutofix(line *Line) *Autofix {
-       // FIXME: replacing the returned value with
-       //  &Autofix{line: line, autofixShortTerm: autofixShortTerm{anyway: true}}
-       //  makes some tests output source code without diagnostic.
        return &Autofix{line: line}
 }
 
diff -r 90024aad8fe9 -r e3b0fe3d8b18 pkgtools/pkglint/files/autofix_test.go
--- a/pkgtools/pkglint/files/autofix_test.go    Mon Jul 01 22:13:09 2019 +0000
+++ b/pkgtools/pkglint/files/autofix_test.go    Mon Jul 01 22:25:52 2019 +0000
@@ -988,6 +988,31 @@
        t.CheckOutputEmpty()
 }
 
+func (s *Suite) Test_Autofix_Apply__source_autofix_no_change(c *check.C) {
+       t := s.Init(c)
+
+       t.SetUpCommandLine("--autofix", "--source")
+       lines := t.SetUpFileLines("filename",
+               "word word word")
+
+       fix := lines.Lines[0].Autofix()
+       fix.Notef("Word should be replaced, but pkglint is not sure which one.")
+       fix.Replace("word", "replacement")
+       fix.Anyway()
+       fix.Apply()
+
+       lines.SaveAutofixChanges()
+
+       // Nothing is replaced since, as of June 2019, pkglint doesn't
+       // know which of the three "word" should be replaced.
+       //
+       // The note is not logged since fix.Anyway only applies when neither
+       // --show-autofix nor --autofix is given in the command line.
+       t.CheckOutputEmpty()
+       t.CheckFileLines("filename",
+               "word word word")
+}
+
 // Ensures that without explanations, the separator between the individual
 // diagnostics are generated.
 func (s *Suite) Test_Autofix_Apply__source_without_explain(c *check.C) {
diff -r 90024aad8fe9 -r e3b0fe3d8b18 pkgtools/pkglint/files/linelexer.go
--- a/pkgtools/pkglint/files/linelexer.go       Mon Jul 01 22:13:09 2019 +0000
+++ b/pkgtools/pkglint/files/linelexer.go       Mon Jul 01 22:25:52 2019 +0000
@@ -48,7 +48,7 @@
        }
 
        if !llex.EOF() {
-               if m := G.res.Match(llex.lines.Lines[llex.index].Text, re); m != nil {
+               if m := match(llex.lines.Lines[llex.index].Text, re); m != nil {
                        llex.index++
                        return m
                }
diff -r 90024aad8fe9 -r e3b0fe3d8b18 pkgtools/pkglint/files/mklines.go
--- a/pkgtools/pkglint/files/mklines.go Mon Jul 01 22:13:09 2019 +0000
+++ b/pkgtools/pkglint/files/mklines.go Mon Jul 01 22:25:52 2019 +0000
@@ -451,7 +451,7 @@
                                break
                        }
                        if hasSuffix(varname, ".") {
-                               if !parser.lexer.SkipRegexp(G.res.Compile(`^<\w+>`)) {
+                               if !parser.lexer.SkipRegexp(regcomp(`^<\w+>`)) {
                                        break
                                }
                                varname += "*"
diff -r 90024aad8fe9 -r e3b0fe3d8b18 pkgtools/pkglint/files/mkparser.go
--- a/pkgtools/pkglint/files/mkparser.go        Mon Jul 01 22:13:09 2019 +0000
+++ b/pkgtools/pkglint/files/mkparser.go        Mon Jul 01 22:25:52 2019 +0000
@@ -251,7 +251,7 @@
 
        case '=', 'D', 'M', 'N', 'U':
                lexer.Skip(1)
-               re := G.res.Compile(regex.Pattern(ifelseStr(closing == '}', `^([^$:\\}]|\$\$|\\.)+`, `^([^$:\\)]|\$\$|\\.)+`)))
+               re := regcomp(regex.Pattern(ifelseStr(closing == '}', `^([^$:\\}]|\$\$|\\.)+`, `^([^$:\\)]|\$\$|\\.)+`)))
                for p.VarUse() != nil || lexer.SkipRegexp(re) {
                }
                arg := lexer.Since(mark)
@@ -268,7 +268,7 @@
                }
 
        case '[':
-               if lexer.SkipRegexp(G.res.Compile(`^\[(?:[-.\d]+|#)\]`)) {
+               if lexer.SkipRegexp(regcomp(`^\[(?:[-.\d]+|#)\]`)) {
                        return lexer.Since(mark)
                }
 
@@ -283,7 +283,7 @@
 
        lexer.Reset(mark)
 
-       re := G.res.Compile(regex.Pattern(ifelseStr(closing == '}', `^([^:$}]|\$\$)+`, `^([^:$)]|\$\$)+`)))
+       re := regcomp(regex.Pattern(ifelseStr(closing == '}', `^([^:$}]|\$\$)+`, `^([^:$)]|\$\$)+`)))
        for p.VarUse() != nil || lexer.SkipRegexp(re) {
        }
        modifier := lexer.Since(mark)
@@ -309,7 +309,7 @@
 func (p *MkParser) varUseText(closing byte) string {
        lexer := p.lexer
        start := lexer.Mark()
-       re := G.res.Compile(regex.Pattern(ifelseStr(closing == '}', `^([^$:}]|\$\$)+`, `^([^$:)]|\$\$)+`)))
+       re := regcomp(regex.Pattern(ifelseStr(closing == '}', `^([^$:}]|\$\$)+`, `^([^$:)]|\$\$)+`)))
        for p.VarUse() != nil || lexer.SkipRegexp(re) {
        }
        return lexer.Since(start)
@@ -391,7 +391,7 @@
                return false
        }
 
-       re := G.res.Compile(`^([^$@\\]|\\.)+`)
+       re := regcomp(`^([^$@\\]|\\.)+`)
        for p.VarUse() != nil || lexer.SkipString("$$") || lexer.SkipRegexp(re) {
        }
 
@@ -498,11 +498,11 @@
                if lhs != nil {
                        lexer.SkipHspace()
 
-                       if m := lexer.NextRegexp(G.res.Compile(`^(<|<=|==|!=|>=|>)[\t ]*(0x[0-9A-Fa-f]+|\d+(?:\.\d+)?)`)); m != nil {
+                       if m := lexer.NextRegexp(regcomp(`^(<|<=|==|!=|>=|>)[\t ]*(0x[0-9A-Fa-f]+|\d+(?:\.\d+)?)`)); m != nil {
                                return &MkCond{CompareVarNum: &MkCondCompareVarNum{lhs, m[1], m[2]}}
                        }
 
-                       m := lexer.NextRegexp(G.res.Compile(`^(?:<|<=|==|!=|>=|>)`))
+                       m := lexer.NextRegexp(regcomp(`^(?:<|<=|==|!=|>=|>)`))
                        if m == nil {
                                return &MkCond{Var: lhs} // See devel/bmake/files/cond.c:/\* For \.if \$/
                        }
@@ -510,7 +510,7 @@
 
                        op := m[0]
                        if op == "==" || op == "!=" {
-                               if mrhs := lexer.NextRegexp(G.res.Compile(`^"([^"\$\\]*)"`)); mrhs != nil {
+                               if mrhs := lexer.NextRegexp(regcomp(`^"([^"\$\\]*)"`)); mrhs != nil {
                                        return &MkCond{CompareVarStr: &MkCondCompareVarStr{lhs, op, mrhs[1]}}
                                }
                        }
@@ -559,7 +559,7 @@
                }
 
                // See devel/bmake/files/cond.c:/^CondCvtArg
-               if m := lexer.NextRegexp(G.res.Compile(`^(?:0x[0-9A-Fa-f]+|\d+(?:\.\d+)?)`)); m != nil {
+               if m := lexer.NextRegexp(regcomp(`^(?:0x[0-9A-Fa-f]+|\d+(?:\.\d+)?)`)); m != nil {
                        return &MkCond{Num: m[0]}
                }
        }
@@ -652,8 +652,8 @@
 
        for {
                if p.VarUse() != nil ||
-                       lexer.SkipRegexp(G.res.Compile(`^[\w.*+,{}]+`)) ||
-                       lexer.SkipRegexp(G.res.Compile(`^\[[\w-]+\]`)) {
+                       lexer.SkipRegexp(regcomp(`^[\w.*+,{}]+`)) ||
+                       lexer.SkipRegexp(regcomp(`^\[[\w-]+\]`)) {
                        continue
                }
 
@@ -696,7 +696,7 @@
                        return lexer.Since(mark)
                }
 
-               m := lexer.NextRegexp(G.res.Compile(`^\d[\w.]*`))
+               m := lexer.NextRegexp(regcomp(`^\d[\w.]*`))
                if m != nil {
                        return m[0]
                }
@@ -749,7 +749,7 @@
        if lexer.SkipByte('-') && lexer.Rest() != "" {
                versionMark := lexer.Mark()
 
-               for p.VarUse() != nil || lexer.SkipRegexp(G.res.Compile(`^[\w\[\]*_.\-]+`)) {
+               for p.VarUse() != nil || lexer.SkipRegexp(regcomp(`^[\w\[\]*_.\-]+`)) {
                }
 
                if !lexer.SkipString("{,nb*}") {
diff -r 90024aad8fe9 -r e3b0fe3d8b18 pkgtools/pkglint/files/package.go
--- a/pkgtools/pkglint/files/package.go Mon Jul 01 22:13:09 2019 +0000
+++ b/pkgtools/pkglint/files/package.go Mon Jul 01 22:25:52 2019 +0000
@@ -1214,8 +1214,8 @@
 }
 
 func (pkg *Package) checkFreeze(filename string) {
-       freezeStart := G.Pkgsrc.FreezeStart
-       if freezeStart == "" {
+       freezeStart := G.Pkgsrc.LastFreezeStart
+       if freezeStart == "" || G.Pkgsrc.LastFreezeEnd != "" {
                return
        }
 
diff -r 90024aad8fe9 -r e3b0fe3d8b18 pkgtools/pkglint/files/package_test.go
--- a/pkgtools/pkglint/files/package_test.go    Mon Jul 01 22:13:09 2019 +0000
+++ b/pkgtools/pkglint/files/package_test.go    Mon Jul 01 22:25:52 2019 +0000
@@ -962,7 +962,7 @@
                "ERROR: gnu-style.mk:1: Unknown Makefile line format: \"ifeq ($(CC),gcc)\".",
                "ERROR: gnu-style.mk:3: Unknown Makefile line format: \"else\".",
                "ERROR: gnu-style.mk:5: Unknown Makefile line format: \"endif\".",
-               "ERROR: gnu-style.mk:1: Expected \"# $NetBSD: package_test.go,v 1.48 2019/06/30 20:56:19 rillig Exp $\".",
+               "ERROR: gnu-style.mk:1: Expected \""+MkCvsID+"\".",
                "WARN: gnu-style.mk:2: IS_GCC is defined but not used.",
 
                // There is no warning about files/gnu-style.mk since pkglint
@@ -983,7 +983,7 @@
                "ERROR: ../../category/other/gnu-style.mk:1: Unknown Makefile line format: \"ifeq ($(CC),gcc)\".",
                "ERROR: ../../category/other/gnu-style.mk:3: Unknown Makefile line format: \"else\".",
                "ERROR: ../../category/other/gnu-style.mk:5: Unknown Makefile line format: \"endif\".",
-               "ERROR: ../../category/other/gnu-style.mk:1: Expected \"# $NetBSD: package_test.go,v 1.48 2019/06/30 20:56:19 rillig Exp $\".",
+               "ERROR: ../../category/other/gnu-style.mk:1: Expected \""+MkCvsID+"\".",
                "WARN: ../../category/other/gnu-style.mk:2: IS_GCC is defined but not used.",
 
                "ERROR: patches/patch-Makefile.mk: Contains no patch.",
diff -r 90024aad8fe9 -r e3b0fe3d8b18 pkgtools/pkglint/files/pkglint_test.go
--- a/pkgtools/pkglint/files/pkglint_test.go    Mon Jul 01 22:13:09 2019 +0000
+++ b/pkgtools/pkglint/files/pkglint_test.go    Mon Jul 01 22:25:52 2019 +0000
@@ -246,7 +246,7 @@
        exitcode := t.Main("-Wall", "--autofix", t.File("filename.mk"))
 
        t.CheckOutputLines(
-               "AUTOFIX: ~/filename.mk:1: Inserting a line \"# $NetBSD: pkglint_test.go,v 1.44 2019/06/30 20:56:19 rillig Exp $\" before this line.")
+               "AUTOFIX: ~/filename.mk:1: Inserting a line \"" + MkCvsID + "\" before this line.")
        t.Check(exitcode, equals, 0)
 }
 
diff -r 90024aad8fe9 -r e3b0fe3d8b18 pkgtools/pkglint/files/pkgsrc.go
--- a/pkgtools/pkglint/files/pkgsrc.go  Mon Jul 01 22:13:09 2019 +0000
+++ b/pkgtools/pkglint/files/pkgsrc.go  Mon Jul 01 22:25:52 2019 +0000
@@ -36,8 +36,9 @@
        suggestedUpdates    []SuggestedUpdate
        suggestedWipUpdates []SuggestedUpdate
 
-       LastChange  map[string]*Change
-       FreezeStart string // e.g. "2018-01-01", or ""
+       LastChange      map[string]*Change
+       LastFreezeStart string // e.g. "2018-01-01", or ""
+       LastFreezeEnd   string // e.g. "2018-01-01", or ""
 
        listVersions map[string][]string // See Pkgsrc.ListVersions
 
@@ -64,6 +65,7 @@
                nil,
                make(map[string]*Change),
                "",
+               "",
                make(map[string][]string),
                NewScope(),
                make(map[string]string),
@@ -517,11 +519,14 @@
                if hasPrefix(line.Text, "\tmk/") {
                        infra = true
                        if hasPrefix(line.Text, "\tmk/bsd.pkg.mk: started freeze for") {
-                               if m, freezeDate := match1(line.Text, `(\d\d\d\d-\d\d-\d\d)\]$`); m {
-                                       src.FreezeStart = freezeDate
+                               if m, date := match1(line.Text, `(\d\d\d\d-\d\d-\d\d)\]$`); m {
+                                       src.LastFreezeStart = date
+                                       src.LastFreezeEnd = ""
                                }
                        } else if hasPrefix(line.Text, "\tmk/bsd.pkg.mk: freeze ended for") {
-                               src.FreezeStart = ""
+                               if m, date := match1(line.Text, `(\d\d\d\d-\d\d-\d\d)\]$`); m {
+                                       src.LastFreezeEnd = date
+                               }
                        }
                }
                if infra {
@@ -603,6 +608,40 @@
                        }
                }
        }
+
+       src.checkRemovedAfterLastFreeze()
+}
+
+func (src *Pkgsrc) checkRemovedAfterLastFreeze() {
+       if src.LastFreezeStart == "" || G.Wip {
+               return
+       }
+
+       var wrong []*Change
+       for pkgpath, change := range src.LastChange {
+               switch change.Action {
+               case Added, Updated, Downgraded:
+                       if !dirExists(src.File(pkgpath)) {
+                               wrong = append(wrong, change)



Home | Main Index | Thread Index | Old Index