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 19.3.2



details:   https://anonhg.NetBSD.org/pkgsrc/rev/4d1f57c7eb5c
branches:  trunk
changeset: 403374:4d1f57c7eb5c
user:      rillig <rillig%pkgsrc.org@localhost>
date:      Sat Oct 26 09:51:47 2019 +0000

description:
pkgtools/pkglint: update to 19.3.2

Changes since 19.3.1:

* Pkglint no longer warns about a missing :Q modifier if there is also
  a :D modifier, since the latter hides the original variable value
  from the expression value.

* Variable names like .CURDIR are now allowed in the _VARGROUPS section.

* In dependency lines like "${_COOKIE.extract}:", pkglint no longer
  warns about the unknown target. No matter whether this is a file name
  or even a list of other targets, there's no chance for a typo here.

* If some dependencies are included conditionally, and the package
  Makefile and buildlink3.mk disagree, and the conditions depend on
  PKG_OPTIONS, pkglint outputs a helpful explanation.

* The check for including builtin.mk directly can be disabled by giving
  a reason in a comment at the end of the line.

diffstat:

 pkgtools/pkglint/Makefile                    |     5 +-
 pkgtools/pkglint/PLIST                       |     4 +-
 pkgtools/pkglint/files/buildlink3_test.go    |    31 +-
 pkgtools/pkglint/files/category.go           |     2 +-
 pkgtools/pkglint/files/check_test.go         |     2 +-
 pkgtools/pkglint/files/files_test.go         |     4 +-
 pkgtools/pkglint/files/mkline.go             |   485 +----------
 pkgtools/pkglint/files/mkline_test.go        |  1169 +------------------------
 pkgtools/pkglint/files/mklinechecker.go      |    66 +-
 pkgtools/pkglint/files/mklinechecker_test.go |    27 +-
 pkgtools/pkglint/files/mklineparser.go       |   450 ++++++++++
 pkgtools/pkglint/files/mklineparser_test.go  |  1147 +++++++++++++++++++++++++
 pkgtools/pkglint/files/mklines.go            |     4 +-
 pkgtools/pkglint/files/mkparser_test.go      |   180 +--
 pkgtools/pkglint/files/mktokenslexer_test.go |   104 +-
 pkgtools/pkglint/files/mktypes_test.go       |    29 +-
 pkgtools/pkglint/files/package.go            |    14 +-
 pkgtools/pkglint/files/shtokenizer_test.go   |     2 +-
 pkgtools/pkglint/files/substcontext.go       |     2 +-
 pkgtools/pkglint/files/toplevel.go           |     3 +-
 pkgtools/pkglint/files/util.go               |     9 +
 pkgtools/pkglint/files/varalignblock.go      |     2 +-
 pkgtools/pkglint/files/vargroups_test.go     |     9 +-
 pkgtools/pkglint/files/vartypecheck.go       |     4 +-
 pkgtools/pkglint/files/vartypecheck_test.go  |     5 +-
 25 files changed, 1993 insertions(+), 1766 deletions(-)

diffs (truncated from 4701 to 300 lines):

diff -r 3ef286d188ab -r 4d1f57c7eb5c pkgtools/pkglint/Makefile
--- a/pkgtools/pkglint/Makefile Sat Oct 26 07:27:18 2019 +0000
+++ b/pkgtools/pkglint/Makefile Sat Oct 26 09:51:47 2019 +0000
@@ -1,7 +1,6 @@
-# $NetBSD: Makefile,v 1.601 2019/10/18 14:58:55 bsiegert Exp $
+# $NetBSD: Makefile,v 1.602 2019/10/26 09:51:47 rillig Exp $
 
-PKGNAME=       pkglint-19.3.1
-PKGREVISION=   1
+PKGNAME=       pkglint-19.3.2
 CATEGORIES=    pkgtools
 DISTNAME=      tools
 MASTER_SITES=  ${MASTER_SITE_GITHUB:=golang/}
