pkgsrc-Changes archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
CVS commit: pkgsrc/pkgtools/pkglint
Module Name: pkgsrc
Committed By: rillig
Date: Mon Feb 17 20:22:21 UTC 2020
Modified Files:
pkgsrc/pkgtools/pkglint: Makefile
pkgsrc/pkgtools/pkglint/files: autofix.go package.go package_test.go
pkgsrc_test.go plist.go plist_test.go varalignblock_test.go
Log Message:
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.
To generate a diff of this commit:
cvs rdiff -u -r1.631 -r1.632 pkgsrc/pkgtools/pkglint/Makefile
cvs rdiff -u -r1.38 -r1.39 pkgsrc/pkgtools/pkglint/files/autofix.go
cvs rdiff -u -r1.80 -r1.81 pkgsrc/pkgtools/pkglint/files/package.go
cvs rdiff -u -r1.68 -r1.69 pkgsrc/pkgtools/pkglint/files/package_test.go
cvs rdiff -u -r1.43 -r1.44 pkgsrc/pkgtools/pkglint/files/pkgsrc_test.go
cvs rdiff -u -r1.53 -r1.54 pkgsrc/pkgtools/pkglint/files/plist.go
cvs rdiff -u -r1.45 -r1.46 pkgsrc/pkgtools/pkglint/files/plist_test.go
cvs rdiff -u -r1.13 -r1.14 \
pkgsrc/pkgtools/pkglint/files/varalignblock_test.go
Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.
Modified files:
Index: pkgsrc/pkgtools/pkglint/Makefile
diff -u pkgsrc/pkgtools/pkglint/Makefile:1.631 pkgsrc/pkgtools/pkglint/Makefile:1.632
--- pkgsrc/pkgtools/pkglint/Makefile:1.631 Sat Feb 15 13:48:40 2020
+++ pkgsrc/pkgtools/pkglint/Makefile Mon Feb 17 20:22:21 2020
@@ -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/}
Index: pkgsrc/pkgtools/pkglint/files/autofix.go
diff -u pkgsrc/pkgtools/pkglint/files/autofix.go:1.38 pkgsrc/pkgtools/pkglint/files/autofix.go:1.39
--- pkgsrc/pkgtools/pkglint/files/autofix.go:1.38 Sat Feb 15 13:48:40 2020
+++ pkgsrc/pkgtools/pkglint/files/autofix.go Mon Feb 17 20:22:21 2020
@@ -219,7 +219,7 @@ func (fix *Autofix) Delete() {
// 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.
Index: pkgsrc/pkgtools/pkglint/files/package.go
diff -u pkgsrc/pkgtools/pkglint/files/package.go:1.80 pkgsrc/pkgtools/pkglint/files/package.go:1.81
--- pkgsrc/pkgtools/pkglint/files/package.go:1.80 Sat Feb 15 13:48:40 2020
+++ pkgsrc/pkgtools/pkglint/files/package.go Mon Feb 17 20:22:21 2020
@@ -651,7 +651,7 @@ func (pkg *Package) checkfilePackageMake
// 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 @@ func (pkg *Package) Rel(filename CurrPat
// 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
Index: pkgsrc/pkgtools/pkglint/files/package_test.go
diff -u pkgsrc/pkgtools/pkglint/files/package_test.go:1.68 pkgsrc/pkgtools/pkglint/files/package_test.go:1.69
--- pkgsrc/pkgtools/pkglint/files/package_test.go:1.68 Sat Feb 15 13:48:40 2020
+++ pkgsrc/pkgtools/pkglint/files/package_test.go Mon Feb 17 20:22:21 2020
@@ -3525,9 +3525,9 @@ func (s *Suite) Test_Package_Includes(c
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
Index: pkgsrc/pkgtools/pkglint/files/pkgsrc_test.go
diff -u pkgsrc/pkgtools/pkglint/files/pkgsrc_test.go:1.43 pkgsrc/pkgtools/pkglint/files/pkgsrc_test.go:1.44
--- pkgsrc/pkgtools/pkglint/files/pkgsrc_test.go:1.43 Sat Feb 15 13:48:40 2020
+++ pkgsrc/pkgtools/pkglint/files/pkgsrc_test.go Mon Feb 17 20:22:21 2020
@@ -1407,6 +1407,24 @@ func (s *Suite) Test_Pkgsrc_File(c *chec
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)
Index: pkgsrc/pkgtools/pkglint/files/plist.go
diff -u pkgsrc/pkgtools/pkglint/files/plist.go:1.53 pkgsrc/pkgtools/pkglint/files/plist.go:1.54
--- pkgsrc/pkgtools/pkglint/files/plist.go:1.53 Sat Feb 15 13:48:40 2020
+++ pkgsrc/pkgtools/pkglint/files/plist.go Mon Feb 17 20:22:21 2020
@@ -72,6 +72,7 @@ func (ck *PlistChecker) Check(plainLines
ck.checkLine(pline)
pline.CheckTrailingWhitespace()
}
+ ck.checkOmf(plines)
CheckLinesTrailingEmptyLines(plainLines)
sorter := NewPlistLineSorter(plines)
@@ -498,6 +499,29 @@ func (ck *PlistChecker) checkCond(pline
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
Index: pkgsrc/pkgtools/pkglint/files/plist_test.go
diff -u pkgsrc/pkgtools/pkglint/files/plist_test.go:1.45 pkgsrc/pkgtools/pkglint/files/plist_test.go:1.46
--- pkgsrc/pkgtools/pkglint/files/plist_test.go:1.45 Mon Jan 6 20:38:42 2020
+++ pkgsrc/pkgtools/pkglint/files/plist_test.go Mon Feb 17 20:22:21 2020
@@ -1106,6 +1106,58 @@ func (s *Suite) Test_PlistChecker_checkC
"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)
Index: pkgsrc/pkgtools/pkglint/files/varalignblock_test.go
diff -u pkgsrc/pkgtools/pkglint/files/varalignblock_test.go:1.13 pkgsrc/pkgtools/pkglint/files/varalignblock_test.go:1.14
--- pkgsrc/pkgtools/pkglint/files/varalignblock_test.go:1.13 Sat Feb 15 13:48:40 2020
+++ pkgsrc/pkgtools/pkglint/files/varalignblock_test.go Mon Feb 17 20:22:21 2020
@@ -3134,11 +3134,28 @@ func (s *Suite) Test_VaralignBlock_Finis
}
func (s *Suite) Test_varalignLine_realignDetails(c *check.C) {
- t := s.Init(c)
-
- // FIXME
+ vt := NewVaralignTester(s, c)
- t.CheckOutputEmpty()
+ // 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_alignC
func (s *Suite) Test_varalignLine_replaceSpaceBeforeValue(c *check.C) {
t := s.Init(c)
- // FIXME
+ 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.")
- t.CheckOutputEmpty()
+ 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