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



details:   https://anonhg.NetBSD.org/pkgsrc/rev/93a56374ad37
branches:  trunk
changeset: 415688:93a56374ad37
user:      rillig <rillig%pkgsrc.org@localhost>
date:      Fri Oct 11 23:30:02 2019 +0000

description:
pkgtools/pkglint: update to 19.3.1

Changes since 19.3.0:

* In buildlink3.mk files, the package identifier doesn't have to match
  the PKGBASE from the package Makefile exactly. The PKGBASE may have a
  leading "lib" (for libiconv and libgettext), as well as a trailing
  number (for emacs20 and netatalk22).

* GITHUB_RELEASE is added to the variables that should appear in a fixed
  order in the package Makefile.

* In the MASTER_SITE URLs, the transport protocol is irrelevant for
  matching direct URLs to the predefined MASTER_SITE_* variables.

diffstat:

 pkgtools/pkglint/Makefile                   |    4 +-
 pkgtools/pkglint/files/buildlink3.go        |   29 ++++-
 pkgtools/pkglint/files/buildlink3_test.go   |   65 +++++++++++++
 pkgtools/pkglint/files/mkshparser_test.go   |  134 ++++++++++++++++++++++++---
 pkgtools/pkglint/files/package.go           |    2 +
 pkgtools/pkglint/files/pkgsrc.go            |    4 +-
 pkgtools/pkglint/files/pkgsrc_test.go       |   10 +-
 pkgtools/pkglint/files/shell.y              |    2 +-
 pkgtools/pkglint/files/vartypecheck.go      |   28 +++--
 pkgtools/pkglint/files/vartypecheck_test.go |   24 +++++
 10 files changed, 255 insertions(+), 47 deletions(-)

diffs (truncated from 495 to 300 lines):

diff -r 6b2e6fb04d70 -r 93a56374ad37 pkgtools/pkglint/Makefile
--- a/pkgtools/pkglint/Makefile Fri Oct 11 20:02:10 2019 +0000
+++ b/pkgtools/pkglint/Makefile Fri Oct 11 23:30:02 2019 +0000
@@ -1,6 +1,6 @@
-# $NetBSD: Makefile,v 1.599 2019/10/01 21:37:59 rillig Exp $
+# $NetBSD: Makefile,v 1.600 2019/10/11 23:30:02 rillig Exp $
 
-PKGNAME=       pkglint-19.3.0
+PKGNAME=       pkglint-19.3.1
 CATEGORIES=    pkgtools
 DISTNAME=      tools
 MASTER_SITES=  ${MASTER_SITE_GITHUB:=golang/}
diff -r 6b2e6fb04d70 -r 93a56374ad37 pkgtools/pkglint/files/buildlink3.go
--- a/pkgtools/pkglint/files/buildlink3.go      Fri Oct 11 20:02:10 2019 +0000
+++ b/pkgtools/pkglint/files/buildlink3.go      Fri Oct 11 23:30:02 2019 +0000
@@ -119,8 +119,6 @@
 // introduces the uppercase package identifier.
 func (ck *Buildlink3Checker) checkSecondParagraph(mlex *MkLinesLexer) bool {
        pkgbase := ck.pkgbase
-       pkgbaseLine := ck.pkgbaseLine
-
        m := mlex.NextRegexp(`^\.if !defined\(([^\t ]+)_BUILDLINK3_MK\)$`)
        if m == nil {
                return false
@@ -136,16 +134,29 @@
        ucPkgbase := strings.ToUpper(strings.Replace(pkgbase, "-", "_", -1))
        if ucPkgbase != pkgupper && !containsVarRef(pkgbase) {
                pkgupperLine.Errorf("Package name mismatch between multiple-inclusion guard %q (expected %q) and package name %q (from %s).",
-                       pkgupper, ucPkgbase, pkgbase, pkgupperLine.RefTo(pkgbaseLine))
+                       pkgupper, ucPkgbase, pkgbase, pkgupperLine.RefTo(ck.pkgbaseLine))
        }
-       if G.Pkg != nil {
-               if mkbase := G.Pkg.EffectivePkgbase; mkbase != "" && mkbase != pkgbase {
-                       pkgbaseLine.Errorf("Package name mismatch between %q in this file and %q from %s.",
-                               pkgbase, mkbase, pkgbaseLine.RefTo(G.Pkg.EffectivePkgnameLine))
-               }
+       ck.checkPkgbaseMismatch(pkgbase)
+
+       return true
+}
+
+func (ck *Buildlink3Checker) checkPkgbaseMismatch(bl3base string) {
+       if G.Pkg == nil {
+               return
        }
 
-       return true
+       mkbase := G.Pkg.EffectivePkgbase
+       if mkbase == "" || mkbase == bl3base || strings.TrimPrefix(mkbase, "lib") == bl3base {
+               return
+       }
+
+       if hasPrefix(mkbase, bl3base) && matches(mkbase[len(bl3base):], `^\d+$`) {
+               return
+       }
+
+       ck.pkgbaseLine.Errorf("Package name mismatch between %q in this file and %q from %s.",
+               bl3base, mkbase, ck.pkgbaseLine.RefTo(G.Pkg.EffectivePkgnameLine))
 }
 
 // Third paragraph: Package information.
diff -r 6b2e6fb04d70 -r 93a56374ad37 pkgtools/pkglint/files/buildlink3_test.go
--- a/pkgtools/pkglint/files/buildlink3_test.go Fri Oct 11 20:02:10 2019 +0000
+++ b/pkgtools/pkglint/files/buildlink3_test.go Fri Oct 11 23:30:02 2019 +0000
@@ -164,6 +164,71 @@
        t.CheckOutputEmpty()
 }
 