diff -r 3ef286d188ab -r 4d1f57c7eb5c pkgtools/pkglint/PLIST
--- a/pkgtools/pkglint/PLIST    Sat Oct 26 07:27:18 2019 +0000
+++ b/pkgtools/pkglint/PLIST    Sat Oct 26 09:51:47 2019 +0000
@@ -1,4 +1,4 @@
-@comment $NetBSD: PLIST,v 1.14 2019/09/08 22:47:47 rillig Exp $
+@comment $NetBSD: PLIST,v 1.15 2019/10/26 09:51:47 rillig Exp $
 bin/pkglint
 gopkg/pkg/${GO_PLATFORM}/netbsd.org/pkglint.a
 gopkg/pkg/${GO_PLATFORM}/netbsd.org/pkglint/getopt.a
@@ -52,6 +52,8 @@
 gopkg/src/netbsd.org/pkglint/mkline_test.go
 gopkg/src/netbsd.org/pkglint/mklinechecker.go
 gopkg/src/netbsd.org/pkglint/mklinechecker_test.go
+gopkg/src/netbsd.org/pkglint/mklineparser.go
+gopkg/src/netbsd.org/pkglint/mklineparser_test.go
 gopkg/src/netbsd.org/pkglint/mklines.go
 gopkg/src/netbsd.org/pkglint/mklines_test.go
 gopkg/src/netbsd.org/pkglint/mkparser.go
diff -r 3ef286d188ab -r 4d1f57c7eb5c pkgtools/pkglint/files/buildlink3_test.go
--- a/pkgtools/pkglint/files/buildlink3_test.go Sat Oct 26 07:27:18 2019 +0000
+++ b/pkgtools/pkglint/files/buildlink3_test.go Sat Oct 26 09:51:47 2019 +0000
@@ -196,7 +196,7 @@
        t.CheckOutputEmpty()
 }
 
