Source-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 20.1.15
details: https://anonhg.NetBSD.org/pkgsrc/rev/c1cdc6d1ea3b
branches: trunk
changeset: 433831:c1cdc6d1ea3b
user: rillig <rillig%pkgsrc.org@localhost>
date: Sun Jun 07 15:49:23 2020 +0000
description:
pkgtools/pkglint: update to 20.1.15
Changes since 20.1.14:
Fix confusing wording of diagnostic "should contain text". It's more
precise to say "this line should consist of this text". Otherwise it's
too easy to interpret it as "the text should occur somewhere in the
line".
Allow BUILDLINK_PREFIX.* to be used in helper files. Especially for
programming language packages, files like plugin.mk often include
buildlink3.mk and therefore may refer to the BUILDLINK_PREFIX of this
package.
Warn about redundant BUILDLINK_API_VERSION restrictions. Previously, the
check had only been enabled if the operators from the default dependency
pattern (buildlink3.mk) and the additional dependency pattern (package)
used the same operators, which already covered most practical cases.
Determine SuSE versions from the pkgsrc tree.
diffstat:
pkgtools/pkglint/Makefile | 4 +-
pkgtools/pkglint/files/autofix_test.go | 3 +-
pkgtools/pkglint/files/buildlink3.go | 4 +-
pkgtools/pkglint/files/buildlink3_test.go | 34 +++-
pkgtools/pkglint/files/category.go | 2 +-
pkgtools/pkglint/files/category_test.go | 6 +-
pkgtools/pkglint/files/check_test.go | 7 +-
pkgtools/pkglint/files/lineslexer.go | 4 +-
pkgtools/pkglint/files/lineslexer_test.go | 233 +++++++++++++++++++++++++
pkgtools/pkglint/files/mkcondchecker.go | 2 +-
pkgtools/pkglint/files/mklexer.go | 1 -
pkgtools/pkglint/files/mklinechecker_test.go | 11 +-
pkgtools/pkglint/files/mklines.go | 3 +
pkgtools/pkglint/files/mkvarusechecker.go | 18 +-
pkgtools/pkglint/files/mkvarusechecker_test.go | 99 ++++++++++-
pkgtools/pkglint/files/package.go | 7 +-
pkgtools/pkglint/files/package_test.go | 100 ++++++++++-
pkgtools/pkglint/files/patches.go | 2 +-
pkgtools/pkglint/files/patches_test.go | 21 ++
pkgtools/pkglint/files/pkgsrc.go | 3 +-
pkgtools/pkglint/files/pkgsrc_test.go | 9 +-
pkgtools/pkglint/files/plist_test.go | 5 +-
pkgtools/pkglint/files/redundantscope_test.go | 24 ++
pkgtools/pkglint/files/shell.go | 4 -
pkgtools/pkglint/files/vardefs.go | 3 +-
pkgtools/pkglint/files/vardefs_test.go | 4 +
pkgtools/pkglint/files/vartype_test.go | 2 +
pkgtools/pkglint/files/vartypecheck.go | 12 +-
pkgtools/pkglint/files/vartypecheck_test.go | 104 ++++++++++-
29 files changed, 668 insertions(+), 63 deletions(-)
diffs (truncated from 1207 to 300 lines):
diff -r 13c4d6c245a8 -r c1cdc6d1ea3b pkgtools/pkglint/Makefile
--- a/pkgtools/pkglint/Makefile Sun Jun 07 15:49:21 2020 +0000
+++ b/pkgtools/pkglint/Makefile Sun Jun 07 15:49:23 2020 +0000
@@ -1,6 +1,6 @@
-# $NetBSD: Makefile,v 1.653 2020/06/06 20:42:56 rillig Exp $
+# $NetBSD: Makefile,v 1.654 2020/06/07 15:49:23 rillig Exp $
-PKGNAME= pkglint-20.1.14
+PKGNAME= pkglint-20.1.15
CATEGORIES= pkgtools
DISTNAME= tools
MASTER_SITES= ${MASTER_SITE_GITHUB:=golang/}
diff -r 13c4d6c245a8 -r c1cdc6d1ea3b pkgtools/pkglint/files/autofix_test.go
--- a/pkgtools/pkglint/files/autofix_test.go Sun Jun 07 15:49:21 2020 +0000
+++ b/pkgtools/pkglint/files/autofix_test.go Sun Jun 07 15:49:23 2020 +0000
@@ -2,6 +2,7 @@
import (
"gopkg.in/check.v1"
+ "netbsd.org/pkglint/regex"
"os"
"runtime"
"strings"
@@ -702,7 +703,7 @@
t.ExpectDiagnosticsAutofix(doTest, nil...)
}
- testPanicMatches := func(texts []string, rawIndex int, column int, from, to, panicMessage string) {
+ testPanicMatches := func(texts []string, rawIndex int, column int, from, to string, panicMessage regex.Pattern) {
doTest := func(bool) {
t.ExpectPanicMatches(
func() { mainPart(texts, rawIndex, column, from, to) },
diff -r 13c4d6c245a8 -r c1cdc6d1ea3b pkgtools/pkglint/files/buildlink3.go
--- a/pkgtools/pkglint/files/buildlink3.go Sun Jun 07 15:49:21 2020 +0000
+++ b/pkgtools/pkglint/files/buildlink3.go Sun Jun 07 15:49:23 2020 +0000
@@ -54,7 +54,7 @@
}
// Fourth paragraph: Cleanup, corresponding to the first paragraph.
- if !llex.SkipContainsOrWarn("BUILDLINK_TREE+=\t-" + ck.pkgbase) {
+ if !llex.SkipTextOrWarn("BUILDLINK_TREE+=\t-" + ck.pkgbase) {
return
}
@@ -132,7 +132,7 @@
}
pkgupperLine, pkgupper := mlex.PreviousMkLine(), m[1]
- if !mlex.SkipContainsOrWarn(pkgupper + "_BUILDLINK3_MK:=") {
+ if !mlex.SkipTextOrWarn(pkgupper + "_BUILDLINK3_MK:=") {
return false
}
mlex.SkipEmptyOrNote()
diff -r 13c4d6c245a8 -r c1cdc6d1ea3b pkgtools/pkglint/files/buildlink3_test.go
--- a/pkgtools/pkglint/files/buildlink3_test.go Sun Jun 07 15:49:21 2020 +0000
+++ b/pkgtools/pkglint/files/buildlink3_test.go Sun Jun 07 15:49:23 2020 +0000
@@ -376,7 +376,7 @@
CheckLinesBuildlink3Mk(mklines)
t.CheckOutputLines(
- "WARN: buildlink3.mk:13: This line should contain the following text: BUILDLINK_TREE+=\t-hs-X11")
+ "WARN: buildlink3.mk:13: This line should consist of the following text: BUILDLINK_TREE+=\t-hs-X11")
}
func (s *Suite) Test_CheckLinesBuildlink3Mk__DEPMETHOD_placement(c *check.C) {
@@ -424,7 +424,7 @@
t.CheckOutputLines(
"WARN: buildlink3.mk:5: HS_X11_BUILDLINK3_MK is used but not defined.",
"WARN: buildlink3.mk:6: UNRELATED_BUILDLINK3_MK is defined but not used.",
- "WARN: buildlink3.mk:6: This line should contain the following text: HS_X11_BUILDLINK3_MK:=")
+ "WARN: buildlink3.mk:6: This line should consist of the following text: HS_X11_BUILDLINK3_MK:=")
}
func (s *Suite) Test_CheckLinesBuildlink3Mk__missing_endif(c *check.C) {
@@ -631,6 +631,21 @@
"WARN: ~/category/package/Makefile:4: \"\" is not a valid package name.")
}
+func (s *Suite) Test_Buildlink3Checker_checkPkgbaseMismatch(c *check.C) {
+ t := s.Init(c)
+
+ t.SetUpPackage("category/package")
+ t.CreateFileBuildlink3Id("category/package/buildlink3.mk", "unrelated")
+ t.Chdir("category/package")
+ t.FinishSetUp()
+
+ G.Check(".")
+
+ t.CheckOutputLines(
+ "ERROR: buildlink3.mk:3: Package name mismatch between \"unrelated\" " +
+ "in this file and \"package\" from Makefile:3.")
+}
+
func (s *Suite) Test_Buildlink3Checker_checkMainPart__if_else_endif(c *check.C) {
t := s.Init(c)
@@ -1098,7 +1113,19 @@
t := s.Init(c)
t.CreateFileBuildlink3("category/package/buildlink3.mk",
- "BUILDLINK_ABI_DEPENDS.package+=\tpackage>=0.1")
+ "BUILDLINK_ABI_DEPENDS.package+=\tpackage>=0.1",
+ "",
+ "BUILDLINK_API_DEPENDS.other+=\tother>=0.1",
+ "BUILDLINK_ABI_DEPENDS.other+=\tother>=0.1.3",
+ "BUILDLINK_API_DEPENDS.package+=\tinvalid",
+ "BUILDLINK_API_DEPENDS.package+=\tpackage>=0.1:extra",
+ "BUILDLINK_ABI_DEPENDS.package+=\tinvalid",
+ "BUILDLINK_ABI_DEPENDS.package+=\tpackage>=0.1:extra",
+
+ "BUILDLINK_PREFIX.package=\t${PREFIX}",
+ "BUILDLINK_PREFIX.other=\t${PREFIX}",
+
+ "BUILDLINK_PKGSRCDIR.other=\tcategory/package")
t.Chdir("category/package")
mklines := LoadMk("buildlink3.mk", nil, MustSucceed)
@@ -1106,6 +1133,7 @@
t.CheckDeepEquals(data, &Buildlink3Data{
id: "package",
+ prefix: "${PREFIX}",
pkgsrcdir: "../../category/package",
apiDepends: &DependencyPattern{
Pkgbase: "package",
diff -r 13c4d6c245a8 -r c1cdc6d1ea3b pkgtools/pkglint/files/category.go
--- a/pkgtools/pkglint/files/category.go Sun Jun 07 15:49:21 2020 +0000
+++ b/pkgtools/pkglint/files/category.go Sun Jun 07 15:49:23 2020 +0000
@@ -145,7 +145,7 @@
// generating indexes and READMEs. Just skip them.
if !G.Wip {
mlex.SkipEmptyOrNote()
- mlex.SkipContainsOrWarn(".include \"../mk/misc/category.mk\"")
+ mlex.SkipTextOrWarn(".include \"../mk/misc/category.mk\"")
if !mlex.EOF() {
mlex.CurrentLine().Errorf("The file must end here.")
}
diff -r 13c4d6c245a8 -r c1cdc6d1ea3b pkgtools/pkglint/files/category_test.go
--- a/pkgtools/pkglint/files/category_test.go Sun Jun 07 15:49:21 2020 +0000
+++ b/pkgtools/pkglint/files/category_test.go Sun Jun 07 15:49:23 2020 +0000
@@ -32,7 +32,7 @@
"ERROR: ~/archivers/Makefile:2: \"pkg1\" does not contain a package.",
"ERROR: ~/archivers/Makefile:3: \"aaaaa\" does not contain a package.",
"NOTE: ~/archivers/Makefile:4: Empty line expected above this line.",
- "WARN: ~/archivers/Makefile:4: This line should contain the following text: .include \"../mk/misc/category.mk\"",
+ "WARN: ~/archivers/Makefile:4: This line should consist of the following text: .include \"../mk/misc/category.mk\"",
"ERROR: ~/archivers/Makefile:4: The file must end here.")
}
@@ -303,7 +303,7 @@
"ERROR: ~/category/Makefile:3: SUBDIR+= line or empty line expected.",
"ERROR: ~/category/Makefile:3: Package \"package\" must be listed here.",
"NOTE: ~/category/Makefile:3: Empty line expected above this line.",
- "WARN: ~/category/Makefile:3: This line should contain the following text: .include \"../mk/misc/category.mk\"",
+ "WARN: ~/category/Makefile:3: This line should consist of the following text: .include \"../mk/misc/category.mk\"",
"ERROR: ~/category/Makefile:3: The file must end here.")
}
@@ -326,7 +326,7 @@
// Doesn't happen in practice since categories are created very seldom.
t.CheckOutputLines(
"NOTE: ~/category/Makefile:5: Empty line expected below this line.",
- "WARN: ~/category/Makefile:EOF: This line should contain the following text: "+
+ "WARN: ~/category/Makefile:EOF: This line should consist of the following text: "+
".include \"../mk/misc/category.mk\"")
}
diff -r 13c4d6c245a8 -r c1cdc6d1ea3b pkgtools/pkglint/files/check_test.go
--- a/pkgtools/pkglint/files/check_test.go Sun Jun 07 15:49:21 2020 +0000
+++ b/pkgtools/pkglint/files/check_test.go Sun Jun 07 15:49:23 2020 +0000
@@ -104,13 +104,11 @@
func Test__qa(t *testing.T) {
ck := intqa.NewQAChecker(t.Errorf)
- ck.Configure("buildlink3.go", "*", "*", -intqa.EMissingTest) // TODO
ck.Configure("distinfo.go", "*", "*", -intqa.EMissingTest) // TODO
ck.Configure("files.go", "*", "*", -intqa.EMissingTest) // TODO
ck.Configure("licenses.go", "*", "*", -intqa.EMissingTest) // TODO
ck.Configure("line.go", "*", "*", -intqa.EMissingTest) // TODO
ck.Configure("linechecker.go", "*", "*", -intqa.EMissingTest) // TODO
- ck.Configure("lineslexer.go", "*", "*", -intqa.EMissingTest) // TODO
ck.Configure("lines.go", "*", "*", -intqa.EMissingTest) // TODO
ck.Configure("logging.go", "*", "*", -intqa.EMissingTest) // TODO
ck.Configure("mkline.go", "*", "*", -intqa.EMissingTest) // TODO
@@ -962,8 +960,9 @@
// ExpectPanicMatches runs the given action and expects that this action
// calls assert or assertf, or uses some other way to panic.
-func (t *Tester) ExpectPanicMatches(action func(), expectedMessage string) {
- t.Check(action, check.PanicMatches, expectedMessage)
+// The expectedMessage is anchored on both ends.
+func (t *Tester) ExpectPanicMatches(action func(), expectedMessage regex.Pattern) {
+ t.Check(action, check.PanicMatches, string(expectedMessage))
}
// ExpectAssert runs the given action and expects that this action calls assert.
diff -r 13c4d6c245a8 -r c1cdc6d1ea3b pkgtools/pkglint/files/lineslexer.go
--- a/pkgtools/pkglint/files/lineslexer.go Sun Jun 07 15:49:21 2020 +0000
+++ b/pkgtools/pkglint/files/lineslexer.go Sun Jun 07 15:49:23 2020 +0000
@@ -109,10 +109,10 @@
return false
}
-func (llex *LinesLexer) SkipContainsOrWarn(text string) bool {
+func (llex *LinesLexer) SkipTextOrWarn(text string) bool {
result := llex.SkipText(text)
if !result {
- llex.CurrentLine().Warnf("This line should contain the following text: %s", text)
+ llex.CurrentLine().Warnf("This line should consist of the following text: %s", text)
}
return result
}
diff -r 13c4d6c245a8 -r c1cdc6d1ea3b pkgtools/pkglint/files/lineslexer_test.go
--- a/pkgtools/pkglint/files/lineslexer_test.go Sun Jun 07 15:49:21 2020 +0000
+++ b/pkgtools/pkglint/files/lineslexer_test.go Sun Jun 07 15:49:23 2020 +0000
@@ -4,6 +4,121 @@
"gopkg.in/check.v1"
)
+func (s *Suite) Test_NewLinesLexer(c *check.C) {
+ t := s.Init(c)
+
+ lines := t.NewLines("file.txt",
+ "line 1")
+
+ llex := NewLinesLexer(lines)
+
+ t.CheckEquals(llex.line, lines.Lines[0])
+}
+
+func (s *Suite) Test_LinesLexer_CurrentLine(c *check.C) {
+ t := s.Init(c)
+
+ lines := t.NewLines("file.txt",
+ "line 1")
+
+ llex := NewLinesLexer(lines)
+
+ t.CheckEquals(llex.CurrentLine(), lines.Lines[0])
+
+ llex.Skip()
+
+ t.CheckEquals(llex.CurrentLine().Linenos(), "EOF")
+}
+
+func (s *Suite) Test_LinesLexer_PreviousLine(c *check.C) {
+ t := s.Init(c)
+
+ lines := t.NewLines("file.txt",
+ "line 1")
+
+ llex := NewLinesLexer(lines)
+
+ t.ExpectPanicMatches(func() { llex.PreviousLine() }, `.*index out of range.*`)
+
+ llex.Skip()
+
+ t.CheckEquals(llex.PreviousLine(), lines.Lines[0])
+}
+
+func (s *Suite) Test_LinesLexer_EOF(c *check.C) {
+ t := s.Init(c)
+
+ lines := t.NewLines("file.txt",
+ "line 1")
+
+ llex := NewLinesLexer(lines)
+
+ t.CheckEquals(llex.EOF(), false)
+
+ llex.Skip()
+
+ t.CheckEquals(llex.EOF(), true)
+}
+
+func (s *Suite) Test_LinesLexer_Skip(c *check.C) {
+ t := s.Init(c)
+
+ lines := t.NewLines("file.txt",
+ "line 1")
+
+ llex := NewLinesLexer(lines)
+
+ t.CheckEquals(llex.Skip(), true)
+ t.CheckEquals(llex.Skip(), false)
+}
+
+func (s *Suite) Test_LinesLexer_Undo(c *check.C) {
+ t := s.Init(c)
+
+ lines := t.NewLines("file.txt",
+ "line 1")
+
+ llex := NewLinesLexer(lines)
+
+ t.CheckEquals(llex.Skip(), true)
+
+ llex.Undo()
+
+ t.CheckEquals(llex.CurrentLine(), lines.Lines[0])
Home |
Main Index |
Thread Index |
Old Index