+func (s *Suite) Test_CheckLinesBuildlink3Mk__name_mismatch__lib(c *check.C) {
+       t := s.Init(c)
+
+       t.SetUpPackage("converters/libiconv")
+       t.CreateFileLines("converters/libiconv/buildlink3.mk",
+               MkCvsID,
+               "",
+               "BUILDLINK_TREE+=\ticonv",
+               "",
+               ".if !defined(ICONV_BUILDLINK3_MK)",
+               "ICONV_BUILDLINK3_MK:=",
+               "",
+               "BUILDLINK_API_DEPENDS.iconv+=\tlibiconv>=1.0",
+               "BUILDLINK_ABI_DEPENDS.iconv+=\tlibiconv>=1.0",
+               "",
+               ".endif\t# ICONV_BUILDLINK3_MK",
+               "",
+               "BUILDLINK_TREE+=\t-iconv")
+       t.FinishSetUp()
+
+       G.Check(t.File("converters/libiconv"))
+
+       // Up to 2019-10-12, pkglint complained about a mismatch
+       // between the package name from buildlink3.mk (iconv) and the
+       // one from the package Makefile (libiconv).
+       //
+       // This mismatch is not important enough to warrant a global
+       // renaming of the buildlink3 identifier, therefore the warning
+       // is suppressed in cases like this.
+       t.CheckOutputEmpty()
+}
+
+func (s *Suite) Test_CheckLinesBuildlink3Mk__name_mismatch__version(c *check.C) {
+       t := s.Init(c)
+
+       t.SetUpPackage("editors/emacs22",
+               "PKGNAME=\temacs22-22.0")
+       t.CreateFileLines("editors/emacs22/buildlink3.mk",
+               MkCvsID,
+               "",
+               "BUILDLINK_TREE+=\temacs",
+               "",
+               ".if !defined(EMACS_BUILDLINK3_MK)",
+               "EMACS_BUILDLINK3_MK:=",
+               "",
+               "BUILDLINK_API_DEPENDS.emacs+=\temacs22>=1.0",
+               "BUILDLINK_ABI_DEPENDS.emacs+=\temacs22>=1.0",
+               "",
+               ".endif\t# EMACS_BUILDLINK3_MK",
+               "",
+               "BUILDLINK_TREE+=\t-emacs")
+       t.FinishSetUp()
+
+       G.Check(t.File("editors/emacs22"))
+
+       // Up to 2019-10-12, pkglint complained about a mismatch
+       // between the package name from buildlink3.mk (emacs) and the
+       // one from the package Makefile (emacs22).
+       //
+       // This mismatch is not important enough to warrant a global
+       // renaming of the buildlink3 identifier, therefore the warning
+       // is suppressed in cases like this.
+       t.CheckOutputEmpty()
+}
+
 func (s *Suite) Test_CheckLinesBuildlink3Mk__name_mismatch_multiple_inclusion(c *check.C) {
        t := s.Init(c)
 
diff -r 6b2e6fb04d70 -r 93a56374ad37 pkgtools/pkglint/files/mkshparser_test.go
--- a/pkgtools/pkglint/files/mkshparser_test.go Fri Oct 11 20:02:10 2019 +0000
+++ b/pkgtools/pkglint/files/mkshparser_test.go Fri Oct 11 23:30:02 2019 +0000
@@ -331,12 +331,24 @@
                        b.Words("a", "b", "c"),
                        b.List().AddCommand(b.SimpleCommand("echo", "$var")).AddSemicolon())))
 