-func (s *Suite) Test_CheckLinesBuildlink3Mk__name_mismatch__version(c *check.C) {
+func (s *Suite) Test_CheckLinesBuildlink3Mk__name_mismatch__version_ok(c *check.C) {
        t := s.Init(c)
 
        t.SetUpPackage("editors/emacs22",
@@ -229,6 +229,35 @@
        t.CheckOutputEmpty()
 }
 
+func (s *Suite) Test_CheckLinesBuildlink3Mk__name_mismatch__version_bad(c *check.C) {
+       t := s.Init(c)
+
+       t.SetUpPackage("editors/emacs-client",
+               "PKGNAME=\temacs-client-22.0")
+       t.CreateFileLines("editors/emacs-client/buildlink3.mk",
+               MkCvsID,
+               "",
+               "BUILDLINK_TREE+=\temacs",
+               "",
+               ".if !defined(EMACS_BUILDLINK3_MK)",
+               "EMACS_BUILDLINK3_MK:=",
+               "",
+               "BUILDLINK_API_DEPENDS.emacs+=\temacs-client>=1.0",
+               "BUILDLINK_ABI_DEPENDS.emacs+=\temacs-client>=1.0",
+               "",
+               ".endif\t# EMACS_BUILDLINK3_MK",
+               "",
+               "BUILDLINK_TREE+=\t-emacs")
+       t.FinishSetUp()
+
+       G.Check(t.File("editors/emacs-client"))
+
+       t.CheckOutputLines(
+               "ERROR: ~/editors/emacs-client/buildlink3.mk:3: " +
+                       "Package name mismatch between \"emacs\" in this file " +
+                       "and \"emacs-client\" from Makefile:4.")
+}
+
 func (s *Suite) Test_CheckLinesBuildlink3Mk__name_mismatch_multiple_inclusion(c *check.C) {
        t := s.Init(c)
 
diff -r 3ef286d188ab -r 4d1f57c7eb5c pkgtools/pkglint/files/category.go
--- a/pkgtools/pkglint/files/category.go        Sat Oct 26 07:27:18 2019 +0000
+++ b/pkgtools/pkglint/files/category.go        Sat Oct 26 09:51:47 2019 +0000
@@ -68,7 +68,7 @@
                        mlex.Skip()
 
                        name := mkline.Value()
-                       if mkline.IsCommentedVarassign() && mkline.VarassignComment() == "" {
+                       if mkline.IsCommentedVarassign() && !mkline.HasComment() {
                                mkline.Warnf("%q commented out without giving a reason.", name)
                        }
 
diff -r 3ef286d188ab -r 4d1f57c7eb5c pkgtools/pkglint/files/check_test.go
--- a/pkgtools/pkglint/files/check_test.go      Sat Oct 26 07:27:18 2019 +0000
+++ b/pkgtools/pkglint/files/check_test.go      Sat Oct 26 09:51:47 2019 +0000
@@ -852,7 +852,7 @@
                        basename == "mk.conf",
                "filename %q must be realistic, otherwise the variable permissions are wrong", filename)
 
-       return MkLineParser{}.Parse(t.NewLine(filename, lineno, text))
+       return NewMkLineParser().Parse(t.NewLine(filename, lineno, text))
 }
 
 func (t *Tester) NewShellLineChecker(text string) *ShellLineChecker {
diff -r 3ef286d188ab -r 4d1f57c7eb5c pkgtools/pkglint/files/files_test.go
--- a/pkgtools/pkglint/files/files_test.go      Sat Oct 26 07:27:18 2019 +0000
+++ b/pkgtools/pkglint/files/files_test.go      Sat Oct 26 09:51:47 2019 +0000
@@ -105,7 +105,7 @@
 func (s *Suite) Test_nextLogicalLine__commented_multi(c *check.C) {
        t := s.Init(c)
 
-       mklines := t.SetUpFileMkLines("filename.mk",
+       mklines := t.NewMkLines("filename.mk",
                "#COMMENTED= \\",
                "#\tcontinuation 1 \\",
                "#\tcontinuation 2")
@@ -113,7 +113,7 @@
 
        // The leading comments are stripped from the continuation lines as well.
        t.CheckEquals(mkline.Value(), "continuation 1 \tcontinuation 2")
-       t.CheckEquals(mkline.VarassignComment(), "")
+       t.CheckEquals(mkline.HasComment(), false)
 }
 
 func (s *Suite) Test_convertToLogicalLines__missing_newline_at_eof(c *check.C) {
diff -r 3ef286d188ab -r 4d1f57c7eb5c pkgtools/pkglint/files/mkline.go
--- a/pkgtools/pkglint/files/mkline.go  Sat Oct 26 07:27:18 2019 +0000
+++ b/pkgtools/pkglint/files/mkline.go  Sat Oct 26 09:51:47 2019 +0000
@@ -15,6 +15,8 @@
 type MkLine struct {
        *Line
 
+       splitResult mkLineSplitResult
+
        // One of the following mkLine* types.
        //
        // For the larger of these types, a pointer is used instead of a direct
@@ -34,8 +36,6 @@
        valueMk           []*MkToken // The value, sent through splitIntoMkWords
        valueMkRest       string     // nonempty in case of parse errors
        fields            []string   // The value, space-separated according to shell quoting rules
-       spaceAfterValue   string
-       comment           string
 }
 
 type mkLineShell struct {
@@ -69,164 +69,28 @@
        sources string
 }
 
-type MkLineParser struct{}
-
-// Parse parses the text of a Makefile line to see what kind of line
-// it is: variable assignment, include, comment, etc.
-//
-// See devel/bmake/parse.c:/^Parse_File/
-func (p MkLineParser) Parse(line *Line) *MkLine {
-       text := line.Text
-
-       // XXX: This check should be moved somewhere else. NewMkLine should only be concerned with parsing.
-       if hasPrefix(text, " ") && line.Basename != "bsd.buildlink3.mk" {
-               line.Warnf("Makefile lines should not start with space characters.")
-               line.Explain(
-                       "If this line should be a shell command connected to a target, use a tab character for indentation.",
-                       "Otherwise remove the leading whitespace.")
-       }
-
-       // Check for shell commands first because these cannot have comments
-       // at the end of the line.
-       if hasPrefix(text, "\t") {
-               lex := textproc.NewLexer(text)
-               for lex.SkipByte('\t') {
-               }
-
-               // Just for the side effects of the warnings.
-               _ = p.split(line, lex.Rest())
-
-               return p.parseShellcmd(line)
-       }
-
-       data := p.split(line, text)
-
-       if mkline := p.parseVarassign(line); mkline != nil {
-               return mkline
-       }
-       if mkline := p.parseCommentOrEmpty(line); mkline != nil {
-               return mkline
-       }
-       if mkline := p.parseDirective(line, data); mkline != nil {
-               return mkline
-       }
-       if mkline := p.parseInclude(line); mkline != nil {
-               return mkline
-       }
-       if mkline := p.parseSysinclude(line); mkline != nil {
-               return mkline
-       }
-       if mkline := p.parseDependency(line); mkline != nil {
-               return mkline
-       }
-       if mkline := p.parseMergeConflict(line); mkline != nil {
-               return mkline
-       }
-
-       // The %q is deliberate here since it shows possible strange characters.
-       line.Errorf("Unknown Makefile line format: %q.", text)
-       return &MkLine{line, nil}
-}
-
-func (p MkLineParser) parseVarassign(line *Line) *MkLine {
-       m, a := p.MatchVarassign(line, line.Text)
-       if !m {
-               return nil
-       }
-
-       if a.spaceAfterVarname != "" {
-               varname := a.varname
-               op := a.op
-               switch {
-               case hasSuffix(varname, "+") && (op == opAssign || op == opAssignAppend):
-                       break
-               case matches(varname, `^[a-z]`) && op == opAssignEval:
-                       break
-               default:
-                       fix := line.Autofix()
-                       fix.Notef("Unnecessary space after variable name %q.", varname)
-                       fix.Replace(varname+a.spaceAfterVarname+op.String(), varname+op.String())
-                       fix.Apply()
-               }
-       }
-
-       if a.comment != "" && a.value != "" && a.spaceAfterValue == "" {
-               line.Warnf("The # character starts a Makefile comment.")
-               line.Explain(
-                       "In a variable assignment, an unescaped # starts a comment that",
-                       "continues until the end of the line.",
-                       "To escape the #, write \\#.",
-                       "",
-                       "If this # character intentionally starts a comment,",
-                       "it should be preceded by a space in order to make it more visible.")
-       }
-
-       return &MkLine{line, a}
-}
-
-func (p MkLineParser) parseShellcmd(line *Line) *MkLine {
-       return &MkLine{line, mkLineShell{line.Text[1:]}}
-}
-
-func (p MkLineParser) parseCommentOrEmpty(line *Line) *MkLine {
-       trimmedText := trimHspace(line.Text)
-
-       if strings.HasPrefix(trimmedText, "#") {
-               return &MkLine{line, mkLineComment{}}
-       }
-
-       if trimmedText == "" {
-               return &MkLine{line, mkLineEmpty{}}
-       }
-
-       return nil
-}
-
-func (p MkLineParser) parseInclude(line *Line) *MkLine {
-       m, indent, directive, includedFile := MatchMkInclude(line.Text)
-       if !m {
-               return nil
-       }
-
-       return &MkLine{line, &mkLineInclude{directive == "include", false, indent, includedFile, nil}}
-}
-
-func (p MkLineParser) parseSysinclude(line *Line) *MkLine {
-       m, indent, directive, includedFile := match3(line.Text, `^\.([\t ]*)(s?include)[\t ]+<([^>]+)>[\t ]*(?:#.*)?$`)
-       if !m {
-               return nil
-       }
-
-       return &MkLine{line, &mkLineInclude{directive == "include", true, indent, includedFile, nil}}
-}
-
-func (p MkLineParser) parseDependency(line *Line) *MkLine {
-       // XXX: Replace this regular expression with proper parsing.
-       // There might be a ${VAR:M*.c} in these variables, which the below regular expression cannot handle.
-       m, targets, whitespace, sources := match3(line.Text, `^([^\t :]+(?:[\t ]*[^\t :]+)*)([\t ]*):[\t ]*([^#]*?)(?:[\t ]*#.*)?$`)
-       if !m {
-               return nil
-       }
-
-       if whitespace != "" {
-               line.Notef("Space before colon in dependency line.")
-       }
-       return &MkLine{line, mkLineDependency{targets, sources}}
-}
-
-func (p MkLineParser) parseMergeConflict(line *Line) *MkLine {
-       if !matches(line.Text, `^(<<<<<<<|=======|>>>>>>>)`) {
-               return nil
-       }
-
-       return &MkLine{line, nil}



Home | Main Index | Thread Index | Old Index