summaryrefslogtreecommitdiff
path: root/pkgtools
diff options
context:
space:
mode:
authorrillig <rillig>2016-01-27 21:55:50 +0000
committerrillig <rillig>2016-01-27 21:55:50 +0000
commit3449499e1d22d57d14f5a5363b874e1276e37730 (patch)
treebfa6944ab403c463430768a0117ec5bd0f7a2c06 /pkgtools
parent6343b1a340ecdd318227889e4012151b6ae5552a (diff)
downloadpkgsrc-3449499e1d22d57d14f5a5363b874e1276e37730.tar.gz
Updated pkglint to 5.3.4
Changes since 5.3.3: * Added some unit tests * Fixed the Makefile parser to recognize seldomly-used variable modifiers like :S///S/// without intermediate colon or :ts\n * Cleaned up some unit tests * Combined diagnostics that span multiple lines into single-line ones
Diffstat (limited to 'pkgtools')
-rw-r--r--pkgtools/pkglint/Makefile4
-rw-r--r--pkgtools/pkglint/files/buildlink3.go16
-rw-r--r--pkgtools/pkglint/files/buildlink3_test.go14
-rw-r--r--pkgtools/pkglint/files/category_test.go4
-rw-r--r--pkgtools/pkglint/files/check_test.go12
-rw-r--r--pkgtools/pkglint/files/dir_test.go10
-rw-r--r--pkgtools/pkglint/files/distinfo.go4
-rw-r--r--pkgtools/pkglint/files/distinfo_test.go7
-rw-r--r--pkgtools/pkglint/files/files_test.go4
-rw-r--r--pkgtools/pkglint/files/licenses_test.go4
-rw-r--r--pkgtools/pkglint/files/line.go3
-rw-r--r--pkgtools/pkglint/files/mkline_test.go4
-rw-r--r--pkgtools/pkglint/files/mklines_test.go2
-rw-r--r--pkgtools/pkglint/files/package.go17
-rw-r--r--pkgtools/pkglint/files/package_test.go5
-rw-r--r--pkgtools/pkglint/files/parser.go19
-rw-r--r--pkgtools/pkglint/files/parser_test.go8
-rw-r--r--pkgtools/pkglint/files/patches_test.go2
-rw-r--r--pkgtools/pkglint/files/pkglint_test.go2
-rw-r--r--pkgtools/pkglint/files/plist_test.go4
-rw-r--r--pkgtools/pkglint/files/shell_test.go2
-rw-r--r--pkgtools/pkglint/files/toplevel_test.go2
-rw-r--r--pkgtools/pkglint/files/vartypecheck_test.go33
23 files changed, 112 insertions, 70 deletions
diff --git a/pkgtools/pkglint/Makefile b/pkgtools/pkglint/Makefile
index 10b12094f7f..69b87d96636 100644
--- a/pkgtools/pkglint/Makefile
+++ b/pkgtools/pkglint/Makefile
@@ -1,6 +1,6 @@
-# $NetBSD: Makefile,v 1.479 2016/01/26 21:10:42 rillig Exp $
+# $NetBSD: Makefile,v 1.480 2016/01/27 21:55:50 rillig Exp $
-PKGNAME= pkglint-5.3.3
+PKGNAME= pkglint-5.3.4
DISTFILES= # none
CATEGORIES= pkgtools
diff --git a/pkgtools/pkglint/files/buildlink3.go b/pkgtools/pkglint/files/buildlink3.go
index 7efef6a43a6..ab42134c7cd 100644
--- a/pkgtools/pkglint/files/buildlink3.go
+++ b/pkgtools/pkglint/files/buildlink3.go
@@ -85,13 +85,13 @@ func ChecklinesBuildlink3Mk(mklines *MkLines) {
// See pkgtools/createbuildlink/files/createbuildlink, keyword PKGUPPER
ucPkgbase := strings.ToUpper(strings.Replace(pkgbase, "-", "_", -1))
if ucPkgbase != pkgupper && !containsVarRef(pkgbase) {
- pkgupperLine.Error2("Package name mismatch between multiple-inclusion guard %q (expected %q) ...", pkgupper, ucPkgbase)
- pkgbaseLine.Error1("... and package name %q.", pkgbase)
+ pkgupperLine.Errorf("Package name mismatch between multiple-inclusion guard %q (expected %q) and package name %q (from %s).",
+ pkgupper, ucPkgbase, pkgbase, pkgbaseLine.ReferenceFrom(pkgupperLine))
}
if G.Pkg != nil {
if mkbase := G.Pkg.EffectivePkgbase; mkbase != "" && mkbase != pkgbase {
- pkgbaseLine.Error1("Package name mismatch between %q in this file ...", pkgbase)
- G.Pkg.EffectivePkgnameLine.Line.Error1("... and %q from the package Makefile.", mkbase)
+ pkgbaseLine.Errorf("Package name mismatch between %q in this file and %q from %s.",
+ pkgbase, mkbase, G.Pkg.EffectivePkgnameLine.Line.ReferenceFrom(pkgbaseLine))
}
}
@@ -133,15 +133,15 @@ func ChecklinesBuildlink3Mk(mklines *MkLines) {
doCheck = true
}
if doCheck && abi != nil && api != nil && abi.pkgbase != api.pkgbase && !hasPrefix(api.pkgbase, "{") {
- abiLine.Warn1("Package name mismatch between ABI %q ...", abi.pkgbase)
- apiLine.Warn1("... and API %q.", api.pkgbase)
+ abiLine.Warnf("Package name mismatch between ABI %q and API %q (from %s).",
+ abi.pkgbase, api.pkgbase, apiLine.ReferenceFrom(abiLine))
}
if doCheck {
if abi != nil && abi.lower != "" && !containsVarRef(abi.lower) {
if api != nil && api.lower != "" && !containsVarRef(api.lower) {
if pkgverCmp(abi.lower, api.lower) < 0 {
- abiLine.Warn1("ABI version %q should be at least ...", abi.lower)
- apiLine.Warn1("... API version %q.", api.lower)
+ abiLine.Warnf("ABI version %q should be at least API version %q (see %s).",
+ abi.lower, api.lower, apiLine.ReferenceFrom(abiLine))
}
}
}
diff --git a/pkgtools/pkglint/files/buildlink3_test.go b/pkgtools/pkglint/files/buildlink3_test.go
index 9bceff8b036..8fca46538a2 100644
--- a/pkgtools/pkglint/files/buildlink3_test.go
+++ b/pkgtools/pkglint/files/buildlink3_test.go
@@ -59,9 +59,7 @@ func (s *Suite) TestChecklinesBuildlink3_NameMismatch(c *check.C) {
ChecklinesBuildlink3Mk(mklines)
- c.Check(s.Output(), equals, ""+
- "ERROR: buildlink3.mk:3: Package name mismatch between \"hs-X11\" in this file ...\n"+
- "ERROR: Makefile:3: ... and \"X11\" from the package Makefile.\n")
+ c.Check(s.Output(), equals, "ERROR: buildlink3.mk:3: Package name mismatch between \"hs-X11\" in this file and \"X11\" from Makefile:3.\n")
}
func (s *Suite) TestChecklinesBuildlink3_NameMismatchMultipleInclusion(c *check.C) {
@@ -81,8 +79,7 @@ func (s *Suite) TestChecklinesBuildlink3_NameMismatchMultipleInclusion(c *check.
ChecklinesBuildlink3Mk(mklines)
c.Check(s.Output(), equals, ""+
- "ERROR: buildlink3.mk:5: Package name mismatch between multiple-inclusion guard \"PKGBASE2\" (expected \"PKGBASE1\") ...\n"+
- "ERROR: buildlink3.mk:3: ... and package name \"pkgbase1\".\n"+
+ "ERROR: buildlink3.mk:5: Package name mismatch between multiple-inclusion guard \"PKGBASE2\" (expected \"PKGBASE1\") and package name \"pkgbase1\" (from line 3).\n"+
"WARN: buildlink3.mk:9: Definition of BUILDLINK_API_DEPENDS is missing.\n")
}
@@ -105,9 +102,7 @@ func (s *Suite) TestChecklinesBuildlink3_NameMismatchAbiApi(c *check.C) {
ChecklinesBuildlink3Mk(mklines)
- c.Check(s.Output(), equals, ""+
- "WARN: buildlink3.mk:9: Package name mismatch between ABI \"hs-X12\" ...\n"+
- "WARN: buildlink3.mk:8: ... and API \"hs-X11\".\n")
+ c.Check(s.Output(), equals, "WARN: buildlink3.mk:9: Package name mismatch between ABI \"hs-X12\" and API \"hs-X11\" (from line 8).\n")
}
func (s *Suite) TestChecklinesBuildlink3_AbiApiVersions(c *check.C) {
@@ -130,8 +125,7 @@ func (s *Suite) TestChecklinesBuildlink3_AbiApiVersions(c *check.C) {
ChecklinesBuildlink3Mk(mklines)
c.Check(s.Output(), equals, ""+
- "WARN: buildlink3.mk:9: ABI version \"1.6.0\" should be at least ...\n"+
- "WARN: buildlink3.mk:8: ... API version \"1.6.1\".\n")
+ "WARN: buildlink3.mk:9: ABI version \"1.6.0\" should be at least API version \"1.6.1\" (see line 8).\n")
}
func (s *Suite) TestChecklinesBuildlink3_NoBuildlinkTreeAtBeginning(c *check.C) {
diff --git a/pkgtools/pkglint/files/category_test.go b/pkgtools/pkglint/files/category_test.go
index 01dc8f63897..1db1e059cf9 100644
--- a/pkgtools/pkglint/files/category_test.go
+++ b/pkgtools/pkglint/files/category_test.go
@@ -17,7 +17,7 @@ func (s *Suite) TestCheckdirCategory_TotallyBroken(c *check.C) {
G.CurrentDir = s.tmpdir + "/archivers"
CheckdirCategory()
- c.Check(s.OutputCleanTmpdir(), equals, ""+
+ c.Check(s.Output(), equals, ""+
"ERROR: ~/archivers/Makefile:1: Expected \"# $"+"NetBSD$\".\n"+
"WARN: ~/archivers/Makefile:4: Line contains invalid characters (U+2019).\n"+
"WARN: ~/archivers/Makefile:4: SUBDIR- is defined but not used. Spelling mistake?\n"+
@@ -49,5 +49,5 @@ func (s *Suite) TestCheckdirCategory_InvalidComment(c *check.C) {
CheckdirCategory()
- c.Check(s.OutputCleanTmpdir(), equals, "WARN: ~/archivers/Makefile:2: COMMENT contains invalid characters (U+005C U+0024 U+0024 U+0024 U+0024 U+0022).\n")
+ c.Check(s.Output(), equals, "WARN: ~/archivers/Makefile:2: COMMENT contains invalid characters (U+005C U+0024 U+0024 U+0024 U+0024 U+0022).\n")
}
diff --git a/pkgtools/pkglint/files/check_test.go b/pkgtools/pkglint/files/check_test.go
index cee87f982e2..da58cd729df 100644
--- a/pkgtools/pkglint/files/check_test.go
+++ b/pkgtools/pkglint/files/check_test.go
@@ -33,15 +33,13 @@ func (s *Suite) Stderr() string {
}
// Returns and consumes the output from both stdout and stderr.
+// The temporary directory is replaced with a tilde (~).
func (s *Suite) Output() string {
- return s.Stdout() + s.Stderr()
-}
-
-func (s *Suite) OutputCleanTmpdir() string {
- if s.tmpdir == "" {
- return "error: OutputCleanTmpdir must only be called when s.tmpdir is actually set."
+ output := s.Stdout() + s.Stderr()
+ if s.tmpdir != "" {
+ output = strings.Replace(output, s.tmpdir, "~", -1)
}
- return strings.Replace(s.Output(), s.tmpdir, "~", -1)
+ return output
}
// Arguments are either (lineno, orignl) or (lineno, orignl, textnl).
diff --git a/pkgtools/pkglint/files/dir_test.go b/pkgtools/pkglint/files/dir_test.go
index 39bf5ba59d0..0571449fe62 100644
--- a/pkgtools/pkglint/files/dir_test.go
+++ b/pkgtools/pkglint/files/dir_test.go
@@ -9,7 +9,7 @@ func (s *Suite) TestCheckDirent_outside(c *check.C) {
CheckDirent(s.tmpdir)
- c.Check(s.OutputCleanTmpdir(), equals, "ERROR: ~: Cannot determine the pkgsrc root directory for \"~\".\n")
+ c.Check(s.Output(), equals, "ERROR: ~: Cannot determine the pkgsrc root directory for \"~\".\n")
}
func (s *Suite) TestCheckDirent(c *check.C) {
@@ -21,17 +21,17 @@ func (s *Suite) TestCheckDirent(c *check.C) {
CheckDirent(s.tmpdir)
- c.Check(s.OutputCleanTmpdir(), equals, "ERROR: ~/Makefile: Must not be empty.\n")
+ c.Check(s.Output(), equals, "ERROR: ~/Makefile: Must not be empty.\n")
CheckDirent(s.tmpdir + "/category")
- c.Check(s.OutputCleanTmpdir(), equals, "ERROR: ~/category/Makefile: Must not be empty.\n")
+ c.Check(s.Output(), equals, "ERROR: ~/category/Makefile: Must not be empty.\n")
CheckDirent(s.tmpdir + "/category/package")
- c.Check(s.OutputCleanTmpdir(), equals, "ERROR: ~/category/package/Makefile: Must not be empty.\n")
+ c.Check(s.Output(), equals, "ERROR: ~/category/package/Makefile: Must not be empty.\n")
CheckDirent(s.tmpdir + "/category/package/nonexistent")
- c.Check(s.OutputCleanTmpdir(), equals, "ERROR: ~/category/package/nonexistent: No such file or directory.\n")
+ c.Check(s.Output(), equals, "ERROR: ~/category/package/nonexistent: No such file or directory.\n")
}
diff --git a/pkgtools/pkglint/files/distinfo.go b/pkgtools/pkglint/files/distinfo.go
index 8607fc30e11..07e34551142 100644
--- a/pkgtools/pkglint/files/distinfo.go
+++ b/pkgtools/pkglint/files/distinfo.go
@@ -145,8 +145,8 @@ func (ck *distinfoLinesChecker) checkGlobalMismatch(line *Line, fname, alg, hash
otherHash := G.Hash[key]
if otherHash != nil {
if otherHash.hash != hash {
- line.Errorf("The hash %s for %s is %s, ...", alg, fname, hash)
- otherHash.line.Error1("... which differs from %s.", otherHash.hash)
+ line.Errorf("The hash %s for %s is %s, which differs from %s in %s.",
+ alg, fname, hash, otherHash.hash, otherHash.line.ReferenceFrom(line))
}
} else {
G.Hash[key] = &Hash{hash, line}
diff --git a/pkgtools/pkglint/files/distinfo_test.go b/pkgtools/pkglint/files/distinfo_test.go
index 0f59e9b8c3b..008bf4ad28a 100644
--- a/pkgtools/pkglint/files/distinfo_test.go
+++ b/pkgtools/pkglint/files/distinfo_test.go
@@ -39,8 +39,7 @@ func (s *Suite) TestChecklinesDistinfo_GlobalHashMismatch(c *check.C) {
"SHA512 (pkgname-1.0.tar.gz) = 12341234"))
c.Check(s.Output(), equals, ""+
- "ERROR: distinfo:3: The hash SHA512 for pkgname-1.0.tar.gz is 12341234, ...\n"+
- "ERROR: other/distinfo:7: ... which differs from asdfasdf.\n"+
+ "ERROR: distinfo:3: The hash SHA512 for pkgname-1.0.tar.gz is 12341234, which differs from asdfasdf in other/distinfo:7.\n"+
"ERROR: distinfo:EOF: Expected SHA1, RMD160, SHA512, Size checksums for \"pkgname-1.0.tar.gz\", got SHA512.\n")
}
@@ -62,7 +61,7 @@ func (s *Suite) TestChecklinesDistinfo_UncommittedPatch(c *check.C) {
"",
"SHA1 (patch-aa) = 5ad1fb9b3c328fff5caa1a23e8f330e707dd50c0"))
- c.Check(s.OutputCleanTmpdir(), equals, ""+
+ c.Check(s.Output(), equals, ""+
"WARN: ~/distinfo:3: patches/patch-aa is registered in distinfo but not added to CVS.\n")
}
@@ -80,7 +79,7 @@ func (s *Suite) TestChecklinesDistinfo_UnrecordedPatches(c *check.C) {
"SHA512 (distfile.tar.gz) = ...",
"Size (distfile.tar.gz) = 1024 bytes"))
- c.Check(s.OutputCleanTmpdir(), equals, ""+
+ c.Check(s.Output(), equals, ""+
"ERROR: ~/distinfo: patch \"patches/patch-aa\" is not recorded. Run \""+confMake+" makepatchsum\".\n"+
"ERROR: ~/distinfo: patch \"patches/patch-src-Makefile\" is not recorded. Run \""+confMake+" makepatchsum\".\n")
}
diff --git a/pkgtools/pkglint/files/files_test.go b/pkgtools/pkglint/files/files_test.go
index 57bfb5bf801..ae588b851d0 100644
--- a/pkgtools/pkglint/files/files_test.go
+++ b/pkgtools/pkglint/files/files_test.go
@@ -71,7 +71,7 @@ func (s *Suite) TestAutofix_show(c *check.C) {
c.Check(lines[1].raw[0].textnl, equals, "XXXXX\n")
c.Check(s.LoadTmpFile(c, "Makefile"), equals, "line1\nline2\nline3\n")
- c.Check(s.OutputCleanTmpdir(), equals, ""+
+ c.Check(s.Output(), equals, ""+
"WARN: ~/Makefile:2: Something's wrong here.\n"+
"AUTOFIX: ~/Makefile:2: Replacing regular expression \".\" with \"X\".\n")
}
@@ -90,7 +90,7 @@ func (s *Suite) TestAutofix_fix(c *check.C) {
SaveAutofixChanges(lines)
c.Check(s.LoadTmpFile(c, "Makefile"), equals, "line1\nXXXXX\nline3\n")
- c.Check(s.OutputCleanTmpdir(), equals, ""+
+ c.Check(s.Output(), equals, ""+
"AUTOFIX: ~/Makefile:2: Replacing regular expression \".\" with \"X\".\n"+
"AUTOFIX: ~/Makefile: Has been auto-fixed. Please re-run pkglint.\n")
}
diff --git a/pkgtools/pkglint/files/licenses_test.go b/pkgtools/pkglint/files/licenses_test.go
index 1452876529b..1224b24f66b 100644
--- a/pkgtools/pkglint/files/licenses_test.go
+++ b/pkgtools/pkglint/files/licenses_test.go
@@ -17,11 +17,11 @@ func (s *Suite) TestChecklineLicense(c *check.C) {
checklineLicense(mkline, "gpl-v2")
- c.Check(s.OutputCleanTmpdir(), equals, "WARN: Makefile:7: License file ~/licenses/gpl-v2 does not exist.\n")
+ c.Check(s.Output(), equals, "WARN: Makefile:7: License file ~/licenses/gpl-v2 does not exist.\n")
checklineLicense(mkline, "no-profit shareware")
- c.Check(s.OutputCleanTmpdir(), equals, ""+
+ c.Check(s.Output(), equals, ""+
"WARN: Makefile:7: License file ~/licenses/no-profit does not exist.\n"+
"WARN: Makefile:7: License \"no-profit\" is deprecated.\n"+
"WARN: Makefile:7: License file ~/licenses/shareware does not exist.\n"+
diff --git a/pkgtools/pkglint/files/line.go b/pkgtools/pkglint/files/line.go
index 4cefd8024b7..3af10a65846 100644
--- a/pkgtools/pkglint/files/line.go
+++ b/pkgtools/pkglint/files/line.go
@@ -16,6 +16,7 @@ package main
import (
"fmt"
"io"
+ "path"
"strconv"
"strings"
)
@@ -77,7 +78,7 @@ func (line *Line) linenos() string {
func (line *Line) ReferenceFrom(other *Line) string {
if line.Fname != other.Fname {
- return line.Fname + ":" + line.linenos()
+ return cleanpath(relpath(path.Dir(other.Fname), line.Fname)) + ":" + line.linenos()
}
return "line " + line.linenos()
}
diff --git a/pkgtools/pkglint/files/mkline_test.go b/pkgtools/pkglint/files/mkline_test.go
index d13feb748f3..74b01ddbd44 100644
--- a/pkgtools/pkglint/files/mkline_test.go
+++ b/pkgtools/pkglint/files/mkline_test.go
@@ -177,7 +177,7 @@ func (s *Suite) TestMkLine_CheckVaralign_Advanced(c *check.C) {
mklines.Check()
- c.Check(s.OutputCleanTmpdir(), equals, ""+
+ c.Check(s.Output(), equals, ""+
"NOTE: ~/Makefile:6: This variable value should be aligned with tabs, not spaces, to column 9.\n"+
"NOTE: ~/Makefile:7: This variable value should be aligned with tabs, not spaces, to column 9.\n"+
"NOTE: ~/Makefile:12: This variable value should be aligned to column 17.\n"+
@@ -190,7 +190,7 @@ func (s *Suite) TestMkLine_CheckVaralign_Advanced(c *check.C) {
mklines.Check()
- c.Check(s.OutputCleanTmpdir(), equals, ""+
+ c.Check(s.Output(), equals, ""+
"AUTOFIX: ~/Makefile:6: Replacing \"VAR= \" with \"VAR=\\t\".\n"+
"AUTOFIX: ~/Makefile:7: Replacing \"VAR= \" with \"VAR=\\t\".\n"+
"AUTOFIX: ~/Makefile:12: Replacing \"BLOCK=\\t\" with \"BLOCK=\\t\\t\".\n"+
diff --git a/pkgtools/pkglint/files/mklines_test.go b/pkgtools/pkglint/files/mklines_test.go
index 40e5fcaf46b..1efba51ba8d 100644
--- a/pkgtools/pkglint/files/mklines_test.go
+++ b/pkgtools/pkglint/files/mklines_test.go
@@ -18,7 +18,7 @@ func (s *Suite) TestMkLines_AutofixConditionalIndentation(c *check.C) {
mklines.Check()
- c.Check(s.OutputCleanTmpdir(), equals, ""+
+ c.Check(s.Output(), equals, ""+
"AUTOFIX: ~/fname.mk:3: Replacing \".\" with \". \".\n"+
"AUTOFIX: ~/fname.mk:4: Replacing \".\" with \". \".\n"+
"AUTOFIX: ~/fname.mk:5: Replacing \".\" with \". \".\n"+
diff --git a/pkgtools/pkglint/files/package.go b/pkgtools/pkglint/files/package.go
index 527d49f7be0..a2205397407 100644
--- a/pkgtools/pkglint/files/package.go
+++ b/pkgtools/pkglint/files/package.go
@@ -362,26 +362,23 @@ func (pkg *Package) checkfilePackageMakefile(fname string, mklines *MkLines) {
}
}
- if vardef["REPLACE_PERL"] != nil && vardef["NO_CONFIGURE"] != nil {
- vardef["REPLACE_PERL"].Warn0("REPLACE_PERL is ignored when ...")
- vardef["NO_CONFIGURE"].Warn0("... NO_CONFIGURE is set.")
+ if perlLine, noconfLine := vardef["REPLACE_PERL"], vardef["NO_CONFIGURE"]; perlLine != nil && noconfLine != nil {
+ perlLine.Warn1("REPLACE_PERL is ignored when NO_CONFIGURE is set (in %s)", noconfLine.Line.ReferenceFrom(perlLine.Line))
}
if vardef["LICENSE"] == nil {
Errorf(fname, noLines, "Each package must define its LICENSE.")
}
- if vardef["GNU_CONFIGURE"] != nil && vardef["USE_LANGUAGES"] != nil {
- languagesLine := vardef["USE_LANGUAGES"]
-
- if matches(languagesLine.Comment(), `(?-i)\b(?:c|empty|none)\b`) {
+ if gnuLine, useLine := vardef["GNU_CONFIGURE"], vardef["USE_LANGUAGES"]; gnuLine != nil && useLine != nil {
+ if matches(useLine.Comment(), `(?-i)\b(?:c|empty|none)\b`) {
// Don't emit a warning, since the comment
// probably contains a statement that C is
// really not needed.
- } else if !matches(languagesLine.Value(), `(?:^|\s+)(?:c|c99|objc)(?:\s+|$)`) {
- vardef["GNU_CONFIGURE"].Warn0("GNU_CONFIGURE almost always needs a C compiler, ...")
- languagesLine.Warn0("... but \"c\" is not added to USE_LANGUAGES.")
+ } else if !matches(useLine.Value(), `(?:^|\s+)(?:c|c99|objc)(?:\s+|$)`) {
+ gnuLine.Warn1("GNU_CONFIGURE almost always needs a C compiler, but \"c\" is not added to USE_LANGUAGES in %s.",
+ useLine.Line.ReferenceFrom(gnuLine.Line))
}
}
diff --git a/pkgtools/pkglint/files/package_test.go b/pkgtools/pkglint/files/package_test.go
index 04903ee7673..ebebfa9bb67 100644
--- a/pkgtools/pkglint/files/package_test.go
+++ b/pkgtools/pkglint/files/package_test.go
@@ -121,8 +121,9 @@ func (s *Suite) TestPackage_DetermineEffectivePkgVars_Precedence(c *check.C) {
func (s *Suite) TestPackage_CheckPossibleDowngrade(c *check.C) {
G.Pkg = NewPackage("category/pkgbase")
+ G.CurPkgsrcdir = "../.."
G.Pkg.EffectivePkgname = "package-1.0nb15"
- G.Pkg.EffectivePkgnameLine = NewMkLine(NewLine("Makefile", 5, "PKGNAME=dummy", nil))
+ G.Pkg.EffectivePkgnameLine = NewMkLine(NewLine("category/pkgbase/Makefile", 5, "PKGNAME=dummy", nil))
G.globalData.LastChange = map[string]*Change{
"category/pkgbase": &Change{
Action: "Updated",
@@ -133,7 +134,7 @@ func (s *Suite) TestPackage_CheckPossibleDowngrade(c *check.C) {
G.Pkg.checkPossibleDowngrade()
- c.Check(s.Output(), equals, "WARN: Makefile:5: The package is being downgraded from 1.8 (see doc/CHANGES:116) to 1.0nb15\n")
+ c.Check(s.Output(), equals, "WARN: category/pkgbase/Makefile:5: The package is being downgraded from 1.8 (see ../../doc/CHANGES:116) to 1.0nb15\n")
G.globalData.LastChange["category/pkgbase"].Version = "1.0nb22"
diff --git a/pkgtools/pkglint/files/parser.go b/pkgtools/pkglint/files/parser.go
index 0b7f19d054c..49fadbcc402 100644
--- a/pkgtools/pkglint/files/parser.go
+++ b/pkgtools/pkglint/files/parser.go
@@ -189,12 +189,26 @@ func (p *Parser) VarUseModifiers(closing string) []string {
repl := p.repl
var modifiers []string
- for repl.AdvanceStr(":") {
+ mayOmitColon := false
+ for repl.AdvanceStr(":") || mayOmitColon {
+ mayOmitColon = false
modifierMark := repl.Mark()
switch repl.PeekByte() {
case 'E', 'H', 'L', 'O', 'Q', 'R', 'T', 's', 't', 'u':
- if repl.AdvanceRegexp(`^(E|H|L|Ox?|Q|R|T|sh|tA|tW|tl|ts.|tu|tw|u)`) {
+ if repl.AdvanceRegexp(`^(E|H|L|Ox?|Q|R|T|sh|tA|tW|tl|tu|tw|u)`) {
+ modifiers = append(modifiers, repl.Since(modifierMark))
+ continue
+ }
+ if repl.AdvanceStr("ts") {
+ rest := repl.rest
+ if len(rest) >= 2 && (rest[1] == closing[0] || rest[1] == ':') {
+ repl.Skip(1)
+ } else if len(rest) >= 1 && (rest[0] == closing[0] || rest[0] == ':') {
+ } else if repl.AdvanceRegexp(`^\\\d+`) {
+ } else {
+ break
+ }
modifiers = append(modifiers, repl.Since(modifierMark))
continue
}
@@ -221,6 +235,7 @@ func (p *Parser) VarUseModifiers(closing string) []string {
if repl.AdvanceStr(separator) {
repl.AdvanceRegexp(`^[1gW]`)
modifiers = append(modifiers, repl.Since(modifierMark))
+ mayOmitColon = true
continue
}
}
diff --git a/pkgtools/pkglint/files/parser_test.go b/pkgtools/pkglint/files/parser_test.go
index 4f66b6c2c68..6c7dad7d263 100644
--- a/pkgtools/pkglint/files/parser_test.go
+++ b/pkgtools/pkglint/files/parser_test.go
@@ -130,7 +130,11 @@ func (s *Suite) TestParser_MkTokens(c *check.C) {
token("${empty(CFLAGS):?:-cflags ${CFLAGS:Q}}", varuse("empty(CFLAGS)", "?:-cflags ${CFLAGS:Q}"))
token("${${${PKG_INFO} -E ${d} || echo:L:sh}:L:C/[^[0-9]]*/ /g:[1..3]:ts.}",
varuse("${${PKG_INFO} -E ${d} || echo:L:sh}", "L", "C/[^[0-9]]*/ /g", "[1..3]", "ts."))
+ token("${VAR:S/-//S/.//}", varuse("VAR", "S/-//", "S/.//")) // For :S and :C, the colon can be left out.
+ token("${VAR:ts}", varuse("VAR", "ts")) // The separator character can be left out.
+ token("${VAR:ts\\000012}", varuse("VAR", "ts\\000012")) // The separator character can be a long octal number.
+ token("${VAR:ts\\124}", varuse("VAR", "ts\\124")) // Or even decimal.
- parse("${VAR)", nil, "${VAR)")
- parse("$(VAR}", nil, "$(VAR}")
+ parse("${VAR)", nil, "${VAR)") // Opening brace, closing parenthesis
+ parse("$(VAR}", nil, "$(VAR}") // Opening parenthesis, closing brace
}
diff --git a/pkgtools/pkglint/files/patches_test.go b/pkgtools/pkglint/files/patches_test.go
index 317eba72c3a..486e8105c60 100644
--- a/pkgtools/pkglint/files/patches_test.go
+++ b/pkgtools/pkglint/files/patches_test.go
@@ -42,7 +42,7 @@ func (s *Suite) TestChecklinesPatch_WithoutEmptyLine(c *check.C) {
ChecklinesPatch(lines)
- c.Check(s.OutputCleanTmpdir(), equals, ""+
+ c.Check(s.Output(), equals, ""+
"AUTOFIX: ~/patch-WithoutEmptyLines:2: Inserting a line \"\" before this line.\n"+
"AUTOFIX: ~/patch-WithoutEmptyLines:3: Inserting a line \"\" before this line.\n"+
"AUTOFIX: ~/patch-WithoutEmptyLines: Has been auto-fixed. Please re-run pkglint.\n")
diff --git a/pkgtools/pkglint/files/pkglint_test.go b/pkgtools/pkglint/files/pkglint_test.go
index 8df1aa903cd..03a12d3013c 100644
--- a/pkgtools/pkglint/files/pkglint_test.go
+++ b/pkgtools/pkglint/files/pkglint_test.go
@@ -132,7 +132,7 @@ func (s *Suite) TestPackage_LoadPackageMakefile(c *check.C) {
pkg.loadPackageMakefile(makefile)
- c.Check(s.OutputCleanTmpdir(), equals, "")
+ c.Check(s.Output(), equals, "")
}
func (s *Suite) TestChecklinesDescr(c *check.C) {
diff --git a/pkgtools/pkglint/files/plist_test.go b/pkgtools/pkglint/files/plist_test.go
index 04cafbb097c..bb67ca0f69b 100644
--- a/pkgtools/pkglint/files/plist_test.go
+++ b/pkgtools/pkglint/files/plist_test.go
@@ -65,7 +65,7 @@ func (s *Suite) TestChecklinesPlist_commonEnd(c *check.C) {
ChecklinesPlist(LoadExistingLines(fname, false))
- c.Check(s.OutputCleanTmpdir(), equals, "")
+ c.Check(s.Output(), equals, "")
}
func (s *Suite) TestChecklinesPlist_conditional(c *check.C) {
@@ -122,7 +122,7 @@ func (s *Suite) TestPlistChecker_sort(c *check.C) {
NewPlistLineSorter(plines).Sort()
- c.Check(s.OutputCleanTmpdir(), equals, ""+
+ c.Check(s.Output(), equals, ""+
"AUTOFIX: ~/PLIST:1: Sorting the whole file.\n"+
"AUTOFIX: ~/PLIST: Has been auto-fixed. Please re-run pkglint.\n")
c.Check(s.LoadTmpFile(c, "PLIST"), equals, ""+
diff --git a/pkgtools/pkglint/files/shell_test.go b/pkgtools/pkglint/files/shell_test.go
index d1b37470353..e3bb4767525 100644
--- a/pkgtools/pkglint/files/shell_test.go
+++ b/pkgtools/pkglint/files/shell_test.go
@@ -387,5 +387,5 @@ func (s *Suite) TestShellLine_(c *check.C) {
NewMkLines(lines).Check()
- c.Check(s.OutputCleanTmpdir(), equals, "WARN: ~/Makefile:3--4: A shell comment does not stop at the end of line.\n")
+ c.Check(s.Output(), equals, "WARN: ~/Makefile:3--4: A shell comment does not stop at the end of line.\n")
}
diff --git a/pkgtools/pkglint/files/toplevel_test.go b/pkgtools/pkglint/files/toplevel_test.go
index 4c98f9c0753..9160bef32b6 100644
--- a/pkgtools/pkglint/files/toplevel_test.go
+++ b/pkgtools/pkglint/files/toplevel_test.go
@@ -24,7 +24,7 @@ func (s *Suite) TestCheckdirToplevel(c *check.C) {
G.CurrentDir = s.tmpdir
CheckdirToplevel()
- c.Check(s.OutputCleanTmpdir(), equals, ""+
+ c.Check(s.Output(), equals, ""+
"WARN: ~/Makefile:3: Indentation should be a single tab character.\n"+
"ERROR: ~/Makefile:6: Each subdir must only appear once.\n"+
"WARN: ~/Makefile:7: \"ignoreme\" commented out without giving a reason.\n"+
diff --git a/pkgtools/pkglint/files/vartypecheck_test.go b/pkgtools/pkglint/files/vartypecheck_test.go
index a9b866a0091..cbcb313c3b8 100644
--- a/pkgtools/pkglint/files/vartypecheck_test.go
+++ b/pkgtools/pkglint/files/vartypecheck_test.go
@@ -344,6 +344,16 @@ func (s *Suite) TestVartypeCheck_URL(c *check.C) {
c.Check(s.Output(), equals, "WARN: fname:3: \"http://example.org/download?fname=<distfile>;version=<version>\" is not a valid URL.\n")
}
+func (s *Suite) TestVartypeCheck_Varname(c *check.C) {
+ runVartypeChecks("BUILD_DEFS", opAssign, (*VartypeCheck).Varname,
+ "VARBASE",
+ "VarBase",
+ "PKG_OPTIONS_VAR.pkgbase",
+ "${INDIRECT}")
+
+ c.Check(s.Output(), equals, "WARN: fname:2: \"VarBase\" is not a valid variable name.\n")
+}
+
func (s *Suite) TestVartypeCheck_Yes(c *check.C) {
runVartypeChecks("APACHE_MODULE", opAssign, (*VartypeCheck).Yes,
"yes",
@@ -355,6 +365,29 @@ func (s *Suite) TestVartypeCheck_Yes(c *check.C) {
"WARN: fname:3: APACHE_MODULE should be set to YES or yes.\n")
}
+func (s *Suite) TestVartypeCheck_YesNo(c *check.C) {
+ runVartypeChecks("GNU_CONFIGURE", opAssign, (*VartypeCheck).YesNo,
+ "yes",
+ "no",
+ "ja",
+ "${YESVAR}")
+
+ c.Check(s.Output(), equals, ""+
+ "WARN: fname:3: GNU_CONFIGURE should be set to YES, yes, NO, or no.\n"+
+ "WARN: fname:4: GNU_CONFIGURE should be set to YES, yes, NO, or no.\n")
+}
+
+func (s *Suite) TestVartypeCheck_YesNoIndirectly(c *check.C) {
+ runVartypeChecks("GNU_CONFIGURE", opAssign, (*VartypeCheck).YesNoIndirectly,
+ "yes",
+ "no",
+ "ja",
+ "${YESVAR}")
+
+ c.Check(s.Output(), equals, ""+
+ "WARN: fname:3: GNU_CONFIGURE should be set to YES, yes, NO, or no.\n")
+}
+
func runVartypeChecks(varname string, op MkOperator, checker func(*VartypeCheck), values ...string) {
for i, value := range values {
mkline := NewMkLine(NewLine("fname", i+1, varname+op.String()+value, nil))