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



details:   https://anonhg.NetBSD.org/pkgsrc/rev/c829a65d928f
branches:  trunk
changeset: 355832:c829a65d928f
user:      rillig <rillig%pkgsrc.org@localhost>
date:      Tue Dec 13 00:58:06 2016 +0000

description:
Updated pkglint to 5.4.13.

Changes since 5.4.12:

* Added check for unintended # comments, especially in HOMEPAGE
* Added check for quotes in COMMENT
* Fixed hardcoded package versions for PHP, Python, Lua, etc.
* Code cleanup in the tests

diffstat:

 pkgtools/pkglint/Makefile                   |    5 +-
 pkgtools/pkglint/files/category_test.go     |   10 +-
 pkgtools/pkglint/files/check_test.go        |   49 +++++++--
 pkgtools/pkglint/files/dir_test.go          |   12 +-
 pkgtools/pkglint/files/distinfo.go          |   14 ++-
 pkgtools/pkglint/files/distinfo_test.go     |   21 ++-
 pkgtools/pkglint/files/files_test.go        |   14 +-
 pkgtools/pkglint/files/globaldata.go        |   42 ++++++++-
 pkgtools/pkglint/files/globaldata_test.go   |   16 +-
 pkgtools/pkglint/files/licenses_test.go     |    3 +-
 pkgtools/pkglint/files/line_test.go         |   12 +-
 pkgtools/pkglint/files/mkline.go            |    9 +-
 pkgtools/pkglint/files/mkline_test.go       |  133 +++++++++++++++++++--------
 pkgtools/pkglint/files/mklines_test.go      |   58 +++++++----
 pkgtools/pkglint/files/package_test.go      |   60 ++++++-----
 pkgtools/pkglint/files/patches_test.go      |   23 +++-
 pkgtools/pkglint/files/pkglint.go           |   30 ++++-
 pkgtools/pkglint/files/pkglint_test.go      |   63 ++++++++++--
 pkgtools/pkglint/files/plist_test.go        |   32 ++++--
 pkgtools/pkglint/files/shell_test.go        |   24 +++-
 pkgtools/pkglint/files/substcontext_test.go |    3 +-
 pkgtools/pkglint/files/toplevel_test.go     |   11 +-
 pkgtools/pkglint/files/util_test.go         |    5 +-
 pkgtools/pkglint/files/vardefs.go           |    2 +-
 pkgtools/pkglint/files/vartypecheck.go      |    4 +
 pkgtools/pkglint/files/vartypecheck_test.go |   21 ++-
 26 files changed, 462 insertions(+), 214 deletions(-)

diffs (truncated from 1848 to 300 lines):

diff -r 5f7f02fe1d49 -r c829a65d928f pkgtools/pkglint/Makefile
--- a/pkgtools/pkglint/Makefile Mon Dec 12 23:54:12 2016 +0000
+++ b/pkgtools/pkglint/Makefile Tue Dec 13 00:58:06 2016 +0000
@@ -1,7 +1,6 @@
-# $NetBSD: Makefile,v 1.502 2016/12/04 16:30:00 bsiegert Exp $
+# $NetBSD: Makefile,v 1.503 2016/12/13 00:58:06 rillig Exp $
 
-PKGNAME=       pkglint-5.4.12
-PKGREVISION=   1
+PKGNAME=       pkglint-5.4.13
 DISTFILES=     # none
 CATEGORIES=    pkgtools
 
