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 pkglint to 1...
details: https://anonhg.NetBSD.org/pkgsrc/rev/bcfd1cfe4062
branches: trunk
changeset: 405799:bcfd1cfe4062
user: rillig <rillig%pkgsrc.org@localhost>
date: Sun Dec 08 22:03:37 2019 +0000
description:
pkgtools/pkglint: update pkglint to 19.3.15
Changes since 19.3.14:
Invalid lines in PLIST files are now reported as errors instead of
warnings. If pkglint doesn't know about it, it must be an error.
In PLIST files, all paths are validated to be canonical. That is, no
dotdot components, no absolute paths, no extra slashes, no intermediate
dot components.
Fewer notes for unexpanded variable expressions in DESCR files. Before,
the text $@ was reported as possible Makefile variable even though it
was just a Perl expression.
README files are allowed again in pkgsrc package directories. There was
no convincing argument why these should be forbidden.
A few diagnostics have been changed from NOTE to WARNING or from WARNING
to ERROR, to match their wording.
When pkglint suggests to replace :M with ==, the wording is now "can be
made" instead of "should".
diffstat:
pkgtools/pkglint/Makefile | 4 +-
pkgtools/pkglint/files/autofix_test.go | 5 +-
pkgtools/pkglint/files/buildlink3.go | 2 +-
pkgtools/pkglint/files/category.go | 2 +-
pkgtools/pkglint/files/category_test.go | 4 +-
pkgtools/pkglint/files/check_test.go | 39 +-
pkgtools/pkglint/files/logging.go | 9 +
pkgtools/pkglint/files/logging_test.go | 26 +-
pkgtools/pkglint/files/mkassignchecker.go | 4 +-
pkgtools/pkglint/files/mkassignchecker_test.go | 6 +-
pkgtools/pkglint/files/mkcondchecker.go | 58 +-
pkgtools/pkglint/files/mkcondchecker_test.go | 785 +++++++++++++-----------
pkgtools/pkglint/files/mklexer.go | 9 +-
pkgtools/pkglint/files/mklexer_test.go | 4 +-
pkgtools/pkglint/files/mkline.go | 2 +-
pkgtools/pkglint/files/mklinechecker.go | 6 +-
pkgtools/pkglint/files/mklinechecker_test.go | 2 +-
pkgtools/pkglint/files/mklineparser_test.go | 2 +-
pkgtools/pkglint/files/mklines.go | 15 +-
pkgtools/pkglint/files/mklines_test.go | 20 +-
pkgtools/pkglint/files/mkparser_test.go | 2 +-
pkgtools/pkglint/files/mktypes_test.go | 4 +-
pkgtools/pkglint/files/mkvarusechecker.go | 9 +-
pkgtools/pkglint/files/mkvarusechecker_test.go | 22 +-
pkgtools/pkglint/files/options.go | 3 +-
pkgtools/pkglint/files/options_test.go | 2 +-
pkgtools/pkglint/files/package.go | 38 +-
pkgtools/pkglint/files/package_test.go | 36 +-
pkgtools/pkglint/files/patches_test.go | 2 +-
pkgtools/pkglint/files/path.go | 6 +-
pkgtools/pkglint/files/path_test.go | 3 +
pkgtools/pkglint/files/pkglint.1 | 2 +-
pkgtools/pkglint/files/pkglint.go | 55 +-
pkgtools/pkglint/files/pkglint_test.go | 48 +-
pkgtools/pkglint/files/pkgsrc.go | 23 +-
pkgtools/pkglint/files/plist.go | 191 +++--
pkgtools/pkglint/files/plist_test.go | 291 ++++++++-
pkgtools/pkglint/files/redundantscope.go | 2 +-
pkgtools/pkglint/files/shell.go | 6 +-
pkgtools/pkglint/files/shell_test.go | 10 +-
pkgtools/pkglint/files/shtokenizer_test.go | 4 +-
pkgtools/pkglint/files/substcontext.go | 2 +-
pkgtools/pkglint/files/util.go | 12 +-
pkgtools/pkglint/files/util_test.go | 29 +-
pkgtools/pkglint/files/vardefs.go | 4 +-
pkgtools/pkglint/files/vargroups.go | 2 +-
pkgtools/pkglint/files/vartype.go | 60 +-
pkgtools/pkglint/files/vartypecheck.go | 74 +--
pkgtools/pkglint/files/vartypecheck_test.go | 273 ++++++++-
49 files changed, 1481 insertions(+), 738 deletions(-)
diffs (truncated from 4072 to 300 lines):
diff -r 5f3d7d730536 -r bcfd1cfe4062 pkgtools/pkglint/Makefile
--- a/pkgtools/pkglint/Makefile Sun Dec 08 21:56:42 2019 +0000
+++ b/pkgtools/pkglint/Makefile Sun Dec 08 22:03:37 2019 +0000
@@ -1,6 +1,6 @@
-# $NetBSD: Makefile,v 1.614 2019/12/08 00:06:37 rillig Exp $
+# $NetBSD: Makefile,v 1.615 2019/12/08 22:03:37 rillig Exp $
-PKGNAME= pkglint-19.3.14
+PKGNAME= pkglint-19.3.15
CATEGORIES= pkgtools
DISTNAME= tools
MASTER_SITES= ${MASTER_SITE_GITHUB:=golang/}
diff -r 5f3d7d730536 -r bcfd1cfe4062 pkgtools/pkglint/files/autofix_test.go
--- a/pkgtools/pkglint/files/autofix_test.go Sun Dec 08 21:56:42 2019 +0000
+++ b/pkgtools/pkglint/files/autofix_test.go Sun Dec 08 22:03:37 2019 +0000
@@ -164,7 +164,8 @@
t.CheckOutputLines(
">\tPRE_XORGPROTO_LIST_MISSING =\tapplewmproto",
- "NOTE: x11/xorgproto/builtin.mk:5: Unnecessary space after variable name \"PRE_XORGPROTO_LIST_MISSING\".")
+ "NOTE: x11/xorg-cf-files/../../x11/xorgproto/builtin.mk:5: "+
+ "Unnecessary space after variable name \"PRE_XORGPROTO_LIST_MISSING\".")
}
// Up to 2018-11-26, pkglint in some cases logged only the source without
@@ -557,7 +558,7 @@
lines := func(lines ...string) []string { return lines }
test := func(texts []string, rawIndex int, column int, from, to string, diagnostics ...string) {
- mainPart := func() {
+ mainPart := func(autofix bool) {
mklines := t.NewMkLines("filename.mk", texts...)
assert(len(mklines.mklines) == 1)
mkline := mklines.mklines[0]
diff -r 5f3d7d730536 -r bcfd1cfe4062 pkgtools/pkglint/files/buildlink3.go
--- a/pkgtools/pkglint/files/buildlink3.go Sun Dec 08 21:56:42 2019 +0000
+++ b/pkgtools/pkglint/files/buildlink3.go Sun Dec 08 22:03:37 2019 +0000
@@ -99,7 +99,7 @@
return
}
- dirname := G.Pkgsrc.ToRel(mkline.Filename.DirNoClean()).Base()
+ dirname := G.Pkgsrc.Rel(mkline.Filename.DirNoClean()).Base()
base, name := trimCommon(pkgbase, dirname)
if base == "" && matches(name, `^(\d*|-cvs|-fossil|-git|-hg|-svn|-devel|-snapshot)$`) {
return
diff -r 5f3d7d730536 -r bcfd1cfe4062 pkgtools/pkglint/files/category.go
--- a/pkgtools/pkglint/files/category.go Sun Dec 08 21:56:42 2019 +0000
+++ b/pkgtools/pkglint/files/category.go Sun Dec 08 22:03:37 2019 +0000
@@ -148,7 +148,7 @@
mlex.SkipEmptyOrNote()
mlex.SkipContainsOrWarn(".include \"../mk/misc/category.mk\"")
if !mlex.EOF() {
- mlex.CurrentLine().Errorf("The file should end here.")
+ mlex.CurrentLine().Errorf("The file must end here.")
}
}
diff -r 5f3d7d730536 -r bcfd1cfe4062 pkgtools/pkglint/files/category_test.go
--- a/pkgtools/pkglint/files/category_test.go Sun Dec 08 21:56:42 2019 +0000
+++ b/pkgtools/pkglint/files/category_test.go Sun Dec 08 22:03:37 2019 +0000
@@ -33,7 +33,7 @@
"ERROR: ~/archivers/Makefile:3: \"aaaaa\" exists in the Makefile but not in the file system.",
"NOTE: ~/archivers/Makefile:3: Empty line expected after this line.",
"WARN: ~/archivers/Makefile:4: This line should contain the following text: .include \"../mk/misc/category.mk\"",
- "ERROR: ~/archivers/Makefile:4: The file should end here.")
+ "ERROR: ~/archivers/Makefile:4: The file must end here.")
}
func (s *Suite) Test_CheckdirCategory__invalid_comment(c *check.C) {
@@ -305,7 +305,7 @@
"ERROR: ~/category/Makefile:3: \"package\" exists in the file system but not in the Makefile.",
"NOTE: ~/category/Makefile:2: Empty line expected after this line.",
"WARN: ~/category/Makefile:3: This line should contain the following text: .include \"../mk/misc/category.mk\"",
- "ERROR: ~/category/Makefile:3: The file should end here.")
+ "ERROR: ~/category/Makefile:3: The file must end here.")
}
func (s *Suite) Test_CheckdirCategory__unexpected_EOF_while_reading_SUBDIR(c *check.C) {
diff -r 5f3d7d730536 -r bcfd1cfe4062 pkgtools/pkglint/files/check_test.go
--- a/pkgtools/pkglint/files/check_test.go Sun Dec 08 21:56:42 2019 +0000
+++ b/pkgtools/pkglint/files/check_test.go Sun Dec 08 22:03:37 2019 +0000
@@ -102,8 +102,8 @@
// Ensures that all test names follow a common naming scheme:
//
// Test_${Type}_${Method}__${description_using_underscores}
-func (s *Suite) Test__qa(c *check.C) {
- ck := intqa.NewQAChecker(c.Errorf)
+func Test__qa(t *testing.T) {
+ ck := intqa.NewQAChecker(t.Errorf)
ck.Configure("autofix.go", "*", "*", -intqa.EMissingTest) // TODO
ck.Configure("buildlink3.go", "*", "*", -intqa.EMissingTest) // TODO
@@ -131,7 +131,6 @@
ck.Configure("patches.go", "*", "*", -intqa.EMissingTest) // TODO
ck.Configure("pkglint.go", "*", "*", -intqa.EMissingTest) // TODO
ck.Configure("pkgsrc.go", "*", "*", -intqa.EMissingTest) // TODO
- ck.Configure("plist.go", "*", "*", -intqa.EMissingTest) // TODO
ck.Configure("redundantscope.go", "*", "*", -intqa.EMissingTest) // TODO
ck.Configure("shell.go", "*", "*", -intqa.EMissingTest) // TODO
ck.Configure("shtokenizer.go", "*", "*", -intqa.EMissingTest) // TODO
@@ -144,7 +143,6 @@
ck.Configure("vardefs.go", "*", "*", -intqa.EMissingTest) // TODO
ck.Configure("vargroups.go", "*", "*", -intqa.EMissingTest) // TODO
ck.Configure("vartype.go", "*", "*", -intqa.EMissingTest) // TODO
- ck.Configure("vartypecheck.go", "*", "*", -intqa.EMissingTest) // TODO
// For now, don't require tests for all the test code.
// Having good coverage for the main code is more important.
@@ -262,6 +260,27 @@
return G.Pkgsrc.Tools.def(name, varname, false, validity, nil)
}
+// SetUpType defines a variable to have a certain type and access permissions,
+// like in the type definitions in vardefs.go.
+//
+// Example:
+// SetUpType("PKGPATH", BtPkgpath, DefinedIfInScope|NonemptyIfDefined,
+// "Makefile, *.mk: default, set, append, use, use-loadtime")
+func (t *Tester) SetUpType(varname string, basicType *BasicType,
+ options vartypeOptions, aclEntries ...string) {
+
+ if len(aclEntries) == 0 {
+ aclEntries = []string{"Makefile, *.mk: default, set, append, use, use-loadtime"}
+ }
+
+ G.Pkgsrc.vartypes.acl(varname, basicType, options, aclEntries...)
+
+ // Make sure that registering the type succeeds.
+ // This is necessary for BtUnknown and guessed types.
+ vartype := G.Pkgsrc.VariableType(nil, varname)
+ t.c.Assert(vartype.basicType, check.Equals, basicType)
+}
+
// SetUpFileLines creates a temporary file and writes the given lines to it.
// The file is then read in, without interpreting line continuations.
//
@@ -399,7 +418,7 @@
// SetUpCategory makes the given category valid by creating a dummy Makefile.
// After that, it can be mentioned in the CATEGORIES variable of a package.
func (t *Tester) SetUpCategory(name RelPath) {
- assert(G.Pkgsrc.ToRel(t.File(name)).Count() == 1)
+ assert(G.Pkgsrc.Rel(t.File(name)).Count() == 1)
makefile := name.JoinNoClean("Makefile")
if !t.File(makefile).IsFile() {
@@ -535,7 +554,7 @@
// temporary directory.
func (t *Tester) CreateFileDummyPatch(filename RelPath) {
// Patch files only make sense in category/package/patches directories.
- assert(G.Pkgsrc.ToRel(t.File(filename)).Count() == 4)
+ assert(G.Pkgsrc.Rel(t.File(filename)).Count() == 4)
t.CreateFileLines(filename,
CvsID,
@@ -551,7 +570,7 @@
func (t *Tester) CreateFileBuildlink3(filename RelPath, customLines ...string) {
// Buildlink3.mk files only make sense in category/package directories.
- assert(G.Pkgsrc.ToRel(t.File(filename)).Count() == 3)
+ assert(G.Pkgsrc.Rel(t.File(filename)).Count() == 3)
dir := filename.DirClean()
lower := dir.Base()
@@ -924,12 +943,12 @@
// ExpectDiagnosticsAutofix first runs the given action with -Wall, and
// then another time with -Wall --autofix.
-func (t *Tester) ExpectDiagnosticsAutofix(action func(), diagnostics ...string) {
+func (t *Tester) ExpectDiagnosticsAutofix(action func(autofix bool), diagnostics ...string) {
t.SetUpCommandLine("-Wall")
- action()
+ action(false)
t.SetUpCommandLine("-Wall", "--autofix")
- action()
+ action(true)
t.CheckOutput(diagnostics)
}
diff -r 5f3d7d730536 -r bcfd1cfe4062 pkgtools/pkglint/files/logging.go
--- a/pkgtools/pkglint/files/logging.go Sun Dec 08 21:56:42 2019 +0000
+++ b/pkgtools/pkglint/files/logging.go Sun Dec 08 22:03:37 2019 +0000
@@ -255,6 +255,15 @@
return
}
+ if G.Testing {
+ if level != Error {
+ assertf(!contains(format, "must"), "Must must only appear in errors: %s", format)
+ }
+ if level != Warn && level != Note {
+ assertf(!contains(format, "should"), "Should must only appear in warnings: %s", format)
+ }
+ }
+
if G.Testing && format != AutofixFormat {
if textproc.Alpha.Contains(format[0]) {
assertf(
diff -r 5f3d7d730536 -r bcfd1cfe4062 pkgtools/pkglint/files/logging_test.go
--- a/pkgtools/pkglint/files/logging_test.go Sun Dec 08 21:56:42 2019 +0000
+++ b/pkgtools/pkglint/files/logging_test.go Sun Dec 08 22:03:37 2019 +0000
@@ -172,11 +172,11 @@
logger := Logger{out: NewSeparatorWriter(&sw)}
line := t.NewLine("filename", 3, "Text")
- logger.Diag(line, Error, "Blue should be %s.", "orange")
- logger.Diag(line, Error, "Blue should be %s.", "orange")
+ logger.Diag(line, Error, "Blue must be %s.", "orange")
+ logger.Diag(line, Error, "Blue must be %s.", "orange")
t.CheckEquals(sw.String(), ""+
- "ERROR: filename:3: Blue should be orange.\n")
+ "ERROR: filename:3: Blue must be orange.\n")
}
// Explanations are associated with their diagnostics. Therefore, when one
@@ -189,22 +189,22 @@
logger.Opts.Explain = true
line := t.NewLine("filename", 3, "Text")
- logger.Diag(line, Error, "Blue should be %s.", "orange")
+ logger.Diag(line, Error, "Blue must be %s.", "orange")
logger.Explain(
"The colors have changed.")
- logger.Diag(line, Error, "Blue should be %s.", "orange")
+ logger.Diag(line, Error, "Blue must be %s.", "orange")
logger.Explain(
"The colors have changed.")
// Even when the text of the explanation is not the same, it is still
// suppressed since it belongs to the diagnostic.
- logger.Diag(line, Error, "Blue should be %s.", "orange")
+ logger.Diag(line, Error, "Blue must be %s.", "orange")
logger.Explain(
"The colors have further changed.")
t.CheckEquals(sw.String(), ""+
- "ERROR: filename:3: Blue should be orange.\n"+
+ "ERROR: filename:3: Blue must be orange.\n"+
"\n"+
"\tThe colors have changed.\n"+
"\n")
@@ -571,10 +571,10 @@
var sw strings.Builder
logger := Logger{out: NewSeparatorWriter(&sw)}
- logger.Logf(Error, "filename", "3", "Blue should be %s.", "Blue should be orange.")
+ logger.Logf(Error, "filename", "3", "Blue must be %s.", "Blue must be orange.")
t.CheckEquals(sw.String(), ""+
- "ERROR: filename:3: Blue should be orange.\n")
+ "ERROR: filename:3: Blue must be orange.\n")
}
// Logf doesn't filter duplicates, but Diag does.
@@ -584,12 +584,12 @@
var sw strings.Builder
logger := Logger{out: NewSeparatorWriter(&sw)}
- logger.Logf(Error, "filename", "3", "Blue should be %s.", "Blue should be orange.")
- logger.Logf(Error, "filename", "3", "Blue should be %s.", "Blue should be orange.")
+ logger.Logf(Error, "filename", "3", "Blue must be %s.", "Blue must be orange.")
+ logger.Logf(Error, "filename", "3", "Blue must be %s.", "Blue must be orange.")
t.CheckEquals(sw.String(), ""+
- "ERROR: filename:3: Blue should be orange.\n"+
- "ERROR: filename:3: Blue should be orange.\n")
+ "ERROR: filename:3: Blue must be orange.\n"+
+ "ERROR: filename:3: Blue must be orange.\n")
}
// Ensure that suppressing a diagnostic doesn't influence later calls to Logf.
diff -r 5f3d7d730536 -r bcfd1cfe4062 pkgtools/pkglint/files/mkassignchecker.go
--- a/pkgtools/pkglint/files/mkassignchecker.go Sun Dec 08 21:56:42 2019 +0000
+++ b/pkgtools/pkglint/files/mkassignchecker.go Sun Dec 08 22:03:37 2019 +0000
@@ -56,7 +56,7 @@
return
}
- if ck.MkLines.vars.IsUsedSimilar(varname) {
+ if ck.MkLines.allVars.IsUsedSimilar(varname) {
return
}
@@ -384,7 +384,7 @@
categories := mkline.ValueFields(mkline.Value())
actual := categories[0]
- expected := G.Pkgsrc.ToRel(mkline.Filename).DirNoClean().DirNoClean().Base()
+ expected := G.Pkgsrc.Rel(mkline.Filename).DirNoClean().DirNoClean().Base()
if expected == "wip" || actual == expected {
return
diff -r 5f3d7d730536 -r bcfd1cfe4062 pkgtools/pkglint/files/mkassignchecker_test.go
--- a/pkgtools/pkglint/files/mkassignchecker_test.go Sun Dec 08 21:56:42 2019 +0000
+++ b/pkgtools/pkglint/files/mkassignchecker_test.go Sun Dec 08 22:03:37 2019 +0000
@@ -89,7 +89,7 @@
MkCvsID,
Home |
Main Index |
Thread Index |
Old Index