diff options
author | rillig <rillig@pkgsrc.org> | 2019-07-30 18:16:13 +0000 |
---|---|---|
committer | rillig <rillig@pkgsrc.org> | 2019-07-30 18:16:13 +0000 |
commit | 5a6030414cc7b4788870890955ef5872ba0db5ac (patch) | |
tree | fde2d56a83d2a9ae0fdd5a0df9347e52dfb2b6bb /pkgtools | |
parent | 83ea3e6a2a239639f323620dce30c33ae4421bdf (diff) | |
download | pkgsrc-5a6030414cc7b4788870890955ef5872ba0db5ac.tar.gz |
pkgtools/pkglint: update to 5.7.17
Changes since 5.7.16:
* The warnings for doc/CHANGES are only enabled when the -Cglobal option
is given. This is to avoid warnings that are unrelated to the package
that is being checked.
Diffstat (limited to 'pkgtools')
-rw-r--r-- | pkgtools/pkglint/Makefile | 4 | ||||
-rw-r--r-- | pkgtools/pkglint/files/check_test.go | 16 | ||||
-rw-r--r-- | pkgtools/pkglint/files/mkline_test.go | 6 | ||||
-rw-r--r-- | pkgtools/pkglint/files/mklines_test.go | 1 | ||||
-rw-r--r-- | pkgtools/pkglint/files/pkgsrc.go | 2 | ||||
-rw-r--r-- | pkgtools/pkglint/files/pkgsrc_test.go | 45 | ||||
-rw-r--r-- | pkgtools/pkglint/files/vartypecheck.go | 4 | ||||
-rw-r--r-- | pkgtools/pkglint/files/vartypecheck_test.go | 11 |
8 files changed, 72 insertions, 17 deletions
diff --git a/pkgtools/pkglint/Makefile b/pkgtools/pkglint/Makefile index 19494f38d23..2e1fc4f1889 100644 --- a/pkgtools/pkglint/Makefile +++ b/pkgtools/pkglint/Makefile @@ -1,6 +1,6 @@ -# $NetBSD: Makefile,v 1.588 2019/07/14 21:25:47 rillig Exp $ +# $NetBSD: Makefile,v 1.589 2019/07/30 18:16:13 rillig Exp $ -PKGNAME= pkglint-5.7.16 +PKGNAME= pkglint-5.7.17 CATEGORIES= pkgtools DISTNAME= tools MASTER_SITES= ${MASTER_SITE_GITHUB:=golang/} diff --git a/pkgtools/pkglint/files/check_test.go b/pkgtools/pkglint/files/check_test.go index 44f1c52889c..aa07665e0db 100644 --- a/pkgtools/pkglint/files/check_test.go +++ b/pkgtools/pkglint/files/check_test.go @@ -68,7 +68,8 @@ func (s *Suite) SetUpTest(c *check.C) { G.Pkgsrc = NewPkgsrc(t.File(".")) t.c = c - t.SetUpCommandLine("-Wall") // To catch duplicate warnings + t.SetUpCommandLine("-Wall") // To catch duplicate warnings + t.seenSetUpCommandLine = false // This default call doesn't count. // To improve code coverage and ensure that trace.Result works // in all cases. The latter cannot be ensured at compile time. @@ -131,9 +132,10 @@ type Tester struct { prevdir string // The current working directory before the test started relCwd string // See Tester.Chdir - seenSetupPkgsrc int - seenFinish bool - seenMain bool + seenSetUpCommandLine bool + seenSetupPkgsrc int + seenFinish bool + seenMain bool } // SetUpCommandLine simulates a command line for the remainder of the test. @@ -159,6 +161,8 @@ func (t *Tester) SetUpCommandLine(args ...string) { // It also reveals diagnostics that are logged multiple times per // line and thus can easily get annoying to the pkgsrc developers. G.Logger.Opts.LogVerbose = true + + t.seenSetUpCommandLine = true } // SetUpVartypes registers a few hundred variables like MASTER_SITES, @@ -673,6 +677,10 @@ func (t *Tester) Main(args ...string) int { t.Errorf("Calling t.FinishSetup() before t.Main() is redundant " + "since t.Main() loads the pkgsrc infrastructure.") } + if t.seenSetUpCommandLine { + t.Errorf("Calling t.SetupCommandLine() before t.Main() is redundant " + + "since t.Main() accepts the command line options directly.") + } t.seenMain = true diff --git a/pkgtools/pkglint/files/mkline_test.go b/pkgtools/pkglint/files/mkline_test.go index ee2bd2974ea..838d208c5ec 100644 --- a/pkgtools/pkglint/files/mkline_test.go +++ b/pkgtools/pkglint/files/mkline_test.go @@ -1514,17 +1514,17 @@ func (s *Suite) Test_MkLine_ResolveVarsInRelativePath__directory_depth(c *check. t := s.Init(c) t.SetUpVartypes() - mklines := t.SetUpFileMkLines("multimedia/totem/bla.mk", + mklines := t.SetUpFileMkLines("multimedia/totem/filename.mk", MkCvsID, "BUILDLINK_PKGSRCDIR.totem?=\t../../multimedia/totem") mklines.Check() t.CheckOutputLines( - "WARN: ~/multimedia/totem/bla.mk:2: "+ + "WARN: ~/multimedia/totem/filename.mk:2: "+ "The variable BUILDLINK_PKGSRCDIR.totem should not be given a default value in this file; "+ "it would be ok in buildlink3.mk.", - "ERROR: ~/multimedia/totem/bla.mk:2: Relative path \"../../multimedia/totem/Makefile\" does not exist.") + "ERROR: ~/multimedia/totem/filename.mk:2: Relative path \"../../multimedia/totem/Makefile\" does not exist.") } // Just for code coverage diff --git a/pkgtools/pkglint/files/mklines_test.go b/pkgtools/pkglint/files/mklines_test.go index 6a178b37a8c..addb024f6b4 100644 --- a/pkgtools/pkglint/files/mklines_test.go +++ b/pkgtools/pkglint/files/mklines_test.go @@ -1155,7 +1155,6 @@ func (s *Suite) Test_MkLines_Check__autofix_MASTER_SITE_in_HOMEPAGE(c *check.C) func (s *Suite) Test_MkLines_Check__autofix_MASTER_SITE_in_HOMEPAGE_in_package(c *check.C) { t := s.Init(c) - t.SetUpCommandLine("-Wall", "--autofix") t.SetUpPackage("category/package", "MASTER_SITES=\thttps://cdn1.example.org/ https://cdn2.example.org/", "HOMEPAGE=\t${MASTER_SITES}") diff --git a/pkgtools/pkglint/files/pkgsrc.go b/pkgtools/pkglint/files/pkgsrc.go index 18aa9ebcff2..6f836e30f25 100644 --- a/pkgtools/pkglint/files/pkgsrc.go +++ b/pkgtools/pkglint/files/pkgsrc.go @@ -501,7 +501,7 @@ func (*Pkgsrc) parseDocChange(line *Line, warn bool) *Change { func (src *Pkgsrc) loadDocChangesFromFile(filename string) []*Change { - warn := !G.Wip + warn := G.Opts.CheckGlobal && !G.Wip // Each date in the file should be from the same year as the filename says. // This check has been added in 2018. diff --git a/pkgtools/pkglint/files/pkgsrc_test.go b/pkgtools/pkglint/files/pkgsrc_test.go index 92738481a1b..d58a88e85ab 100644 --- a/pkgtools/pkglint/files/pkgsrc_test.go +++ b/pkgtools/pkglint/files/pkgsrc_test.go @@ -340,6 +340,7 @@ func (s *Suite) Test_Pkgsrc_loadDocChanges__not_found(c *check.C) { func (s *Suite) Test_Pkgsrc_loadDocChangesFromFile(c *check.C) { t := s.Init(c) + t.SetUpCommandLine("-Cglobal", "-Wall") t.CreateFileLines("doc/CHANGES-2018", "\tAdded category/package version 1.0 [author1 2015-01-01]", // Wrong year "\tUpdated category/package to 1.5 [author2 2018-01-02]", @@ -410,12 +411,51 @@ func (s *Suite) Test_Pkgsrc_loadDocChangesFromFile__wip_suppresses_warnings(c *c "\t\tWrong indentation", "\tInvalid pkgpath to 1.16 [rillig 2019-06-16]") - t.Main(t.File("wip/package")) + t.Main("-Cglobal", "-Wall", "wip/package") t.CheckOutputLines( "Looks fine.") } +// When a single package is checked, only the lines from doc/CHANGES +// that are related to that package are shown. The others are too +// unrelated. +func (s *Suite) Test_Pkgsrc_loadDocChangesFromFile__default(c *check.C) { + t := s.Init(c) + + t.SetUpPackage("category/package") + t.CreateFileLines("doc/CHANGES-2018", + CvsID, + "", + "Changes to the packages collection and infrastructure in 2018:", + "", + "\tUpdated sysutils/checkperms to 1.10 [rillig 2018-01-05]", + "\tUpdated sysutils/checkperms to 1.11 [rillig 2018-01-01]", + "\t\tWrong indentation", + "\tInvalid pkgpath to 1.16 [rillig 2019-06-16]", + "\tUpdated category/package to 2.0 [rillig 2019-07-24]") + t.CreateFileLines("Makefile", + MkCvsID) + + t.Main("category/package") + + t.CheckOutputLines( + "WARN: ~/category/package/Makefile:3: The package is being downgraded from 2.0 (see ../../doc/CHANGES-2018:9) to 1.0.", + "1 warning found.", + "(Run \"pkglint -e\" to show explanations.)") + + // Only when the global checks are enabled, the errors from doc/CHANGES are shown. + t.Main("-Cglobal", "-Wall", ".") + + t.CheckOutputLines( + "WARN: ~/doc/CHANGES-2018:6: Date \"2018-01-01\" for sysutils/checkperms is earlier than \"2018-01-05\" in line 5.", + "WARN: ~/doc/CHANGES-2018:7: Package changes should be indented using a single tab, not \"\\t\\t\".", + "WARN: ~/doc/CHANGES-2018:8: Unknown doc/CHANGES line: \tInvalid pkgpath to 1.16 [rillig 2019-06-16]", + "WARN: ~/doc/CHANGES-2018:9: Year \"2019\" for category/package does not match the filename ~/doc/CHANGES-2018.", + "4 warnings found.", + "(Run \"pkglint -e\" to show explanations.)") +} + func (s *Suite) Test_Pkgsrc_loadDocChangesFromFile__wrong_indentation(c *check.C) { t := s.Init(c) @@ -428,7 +468,7 @@ func (s *Suite) Test_Pkgsrc_loadDocChangesFromFile__wrong_indentation(c *check.C " Updated sysutils/checkperms to 1.10 [rillig 2018-01-05]", " \tUpdated sysutils/checkperms to 1.11 [rillig 2018-01-01]") - t.Main(t.File("category/package")) + t.Main("-Cglobal", "-Wall", "category/package") t.CheckOutputLines( "WARN: ~/doc/CHANGES-2018:5: Package changes should be indented using a single tab, not \" \".", @@ -548,6 +588,7 @@ func (s *Suite) Test_Pkgsrc_parseDocChange(c *check.C) { func (s *Suite) Test_Pkgsrc_loadDocChangesFromFile__old(c *check.C) { t := s.Init(c) + t.SetUpCommandLine("-Cglobal", "-Wall") t.SetUpPkgsrc() t.CreateFileLines("doc/CHANGES-2010", CvsID, diff --git a/pkgtools/pkglint/files/vartypecheck.go b/pkgtools/pkglint/files/vartypecheck.go index 90cf2f16b7b..0457a2144d1 100644 --- a/pkgtools/pkglint/files/vartypecheck.go +++ b/pkgtools/pkglint/files/vartypecheck.go @@ -502,8 +502,8 @@ func (cv *VartypeCheck) FetchURL() { subdir := cv.Value[len(siteURL):] if hasPrefix(cv.Value, "https://github.com/") { subdir = strings.SplitAfter(subdir, "/")[0] - cv.Warnf("Please use ${%s:=%s} instead of %q and run %q for further tips.", - siteName, subdir, cv.Value, makeHelp("github")) + cv.Warnf("Please use ${%s:=%s} instead of %q and run %q for further instructions.", + siteName, subdir, cv.Value[:len(siteURL)+len(subdir)], makeHelp("github")) } else { cv.Warnf("Please use ${%s:=%s} instead of %q.", siteName, subdir, cv.Value) } diff --git a/pkgtools/pkglint/files/vartypecheck_test.go b/pkgtools/pkglint/files/vartypecheck_test.go index 8669506f024..c99387f1ad3 100644 --- a/pkgtools/pkglint/files/vartypecheck_test.go +++ b/pkgtools/pkglint/files/vartypecheck_test.go @@ -490,8 +490,8 @@ func (s *Suite) Test_VartypeCheck_FetchURL(c *check.C) { vt.Output( "WARN: filename.mk:1: Please use ${MASTER_SITE_GITHUB:=example/} "+ - "instead of \"https://github.com/example/project/\" "+ - "and run \""+confMake+" help topic=github\" for further tips.", + "instead of \"https://github.com/example/\" "+ + "and run \""+confMake+" help topic=github\" for further instructions.", "WARN: filename.mk:2: Please use ${MASTER_SITE_GNU:=bison} "+ "instead of \"http://ftp.gnu.org/pub/gnu/bison\".", "ERROR: filename.mk:3: The subdirectory in MASTER_SITE_GNU must end with a slash.", @@ -525,6 +525,13 @@ func (s *Suite) Test_VartypeCheck_FetchURL(c *check.C) { vt.Values( "${MASTER_SITE_GNU:S,$,subdir/,}") vt.OutputEmpty() + + vt.Values( + "https://github.com/transmission/transmission-releases/raw/master/") + vt.Output( + "WARN: filename.mk:51: Please use ${MASTER_SITE_GITHUB:=transmission/} " + + "instead of \"https://github.com/transmission/\" " + + "and run \"" + confMake + " help topic=github\" for further instructions.") } func (s *Suite) Test_VartypeCheck_FetchURL__without_package(c *check.C) { |