diff -r 5f7f02fe1d49 -r c829a65d928f pkgtools/pkglint/files/category_test.go
--- a/pkgtools/pkglint/files/category_test.go   Mon Dec 12 23:54:12 2016 +0000
+++ b/pkgtools/pkglint/files/category_test.go   Tue Dec 13 00:58:06 2016 +0000
@@ -5,8 +5,9 @@
 )
 
 func (s *Suite) Test_CheckdirCategory_totally_broken(c *check.C) {
+       s.Init(c)
        G.globalData.InitVartypes()
-       s.CreateTmpFile(c, "archivers/Makefile", ""+
+       s.CreateTmpFile("archivers/Makefile", ""+
                "# $\n"+
                "SUBDIR+=pkg1\n"+
                "SUBDIR+=\u0020aaaaa\n"+
@@ -34,16 +35,17 @@
 }
 
 func (s *Suite) Test_CheckdirCategory_invalid_comment(c *check.C) {
+       s.Init(c)
        G.globalData.InitVartypes()
-       s.CreateTmpFile(c, "archivers/Makefile", ""+
+       s.CreateTmpFile("archivers/Makefile", ""+
                "# $"+"NetBSD$\n"+
                "COMMENT=\t\\Make $$$$ fast\"\n"+
                "\n"+
                "SUBDIR+=\tpackage\n"+
                "\n"+
                ".include \"../mk/misc/category.mk\"\n")
-       s.CreateTmpFile(c, "archivers/package/Makefile", "# dummy\n")
-       s.CreateTmpFile(c, "mk/misc/category.mk", "# dummy\n")
+       s.CreateTmpFile("archivers/package/Makefile", "# dummy\n")
+       s.CreateTmpFile("mk/misc/category.mk", "# dummy\n")
        G.CurrentDir = s.tmpdir + "/archivers"
        G.CurPkgsrcdir = ".."
 
diff -r 5f7f02fe1d49 -r c829a65d928f pkgtools/pkglint/files/check_test.go
--- a/pkgtools/pkglint/files/check_test.go      Mon Dec 12 23:54:12 2016 +0000
+++ b/pkgtools/pkglint/files/check_test.go      Tue Dec 13 00:58:06 2016 +0000
@@ -20,6 +20,23 @@
        stdout bytes.Buffer
        stderr bytes.Buffer
        tmpdir string
+       checkC *check.C
+}
+
+// Init initializes the suite with the check.C instance for the actual
+// test run. See https://github.com/go-check/check/issues/22
+func (s *Suite) Init(c *check.C) {
+       if s.checkC != nil {
+               panic("Suite.Init must only be called once.")
+       }
+       s.checkC = c
+}
+
+func (s *Suite) c() *check.C {
+       if s.checkC == nil {
+               panic("Must call Suite.Init before accessing check.C.")
+       }
+       return s.checkC
 }
 
 func (s *Suite) Stdout() string {
@@ -87,10 +104,10 @@
        G.opts.Debug = false
 }
 
-func (s *Suite) UseCommandLine(c *check.C, args ...string) {
+func (s *Suite) UseCommandLine(args ...string) {
        exitcode := new(Pkglint).ParseCommandLine(append([]string{"pkglint"}, args...))
        if exitcode != nil && *exitcode != 0 {
-               c.Fatalf("Cannot parse command line: %#v", args)
+               s.c().Fatalf("Cannot parse command line: %#v", args)
        }
        G.opts.LogVerbose = true // See SetUpTest
 }
@@ -123,11 +140,9 @@
        }
 }
 
-func (s *Suite) CreateTmpFile(c *check.C, relFname, content string) (absFname string) {
-       if s.tmpdir == "" {
-               s.tmpdir = filepath.ToSlash(c.MkDir())
-       }
-       absFname = s.tmpdir + "/" + relFname
+func (s *Suite) CreateTmpFile(relFname, content string) (absFname string) {
+       c := s.c()
+       absFname = s.TmpDir() + "/" + relFname
        err := os.MkdirAll(path.Dir(absFname), 0777)
        c.Assert(err, check.IsNil)
 
@@ -136,20 +151,28 @@
        return
 }
 
-func (s *Suite) CreateTmpFileLines(c *check.C, relFname string, rawTexts ...string) (absFname string) {
+func (s *Suite) CreateTmpFileLines(relFname string, rawTexts ...string) (absFname string) {
        text := ""
        for _, rawText := range rawTexts {
                text += rawText + "\n"
        }
-       return s.CreateTmpFile(c, relFname, text)
+       return s.CreateTmpFile(relFname, text)
 }
 
-func (s *Suite) LoadTmpFile(c *check.C, relFname string) string {
-       bytes, err := ioutil.ReadFile(s.tmpdir + "/" + relFname)
+func (s *Suite) LoadTmpFile(relFname string) (absFname string) {
+       c := s.c()
+       bytes, err := ioutil.ReadFile(s.TmpDir() + "/" + relFname)
        c.Assert(err, check.IsNil)
        return string(bytes)
 }
 
+func (s *Suite) TmpDir() string {
+       if s.tmpdir == "" {
+               s.tmpdir = filepath.ToSlash(s.c().MkDir())
+       }
+       return s.tmpdir
+}
+
 func (s *Suite) ExpectFatalError(action func()) {
        if r := recover(); r != nil {
                if _, ok := r.(pkglintFatal); ok {
@@ -163,7 +186,9 @@
 func (s *Suite) SetUpTest(c *check.C) {
        G = GlobalVars{Testing: true}
        G.logOut, G.logErr, G.debugOut = &s.stdout, &s.stderr, &s.stdout
-       s.UseCommandLine(c /* no arguments */)
+       s.checkC = c
+       s.UseCommandLine( /* no arguments */ )
+       s.checkC = nil
        G.opts.LogVerbose = true // To detect duplicate work being done
 }
 
diff -r 5f7f02fe1d49 -r c829a65d928f pkgtools/pkglint/files/dir_test.go
--- a/pkgtools/pkglint/files/dir_test.go        Mon Dec 12 23:54:12 2016 +0000
+++ b/pkgtools/pkglint/files/dir_test.go        Tue Dec 13 00:58:06 2016 +0000
@@ -5,7 +5,8 @@
 )
 
 func (s *Suite) Test_CheckDirent_outside(c *check.C) {
-       s.CreateTmpFile(c, "empty", "")
+       s.Init(c)
+       s.CreateTmpFile("empty", "")
 
        CheckDirent(s.tmpdir)
 
@@ -13,10 +14,11 @@
 }
 
 func (s *Suite) Test_CheckDirent(c *check.C) {
-       s.CreateTmpFile(c, "mk/bsd.pkg.mk", "")
-       s.CreateTmpFile(c, "category/package/Makefile", "")
-       s.CreateTmpFile(c, "category/Makefile", "")
-       s.CreateTmpFile(c, "Makefile", "")
+       s.Init(c)
+       s.CreateTmpFile("mk/bsd.pkg.mk", "")
+       s.CreateTmpFile("category/package/Makefile", "")
+       s.CreateTmpFile("category/Makefile", "")
+       s.CreateTmpFile("Makefile", "")
        G.globalData.Pkgsrcdir = s.tmpdir
 
        CheckDirent(s.tmpdir)
diff -r 5f7f02fe1d49 -r c829a65d928f pkgtools/pkglint/files/distinfo.go
--- a/pkgtools/pkglint/files/distinfo.go        Mon Dec 12 23:54:12 2016 +0000
+++ b/pkgtools/pkglint/files/distinfo.go        Tue Dec 13 00:58:06 2016 +0000
@@ -14,10 +14,16 @@
        }
 
        fname := lines[0].Fname
-       var patchesDir = "patches"
-       if G.Pkg != nil && hasSuffix(fname, "/lang/php56/distinfo") {
-               patchesDir = G.CurPkgsrcdir + "/lang/php56/patches"
-       } else if G.Pkg != nil && dirExists(G.CurrentDir+"/"+G.Pkg.Patchdir) {
+       patchesDir := "patches"
+       patchesDirSet := false
+       if G.Pkg != nil && contains(fname, "lang/php") {
+               phpdir := G.globalData.Latest("lang", `^php[0-9]+$`, "/lang/$0")
+               if hasSuffix(fname, phpdir+"/distinfo") {
+                       patchesDir = G.CurPkgsrcdir + phpdir + "/patches"
+                       patchesDirSet = true
+               }
+       }
+       if G.Pkg != nil && !patchesDirSet && dirExists(G.CurrentDir+"/"+G.Pkg.Patchdir) {
                patchesDir = G.Pkg.Patchdir
        }
        if G.opts.Debug {
diff -r 5f7f02fe1d49 -r c829a65d928f pkgtools/pkglint/files/distinfo_test.go
--- a/pkgtools/pkglint/files/distinfo_test.go   Mon Dec 12 23:54:12 2016 +0000
+++ b/pkgtools/pkglint/files/distinfo_test.go   Tue Dec 13 00:58:06 2016 +0000
@@ -5,10 +5,11 @@
 )
 
 func (s *Suite) Test_ChecklinesDistinfo(c *check.C) {
-       s.CreateTmpFile(c, "patches/patch-aa", ""+
+       s.Init(c)
+       s.CreateTmpFile("patches/patch-aa", ""+
                "$"+"NetBSD$ line is ignored\n"+
                "patch contents\n")
-       s.CreateTmpFile(c, "patches/patch-ab", ""+
+       s.CreateTmpFile("patches/patch-ab", ""+
                "patch contents\n")
        G.CurrentDir = s.tmpdir
 
@@ -44,7 +45,8 @@
 }
 
 func (s *Suite) Test_ChecklinesDistinfo_uncommitted_patch(c *check.C) {
-       s.CreateTmpFile(c, "patches/patch-aa", ""+
+       s.Init(c)
+       s.CreateTmpFile("patches/patch-aa", ""+
                "$"+"NetBSD$\n"+
                "\n"+
                "--- oldfile\n"+
@@ -52,7 +54,7 @@
                "@@ -1,1 +1,1 @@\n"+
                "-old\n"+
                "+new\n")
-       s.CreateTmpFile(c, "CVS/Entries",
+       s.CreateTmpFile("CVS/Entries",
                "/distinfo/...\n")
        G.CurrentDir = s.tmpdir
 
@@ -66,9 +68,10 @@
 }
 
 func (s *Suite) Test_ChecklinesDistinfo_unrecorded_patches(c *check.C) {
-       s.CreateTmpFile(c, "patches/CVS/Entries", "")
-       s.CreateTmpFile(c, "patches/patch-aa", "")
-       s.CreateTmpFile(c, "patches/patch-src-Makefile", "")
+       s.Init(c)
+       s.CreateTmpFile("patches/CVS/Entries", "")
+       s.CreateTmpFile("patches/patch-aa", "")
+       s.CreateTmpFile("patches/patch-src-Makefile", "")
        G.CurrentDir = s.tmpdir
 
        ChecklinesDistinfo(s.NewLines(s.tmpdir+"/distinfo",
@@ -85,8 +88,8 @@
 }
 
 func (s *Suite) Test_ChecklinesDistinfo_manual_patches(c *check.C) {
-       s.CreateTmpFile(c, "patches/manual-libtool.m4",
-               "")
+       s.Init(c)
+       s.CreateTmpFile("patches/manual-libtool.m4", "")
        G.CurrentDir = s.tmpdir
 
        ChecklinesDistinfo(s.NewLines(s.tmpdir+"/distinfo",
diff -r 5f7f02fe1d49 -r c829a65d928f pkgtools/pkglint/files/files_test.go
--- a/pkgtools/pkglint/files/files_test.go      Mon Dec 12 23:54:12 2016 +0000
+++ b/pkgtools/pkglint/files/files_test.go      Tue Dec 13 00:58:06 2016 +0000
@@ -57,8 +57,9 @@
 }
 
 func (s *Suite) Test_show_autofix(c *check.C) {
-       s.UseCommandLine(c, "--show-autofix")
-       fname := s.CreateTmpFile(c, "Makefile", ""+
+       s.Init(c)
+       s.UseCommandLine("--show-autofix")
+       fname := s.CreateTmpFile("Makefile", ""+
                "line1\n"+
                "line2\n"+
                "line3\n")
@@ -70,15 +71,16 @@
        SaveAutofixChanges(lines)
 
        c.Check(lines[1].raw[0].textnl, equals, "XXXXX\n")
-       c.Check(s.LoadTmpFile(c, "Makefile"), equals, "line1\nline2\nline3\n")
+       c.Check(s.LoadTmpFile("Makefile"), equals, "line1\nline2\nline3\n")
        c.Check(s.Output(), equals, ""+
                "WARN: ~/Makefile:2: Something's wrong here.\n"+
                "AUTOFIX: ~/Makefile:2: Replacing regular expression \".\" with \"X\".\n")
 }
 
 func (s *Suite) Test_autofix(c *check.C) {
-       s.UseCommandLine(c, "--autofix")
-       fname := s.CreateTmpFile(c, "Makefile", ""+
+       s.Init(c)
+       s.UseCommandLine("--autofix")
+       fname := s.CreateTmpFile("Makefile", ""+
                "line1\n"+
                "line2\n"+
                "line3\n")
@@ -89,7 +91,7 @@
        }
        SaveAutofixChanges(lines)
 



Home | Main Index | Thread Index | Old Index