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.4.9
details: https://anonhg.NetBSD.org/pkgsrc/rev/2ba6b6506c5c
branches: trunk
changeset: 411657:2ba6b6506c5c
user: rillig <rillig%pkgsrc.org@localhost>
date: Mon Feb 17 20:22:21 2020 +0000
description:
pkgtools/pkglint: update to 19.4.9
Changes since 19.4.8:
Packages that include omf-scrollkeeper.mk even though their PLIST doesn't
contain any .omf files will generate an error message, suggesting that
the .include line be removed.
diffstat:
pkgtools/pkglint/Makefile | 4 +-
pkgtools/pkglint/files/autofix.go | 2 +-
pkgtools/pkglint/files/package.go | 11 +++-
pkgtools/pkglint/files/package_test.go | 6 +-
pkgtools/pkglint/files/pkgsrc_test.go | 18 ++++++++
pkgtools/pkglint/files/plist.go | 24 ++++++++++
pkgtools/pkglint/files/plist_test.go | 52 +++++++++++++++++++++++
pkgtools/pkglint/files/varalignblock_test.go | 62 +++++++++++++++++++++++----
8 files changed, 160 insertions(+), 19 deletions(-)
diffs (283 lines):
diff -r e04dbf2e462d -r 2ba6b6506c5c pkgtools/pkglint/Makefile
--- a/pkgtools/pkglint/Makefile Mon Feb 17 19:53:41 2020 +0000
+++ b/pkgtools/pkglint/Makefile Mon Feb 17 20:22:21 2020 +0000
@@ -1,6 +1,6 @@
-# $NetBSD: Makefile,v 1.631 2020/02/15 13:48:40 rillig Exp $
+# $NetBSD: Makefile,v 1.632 2020/02/17 20:22:21 rillig Exp $
-PKGNAME= pkglint-19.4.8
+PKGNAME= pkglint-19.4.9
CATEGORIES= pkgtools
DISTNAME= tools
MASTER_SITES= ${MASTER_SITE_GITHUB:=golang/}
diff -r e04dbf2e462d -r 2ba6b6506c5c pkgtools/pkglint/files/autofix.go
--- a/pkgtools/pkglint/files/autofix.go Mon Feb 17 19:53:41 2020 +0000
+++ b/pkgtools/pkglint/files/autofix.go Mon Feb 17 20:22:21 2020 +0000
@@ -219,7 +219,7 @@
// and if so, call Describef to describe the actual fix.
//
// If autofix is false, the fix should be applied, as far as only
-// in-memory data structures are effected, and these are not written
+// in-memory data structures are affected, and these are not written
// back to disk. No externally observable modification must be done.
// For example, changing the text of Line.raw is appropriate,
// but changing files in the file system is not.
diff -r e04dbf2e462d -r 2ba6b6506c5c pkgtools/pkglint/files/package.go
--- a/pkgtools/pkglint/files/package.go Mon Feb 17 19:53:41 2020 +0000
+++ b/pkgtools/pkglint/files/package.go Mon Feb 17 20:22:21 2020 +0000
@@ -651,7 +651,7 @@
// This check is experimental because it's not yet clear how to
// classify the various Python packages and whether all Python
// packages really need the prefix.
- if G.Experimental && pkg.EffectivePkgname != "" && pkg.Includes("../../lang/python/extension.mk") {
+ if G.Experimental && pkg.EffectivePkgname != "" && pkg.Includes("../../lang/python/extension.mk") != nil {
pkg.EffectivePkgnameLine.Warnf("The PKGNAME of Python extensions should start with ${PYPKGPREFIX}.")
}
@@ -1529,9 +1529,12 @@
// Returns whether the given file (relative to the package directory)
// is included somewhere in the package, either directly or indirectly.
-func (pkg *Package) Includes(filename PackagePath) bool {
- return pkg.unconditionalIncludes[filename] != nil ||
- pkg.conditionalIncludes[filename] != nil
+func (pkg *Package) Includes(filename PackagePath) *MkLine {
+ mkline := pkg.unconditionalIncludes[filename]
+ if mkline == nil {
+ mkline = pkg.conditionalIncludes[filename]
+ }
+ return mkline
}
// PlistContent lists the directories and files that appear in the
diff -r e04dbf2e462d -r 2ba6b6506c5c pkgtools/pkglint/files/package_test.go
--- a/pkgtools/pkglint/files/package_test.go Mon Feb 17 19:53:41 2020 +0000
+++ b/pkgtools/pkglint/files/package_test.go Mon Feb 17 20:22:21 2020 +0000
@@ -3525,9 +3525,9 @@
pkg.load()
- t.CheckEquals(pkg.Includes("unconditionally.mk"), true)
- t.CheckEquals(pkg.Includes("conditionally.mk"), true)
- t.CheckEquals(pkg.Includes("other.mk"), false)
+ t.CheckEquals(pkg.Includes("unconditionally.mk") != nil, true)
+ t.CheckEquals(pkg.Includes("conditionally.mk") != nil, true)
+ t.CheckEquals(pkg.Includes("other.mk") != nil, false)
// The file never.mk is in conditionalIncludes since pkglint only
// analyzes on the syntactical level. It doesn't evaluate the
diff -r e04dbf2e462d -r 2ba6b6506c5c pkgtools/pkglint/files/pkgsrc_test.go
--- a/pkgtools/pkglint/files/pkgsrc_test.go Mon Feb 17 19:53:41 2020 +0000
+++ b/pkgtools/pkglint/files/pkgsrc_test.go Mon Feb 17 20:22:21 2020 +0000
@@ -1407,6 +1407,24 @@
test("filename", "filename")
}
+func (s *Suite) Test_Pkgsrc_FilePkg(c *check.C) {
+ t := s.Init(c)
+
+ t.Chdir(".")
+
+ test := func(rel PackagePath, abs CurrPath) {
+ actual := G.Pkgsrc.FilePkg(rel)
+ t.CheckEquals(actual, abs)
+ }
+
+ test("", "")
+ test("category/package", "")
+ test("../package", "")
+ test("../../category", "")
+ test("../../category/package", "category/package")
+ test("../../../something", "")
+}
+
func (s *Suite) Test_Change_Version(c *check.C) {
t := s.Init(c)
diff -r e04dbf2e462d -r 2ba6b6506c5c pkgtools/pkglint/files/plist.go
--- a/pkgtools/pkglint/files/plist.go Mon Feb 17 19:53:41 2020 +0000
+++ b/pkgtools/pkglint/files/plist.go Mon Feb 17 20:22:21 2020 +0000
@@ -72,6 +72,7 @@
ck.checkLine(pline)
pline.CheckTrailingWhitespace()
}
+ ck.checkOmf(plines)
CheckLinesTrailingEmptyLines(plainLines)
sorter := NewPlistLineSorter(plines)
@@ -498,6 +499,29 @@
cond)
}
+func (ck *PlistChecker) checkOmf(plines []*PlistLine) {
+ if ck.pkg == nil {
+ return
+ }
+ mkline := ck.pkg.Includes("../../mk/omf-scrollkeeper.mk")
+ if mkline == nil {
+ return
+ }
+
+ for _, pline := range plines {
+ if hasSuffix(pline.text, ".omf") {
+ return
+ }
+ }
+
+ fix := mkline.Autofix()
+ fix.Errorf("Only packages that have .omf files in their PLIST may include omf-scrollkeeper.mk.")
+ if !mkline.HasRationale() {
+ fix.Delete()
+ }
+ fix.Apply()
+}
+
type PlistLine struct {
*Line
conditions []string // e.g. PLIST.docs
diff -r e04dbf2e462d -r 2ba6b6506c5c pkgtools/pkglint/files/plist_test.go
--- a/pkgtools/pkglint/files/plist_test.go Mon Feb 17 19:53:41 2020 +0000
+++ b/pkgtools/pkglint/files/plist_test.go Mon Feb 17 20:22:21 2020 +0000
@@ -1106,6 +1106,58 @@
"in the package Makefile.")
}
+func (s *Suite) Test_PlistChecker_checkOmf__autofix(c *check.C) {
+ t := s.Init(c)
+
+ t.CreateFileLines("mk/omf-scrollkeeper.mk",
+ MkCvsID)
+ t.SetUpPackage("category/package",
+ ".include \"../../mk/omf-scrollkeeper.mk\"")
+ t.Chdir("category/package")
+ t.FinishSetUp()
+
+ t.ExpectDiagnosticsAutofix(
+ func(bool) { G.checkdirPackage(".") },
+ "ERROR: Makefile:20: Only packages that have .omf files in "+
+ "their PLIST may include omf-scrollkeeper.mk.",
+ "AUTOFIX: Makefile:20: Deleting this line.")
+}
+
+func (s *Suite) Test_PlistChecker_checkOmf__rationale(c *check.C) {
+ t := s.Init(c)
+
+ t.CreateFileLines("mk/omf-scrollkeeper.mk",
+ MkCvsID)
+ t.SetUpPackage("category/package",
+ ".include \"../../mk/omf-scrollkeeper.mk\" # needs to stay")
+ t.Chdir("category/package")
+ t.FinishSetUp()
+
+ t.ExpectDiagnosticsAutofix(
+ func(bool) { G.checkdirPackage(".") },
+ "ERROR: Makefile:20: Only packages that have .omf files in "+
+ "their PLIST may include omf-scrollkeeper.mk.")
+}
+
+func (s *Suite) Test_PlistChecker_checkOmf__ok(c *check.C) {
+ t := s.Init(c)
+
+ t.CreateFileLines("mk/omf-scrollkeeper.mk",
+ MkCvsID)
+ t.SetUpPackage("category/package",
+ ".include \"../../mk/omf-scrollkeeper.mk\" # needs to stay")
+ t.Chdir("category/package")
+ t.CreateFileLines("PLIST",
+ PlistCvsID,
+ "bin/program",
+ "share/omf/documentation.omf")
+ t.FinishSetUp()
+
+ t.ExpectDiagnosticsAutofix(
+ func(bool) { G.checkdirPackage(".") },
+ nil...)
+}
+
func (s *Suite) Test_PlistLine_Path(c *check.C) {
t := s.Init(c)
diff -r e04dbf2e462d -r 2ba6b6506c5c pkgtools/pkglint/files/varalignblock_test.go
--- a/pkgtools/pkglint/files/varalignblock_test.go Mon Feb 17 19:53:41 2020 +0000
+++ b/pkgtools/pkglint/files/varalignblock_test.go Mon Feb 17 20:22:21 2020 +0000
@@ -3134,11 +3134,28 @@
}
func (s *Suite) Test_varalignLine_realignDetails(c *check.C) {
- t := s.Init(c)
-
- // FIXME
-
- t.CheckOutputEmpty()
+ vt := NewVaralignTester(s, c)
+
+ // Just a random example to exercise some of the code paths,
+ // with no particular intention.
+ vt.Input(
+ "VAR=\t\tvalue",
+ "VAR= \\",
+ "\t\t ..24 \\",
+ "\t..12")
+ vt.Diagnostics(
+ "NOTE: Makefile:2: This variable value should be aligned "+
+ "with tabs, not spaces, to column 17 instead of 6.",
+ "NOTE: Makefile:3: This continuation line should be indented with \"\\t\\t\".")
+ vt.Autofixes(
+ "AUTOFIX: Makefile:2: Replacing \" \" with \"\\t\\t\".",
+ "AUTOFIX: Makefile:3: Replacing \"\\t\\t \" with \"\\t\\t\".")
+ vt.Fixed(
+ "VAR= value",
+ "VAR= \\",
+ " ..24 \\",
+ " ..12")
+ vt.Run()
}
func (s *Suite) Test_VaralignSplitter_split(c *check.C) {
@@ -4391,15 +4408,42 @@
func (s *Suite) Test_varalignLine_replaceSpaceBeforeValue(c *check.C) {
t := s.Init(c)
- // FIXME
-
- t.CheckOutputEmpty()
+ t.SetUpCommandLine("--autofix", "--show-autofix")
+ mklines := t.NewMkLines("filename.mk",
+ "VAR= \t value")
+ line := mklines.lines.Lines[0]
+ parts := NewVaralignSplitter().split(line.RawText(0), true)
+ info := varalignLine{line, 0, false, parts}
+ fix := line.Autofix()
+ fix.Warnf("Warning.")
+
+ info.replaceSpaceBeforeValue(fix, "\t\t")
+ fix.Apply()
+
+ t.CheckOutputLines(
+ "WARN: filename.mk:1: Warning.",
+ "AUTOFIX: filename.mk:1: Replacing \" \\t \" with \"\\t\\t\".")
}
func (s *Suite) Test_varalignLine_replaceSpaceBeforeContinuationSilently(c *check.C) {
t := s.Init(c)
- // FIXME
+ t.SetUpCommandLine("--autofix", "--show-autofix")
+ mklines := t.NewMkLines("filename.mk",
+ "VAR= \t value \\",
+ "\\tend")
+ line := mklines.lines.Lines[0]
+ parts := NewVaralignSplitter().split(line.RawText(0), true)
+ info := varalignLine{line, 0, false, parts}
+ fix := line.Autofix()
+ fix.Warnf("Warning.")
+
+ info.replaceSpaceBeforeContinuationSilently(fix, 32)
+ fix.Apply()
+
+ t.CheckOutputLines(
+ "WARN: filename.mk:1: Warning.",
+ "AUTOFIX: filename.mk:1: Replacing \" \\\\\" with \"\\t\\t\\t\\\\\".")
t.CheckOutputEmpty()
}
Home |
Main Index |
Thread Index |
Old Index