+       s.test("for var \n in ; do echo $var ; done",
+               b.List().AddCommand(b.For(
+                       "var",
+                       nil,
+                       b.List().AddCommand(b.SimpleCommand("echo", "$var")).AddSemicolon())))
+
        s.test("for var in in esac ; do echo $var ; done",
                b.List().AddCommand(b.For(
                        "var",
                        b.Words("in", "esac"),
                        b.List().AddCommand(b.SimpleCommand("echo", "$var")).AddSemicolon())))
 
+       s.test("for var in \n do : ; done",
+               b.List().AddCommand(b.For(
+                       "var",
+                       nil,
+                       b.List().AddCommand(b.SimpleCommand(":")).AddSemicolon())))
+
        // No semicolon necessary between the two "done".
        s.test("for i in 1; do for j in 1; do echo $$i$$j; done done",
                b.List().AddCommand(b.For(
@@ -385,6 +397,20 @@
                                b.Words("pattern"),
                                b.List().AddCommand(b.SimpleCommand("case-item-action")), sepNone))))
 
+       s.test("case selector in pattern) \n case-item-action ; esac",
+               b.List().AddCommand(b.Case(
+                       b.Token("selector"),
+                       b.CaseItem(
+                               b.Words("pattern"),
+                               b.List().AddCommand(b.SimpleCommand("case-item-action")), sepSemicolon))))
+
+       s.test("case selector in pattern) action \n esac",
+               b.List().AddCommand(b.Case(
+                       b.Token("selector"),
+                       b.CaseItem(
+                               b.Words("pattern"),
+                               b.List().AddCommand(b.SimpleCommand("action")), sepNone))))
+
        s.test("case $$expr in (if|then|else) ;; esac",
                b.List().AddCommand(b.Case(
                        b.Token("$$expr"),
@@ -433,6 +459,14 @@
                        b.List().AddCommand(b.If(
                                b.List().AddCommand(b.SimpleCommand("cond2")).AddSemicolon(),
                                b.List().AddCommand(b.SimpleCommand("action")).AddSemicolon())))))
