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: Fri Jun 12 19:14:45 UTC 2020
Modified Files:
pkgsrc/pkgtools/pkglint: Makefile
pkgsrc/pkgtools/pkglint/files: buildlink3_test.go homepage_test.go
mkassignchecker.go mkassignchecker_test.go mkline_test.go
mklinechecker.go mklines_test.go mkvarusechecker.go
mkvarusechecker_test.go package.go redundantscope_test.go
shell_test.go util.go util_test.go var.go var_test.go
vartypecheck_test.go
Log Message:
pkgtools/pkglint: update to 20.1.16
Changes since 20.1.15:
When a package adds an additional version requirement for another
package, it must do so using BUILDLINK_API_DEPENDS instead of
BUILDLINK_ABI_DEPENDS. Most packages already do this.
When a values is appended to an undefined variable using the += operator,
bmake does not add a space before, and pkglint caught up to do the same.
This change has no practical consequences though.
As always, a bit of refactoring. The method names of MkAssignChecker
contained the redundant word "varassign".
To generate a diff of this commit:
cvs rdiff -u -r1.654 -r1.655 pkgsrc/pkgtools/pkglint/Makefile
cvs rdiff -u -r1.46 -r1.47 pkgsrc/pkgtools/pkglint/files/buildlink3_test.go
cvs rdiff -u -r1.5 -r1.6 pkgsrc/pkgtools/pkglint/files/homepage_test.go
cvs rdiff -u -r1.8 -r1.9 pkgsrc/pkgtools/pkglint/files/mkassignchecker.go \
pkgsrc/pkgtools/pkglint/files/var.go
cvs rdiff -u -r1.6 -r1.7 \
pkgsrc/pkgtools/pkglint/files/mkassignchecker_test.go
cvs rdiff -u -r1.81 -r1.82 pkgsrc/pkgtools/pkglint/files/mkline_test.go
cvs rdiff -u -r1.68 -r1.69 pkgsrc/pkgtools/pkglint/files/mklinechecker.go \
pkgsrc/pkgtools/pkglint/files/shell_test.go
cvs rdiff -u -r1.63 -r1.64 pkgsrc/pkgtools/pkglint/files/mklines_test.go
cvs rdiff -u -r1.10 -r1.11 pkgsrc/pkgtools/pkglint/files/mkvarusechecker.go
cvs rdiff -u -r1.12 -r1.13 \
pkgsrc/pkgtools/pkglint/files/mkvarusechecker_test.go
cvs rdiff -u -r1.93 -r1.94 pkgsrc/pkgtools/pkglint/files/package.go
cvs rdiff -u -r1.16 -r1.17 \
pkgsrc/pkgtools/pkglint/files/redundantscope_test.go
cvs rdiff -u -r1.79 -r1.80 pkgsrc/pkgtools/pkglint/files/util.go
cvs rdiff -u -r1.53 -r1.54 pkgsrc/pkgtools/pkglint/files/util_test.go
cvs rdiff -u -r1.7 -r1.8 pkgsrc/pkgtools/pkglint/files/var_test.go
cvs rdiff -u -r1.83 -r1.84 pkgsrc/pkgtools/pkglint/files/vartypecheck_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.654 pkgsrc/pkgtools/pkglint/Makefile:1.655
--- pkgsrc/pkgtools/pkglint/Makefile:1.654 Sun Jun 7 15:49:23 2020
+++ pkgsrc/pkgtools/pkglint/Makefile Fri Jun 12 19:14:45 2020
@@ -1,6 +1,6 @@
-# $NetBSD: Makefile,v 1.654 2020/06/07 15:49:23 rillig Exp $
+# $NetBSD: Makefile,v 1.655 2020/06/12 19:14:45 rillig Exp $
-PKGNAME= pkglint-20.1.15
+PKGNAME= pkglint-20.1.16
CATEGORIES= pkgtools
DISTNAME= tools
MASTER_SITES= ${MASTER_SITE_GITHUB:=golang/}
Index: pkgsrc/pkgtools/pkglint/files/buildlink3_test.go
diff -u pkgsrc/pkgtools/pkglint/files/buildlink3_test.go:1.46 pkgsrc/pkgtools/pkglint/files/buildlink3_test.go:1.47
--- pkgsrc/pkgtools/pkglint/files/buildlink3_test.go:1.46 Sun Jun 7 15:49:23 2020
+++ pkgsrc/pkgtools/pkglint/files/buildlink3_test.go Fri Jun 12 19:14:45 2020
@@ -305,6 +305,7 @@ func (s *Suite) Test_CheckLinesBuildlink
CheckLinesBuildlink3Mk(mklines)
t.CheckOutputLines(
+ "ERROR: buildlink3.mk:10: Packages must only require API versions, not ABI versions of dependencies.",
"WARN: buildlink3.mk:9: Package name mismatch between ABI \"hs-X12\" and API \"hs-X11\" (from line 8).",
"WARN: buildlink3.mk:10: Only buildlink variables for \"hs-X11\", not \"hs-X12\" may be set in this file.")
}
Index: pkgsrc/pkgtools/pkglint/files/homepage_test.go
diff -u pkgsrc/pkgtools/pkglint/files/homepage_test.go:1.5 pkgsrc/pkgtools/pkglint/files/homepage_test.go:1.6
--- pkgsrc/pkgtools/pkglint/files/homepage_test.go:1.5 Thu Apr 30 21:15:03 2020
+++ pkgsrc/pkgtools/pkglint/files/homepage_test.go Fri Jun 12 19:14:45 2020
@@ -64,8 +64,8 @@ func (s *Suite) Test_HomepageChecker_che
vt.Output(
"WARN: filename.mk:11: HOMEPAGE should not be defined in terms of MASTER_SITEs.")
- pkg.vars.v("MASTER_SITES").firstDef = nil
- pkg.vars.v("MASTER_SITES").lastDef = nil
+ pkg.vars.create("MASTER_SITES").firstDef = nil
+ pkg.vars.create("MASTER_SITES").lastDef = nil
pkg.vars.Define("MASTER_SITES", t.NewMkLine(pkg.File("Makefile"), 5,
"MASTER_SITES=\thttps://cdn.NetBSD.org/pub/pkgsrc/distfiles/"))
@@ -76,8 +76,8 @@ func (s *Suite) Test_HomepageChecker_che
"WARN: filename.mk:21: HOMEPAGE should not be defined in terms of MASTER_SITEs. " +
"Use https://cdn.NetBSD.org/pub/pkgsrc/distfiles/ directly.")
- pkg.vars.v("MASTER_SITES").firstDef = nil
- pkg.vars.v("MASTER_SITES").lastDef = nil
+ pkg.vars.create("MASTER_SITES").firstDef = nil
+ pkg.vars.create("MASTER_SITES").lastDef = nil
pkg.vars.Define("MASTER_SITES", t.NewMkLine(pkg.File("Makefile"), 5,
"MASTER_SITES=\t${MASTER_SITE_GITHUB}"))
@@ -89,8 +89,8 @@ func (s *Suite) Test_HomepageChecker_che
vt.Output(
"WARN: filename.mk:31: HOMEPAGE should not be defined in terms of MASTER_SITEs.")
- pkg.vars.v("MASTER_SITES").firstDef = nil
- pkg.vars.v("MASTER_SITES").lastDef = nil
+ pkg.vars.create("MASTER_SITES").firstDef = nil
+ pkg.vars.create("MASTER_SITES").lastDef = nil
pkg.vars.Define("MASTER_SITES", t.NewMkLine(pkg.File("Makefile"), 5,
"MASTER_SITES=\t# none"))
Index: pkgsrc/pkgtools/pkglint/files/mkassignchecker.go
diff -u pkgsrc/pkgtools/pkglint/files/mkassignchecker.go:1.8 pkgsrc/pkgtools/pkglint/files/mkassignchecker.go:1.9
--- pkgsrc/pkgtools/pkglint/files/mkassignchecker.go:1.8 Mon Jun 1 20:49:54 2020
+++ pkgsrc/pkgtools/pkglint/files/mkassignchecker.go Fri Jun 12 19:14:45 2020
@@ -15,26 +15,27 @@ func NewMkAssignChecker(mkLine *MkLine,
return &MkAssignChecker{MkLine: mkLine, MkLines: mkLines}
}
-func (ck *MkAssignChecker) checkVarassign() {
- ck.checkVarassignLeft()
- ck.checkVarassignOp()
- ck.checkVarassignRight()
+func (ck *MkAssignChecker) check() {
+ ck.checkLeft()
+ ck.checkOp()
+ ck.checkRight()
}
-// checkVarassignLeft checks everything to the left of the assignment operator.
-func (ck *MkAssignChecker) checkVarassignLeft() {
+// checkLeft checks everything to the left of the assignment operator.
+func (ck *MkAssignChecker) checkLeft() {
varname := ck.MkLine.Varname()
if hasPrefix(varname, "_") && !G.Infrastructure && G.Pkgsrc.vartypes.Canon(varname) == nil {
ck.MkLine.Warnf("Variable names starting with an underscore (%s) are reserved for internal pkgsrc use.", varname)
}
- ck.checkVarassignLeftNotUsed()
- ck.checkVarassignLeftDeprecated()
- ck.checkVarassignLeftBsdPrefs()
- if !ck.checkVarassignLeftUserSettable() {
- ck.checkVarassignLeftPermissions()
+ ck.checkLeftNotUsed()
+ ck.checkLeftDeprecated()
+ ck.checkLeftBsdPrefs()
+ if !ck.checkLeftUserSettable() {
+ ck.checkLeftPermissions()
+ ck.checkLeftAbiDepends()
}
- ck.checkVarassignLeftRationale()
+ ck.checkLeftRationale()
NewMkLineChecker(ck.MkLines, ck.MkLine).checkTextVarUse(
ck.MkLine.Varname(),
@@ -42,10 +43,10 @@ func (ck *MkAssignChecker) checkVarassig
VucLoadTime)
}
-// checkVarassignLeftNotUsed checks whether the left-hand side of a variable
+// checkLeftNotUsed checks whether the left-hand side of a variable
// assignment is not used. If it is unused and also doesn't have a predefined
// data type, it may be a spelling mistake.
-func (ck *MkAssignChecker) checkVarassignLeftNotUsed() {
+func (ck *MkAssignChecker) checkLeftNotUsed() {
varname := ck.MkLine.Varname()
varcanon := varnameCanon(varname)
@@ -90,7 +91,7 @@ func (ck *MkAssignChecker) checkVarassig
"see mk/subst.mk for an example of such a documentation comment.")
}
-func (ck *MkAssignChecker) checkVarassignLeftDeprecated() {
+func (ck *MkAssignChecker) checkLeftDeprecated() {
varname := ck.MkLine.Varname()
if fix := G.Pkgsrc.Deprecated[varname]; fix != "" {
ck.MkLine.Warnf("Definition of %s is deprecated. %s", varname, fix)
@@ -99,7 +100,7 @@ func (ck *MkAssignChecker) checkVarassig
}
}
-func (ck *MkAssignChecker) checkVarassignLeftBsdPrefs() {
+func (ck *MkAssignChecker) checkLeftBsdPrefs() {
mkline := ck.MkLine
switch mkline.Varcanon() {
@@ -147,10 +148,10 @@ func (ck *MkAssignChecker) checkVarassig
"bsd.prefs.mk file, which will take care of everything.")
}
-// checkVarassignLeftUserSettable checks whether a package defines a
+// checkLeftUserSettable checks whether a package defines a
// variable that is marked as user-settable since it is defined in
// mk/defaults/mk.conf.
-func (ck *MkAssignChecker) checkVarassignLeftUserSettable() bool {
+func (ck *MkAssignChecker) checkLeftUserSettable() bool {
mkline := ck.MkLine
varname := mkline.Varname()
@@ -198,11 +199,11 @@ func (ck *MkAssignChecker) checkVarassig
return true
}
-// checkVarassignLeftPermissions checks the permissions for the left-hand side
+// checkLeftPermissions checks the permissions for the left-hand side
// of a variable assignment line.
//
// See checkPermissions.
-func (ck *MkAssignChecker) checkVarassignLeftPermissions() {
+func (ck *MkAssignChecker) checkLeftPermissions() {
if !G.WarnPerm {
return
}
@@ -273,7 +274,43 @@ func (ck *MkAssignChecker) checkVarassig
}
}
-func (ck *MkAssignChecker) checkVarassignLeftRationale() {
+func (ck *MkAssignChecker) checkLeftAbiDepends() {
+ mkline := ck.MkLine
+
+ varname := mkline.Varname()
+ if !hasPrefix(varname, "BUILDLINK_ABI_DEPENDS.") {
+ return
+ }
+
+ basename := mkline.Basename
+ if basename == "buildlink3.mk" {
+ varparam := varnameParam(varname)
+ bl3id := ""
+ for _, bl3line := range ck.MkLines.mklines {
+ if bl3line.IsVarassign() && bl3line.Varname() == "BUILDLINK_TREE" {
+ bl3id = bl3line.Value()
+ break
+ }
+ }
+ if varparam == bl3id {
+ return
+ }
+ }
+
+ fix := mkline.Autofix()
+ fix.Errorf("Packages must only require API versions, not ABI versions of dependencies.")
+ fix.Explain(
+ "When building a package from the sources,",
+ "the version of the installed package does not matter.",
+ "That version is specified by BUILDLINK_ABI_VERSION.",
+ "",
+ "The only version that matters is the API of the dependency,",
+ "which is selected by specifying BUILDLINK_API_DEPENDS.")
+ fix.Replace("BUILDLINK_ABI_DEPENDS", "BUILDLINK_API_DEPENDS")
+ fix.Apply()
+}
+
+func (ck *MkAssignChecker) checkLeftRationale() {
if !G.WarnExtra {
return
}
@@ -305,11 +342,11 @@ func (ck *MkAssignChecker) checkVarassig
"* has it been reported upstream?")
}
-func (ck *MkAssignChecker) checkVarassignOp() {
- ck.checkVarassignOpShell()
+func (ck *MkAssignChecker) checkOp() {
+ ck.checkOpShell()
}
-func (ck *MkAssignChecker) checkVarassignOpShell() {
+func (ck *MkAssignChecker) checkOpShell() {
mkline := ck.MkLine
switch {
@@ -356,8 +393,8 @@ func (ck *MkAssignChecker) checkVarassig
"or .for directive.")
}
-// checkVarassignLeft checks everything to the right of the assignment operator.
-func (ck *MkAssignChecker) checkVarassignRight() {
+// checkLeft checks everything to the right of the assignment operator.
+func (ck *MkAssignChecker) checkRight() {
mkline := ck.MkLine
varname := mkline.Varname()
op := mkline.Op()
@@ -372,12 +409,12 @@ func (ck *MkAssignChecker) checkVarassig
mkLineChecker.checkText(value)
mkLineChecker.checkVartype(varname, op, value, comment)
- ck.checkVarassignMisc()
+ ck.checkMisc()
- ck.checkVarassignRightVaruse()
+ ck.checkRightVaruse()
}
-func (ck *MkAssignChecker) checkVarassignRightCategory() {
+func (ck *MkAssignChecker) checkRightCategory() {
mkline := ck.MkLine
if mkline.Op() != opAssign && mkline.Op() != opAssignDefault {
return
@@ -403,7 +440,7 @@ func (ck *MkAssignChecker) checkVarassig
fix.Apply()
}
-func (ck *MkAssignChecker) checkVarassignMisc() {
+func (ck *MkAssignChecker) checkMisc() {
mkline := ck.MkLine
varname := mkline.Varname()
value := mkline.Value()
@@ -413,7 +450,7 @@ func (ck *MkAssignChecker) checkVarassig
}
if varname == "PYTHON_VERSIONS_ACCEPTED" {
- ck.checkVarassignDecreasingVersions()
+ ck.checkDecreasingVersions()
}
if mkline.Comment() == " defined" && !hasSuffix(varname, "_MK") && !hasSuffix(varname, "_COMMON") {
@@ -444,14 +481,16 @@ func (ck *MkAssignChecker) checkVarassig
if varname == "PKG_SKIP_REASON" && ck.MkLines.indentation.DependsOn("OPSYS") {
// TODO: Provide autofix for simple cases, like ".if ${OPSYS} == SunOS".
+ // This needs support for high-level refactoring tools though.
+ // As of June 2020, refactoring is limited to text replacements in single lines.
mkline.Notef("Consider setting NOT_FOR_PLATFORM instead of " +
"PKG_SKIP_REASON depending on ${OPSYS}.")
}
- ck.checkVarassignMiscRedundantInstallationDirs()
+ ck.checkMiscRedundantInstallationDirs()
}
-func (ck *MkAssignChecker) checkVarassignDecreasingVersions() {
+func (ck *MkAssignChecker) checkDecreasingVersions() {
mkline := ck.MkLine
strVersions := mkline.Fields()
intVersions := make([]int, len(strVersions))
@@ -475,7 +514,7 @@ func (ck *MkAssignChecker) checkVarassig
}
}
-func (ck *MkAssignChecker) checkVarassignMiscRedundantInstallationDirs() {
+func (ck *MkAssignChecker) checkMiscRedundantInstallationDirs() {
mkline := ck.MkLine
varname := mkline.Varname()
pkg := ck.MkLines.pkg
@@ -502,10 +541,10 @@ func (ck *MkAssignChecker) checkVarassig
}
}
-// checkVarassignRightVaruse checks that in a variable assignment,
+// checkRightVaruse checks that in a variable assignment,
// each variable used on the right-hand side of the assignment operator
// has the correct data type and quoting.
-func (ck *MkAssignChecker) checkVarassignRightVaruse() {
+func (ck *MkAssignChecker) checkRightVaruse() {
if trace.Tracing {
defer trace.Call0()()
}
@@ -524,16 +563,16 @@ func (ck *MkAssignChecker) checkVarassig
}
if vartype != nil && vartype.IsShell() {
- ck.checkVarassignVaruseShell(vartype, time)
+ ck.checkVaruseShell(vartype, time)
} else {
mkLineChecker := NewMkLineChecker(ck.MkLines, ck.MkLine)
mkLineChecker.checkTextVarUse(ck.MkLine.Value(), vartype, time)
}
}
-// checkVarassignVaruseShell is very similar to checkVarassignRightVaruse, they just differ
+// checkVaruseShell is very similar to checkRightVaruse, they just differ
// in the way they determine isWordPart.
-func (ck *MkAssignChecker) checkVarassignVaruseShell(vartype *Vartype, time VucTime) {
+func (ck *MkAssignChecker) checkVaruseShell(vartype *Vartype, time VucTime) {
if trace.Tracing {
defer trace.Call(vartype, time)()
}
Index: pkgsrc/pkgtools/pkglint/files/var.go
diff -u pkgsrc/pkgtools/pkglint/files/var.go:1.8 pkgsrc/pkgtools/pkglint/files/var.go:1.9
--- pkgsrc/pkgtools/pkglint/files/var.go:1.8 Sat Feb 15 13:48:40 2020
+++ pkgsrc/pkgtools/pkglint/files/var.go Fri Jun 12 19:14:45 2020
@@ -267,12 +267,15 @@ func (v *Var) updateConstantValue(mkline
}
case opAssignAppend:
- v.constantValue += " " + value
+ if v.constantState != 0 {
+ v.constantValue += " "
+ }
+ v.constantValue += value
default:
v.constantState = 3
v.constantValue = ""
}
- v.constantState = [...]uint8{1, 1, 3, 3}[v.constantState]
+ v.constantState |= 1
}
Index: pkgsrc/pkgtools/pkglint/files/mkassignchecker_test.go
diff -u pkgsrc/pkgtools/pkglint/files/mkassignchecker_test.go:1.6 pkgsrc/pkgtools/pkglint/files/mkassignchecker_test.go:1.7
--- pkgsrc/pkgtools/pkglint/files/mkassignchecker_test.go:1.6 Thu Apr 30 21:15:03 2020
+++ pkgsrc/pkgtools/pkglint/files/mkassignchecker_test.go Fri Jun 12 19:14:45 2020
@@ -10,14 +10,14 @@ func (s *Suite) Test_NewMkAssignChecker(
ck := NewMkAssignChecker(mklines.mklines[0], mklines)
- ck.checkVarassign()
+ ck.check()
t.CheckOutputLines(
"WARN: filename.mk:1: VAR is defined but not used.",
"WARN: filename.mk:1: OTHER is used but not defined.")
}
-func (s *Suite) Test_MkAssignChecker_checkVarassign(c *check.C) {
+func (s *Suite) Test_MkAssignChecker_check(c *check.C) {
t := s.Init(c)
t.SetUpVartypes()
@@ -34,7 +34,7 @@ func (s *Suite) Test_MkAssignChecker_che
// Pkglint once interpreted all lists as consisting of shell tokens,
// splitting this URL at the ampersand.
-func (s *Suite) Test_MkAssignChecker_checkVarassign__URL_with_shell_special_characters(c *check.C) {
+func (s *Suite) Test_MkAssignChecker_check__URL_with_shell_special_characters(c *check.C) {
t := s.Init(c)
pkg := NewPackage(t.File("graphics/gimp-fix-ca"))
@@ -48,7 +48,7 @@ func (s *Suite) Test_MkAssignChecker_che
t.CheckOutputEmpty()
}
-func (s *Suite) Test_MkAssignChecker_checkVarassign__list(c *check.C) {
+func (s *Suite) Test_MkAssignChecker_check__list(c *check.C) {
t := s.Init(c)
t.SetUpMasterSite("MASTER_SITE_GITHUB", "https://github.com/")
@@ -82,7 +82,7 @@ func (s *Suite) Test_MkAssignChecker_che
"")
}
-func (s *Suite) Test_MkAssignChecker_checkVarassignLeft(c *check.C) {
+func (s *Suite) Test_MkAssignChecker_checkLeft(c *check.C) {
t := s.Init(c)
mklines := t.NewMkLines("module.mk",
@@ -100,7 +100,7 @@ func (s *Suite) Test_MkAssignChecker_che
// Files from the pkgsrc infrastructure may define and use variables
// whose name starts with an underscore.
-func (s *Suite) Test_MkAssignChecker_checkVarassignLeft__infrastructure(c *check.C) {
+func (s *Suite) Test_MkAssignChecker_checkLeft__infrastructure(c *check.C) {
t := s.Init(c)
t.SetUpPkgsrc()
@@ -116,7 +116,7 @@ func (s *Suite) Test_MkAssignChecker_che
"WARN: ~/mk/infra.mk:2: _VARNAME is defined but not used.")
}
-func (s *Suite) Test_MkAssignChecker_checkVarassignLeft__documented_underscore(c *check.C) {
+func (s *Suite) Test_MkAssignChecker_checkLeft__documented_underscore(c *check.C) {
t := s.Init(c)
t.SetUpPkgsrc()
@@ -130,7 +130,7 @@ func (s *Suite) Test_MkAssignChecker_che
t.CheckOutputEmpty()
}
-func (s *Suite) Test_MkAssignChecker_checkVarassignLeftNotUsed__procedure_call(c *check.C) {
+func (s *Suite) Test_MkAssignChecker_checkLeftNotUsed__procedure_call(c *check.C) {
t := s.Init(c)
t.CreateFileLines("mk/pkg-build-options.mk")
@@ -156,7 +156,7 @@ func (s *Suite) Test_MkAssignChecker_che
"WARN: ~/category/package/filename.mk:6: VAR is defined but not used.")
}
-func (s *Suite) Test_MkAssignChecker_checkVarassignLeftNotUsed__procedure_call_no_tracing(c *check.C) {
+func (s *Suite) Test_MkAssignChecker_checkLeftNotUsed__procedure_call_no_tracing(c *check.C) {
t := s.Init(c)
t.DisableTracing() // Just for code coverage
@@ -172,7 +172,7 @@ func (s *Suite) Test_MkAssignChecker_che
t.CheckOutputEmpty()
}
-func (s *Suite) Test_MkAssignChecker_checkVarassignLeftNotUsed__infra(c *check.C) {
+func (s *Suite) Test_MkAssignChecker_checkLeftNotUsed__infra(c *check.C) {
t := s.Init(c)
t.CreateFileLines("mk/infra.mk",
@@ -200,7 +200,7 @@ func (s *Suite) Test_MkAssignChecker_che
"WARN: ~/category/package/Makefile:22: UNDOCUMENTED is used but not defined.")
}
-func (s *Suite) Test_MkAssignChecker_checkVarassignLeftDeprecated(c *check.C) {
+func (s *Suite) Test_MkAssignChecker_checkLeftDeprecated(c *check.C) {
t := s.Init(c)
t.SetUpPkgsrc()
@@ -211,7 +211,7 @@ func (s *Suite) Test_MkAssignChecker_che
varname+"=\t# none")
ck := NewMkAssignChecker(mklines.mklines[0], mklines)
- ck.checkVarassignLeftDeprecated()
+ ck.checkLeftDeprecated()
t.CheckOutput(diagnostics)
}
@@ -224,7 +224,7 @@ func (s *Suite) Test_MkAssignChecker_che
nil...)
}
-func (s *Suite) Test_MkAssignChecker_checkVarassignLeftBsdPrefs(c *check.C) {
+func (s *Suite) Test_MkAssignChecker_checkLeftBsdPrefs(c *check.C) {
t := s.Init(c)
t.SetUpCommandLine("-Wall", "--only", "bsd.prefs.mk")
@@ -257,7 +257,7 @@ func (s *Suite) Test_MkAssignChecker_che
// Up to 2019-12-03, pkglint didn't issue a warning if a default assignment
// to a package-settable variable appeared before one to a user-settable
// variable. This was a mistake.
-func (s *Suite) Test_MkAssignChecker_checkVarassignLeftBsdPrefs__first_time(c *check.C) {
+func (s *Suite) Test_MkAssignChecker_checkLeftBsdPrefs__first_time(c *check.C) {
t := s.Init(c)
t.SetUpVartypes()
@@ -276,7 +276,7 @@ func (s *Suite) Test_MkAssignChecker_che
"be given a default value by any package.")
}
-func (s *Suite) Test_MkAssignChecker_checkVarassignLeftBsdPrefs__vartype_nil(c *check.C) {
+func (s *Suite) Test_MkAssignChecker_checkLeftBsdPrefs__vartype_nil(c *check.C) {
t := s.Init(c)
mklines := t.NewMkLines("builtin.mk",
@@ -290,7 +290,7 @@ func (s *Suite) Test_MkAssignChecker_che
"WARN: builtin.mk:2: Please include \"../../mk/bsd.prefs.mk\" before using \"?=\".")
}
-func (s *Suite) Test_MkAssignChecker_checkVarassignLeftUserSettable(c *check.C) {
+func (s *Suite) Test_MkAssignChecker_checkLeftUserSettable(c *check.C) {
t := s.Init(c)
// TODO: Allow CreateFileLines before SetUpPackage, since it matches
@@ -335,7 +335,7 @@ func (s *Suite) Test_MkAssignChecker_che
"which differs from the default value \"default\" from mk/defaults/mk.conf.")
}
-func (s *Suite) Test_MkAssignChecker_checkVarassignLeftUserSettable__before_prefs(c *check.C) {
+func (s *Suite) Test_MkAssignChecker_checkLeftUserSettable__before_prefs(c *check.C) {
t := s.Init(c)
t.SetUpCommandLine("-Wall", "--explain")
@@ -358,7 +358,7 @@ func (s *Suite) Test_MkAssignChecker_che
"")
}
-func (s *Suite) Test_MkAssignChecker_checkVarassignLeftUserSettable__after_prefs(c *check.C) {
+func (s *Suite) Test_MkAssignChecker_checkLeftUserSettable__after_prefs(c *check.C) {
t := s.Init(c)
t.SetUpCommandLine("-Wall", "--explain")
@@ -377,7 +377,7 @@ func (s *Suite) Test_MkAssignChecker_che
"NOTE: Makefile:21: Redundant definition for AFTER from mk/defaults/mk.conf.")
}
-func (s *Suite) Test_MkAssignChecker_checkVarassignLeftUserSettable__vartype_nil(c *check.C) {
+func (s *Suite) Test_MkAssignChecker_checkLeftUserSettable__vartype_nil(c *check.C) {
t := s.Init(c)
t.CreateFileLines("category/package/allVars.mk",
@@ -405,7 +405,7 @@ func (s *Suite) Test_MkAssignChecker_che
"WARN: Makefile:20: USER_SETTABLE is defined but not used.")
}
-func (s *Suite) Test_MkAssignChecker_checkVarassignLeftPermissions__hacks_mk(c *check.C) {
+func (s *Suite) Test_MkAssignChecker_checkLeftPermissions__hacks_mk(c *check.C) {
t := s.Init(c)
t.SetUpVartypes()
@@ -422,7 +422,7 @@ func (s *Suite) Test_MkAssignChecker_che
t.CheckOutputEmpty()
}
-func (s *Suite) Test_MkAssignChecker_checkVarassignLeftPermissions(c *check.C) {
+func (s *Suite) Test_MkAssignChecker_checkLeftPermissions(c *check.C) {
t := s.Init(c)
t.SetUpVartypes()
@@ -466,7 +466,7 @@ func (s *Suite) Test_MkAssignChecker_che
"but not options.mk.")
}
-func (s *Suite) Test_MkAssignChecker_checkVarassignLeftPermissions__no_tracing(c *check.C) {
+func (s *Suite) Test_MkAssignChecker_checkLeftPermissions__no_tracing(c *check.C) {
t := s.Init(c)
t.SetUpVartypes()
@@ -483,7 +483,7 @@ func (s *Suite) Test_MkAssignChecker_che
// languages like Perl or Python that suggest certain licenses.
//
// The default license is typically set in a Makefile.common or module.mk.
-func (s *Suite) Test_MkAssignChecker_checkVarassignLeftPermissions__license_default(c *check.C) {
+func (s *Suite) Test_MkAssignChecker_checkLeftPermissions__license_default(c *check.C) {
t := s.Init(c)
t.SetUpPkgsrc()
@@ -502,7 +502,7 @@ func (s *Suite) Test_MkAssignChecker_che
}
// Don't check the permissions for infrastructure files since they have their own rules.
-func (s *Suite) Test_MkAssignChecker_checkVarassignLeftPermissions__infrastructure(c *check.C) {
+func (s *Suite) Test_MkAssignChecker_checkLeftPermissions__infrastructure(c *check.C) {
t := s.Init(c)
t.SetUpVartypes()
@@ -517,7 +517,26 @@ func (s *Suite) Test_MkAssignChecker_che
t.CheckOutputEmpty()
}
-func (s *Suite) Test_MkAssignChecker_checkVarassignLeftRationale(c *check.C) {
+// Seen in x11/gtkmm3 before 2020-06-07.
+func (s *Suite) Test_MkAssignChecker_checkLeftAbiDepends(c *check.C) {
+ t := s.Init(c)
+
+ t.SetUpPackage("category/package",
+ "BUILDLINK_ABI_DEPENDS.lib+=\tlib>=1.0")
+ t.Chdir("category/package")
+ t.FinishSetUp()
+
+ G.Check(".")
+
+ // It may be a good idea to not only check the buildlink identifier
+ // for ${BUILDLINK_PREFIX.*} but also for appending to
+ // BUILDLINK_API_DEPENDS and BUILDLINK_ABI_DEPENDS.
+ t.CheckOutputLines(
+ "ERROR: Makefile:20: Packages must only require API versions, " +
+ "not ABI versions of dependencies.")
+}
+
+func (s *Suite) Test_MkAssignChecker_checkLeftRationale(c *check.C) {
t := s.Init(c)
t.SetUpVartypes()
@@ -608,7 +627,7 @@ func (s *Suite) Test_MkAssignChecker_che
nil...)
}
-func (s *Suite) Test_MkAssignChecker_checkVarassignOp(c *check.C) {
+func (s *Suite) Test_MkAssignChecker_checkOp(c *check.C) {
t := s.Init(c)
t.SetUpTool("uname", "UNAME", AfterPrefsMk)
@@ -630,7 +649,7 @@ func (s *Suite) Test_MkAssignChecker_che
"bsd.prefs.mk has to be included before.")
}
-func (s *Suite) Test_MkAssignChecker_checkVarassignOpShell(c *check.C) {
+func (s *Suite) Test_MkAssignChecker_checkOpShell(c *check.C) {
t := s.Init(c)
t.SetUpTool("uname", "UNAME", AfterPrefsMk)
@@ -706,7 +725,7 @@ func (s *Suite) Test_MkAssignChecker_che
"WARN: ~/category/package/standalone.mk:15: Please use \"${ECHO}\" instead of \"echo\".")
}
-func (s *Suite) Test_MkAssignChecker_checkVarassignRight(c *check.C) {
+func (s *Suite) Test_MkAssignChecker_checkRight(c *check.C) {
t := s.Init(c)
t.SetUpVartypes()
@@ -715,7 +734,7 @@ func (s *Suite) Test_MkAssignChecker_che
mklines.ForEach(func(mkline *MkLine) {
ck := NewMkAssignChecker(mkline, mklines)
- ck.checkVarassignRight()
+ ck.checkRight()
})
// No warning about the UNKNOWN variable on the left-hand side,
@@ -726,7 +745,7 @@ func (s *Suite) Test_MkAssignChecker_che
"WARN: filename.mk:1: Unknown shell command \"make\".")
}
-func (s *Suite) Test_MkAssignChecker_checkVarassignRightCategory__none(c *check.C) {
+func (s *Suite) Test_MkAssignChecker_checkRightCategory__none(c *check.C) {
t := s.Init(c)
t.SetUpPackage("obscure/package",
@@ -738,7 +757,7 @@ func (s *Suite) Test_MkAssignChecker_che
t.CheckOutputEmpty()
}
-func (s *Suite) Test_MkAssignChecker_checkVarassignRightCategory__indirect(c *check.C) {
+func (s *Suite) Test_MkAssignChecker_checkRightCategory__indirect(c *check.C) {
t := s.Init(c)
t.SetUpPackage("obscure/package",
@@ -756,7 +775,7 @@ func (s *Suite) Test_MkAssignChecker_che
"Invalid category \"${PKGPATH:C,/.*,,}\".")
}
-func (s *Suite) Test_MkAssignChecker_checkVarassignRightCategory__wrong(c *check.C) {
+func (s *Suite) Test_MkAssignChecker_checkRightCategory__wrong(c *check.C) {
t := s.Init(c)
t.SetUpPackage("obscure/package",
@@ -769,7 +788,7 @@ func (s *Suite) Test_MkAssignChecker_che
"WARN: ~/obscure/package/Makefile:5: The primary category should be \"obscure\", not \"perl5\".")
}
-func (s *Suite) Test_MkAssignChecker_checkVarassignRightCategory__wrong_in_package_directory(c *check.C) {
+func (s *Suite) Test_MkAssignChecker_checkRightCategory__wrong_in_package_directory(c *check.C) {
t := s.Init(c)
t.SetUpPackage("obscure/package",
@@ -785,7 +804,7 @@ func (s *Suite) Test_MkAssignChecker_che
// Allow any primary category in "packages" from regress/*.
// These packages won't be installed in a regular pkgsrc installation anyway.
-func (s *Suite) Test_MkAssignChecker_checkVarassignRightCategory__regress(c *check.C) {
+func (s *Suite) Test_MkAssignChecker_checkRightCategory__regress(c *check.C) {
t := s.Init(c)
t.SetUpPackage("regress/regress-package",
@@ -802,7 +821,7 @@ func (s *Suite) Test_MkAssignChecker_che
t.CheckOutputEmpty()
}
-func (s *Suite) Test_MkAssignChecker_checkVarassignRightCategory__append(c *check.C) {
+func (s *Suite) Test_MkAssignChecker_checkRightCategory__append(c *check.C) {
t := s.Init(c)
t.SetUpPackage("obscure/package",
@@ -817,7 +836,7 @@ func (s *Suite) Test_MkAssignChecker_che
t.CheckOutputEmpty()
}
-func (s *Suite) Test_MkAssignChecker_checkVarassignRightCategory__default(c *check.C) {
+func (s *Suite) Test_MkAssignChecker_checkRightCategory__default(c *check.C) {
t := s.Init(c)
t.SetUpPackage("obscure/package",
@@ -831,7 +850,7 @@ func (s *Suite) Test_MkAssignChecker_che
"WARN: ~/obscure/package/Makefile:5: The primary category should be \"obscure\", not \"perl5\".")
}
-func (s *Suite) Test_MkAssignChecker_checkVarassignRightCategory__autofix(c *check.C) {
+func (s *Suite) Test_MkAssignChecker_checkRightCategory__autofix(c *check.C) {
t := s.Init(c)
t.SetUpCommandLine("-Wall", "--autofix")
@@ -846,7 +865,7 @@ func (s *Suite) Test_MkAssignChecker_che
"Replacing \"perl5 obscure\" with \"obscure perl5\".")
}
-func (s *Suite) Test_MkAssignChecker_checkVarassignRightCategory__third(c *check.C) {
+func (s *Suite) Test_MkAssignChecker_checkRightCategory__third(c *check.C) {
t := s.Init(c)
t.SetUpPackage("obscure/package",
@@ -865,7 +884,7 @@ func (s *Suite) Test_MkAssignChecker_che
t.CheckOutputEmpty()
}
-func (s *Suite) Test_MkAssignChecker_checkVarassignRightCategory__other_file(c *check.C) {
+func (s *Suite) Test_MkAssignChecker_checkRightCategory__other_file(c *check.C) {
t := s.Init(c)
t.SetUpPackage("obscure/package",
@@ -885,7 +904,7 @@ func (s *Suite) Test_MkAssignChecker_che
"The primary category should be \"obscure\", not \"perl5\".")
}
-func (s *Suite) Test_MkAssignChecker_checkVarassignMisc(c *check.C) {
+func (s *Suite) Test_MkAssignChecker_checkMisc(c *check.C) {
t := s.Init(c)
t.SetUpPkgsrc()
@@ -946,7 +965,7 @@ func (s *Suite) Test_MkAssignChecker_che
"as it includes the PKGREVISION. Please use PKGVERSION_NOREV instead.")
}
-func (s *Suite) Test_MkAssignChecker_checkVarassignMisc__multiple_inclusion_guards(c *check.C) {
+func (s *Suite) Test_MkAssignChecker_checkMisc__multiple_inclusion_guards(c *check.C) {
t := s.Init(c)
t.SetUpPkgsrc()
@@ -977,7 +996,7 @@ func (s *Suite) Test_MkAssignChecker_che
"instead of \"# defined\".")
}
-func (s *Suite) Test_MkAssignChecker_checkVarassignDecreasingVersions(c *check.C) {
+func (s *Suite) Test_MkAssignChecker_checkDecreasingVersions(c *check.C) {
t := s.Init(c)
t.SetUpVartypes()
@@ -996,7 +1015,7 @@ func (s *Suite) Test_MkAssignChecker_che
mklines.Check()
// Half of these warnings are from VartypeCheck.Enum,
- // the other half are from checkVarassignDecreasingVersions.
+ // the other half are from checkDecreasingVersions.
// Strictly speaking some of them are redundant, but that's ok.
// They all need to be fixed in the end.
t.CheckOutputLines(
@@ -1016,7 +1035,7 @@ func (s *Suite) Test_MkAssignChecker_che
"Use one of { 27 36 37 38 } instead.")
}
-func (s *Suite) Test_MkAssignChecker_checkVarassignMiscRedundantInstallationDirs__AUTO_MKDIRS_yes(c *check.C) {
+func (s *Suite) Test_MkAssignChecker_checkMiscRedundantInstallationDirs__AUTO_MKDIRS_yes(c *check.C) {
t := s.Init(c)
t.SetUpPackage("category/package",
@@ -1037,7 +1056,7 @@ func (s *Suite) Test_MkAssignChecker_che
"The directory \"man\" is redundant in INSTALLATION_DIRS.")
}
-func (s *Suite) Test_MkAssignChecker_checkVarassignMiscRedundantInstallationDirs__AUTO_MKDIRS_no(c *check.C) {
+func (s *Suite) Test_MkAssignChecker_checkMiscRedundantInstallationDirs__AUTO_MKDIRS_no(c *check.C) {
t := s.Init(c)
t.SetUpPackage("category/package",
@@ -1054,7 +1073,7 @@ func (s *Suite) Test_MkAssignChecker_che
t.CheckOutputEmpty()
}
-func (s *Suite) Test_MkAssignChecker_checkVarassignMiscRedundantInstallationDirs__absolute(c *check.C) {
+func (s *Suite) Test_MkAssignChecker_checkMiscRedundantInstallationDirs__absolute(c *check.C) {
t := s.Init(c)
t.SetUpPackage("category/package",
@@ -1074,7 +1093,7 @@ func (s *Suite) Test_MkAssignChecker_che
"must be relative to ${PREFIX}.")
}
-func (s *Suite) Test_MkAssignChecker_checkVarassignRightVaruse(c *check.C) {
+func (s *Suite) Test_MkAssignChecker_checkRightVaruse(c *check.C) {
t := s.Init(c)
t.SetUpVartypes()
@@ -1090,7 +1109,7 @@ func (s *Suite) Test_MkAssignChecker_che
"NOTE: module.mk:2: The :Q modifier isn't necessary for ${LOCALBASE} here.")
}
-func (s *Suite) Test_MkAssignChecker_checkVarassignVaruseShell(c *check.C) {
+func (s *Suite) Test_MkAssignChecker_checkVaruseShell(c *check.C) {
t := s.Init(c)
mklines := t.NewMkLines("filename.mk",
@@ -1098,7 +1117,7 @@ func (s *Suite) Test_MkAssignChecker_che
mklines.ForEach(func(mkline *MkLine) {
ck := NewMkAssignChecker(mkline, mklines)
- ck.checkVarassignRight()
+ ck.checkRight()
})
t.CheckOutputLines(
Index: pkgsrc/pkgtools/pkglint/files/mkline_test.go
diff -u pkgsrc/pkgtools/pkglint/files/mkline_test.go:1.81 pkgsrc/pkgtools/pkglint/files/mkline_test.go:1.82
--- pkgsrc/pkgtools/pkglint/files/mkline_test.go:1.81 Sat May 9 19:26:11 2020
+++ pkgsrc/pkgtools/pkglint/files/mkline_test.go Fri Jun 12 19:14:45 2020
@@ -634,7 +634,7 @@ func (s *Suite) Test_MkLine_VariableNeed
t.CheckEquals(nq, no)
- NewMkAssignChecker(mkline, mklines).checkVarassign()
+ NewMkAssignChecker(mkline, mklines).check()
t.CheckOutputEmpty() // Up to version 5.3.6, pkglint warned about a missing :Q here, which was wrong.
}
@@ -648,7 +648,7 @@ func (s *Suite) Test_MkLine_VariableNeed
MkCvsID,
"MASTER_SITES=\t${MASTER_SITE_SOURCEFORGE:=squirrel-sql/}")
- NewMkAssignChecker(mklines.mklines[1], mklines).checkVarassign()
+ NewMkAssignChecker(mklines.mklines[1], mklines).check()
// Assigning lists to lists is ok.
t.CheckOutputEmpty()
@@ -669,7 +669,7 @@ func (s *Suite) Test_MkLine_VariableNeed
mklines.ForEach(func(mkline *MkLine) {
if mkline.IsVarassign() {
- NewMkAssignChecker(mkline, mklines).checkVarassign()
+ NewMkAssignChecker(mkline, mklines).check()
}
})
@@ -685,7 +685,7 @@ func (s *Suite) Test_MkLine_VariableNeed
MkCvsID,
"SUBST_SED.hpath=\t-e 's|^\\(INSTALL[\t:]*=\\).*|\\1${INSTALL}|'")
- NewMkAssignChecker(mklines.mklines[1], mklines).checkVarassign()
+ NewMkAssignChecker(mklines.mklines[1], mklines).check()
t.CheckOutputLines(
"WARN: Makefile:2: Please use ${INSTALL:Q} instead of ${INSTALL} " +
@@ -933,7 +933,7 @@ func (s *Suite) Test_MkLine_VariableNeed
MkCvsID,
"MASTER_SITES=\tftp://ftp.gtk.org/${PKGNAME}/ ${MASTER_SITE_GNOME:=subdir/}")
- NewMkAssignChecker(mklines.mklines[1], mklines).checkVarassignRightVaruse()
+ NewMkAssignChecker(mklines.mklines[1], mklines).checkRightVaruse()
t.CheckOutputEmpty() // Don't warn about missing :Q modifiers.
}
@@ -948,7 +948,7 @@ func (s *Suite) Test_MkLine_VariableNeed
"",
"CONFIGURE_ENV+=\tSYS_TAR_COMMAND_PATH=${TOOLS_TAR:Q}")
- NewMkAssignChecker(mklines.mklines[2], mklines).checkVarassignRightVaruse()
+ NewMkAssignChecker(mklines.mklines[2], mklines).checkRightVaruse()
// The TOOLS_* variables only contain the path to the tool,
// without any additional arguments that might be necessary
@@ -969,8 +969,8 @@ func (s *Suite) Test_MkLine_VariableNeed
"COMPILE_CMD=\tcc `${CAT} ${WRKDIR}/compileflags`",
"COMMENT_CMD=\techo `echo ${COMMENT}`")
- NewMkAssignChecker(mklines.mklines[2], mklines).checkVarassignRightVaruse()
- NewMkAssignChecker(mklines.mklines[3], mklines).checkVarassignRightVaruse()
+ NewMkAssignChecker(mklines.mklines[2], mklines).checkRightVaruse()
+ NewMkAssignChecker(mklines.mklines[3], mklines).checkRightVaruse()
// Both CAT and WRKDIR are safe from quoting, therefore no warnings.
// But COMMENT may contain arbitrary characters and therefore must
Index: pkgsrc/pkgtools/pkglint/files/mklinechecker.go
diff -u pkgsrc/pkgtools/pkglint/files/mklinechecker.go:1.68 pkgsrc/pkgtools/pkglint/files/mklinechecker.go:1.69
--- pkgsrc/pkgtools/pkglint/files/mklinechecker.go:1.68 Mon Jun 1 20:49:54 2020
+++ pkgsrc/pkgtools/pkglint/files/mklinechecker.go Fri Jun 12 19:14:45 2020
@@ -24,7 +24,7 @@ func (ck MkLineChecker) Check() {
switch {
case mkline.IsVarassign():
- NewMkAssignChecker(mkline, ck.MkLines).checkVarassign()
+ NewMkAssignChecker(mkline, ck.MkLines).check()
case mkline.IsShellCommand():
ck.checkShellCommand()
@@ -171,7 +171,7 @@ func (ck MkLineChecker) checkVartype(var
}
if vartype.basicType == BtCategory {
mkAssignChecker := NewMkAssignChecker(mkline, ck.MkLines)
- mkAssignChecker.checkVarassignRightCategory()
+ mkAssignChecker.checkRightCategory()
}
for _, word := range words {
ck.CheckVartypeBasic(varname, vartype.basicType, op, word, comment, vartype.IsGuessed())
Index: pkgsrc/pkgtools/pkglint/files/shell_test.go
diff -u pkgsrc/pkgtools/pkglint/files/shell_test.go:1.68 pkgsrc/pkgtools/pkglint/files/shell_test.go:1.69
--- pkgsrc/pkgtools/pkglint/files/shell_test.go:1.68 Sat May 9 19:26:11 2020
+++ pkgsrc/pkgtools/pkglint/files/shell_test.go Fri Jun 12 19:14:45 2020
@@ -1393,7 +1393,7 @@ func (s *Suite) Test_ShellLineChecker_Ch
t.SetUpVartypes()
test := func(shellWord string, checkQuoting bool, diagnostics ...string) {
- // See checkVaruseUndefined and checkVarassignLeftNotUsed.
+ // See MkVarUseChecker.checkUndefined and MkAssignChecker.checkLeftNotUsed.
ck := t.NewShellLineChecker("\t echo " + shellWord)
ck.CheckWord(shellWord, checkQuoting, RunTime)
t.CheckOutput(diagnostics)
Index: pkgsrc/pkgtools/pkglint/files/mklines_test.go
diff -u pkgsrc/pkgtools/pkglint/files/mklines_test.go:1.63 pkgsrc/pkgtools/pkglint/files/mklines_test.go:1.64
--- pkgsrc/pkgtools/pkglint/files/mklines_test.go:1.63 Sat Mar 7 23:35:35 2020
+++ pkgsrc/pkgtools/pkglint/files/mklines_test.go Fri Jun 12 19:14:45 2020
@@ -222,6 +222,28 @@ func (s *Suite) Test_MkLines_Check__PKG_
"NOTE: Makefile:7: Consider setting NOT_FOR_PLATFORM instead of PKG_SKIP_REASON depending on ${OPSYS}.")
}
+func (s *Suite) Test_MkLines_Check__PKG_SKIP_REASON_depending_on_OPSYS_and_others(c *check.C) {
+ t := s.Init(c)
+
+ t.SetUpPkgsrc()
+ t.Chdir("category/package")
+ t.FinishSetUp()
+ mklines := t.NewMkLines("Makefile",
+ MkCvsID,
+ "",
+ ".include \"../../mk/bsd.prefs.mk\"",
+ "",
+ "PKG_SKIP_REASON+=\t\"Fails everywhere\"",
+ ".if ${OPSYS} == \"Cygwin\" && ${MACHINE_ARCH} == i386",
+ "PKG_SKIP_REASON+=\t\"Fails on Cygwin i386\"",
+ ".endif")
+
+ mklines.Check()
+
+ t.CheckOutputLines(
+ "NOTE: Makefile:7: Consider setting NOT_FOR_PLATFORM instead of PKG_SKIP_REASON depending on ${OPSYS}.")
+}
+
func (s *Suite) Test_MkLines_Check__use_list_variable_as_part_of_word(c *check.C) {
t := s.Init(c)
@@ -495,7 +517,7 @@ func (s *Suite) Test_MkLines_collectUsed
mklines.collectUsedVariables()
t.Check(mklines.allVars.vs, check.HasLen, 1)
- t.CheckEquals(mklines.allVars.v("VAR").used, mkline)
+ t.CheckEquals(mklines.allVars.create("VAR").used, mkline)
t.CheckEquals(mklines.allVars.FirstUse("VAR"), mkline)
}
Index: pkgsrc/pkgtools/pkglint/files/mkvarusechecker.go
diff -u pkgsrc/pkgtools/pkglint/files/mkvarusechecker.go:1.10 pkgsrc/pkgtools/pkglint/files/mkvarusechecker.go:1.11
--- pkgsrc/pkgtools/pkglint/files/mkvarusechecker.go:1.10 Sun Jun 7 15:49:23 2020
+++ pkgsrc/pkgtools/pkglint/files/mkvarusechecker.go Fri Jun 12 19:14:45 2020
@@ -194,7 +194,7 @@ func (ck *MkVarUseChecker) checkVarnameB
// be it in a variable assignment, in a shell command, a conditional, or
// somewhere else.
//
-// See checkVarassignLeftPermissions.
+// See MkAssignChecker.checkLeftPermissions.
func (ck *MkVarUseChecker) checkPermissions(vuc *VarUseContext) {
if !G.WarnPerm {
return
Index: pkgsrc/pkgtools/pkglint/files/mkvarusechecker_test.go
diff -u pkgsrc/pkgtools/pkglint/files/mkvarusechecker_test.go:1.12 pkgsrc/pkgtools/pkglint/files/mkvarusechecker_test.go:1.13
--- pkgsrc/pkgtools/pkglint/files/mkvarusechecker_test.go:1.12 Sun Jun 7 15:49:23 2020
+++ pkgsrc/pkgtools/pkglint/files/mkvarusechecker_test.go Fri Jun 12 19:14:45 2020
@@ -1083,7 +1083,7 @@ func (s *Suite) Test_MkVarUseChecker_che
mklines.ForEach(func(mkline *MkLine) {
ck := NewMkAssignChecker(mkline, mklines)
- ck.checkVarassignRight()
+ ck.checkRight()
})
t.CheckOutputLines(
@@ -1117,7 +1117,7 @@ func (s *Suite) Test_MkVarUseChecker_che
mklines.ForEach(func(mkline *MkLine) {
ck := NewMkAssignChecker(mkline, mklines)
- ck.checkVarassignRight()
+ ck.checkRight()
})
t.CheckOutputLines(
Index: pkgsrc/pkgtools/pkglint/files/package.go
diff -u pkgsrc/pkgtools/pkglint/files/package.go:1.93 pkgsrc/pkgtools/pkglint/files/package.go:1.94
--- pkgsrc/pkgtools/pkglint/files/package.go:1.93 Sun Jun 7 15:49:23 2020
+++ pkgsrc/pkgtools/pkglint/files/package.go Fri Jun 12 19:14:45 2020
@@ -118,7 +118,7 @@ func NewPackage(dir CurrPath) *Package {
conditionalIncludes: make(map[PackagePath]*MkLine),
unconditionalIncludes: make(map[PackagePath]*MkLine),
}
- pkg.vars.DefineAll(G.Pkgsrc.UserDefinedVars)
+ pkg.vars.DefineAll(&G.Pkgsrc.UserDefinedVars)
pkg.vars.Fallback("PKGDIR", ".")
pkg.vars.Fallback("DISTINFO_FILE", "${PKGDIR}/distinfo")
@@ -157,7 +157,7 @@ func (pkg *Package) load() ([]CurrPath,
files = append(files, pkg.File(pkg.Pkgdir).ReadPaths()...)
}
files = append(files, pkg.File(pkg.Patchdir).ReadPaths()...)
- if pkg.DistinfoFile != NewPackagePathString(pkg.vars.v("DISTINFO_FILE").fallback) {
+ if pkg.DistinfoFile != NewPackagePathString(pkg.vars.create("DISTINFO_FILE").fallback) {
files = append(files, pkg.File(pkg.DistinfoFile))
}
Index: pkgsrc/pkgtools/pkglint/files/redundantscope_test.go
diff -u pkgsrc/pkgtools/pkglint/files/redundantscope_test.go:1.16 pkgsrc/pkgtools/pkglint/files/redundantscope_test.go:1.17
--- pkgsrc/pkgtools/pkglint/files/redundantscope_test.go:1.16 Sun Jun 7 15:49:23 2020
+++ pkgsrc/pkgtools/pkglint/files/redundantscope_test.go Fri Jun 12 19:14:45 2020
@@ -428,6 +428,7 @@ func (s *Suite) Test_RedundantScope__bef
"NOTE: including.mk:2: Default assignment of VAR.def.asg has no effect because of included.mk:2.",
"NOTE: including.mk:4: Definition of VAR.asg.def is redundant because of included.mk:4.",
"NOTE: including.mk:5: Definition of VAR.asg.asg is redundant because of included.mk:5.",
+ "NOTE: including.mk:7: Definition of VAR.app.def is redundant because of included.mk:7.",
"WARN: including.mk:8: Variable VAR.app.asg is overwritten in included.mk:8.")
}
Index: pkgsrc/pkgtools/pkglint/files/util.go
diff -u pkgsrc/pkgtools/pkglint/files/util.go:1.79 pkgsrc/pkgtools/pkglint/files/util.go:1.80
--- pkgsrc/pkgtools/pkglint/files/util.go:1.79 Sat Jun 6 20:42:56 2020
+++ pkgsrc/pkgtools/pkglint/files/util.go Fri Jun 12 19:14:45 2020
@@ -617,7 +617,8 @@ func (o *Once) check(key uint64) bool {
//
// See also RedundantScope.
type Scope struct {
- vs map[string]*scopeVar
+ vs map[string]*scopeVar
+ names []string
}
type scopeVar struct {
@@ -631,15 +632,30 @@ type scopeVar struct {
}
func NewScope() Scope {
- return Scope{make(map[string]*scopeVar)}
+ return Scope{make(map[string]*scopeVar), nil}
}
-func (s *Scope) v(varname string) *scopeVar {
- if v, found := s.vs[varname]; found {
+func (s *Scope) varnames() []string {
+ if len(s.names) == 0 && len(s.vs) > 0 {
+ varnames := make([]string, len(s.vs))
+ i := 0
+ for varname := range s.vs {
+ varnames[i] = varname
+ i++
+ }
+ sort.Strings(varnames)
+ s.names = varnames
+ }
+ return s.names
+}
+
+func (s *Scope) create(varname string) *scopeVar {
+ if v := s.vs[varname]; v != nil {
return v
}
var sv scopeVar
s.vs[varname] = &sv
+ s.names = nil
return &sv
}
@@ -653,7 +669,7 @@ func (s *Scope) Define(varname string, m
}
func (s *Scope) def(name string, mkline *MkLine) {
- v := s.v(name)
+ v := s.create(name)
if v.firstDef == nil {
v.firstDef = mkline
if trace.Tracing {
@@ -694,13 +710,13 @@ func (s *Scope) def(name string, mkline
}
func (s *Scope) Fallback(varname string, value string) {
- s.v(varname).fallback = value
+ s.create(varname).fallback = value
}
// Use marks the variable and its canonicalized form as used.
func (s *Scope) Use(varname string, line *MkLine, time VucTime) {
use := func(name string) {
- v := s.v(name)
+ v := s.create(name)
if v.used == nil {
v.used = line
if trace.Tracing {
@@ -721,7 +737,10 @@ func (s *Scope) Use(varname string, line
// - mentioned in a commented variable assignment,
// - mentioned in a documentation comment.
func (s *Scope) Mentioned(varname string) *MkLine {
- return s.v(varname).firstDef
+ if v := s.vs[varname]; v != nil {
+ return v.firstDef
+ }
+ return nil
}
// IsDefined tests whether the variable is defined.
@@ -730,7 +749,7 @@ func (s *Scope) Mentioned(varname string
// Even if IsDefined returns true, FirstDefinition doesn't necessarily return true
// since the latter ignores the default definitions from vardefs.go, keyword dummyVardefMkline.
func (s *Scope) IsDefined(varname string) bool {
- mkline := s.v(varname).firstDef
+ mkline := s.Mentioned(varname)
return mkline != nil && mkline.IsVarassign()
}
@@ -756,21 +775,19 @@ func (s *Scope) IsDefinedSimilar(varname
// IsUsed tests whether the variable is used.
// It does NOT test the canonicalized variable name.
func (s *Scope) IsUsed(varname string) bool {
- return s.v(varname).used != nil
+ return s.FirstUse(varname) != nil
}
// IsUsedSimilar tests whether the variable or its canonicalized form is used.
func (s *Scope) IsUsedSimilar(varname string) bool {
- if s.v(varname).used != nil {
- return true
- }
- return s.v(varnameCanon(varname)).used != nil
+ return s.FirstUse(varname) != nil || s.FirstUse(varnameCanon(varname)) != nil
}
// IsUsedAtLoadTime returns true if the variable is used at load time
// somewhere.
func (s *Scope) IsUsedAtLoadTime(varname string) bool {
- return s.v(varname).usedAtLoadTime
+ v := s.vs[varname]
+ return v != nil && v.usedAtLoadTime
}
// FirstDefinition returns the line in which the variable has been defined first.
@@ -782,7 +799,12 @@ func (s *Scope) IsUsedAtLoadTime(varname
// round: the including file sets a value first, and the included file then
// assigns a default value using ?=.
func (s *Scope) FirstDefinition(varname string) *MkLine {
- mkline := s.v(varname).firstDef
+ v := s.vs[varname]
+ if v == nil {
+ return nil
+ }
+
+ mkline := v.firstDef
if mkline != nil && mkline.IsVarassign() {
lastLine := s.LastDefinition(varname)
if trace.Tracing && lastLine != mkline {
@@ -803,7 +825,12 @@ func (s *Scope) FirstDefinition(varname
// round: the including file sets a value first, and the included file then
// assigns a default value using ?=.
func (s *Scope) LastDefinition(varname string) *MkLine {
- mkline := s.v(varname).lastDef
+ v := s.vs[varname]
+ if v == nil {
+ return nil
+ }
+
+ mkline := v.lastDef
if mkline != nil && mkline.IsVarassign() {
return mkline
}
@@ -814,12 +841,17 @@ func (s *Scope) LastDefinition(varname s
// variable assignments. These are ignored by bmake but used heavily in
// mk/defaults/mk.conf for documentation.
func (s *Scope) Commented(varname string) *MkLine {
- var mklines []*MkLine
- if first := s.v(varname).firstDef; first != nil {
- mklines = append(mklines, first)
+ v := s.vs[varname]
+ if v == nil {
+ return nil
}
- if last := s.v(varname).lastDef; last != nil {
- mklines = append(mklines, last)
+
+ mklines := make([]*MkLine, 0, 2)
+ if v.firstDef != nil {
+ mklines = append(mklines, v.firstDef)
+ }
+ if v.lastDef != nil {
+ mklines = append(mklines, v.lastDef)
}
for _, mkline := range mklines {
@@ -838,7 +870,11 @@ func (s *Scope) Commented(varname string
}
func (s *Scope) FirstUse(varname string) *MkLine {
- return s.v(varname).used
+ v := s.vs[varname]
+ if v == nil {
+ return nil
+ }
+ return v.used
}
// LastValue returns the value from the last variable definition.
@@ -868,14 +904,8 @@ func (s *Scope) LastValueFound(varname s
return v.fallback, v.fallback != "", v.indeterminate
}
-func (s *Scope) DefineAll(other Scope) {
- var varnames []string
- for varname := range other.vs {
- varnames = append(varnames, varname)
- }
- sort.Strings(varnames)
-
- for _, varname := range varnames {
+func (s *Scope) DefineAll(other *Scope) {
+ for _, varname := range other.varnames() {
v := other.vs[varname]
if v.firstDef != nil {
s.Define(varname, v.firstDef)
Index: pkgsrc/pkgtools/pkglint/files/util_test.go
diff -u pkgsrc/pkgtools/pkglint/files/util_test.go:1.53 pkgsrc/pkgtools/pkglint/files/util_test.go:1.54
--- pkgsrc/pkgtools/pkglint/files/util_test.go:1.53 Sun May 24 19:12:29 2020
+++ pkgsrc/pkgtools/pkglint/files/util_test.go Fri Jun 12 19:14:45 2020
@@ -737,12 +737,12 @@ func (s *Suite) Test_Scope_DefineAll(c *
src := NewScope()
dst := NewScope()
- dst.DefineAll(src)
+ dst.DefineAll(&src)
c.Check(dst.vs, check.HasLen, 0)
src.Define("VAR", t.NewMkLine("file.mk", 1, "VAR=value"))
- dst.DefineAll(src)
+ dst.DefineAll(&src)
t.CheckEquals(dst.IsDefined("VAR"), true)
}
Index: pkgsrc/pkgtools/pkglint/files/var_test.go
diff -u pkgsrc/pkgtools/pkglint/files/var_test.go:1.7 pkgsrc/pkgtools/pkglint/files/var_test.go:1.8
--- pkgsrc/pkgtools/pkglint/files/var_test.go:1.7 Sun Nov 17 01:26:25 2019
+++ pkgsrc/pkgtools/pkglint/files/var_test.go Fri Jun 12 19:14:45 2020
@@ -137,11 +137,11 @@ func (s *Suite) Test_Var_ConstantValue__
v.Write(t.NewMkLine("write.mk", 123, "VARNAME+=\tvalue"), false)
- t.CheckEquals(v.ConstantValue(), " value")
+ t.CheckEquals(v.ConstantValue(), "value")
v.Write(t.NewMkLine("write.mk", 124, "VARNAME+=\tappended"), false)
- t.CheckEquals(v.ConstantValue(), " value appended")
+ t.CheckEquals(v.ConstantValue(), "value appended")
}
func (s *Suite) Test_Var_ConstantValue__eval(c *check.C) {
Index: pkgsrc/pkgtools/pkglint/files/vartypecheck_test.go
diff -u pkgsrc/pkgtools/pkglint/files/vartypecheck_test.go:1.83 pkgsrc/pkgtools/pkglint/files/vartypecheck_test.go:1.84
--- pkgsrc/pkgtools/pkglint/files/vartypecheck_test.go:1.83 Sun Jun 7 15:49:23 2020
+++ pkgsrc/pkgtools/pkglint/files/vartypecheck_test.go Fri Jun 12 19:14:45 2020
@@ -503,6 +503,8 @@ func (s *Suite) Test_VartypeCheck_Depend
t.CheckOutputLines(
"NOTE: Makefile:21: The requirement >=1.0pkg is already guaranteed "+
"by the >=1.3api from ../../category/lib/buildlink3.mk:12.",
+ "ERROR: Makefile:22: Packages must only require API versions, "+
+ "not ABI versions of dependencies.",
"NOTE: Makefile:22: The requirement >=1.1pkg is already guaranteed "+
"by the >=1.4abi from ../../category/lib/buildlink3.mk:13.")
}
@@ -526,6 +528,8 @@ func (s *Suite) Test_VartypeCheck_Depend
t.CheckOutputLines(
"NOTE: Makefile:21: The requirement >=1.0pkg is already guaranteed "+
"by the >1.3api from ../../category/lib/buildlink3.mk:12.",
+ "ERROR: Makefile:22: Packages must only require API versions, "+
+ "not ABI versions of dependencies.",
"NOTE: Makefile:22: The requirement >=1.1pkg is already guaranteed "+
"by the >1.4abi from ../../category/lib/buildlink3.mk:13.")
}
@@ -549,6 +553,8 @@ func (s *Suite) Test_VartypeCheck_Depend
t.CheckOutputLines(
"NOTE: Makefile:21: The requirement >1.0pkg is already guaranteed "+
"by the >=1.3api from ../../category/lib/buildlink3.mk:12.",
+ "ERROR: Makefile:22: Packages must only require API versions, "+
+ "not ABI versions of dependencies.",
"NOTE: Makefile:22: The requirement >1.1pkg is already guaranteed "+
"by the >=1.4abi from ../../category/lib/buildlink3.mk:13.")
}
@@ -570,8 +576,10 @@ func (s *Suite) Test_VartypeCheck_Depend
G.checkdirPackage(".")
// If the additional constraint doesn't have a lower bound,
- // there is nothing to compare and warn about.
- t.CheckOutputEmpty()
+ // there are no version numbers to compare and warn about.
+ t.CheckOutputLines(
+ "ERROR: Makefile:22: Packages must only require API versions, " +
+ "not ABI versions of dependencies.")
}
// Having an upper bound for a library dependency is unusual.
@@ -593,8 +601,10 @@ func (s *Suite) Test_VartypeCheck_Depend
G.checkdirPackage(".")
// If the additional constraint doesn't have a lower bound,
- // there is nothing to compare and warn about.
- t.CheckOutputEmpty()
+ // there are no version numbers to compare and warn about.
+ t.CheckOutputLines(
+ "ERROR: Makefile:22: Packages must only require API versions, " +
+ "not ABI versions of dependencies.")
}
func (s *Suite) Test_VartypeCheck_DependencyPattern__API_ABI(c *check.C) {
@@ -628,7 +638,9 @@ func (s *Suite) Test_VartypeCheck_Depend
G.checkdirPackage(".")
- t.CheckOutputEmpty()
+ t.CheckOutputLines(
+ "ERROR: Makefile:21: Packages must only require API versions, " +
+ "not ABI versions of dependencies.")
}
func (s *Suite) Test_VartypeCheck_DependencyWithPath(c *check.C) {
Home |
Main Index |
Thread Index |
Old Index