+
+       s.test("if cond1; then action1; elif cond2; then action2; else action3; fi",
+               b.List().AddCommand(b.If(
+                       b.List().AddCommand(b.SimpleCommand("cond1")).AddSemicolon(),
+                       b.List().AddCommand(b.SimpleCommand("action1")).AddSemicolon(),
+                       b.List().AddCommand(b.SimpleCommand("cond2")).AddSemicolon(),
+                       b.List().AddCommand(b.SimpleCommand("action2")).AddSemicolon(),
+                       b.List().AddCommand(b.SimpleCommand("action3")).AddSemicolon())))
 }
 
 func (s *ShSuite) Test_ShellParser__while_clause(c *check.C) {
@@ -526,7 +560,23 @@
        s.test("echo >> ${PLIST_SRC}",
                b.List().AddCommand(b.SimpleCommand("echo", ">>${PLIST_SRC}")))
 
-       s.test("echo 1>output 2>>append 3>|clobber 4>&5 6<input >>append",
+       s.test("echo 1>output 2>>append 3>|clobber 4>&5 6<input >>append <&input <>diamond <<-here",
+               b.List().AddCommand(&MkShCommand{Simple: &MkShSimpleCommand{
+                       Assignments: nil,
+                       Name:        b.Token("echo"),
+                       Args:        nil,
+                       Redirections: []*MkShRedirection{
+                               {1, ">", b.Token("output")},
+                               {2, ">>", b.Token("append")},
+                               {3, ">|", b.Token("clobber")},
+                               {4, ">&", b.Token("5")},
+                               {6, "<", b.Token("input")},
+                               {-1, ">>", b.Token("append")},
+                               {-1, "<&", b.Token("input")},
+                               {-1, "<>", b.Token("diamond")},
+                               {-1, "<<-", b.Token("here")}}}}))
+
+       s.test("echo 1> output 2>> append 3>| clobber 4>& 5 6< input >> append <& input <> diamond <<- here",
                b.List().AddCommand(&MkShCommand{Simple: &MkShSimpleCommand{
                        Assignments: nil,
                        Name:        b.Token("echo"),
@@ -537,20 +587,10 @@
                                {3, ">|", b.Token("clobber")},
                                {4, ">&", b.Token("5")},
                                {6, "<", b.Token("input")},
-                               {-1, ">>", b.Token("append")}}}}))
-
-       s.test("echo 1> output 2>> append 3>| clobber 4>& 5 6< input >> append",
-               b.List().AddCommand(&MkShCommand{Simple: &MkShSimpleCommand{
-                       Assignments: nil,
-                       Name:        b.Token("echo"),
-                       Args:        nil,
-                       Redirections: []*MkShRedirection{
-                               {1, ">", b.Token("output")},
-                               {2, ">>", b.Token("append")},
-                               {3, ">|", b.Token("clobber")},
-                               {4, ">&", b.Token("5")},
-                               {6, "<", b.Token("input")},
-                               {-1, ">>", b.Token("append")}}}}))
+                               {-1, ">>", b.Token("append")},
+                               {-1, "<&", b.Token("input")},
+                               {-1, "<>", b.Token("diamond")},
+                               {-1, "<<-", b.Token("here")}}}}))
 
        s.test("${MAKE} print-summary-data  2>&1 > /dev/stderr",
                b.List().AddCommand(&MkShCommand{Simple: &MkShSimpleCommand{
@@ -560,11 +600,60 @@
                        Redirections: []*MkShRedirection{
                                {2, ">&", b.Token("1")},
                                {-1, ">", b.Token("/dev/stderr")}}}}))
+
+       s.test("1> output command",
+               b.List().AddCommand(&MkShCommand{Simple: &MkShSimpleCommand{
+                       Name: b.Token("command"),
+                       Redirections: []*MkShRedirection{
+                               {1, ">", b.Token("output")}}}}))
+
+       s.test("ENV=value 1> output command",
+               b.List().AddCommand(&MkShCommand{Simple: &MkShSimpleCommand{
+                       Assignments: []*ShToken{b.Token("ENV=value")},
+                       Name:        b.Token("command"),
+                       Redirections: []*MkShRedirection{
+                               {1, ">", b.Token("output")}}}}))
+}
+
+func (s *ShSuite) Test_ShellParser__redirect_list(c *check.C) {
+       b := s.init(c)
+
+       s.test("(:) 1>out",
+               b.List().AddCommand(
+                       b.Redirected(
+                               b.Subshell(b.List().AddCommand(b.SimpleCommand(":"))),
+                               b.Redirection(1, ">", "out"))))
+
+       s.test("(:) 1>out 2>out",
+               b.List().AddCommand(
+                       b.Redirected(
+                               b.Subshell(b.List().AddCommand(b.SimpleCommand(":"))),
+                               b.Redirection(1, ">", "out"),
+                               b.Redirection(2, ">", "out"))))
 }
 
 func (s *ShSuite) Test_ShellParser__io_here(c *check.C) {
-       // In pkgsrc Makefiles, the IO here-documents cannot be used since all the text
-       // is joined into a single line. Therefore there are no tests here.
+       // In pkgsrc Makefiles, the IO here-documents cannot be used since
+       // all the text is joined into a single line. Therefore these test
+       // cases only show that pkglint can indeed not parse <<EOF
+       // redirections.
+       b := s.init(c)
+
+       s.test("<<EOF\ntext\nEOF",
+               b.List().
+                       AddCommand(b.SimpleCommand("<<EOF")).
+                       AddNewline().
+                       AddCommand(b.SimpleCommand("text")). // This is wrong.



Home | Main Index | Thread Index | Old Index