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: Thu Sep 12 21:15:48 UTC 2019
Modified Files:
pkgsrc/pkgtools/pkglint: Makefile
pkgsrc/pkgtools/pkglint/files: logging.go logging_test.go mkline.go
mkline_test.go mklinechecker.go mklinechecker_test.go mktypes.go
shell_test.go util.go vardefs.go vardefs_test.go vargroups.go
vargroups_test.go
Log Message:
pkgtools/pkglint: update to 5.7.24
Changes since 5.7.23:
* Improved the _VARGROUPS check for ignored variables
* Removed wrong warnings for variable expressions like ${VAR:Dyes:Uno}
* Used correct terminology for the :Q modifier (it's not an operator)
To generate a diff of this commit:
cvs rdiff -u -r1.596 -r1.597 pkgsrc/pkgtools/pkglint/Makefile
cvs rdiff -u -r1.26 -r1.27 pkgsrc/pkgtools/pkglint/files/logging.go
cvs rdiff -u -r1.19 -r1.20 pkgsrc/pkgtools/pkglint/files/logging_test.go
cvs rdiff -u -r1.57 -r1.58 pkgsrc/pkgtools/pkglint/files/mkline.go
cvs rdiff -u -r1.66 -r1.67 pkgsrc/pkgtools/pkglint/files/mkline_test.go
cvs rdiff -u -r1.45 -r1.46 pkgsrc/pkgtools/pkglint/files/mklinechecker.go
cvs rdiff -u -r1.41 -r1.42 \
pkgsrc/pkgtools/pkglint/files/mklinechecker_test.go
cvs rdiff -u -r1.17 -r1.18 pkgsrc/pkgtools/pkglint/files/mktypes.go
cvs rdiff -u -r1.51 -r1.52 pkgsrc/pkgtools/pkglint/files/shell_test.go \
pkgsrc/pkgtools/pkglint/files/util.go
cvs rdiff -u -r1.71 -r1.72 pkgsrc/pkgtools/pkglint/files/vardefs.go
cvs rdiff -u -r1.20 -r1.21 pkgsrc/pkgtools/pkglint/files/vardefs_test.go
cvs rdiff -u -r1.1 -r1.2 pkgsrc/pkgtools/pkglint/files/vargroups.go \
pkgsrc/pkgtools/pkglint/files/vargroups_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.596 pkgsrc/pkgtools/pkglint/Makefile:1.597
--- pkgsrc/pkgtools/pkglint/Makefile:1.596 Sun Sep 8 22:47:47 2019
+++ pkgsrc/pkgtools/pkglint/Makefile Thu Sep 12 21:15:48 2019
@@ -1,6 +1,6 @@
-# $NetBSD: Makefile,v 1.596 2019/09/08 22:47:47 rillig Exp $
+# $NetBSD: Makefile,v 1.597 2019/09/12 21:15:48 rillig Exp $
-PKGNAME= pkglint-5.7.23
+PKGNAME= pkglint-5.7.24
CATEGORIES= pkgtools
DISTNAME= tools
MASTER_SITES= ${MASTER_SITE_GITHUB:=golang/}
Index: pkgsrc/pkgtools/pkglint/files/logging.go
diff -u pkgsrc/pkgtools/pkglint/files/logging.go:1.26 pkgsrc/pkgtools/pkglint/files/logging.go:1.27
--- pkgsrc/pkgtools/pkglint/files/logging.go:1.26 Sun Sep 8 22:47:47 2019
+++ pkgsrc/pkgtools/pkglint/files/logging.go Thu Sep 12 21:15:48 2019
@@ -180,7 +180,7 @@ func (l *Logger) shallBeLogged(format st
//
// See Logf for logging arbitrary messages.
func (l *Logger) Diag(line *Line, level *LogLevel, format string, args ...interface{}) {
- if l.Opts.ShowAutofix || l.Opts.Autofix {
+ if l.IsAutofix() {
// In these two cases, the only interesting diagnostics are those that can
// be fixed automatically. These are logged by Autofix.Apply.
l.suppressExpl = true
@@ -200,7 +200,7 @@ func (l *Logger) Diag(line *Line, level
}
if l.Opts.ShowSource {
- if !l.IsAutofix() && line != l.prevLine && level != Fatal {
+ if line != l.prevLine {
l.out.Separate()
}
l.showSource(line)
Index: pkgsrc/pkgtools/pkglint/files/logging_test.go
diff -u pkgsrc/pkgtools/pkglint/files/logging_test.go:1.19 pkgsrc/pkgtools/pkglint/files/logging_test.go:1.20
--- pkgsrc/pkgtools/pkglint/files/logging_test.go:1.19 Sun Sep 8 22:47:47 2019
+++ pkgsrc/pkgtools/pkglint/files/logging_test.go Thu Sep 12 21:15:48 2019
@@ -1071,3 +1071,15 @@ func (s *Suite) Test_SeparatorWriter_Sep
t.CheckEquals(sb.String(), "a\n\nc\n")
}
+
+func (s *Suite) Test_SeparatorWriter_Separate__at_the_beginning(c *check.C) {
+ t := s.Init(c)
+
+ var sb strings.Builder
+ wr := NewSeparatorWriter(&sb)
+
+ wr.Separate()
+ wr.WriteLine("a")
+
+ t.CheckEquals(sb.String(), "a\n")
+}
Index: pkgsrc/pkgtools/pkglint/files/mkline.go
diff -u pkgsrc/pkgtools/pkglint/files/mkline.go:1.57 pkgsrc/pkgtools/pkglint/files/mkline.go:1.58
--- pkgsrc/pkgtools/pkglint/files/mkline.go:1.57 Sun Aug 25 21:44:37 2019
+++ pkgsrc/pkgtools/pkglint/files/mkline.go Thu Sep 12 21:15:48 2019
@@ -920,12 +920,12 @@ func (p MkLineParser) parseDirective(lin
return &MkLine{line, &mkLineDirective{indent, directive, args, trimmedComment, nil, nil, nil}}
}
-// VariableNeedsQuoting determines whether the given variable needs the :Q operator
-// in the given context.
+// VariableNeedsQuoting determines whether the given variable needs the :Q
+// modifier in the given context.
//
-// This decision depends on many factors, such as whether the type of the context is
-// a list of things, whether the variable is a list, whether it can contain only
-// safe characters, and so on.
+// This decision depends on many factors, such as whether the type of the
+// context is a list of things, whether the variable is a list, whether it
+// can contain only safe characters, and so on.
func (mkline *MkLine) VariableNeedsQuoting(mklines *MkLines, varuse *MkVarUse, vartype *Vartype, vuc *VarUseContext) (needsQuoting YesNoUnknown) {
if trace.Tracing {
defer trace.Call(varuse, vartype, vuc, trace.Result(&needsQuoting))()
@@ -934,6 +934,13 @@ func (mkline *MkLine) VariableNeedsQuoti
// TODO: Systematically test this function, each and every case, from top to bottom.
// TODO: Re-check the order of all these if clauses whether it really makes sense.
+ if varuse.HasModifier("D") && varuse.HasModifier("U") {
+ // Take the simple way for now. Handling this kind of
+ // conditional expressions correctly and completely would
+ // require a larger rewrite.
+ return unknown
+ }
+
vucVartype := vuc.vartype
if vartype == nil || vucVartype == nil || vartype.basicType == BtUnknown {
return unknown
Index: pkgsrc/pkgtools/pkglint/files/mkline_test.go
diff -u pkgsrc/pkgtools/pkglint/files/mkline_test.go:1.66 pkgsrc/pkgtools/pkglint/files/mkline_test.go:1.67
--- pkgsrc/pkgtools/pkglint/files/mkline_test.go:1.66 Sun Sep 8 22:47:47 2019
+++ pkgsrc/pkgtools/pkglint/files/mkline_test.go Thu Sep 12 21:15:48 2019
@@ -648,7 +648,7 @@ func (s *Suite) Test_MkLine_VariableNeed
MkLineChecker{mklines, mklines.mklines[1]}.checkVarassign()
t.CheckOutputLines(
- "NOTE: builtin.mk:2: The :Q operator isn't necessary for ${BUILTIN_PKG.Xfixes} here.")
+ "NOTE: builtin.mk:2: The :Q modifier isn't necessary for ${BUILTIN_PKG.Xfixes} here.")
}
func (s *Suite) Test_MkLine_VariableNeedsQuoting__command_in_single_quotes(c *check.C) {
@@ -930,7 +930,7 @@ func (s *Suite) Test_MkLine_VariableNeed
// for invoking the tool properly (e.g. touch -t).
// Therefore, no quoting is necessary.
t.CheckOutputLines(
- "NOTE: Makefile:3: The :Q operator isn't necessary for ${TOOLS_TAR} here.")
+ "NOTE: Makefile:3: The :Q modifier isn't necessary for ${TOOLS_TAR} here.")
}
func (s *Suite) Test_MkLine_VariableNeedsQuoting__backticks(c *check.C) {
@@ -1026,6 +1026,28 @@ func (s *Suite) Test_MkLine_VariableNeed
t.CheckOutputEmpty()
}
+func (s *Suite) Test_MkLine_VariableNeedsQuoting__D_and_U_modifiers(c *check.C) {
+ t := s.Init(c)
+
+ t.SetUpVartypes()
+
+ mklines := t.SetUpFileMkLines("Makefile",
+ MkCvsID,
+ "",
+ "SUBST_CLASSES+=\t\turl2pkg",
+ "SUBST_STAGE.url2pkg=\tpost-configure",
+ "SUBST_FILES.url2pkg=\t*.in",
+ "SUBST_SED.url2pkg=\t-e 's,@PKGSRCDIR@,${BATCH:D/usr/pkg:U${PKGSRCDIR}},'")
+
+ mklines.Check()
+
+ // Since the value of the BATCH variable does not appear in the output,
+ // there should be no warning saying that "BATCH should be quoted".
+ // If any, the variable PKGSRCDIR should be quoted, but that is a safe
+ // variable since it is a pkgsrc-specific directory.
+ t.CheckOutputEmpty()
+}
+
// As of October 2018, these examples from real pkgsrc end up in the
// final "unknown" case.
func (s *Suite) Test_MkLine_VariableNeedsQuoting__uncovered_cases(c *check.C) {
Index: pkgsrc/pkgtools/pkglint/files/mklinechecker.go
diff -u pkgsrc/pkgtools/pkglint/files/mklinechecker.go:1.45 pkgsrc/pkgtools/pkglint/files/mklinechecker.go:1.46
--- pkgsrc/pkgtools/pkglint/files/mklinechecker.go:1.45 Sun Sep 8 22:47:47 2019
+++ pkgsrc/pkgtools/pkglint/files/mklinechecker.go Thu Sep 12 21:15:48 2019
@@ -847,11 +847,11 @@ func (ck MkLineChecker) checkVarUseQuoti
mod := varUse.Mod()
// In GNU configure scripts, a few variables need to be passed through
- // the :M* operator before they reach the configure scripts. Otherwise
+ // the :M* modifier before they reach the configure scripts. Otherwise
// the leading or trailing spaces will lead to strange caching errors
// since the GNU configure scripts cannot handle these space characters.
//
- // When doing checks outside a package, the :M* operator is needed for safety.
+ // When doing checks outside a package, the :M* modifier is needed for safety.
needMstar := (G.Pkg == nil || G.Pkg.vars.Defined("GNU_CONFIGURE")) &&
matches(varname, `^(?:.*_)?(?:CFLAGS|CPPFLAGS|CXXFLAGS|FFLAGS|LDFLAGS|LIBS)$`)
@@ -958,9 +958,9 @@ func (ck MkLineChecker) checkVarUseQuoti
good := "${" + varname + strings.TrimSuffix(mod, ":Q") + "}"
fix := mkline.Line.Autofix()
- fix.Notef("The :Q operator isn't necessary for ${%s} here.", varname)
+ fix.Notef("The :Q modifier isn't necessary for ${%s} here.", varname)
fix.Explain(
- "Many variables in pkgsrc do not need the :Q operator since they",
+ "Many variables in pkgsrc do not need the :Q modifier since they",
"are not expected to contain whitespace or other special characters.",
"Examples for these \"safe\" variables are:",
"",
Index: pkgsrc/pkgtools/pkglint/files/mklinechecker_test.go
diff -u pkgsrc/pkgtools/pkglint/files/mklinechecker_test.go:1.41 pkgsrc/pkgtools/pkglint/files/mklinechecker_test.go:1.42
--- pkgsrc/pkgtools/pkglint/files/mklinechecker_test.go:1.41 Sun Sep 8 22:47:47 2019
+++ pkgsrc/pkgtools/pkglint/files/mklinechecker_test.go Thu Sep 12 21:15:48 2019
@@ -1191,7 +1191,7 @@ func (s *Suite) Test_MkLineChecker_check
t.CheckOutputLines(
"WARN: module.mk:2: Please use PREFIX instead of LOCALBASE.",
- "NOTE: module.mk:2: The :Q operator isn't necessary for ${LOCALBASE} here.")
+ "NOTE: module.mk:2: The :Q modifier isn't necessary for ${LOCALBASE} here.")
}
func (s *Suite) Test_MkLineChecker_checkVarusePermissions(c *check.C) {
@@ -2275,7 +2275,7 @@ func (s *Suite) Test_MkLineChecker_check
G.Check(pkg)
t.CheckOutputLines(
- "NOTE: ~/category/package/Makefile:6: The :Q operator isn't necessary for ${HOMEPAGE} here.")
+ "NOTE: ~/category/package/Makefile:6: The :Q modifier isn't necessary for ${HOMEPAGE} here.")
}
func (s *Suite) Test_MkLineChecker_checkVarUseQuoting__undefined_list_in_word_in_shell_command(c *check.C) {
Index: pkgsrc/pkgtools/pkglint/files/mktypes.go
diff -u pkgsrc/pkgtools/pkglint/files/mktypes.go:1.17 pkgsrc/pkgtools/pkglint/files/mktypes.go:1.18
--- pkgsrc/pkgtools/pkglint/files/mktypes.go:1.17 Wed Aug 21 16:45:17 2019
+++ pkgsrc/pkgtools/pkglint/files/mktypes.go Thu Sep 12 21:15:48 2019
@@ -159,3 +159,12 @@ func (vu *MkVarUse) IsQ() bool {
mlen := len(vu.modifiers)
return mlen > 0 && vu.modifiers[mlen-1].IsQ()
}
+
+func (vu *MkVarUse) HasModifier(prefix string) bool {
+ for _, mod := range vu.modifiers {
+ if hasPrefix(mod.Text, prefix) {
+ return true
+ }
+ }
+ return false
+}
Index: pkgsrc/pkgtools/pkglint/files/shell_test.go
diff -u pkgsrc/pkgtools/pkglint/files/shell_test.go:1.51 pkgsrc/pkgtools/pkglint/files/shell_test.go:1.52
--- pkgsrc/pkgtools/pkglint/files/shell_test.go:1.51 Fri Aug 2 18:55:07 2019
+++ pkgsrc/pkgtools/pkglint/files/shell_test.go Thu Sep 12 21:15:48 2019
@@ -180,7 +180,7 @@ func (s *Suite) Test_ShellLineChecker_Ch
"before using a semicolon (after \"uname=`uname`\") to separate commands.")
test("echo ${PKGNAME:Q}", // VucQuotPlain
- "NOTE: filename.mk:1: The :Q operator isn't necessary for ${PKGNAME} here.")
+ "NOTE: filename.mk:1: The :Q modifier isn't necessary for ${PKGNAME} here.")
test("echo \"${CFLAGS:Q}\"", // VucQuotDquot
"WARN: filename.mk:1: The :Q modifier should not be used inside double quotes.",
@@ -316,7 +316,7 @@ func (s *Suite) Test_ShellLineChecker_Ch
ck.CheckShellCommandLine("echo ${PKGNAME:Q}")
t.CheckOutputLines(
- "NOTE: Makefile:1: The :Q operator isn't necessary for ${PKGNAME} here.")
+ "NOTE: Makefile:1: The :Q modifier isn't necessary for ${PKGNAME} here.")
}
func (s *Suite) Test_ShellLineChecker_CheckShellCommandLine__show_autofix(c *check.C) {
@@ -332,7 +332,7 @@ func (s *Suite) Test_ShellLineChecker_Ch
ck.CheckShellCommandLine("echo ${PKGNAME:Q}")
t.CheckOutputLines(
- "NOTE: Makefile:1: The :Q operator isn't necessary for ${PKGNAME} here.",
+ "NOTE: Makefile:1: The :Q modifier isn't necessary for ${PKGNAME} here.",
"AUTOFIX: Makefile:1: Replacing \"${PKGNAME:Q}\" with \"${PKGNAME}\".")
}
@@ -479,10 +479,10 @@ func (s *Suite) Test_ShellLineChecker_Ch
nil...)
test("\"${DISTINFO_FILE:Q}\"", true,
- "NOTE: filename.mk:1: The :Q operator isn't necessary for ${DISTINFO_FILE} here.")
+ "NOTE: filename.mk:1: The :Q modifier isn't necessary for ${DISTINFO_FILE} here.")
test("embed${DISTINFO_FILE:Q}ded", true,
- "NOTE: filename.mk:1: The :Q operator isn't necessary for ${DISTINFO_FILE} here.")
+ "NOTE: filename.mk:1: The :Q modifier isn't necessary for ${DISTINFO_FILE} here.")
test("s,\\.,,", true,
nil...)
Index: pkgsrc/pkgtools/pkglint/files/util.go
diff -u pkgsrc/pkgtools/pkglint/files/util.go:1.51 pkgsrc/pkgtools/pkglint/files/util.go:1.52
--- pkgsrc/pkgtools/pkglint/files/util.go:1.51 Sun Sep 8 22:47:47 2019
+++ pkgsrc/pkgtools/pkglint/files/util.go Thu Sep 12 21:15:48 2019
@@ -267,7 +267,7 @@ func isIgnoredFilename(filename string)
case ".", "..", "CVS", ".svn", ".git", ".hg", ".idea":
return true
}
- return false
+ return hasPrefix(filename, ".#")
}
func dirglob(dirname string) []string {
Index: pkgsrc/pkgtools/pkglint/files/vardefs.go
diff -u pkgsrc/pkgtools/pkglint/files/vardefs.go:1.71 pkgsrc/pkgtools/pkglint/files/vardefs.go:1.72
--- pkgsrc/pkgtools/pkglint/files/vardefs.go:1.71 Sun Sep 8 22:47:47 2019
+++ pkgsrc/pkgtools/pkglint/files/vardefs.go Thu Sep 12 21:15:48 2019
@@ -305,7 +305,7 @@ func (reg *VarTypeRegistry) cmdline(varn
func (reg *VarTypeRegistry) infralist(varname string, basicType *BasicType) {
reg.acllist(varname, basicType,
List,
- "*: set, append")
+ "*: set, append, use")
}
// compilerLanguages reads the available languages that are typically
@@ -1043,6 +1043,7 @@ func (reg *VarTypeRegistry) Init(src *Pk
reg.pkg("DYNAMIC_SITES_CMD", BtShellCommand)
reg.pkg("DYNAMIC_SITES_SCRIPT", BtPathname)
reg.sysbl3("ECHO", BtShellCommand)
+ reg.sysbl3("ECHO_BUILDLINK_MSG", BtShellCommand)
reg.sysbl3("ECHO_MSG", BtShellCommand)
reg.sysbl3("ECHO_N", BtShellCommand)
reg.pkg("EGDIR", BtPathname) // Not defined anywhere but used in many places like this.
@@ -1588,6 +1589,7 @@ func (reg *VarTypeRegistry) Init(src *Pk
reg.syslist("TOOLS_NOOP", BtTool)
reg.sys("TOOLS_PATH.*", BtPathname)
reg.sysload("TOOLS_PLATFORM.*", BtShellCommand)
+ reg.sysload("TOOLS_SHELL", BtShellCommand)
reg.syslist("TOUCH_FLAGS", BtShellWord)
reg.pkglist("UAC_REQD_EXECS", BtPrefixPathname)
reg.pkglistbl3("UNLIMIT_RESOURCES",
@@ -1675,7 +1677,7 @@ func (reg *VarTypeRegistry) Init(src *Pk
reg.infralist("_SYS_VARS.*", BtVariableName)
reg.infralist("_DEF_VARS.*", BtVariableName)
reg.infralist("_USE_VARS.*", BtVariableName)
- reg.infralist("_IGN_VARS.*", BtVariableName)
+ reg.infralist("_IGN_VARS.*", BtVariableNamePattern)
reg.infralist("_SORTED_VARS.*", BtVariableNamePattern)
reg.infralist("_LISTED_VARS.*", BtVariableNamePattern)
}
Index: pkgsrc/pkgtools/pkglint/files/vardefs_test.go
diff -u pkgsrc/pkgtools/pkglint/files/vardefs_test.go:1.20 pkgsrc/pkgtools/pkglint/files/vardefs_test.go:1.21
--- pkgsrc/pkgtools/pkglint/files/vardefs_test.go:1.20 Wed Aug 21 16:45:17 2019
+++ pkgsrc/pkgtools/pkglint/files/vardefs_test.go Thu Sep 12 21:15:48 2019
@@ -185,7 +185,7 @@ func (s *Suite) Test_VarTypeRegistry_Ini
G.Check(pkg)
- // No warning about a missing :Q operator.
+ // No warning about a missing :Q modifier.
t.CheckOutputEmpty()
}
Index: pkgsrc/pkgtools/pkglint/files/vargroups.go
diff -u pkgsrc/pkgtools/pkglint/files/vargroups.go:1.1 pkgsrc/pkgtools/pkglint/files/vargroups.go:1.2
--- pkgsrc/pkgtools/pkglint/files/vargroups.go:1.1 Sun Sep 8 22:47:47 2019
+++ pkgsrc/pkgtools/pkglint/files/vargroups.go Thu Sep 12 21:15:48 2019
@@ -1,6 +1,9 @@
package pkglint
-import "strings"
+import (
+ "path"
+ "strings"
+)
// VargroupsChecker checks that the _VARGROUPS section of an infrastructure
// file matches the rest of the file content:
@@ -147,7 +150,7 @@ func (ck *VargroupsChecker) checkDef(mkl
varname := mkline.Varname()
delete(ck.undefinedVars, varname)
- if ck.ignoreDef(varname) {
+ if ck.ignore(varname) {
return
}
@@ -156,19 +159,6 @@ func (ck *VargroupsChecker) checkDef(mkl
}
}
-func (ck *VargroupsChecker) ignoreDef(varname string) bool {
- switch {
- case containsVarRef(varname),
- ck.registered[varname] != nil,
- hasSuffix(varname, "_MK"),
- ck.isVargroups(varname),
- varname == "PKG_FAIL_REASON":
- return true
- }
-
- return false
-}
-
func (ck *VargroupsChecker) checkUse(mkline *MkLine) {
mkline.ForEachUsed(func(varUse *MkVarUse, _ VucTime) { ck.checkUseVar(mkline, varUse) })
}
@@ -177,7 +167,7 @@ func (ck *VargroupsChecker) checkUseVar(
varname := varUse.varname
delete(ck.unusedVars, varname)
- if ck.ignoreUse(varname) {
+ if ck.ignore(varname) {
return
}
@@ -186,30 +176,36 @@ func (ck *VargroupsChecker) checkUseVar(
}
}
-func (ck *VargroupsChecker) ignoreUse(varname string) bool {
+func (ck *VargroupsChecker) ignore(varname string) bool {
switch {
case containsVarRef(varname),
hasSuffix(varname, "_MK"),
- varname == ".TARGET",
- varname == "TOOLS_SHELL",
- varname == "TOUCH_FLAGS",
- varname == strings.ToLower(varname),
+ ck.registered[varname] != nil,
G.Pkgsrc.Tools.ExistsVar(varname),
+ ck.isVargroups(varname),
+ varname == strings.ToLower(varname),
ck.isShellCommand(varname),
- ck.registered[varname] != nil,
- ck.isVargroups(varname):
+ varname == ".TARGET",
+ varname == "BUILD_DEFS",
+ varname == "BUILD_DEFS_EFFECTS",
+ varname == "PKG_FAIL_REASON",
+ varname == "TOUCH_FLAGS":
return true
}
+ for pattern := range ck.ignVars {
+ matched, err := path.Match(pattern, varname)
+ if err == nil && matched {
+ return true
+ }
+ }
+
return false
}
func (ck *VargroupsChecker) isShellCommand(varname string) bool {
vartype := G.Pkgsrc.VariableType(ck.mklines, varname)
- if vartype != nil && vartype.basicType == BtShellCommand {
- return true
- }
- return false
+ return vartype != nil && vartype.basicType == BtShellCommand
}
func (ck *VargroupsChecker) isVargroups(varname string) bool {
Index: pkgsrc/pkgtools/pkglint/files/vargroups_test.go
diff -u pkgsrc/pkgtools/pkglint/files/vargroups_test.go:1.1 pkgsrc/pkgtools/pkglint/files/vargroups_test.go:1.2
--- pkgsrc/pkgtools/pkglint/files/vargroups_test.go:1.1 Sun Sep 8 22:47:47 2019
+++ pkgsrc/pkgtools/pkglint/files/vargroups_test.go Thu Sep 12 21:15:48 2019
@@ -61,15 +61,16 @@ func (s *Suite) Test_VargroupsChecker__v
"",
"_VARGROUPS+=\t\tgroup",
"_USER_VARS.group=\t${:Uparam:@param@VAR.${param}@}",
+ "_LISTED_VARS.group=\t${:Uparam:@param@VAR.${param}@}",
"",
"VAR.param=\tvalue")
mklines.Check()
t.CheckOutputLines(
- "WARN: Makefile:6: VAR.param is defined but not used.",
+ "WARN: Makefile:7: VAR.param is defined but not used.",
// FIXME: Hmmm, that's going to be complicated to get right.
- "WARN: Makefile:6: Variable VAR.param is defined but not mentioned in the _VARGROUPS section.")
+ "WARN: Makefile:7: Variable VAR.param is defined but not mentioned in the _VARGROUPS section.")
}
func (s *Suite) Test_VargroupsChecker__public_underscore(c *check.C) {
@@ -115,6 +116,49 @@ func (s *Suite) Test_VargroupsChecker__d
"WARN: Makefile:8: The variable UNDEFINED is not actually defined in this file.")
}
+func (s *Suite) Test_VargroupsChecker__defined_but_undeclared(c *check.C) {
+ t := s.Init(c)
+
+ t.SetUpVartypes()
+ mklines := t.NewMkLines("Makefile",
+ MkCvsID,
+ "",
+ ".if !defined(MAKEFILE_MK)",
+ "MAKEFILE_MK=",
+ "",
+ "_VARGROUPS+=\t\tgroup",
+ "",
+ "PKG_FAIL_REASON+=\tReason",
+ "",
+ ".endif")
+
+ mklines.Check()
+
+ t.CheckOutputEmpty()
+}
+
+func (s *Suite) Test_VargroupsChecker__used_but_undeclared(c *check.C) {
+ t := s.Init(c)
+
+ t.SetUpVartypes()
+ t.SetUpTool("touch", "TOUCH", AtRunTime)
+ mklines := t.NewMkLines("Makefile",
+ MkCvsID,
+ "",
+ "_VARGROUPS+=\tgroup",
+ "",
+ "pre-configure:",
+ "\t${TOOLS_SHELL} -c ':'",
+ "\t${TOUCH} ${TOUCH_FLAGS} ${.TARGET}",
+ "\t: ${PKGNAME}")
+
+ mklines.Check()
+
+ t.CheckOutputLines(
+ "WARN: Makefile:8: Variable PKGNAME is used " +
+ "but not mentioned in the _VARGROUPS section.")
+}
+
func (s *Suite) Test_VargroupsChecker__declared_but_unused(c *check.C) {
t := s.Init(c)
@@ -140,3 +184,48 @@ func (s *Suite) Test_VargroupsChecker__d
"WARN: Makefile:11: Variable UNDECLARED is used but not mentioned in the _VARGROUPS section.",
"WARN: Makefile:8: The variable UNUSED is not actually used in this file.")
}
+
+func (s *Suite) Test_VargroupsChecker__used_in_BUILD_DEFS(c *check.C) {
+ t := s.Init(c)
+
+ t.SetUpVartypes()
+
+ mklines := t.NewMkLines("Makefile",
+ MkCvsID,
+ "",
+ "# USER_VAR",
+ "#\tDocumentation.",
+ "#\tDocumentation.",
+ "",
+ "_VARGROUPS+=\t\tgroup",
+ "_USER_VARS.group=\tUSER_VAR",
+ "",
+ ".if ${USER_VAR:U}",
+ ".endif",
+ "BUILD_DEFS+=\t${_USER_VARS.group}")
+
+ mklines.Check()
+
+ // No warning about _USER_VARS.group being a write-only variable.
+ t.CheckOutputEmpty()
+}
+
+func (s *Suite) Test_VargroupsChecker__ignore(c *check.C) {
+ t := s.Init(c)
+
+ t.SetUpVartypes()
+
+ mklines := t.NewMkLines("Makefile",
+ MkCvsID,
+ "",
+ "_VARGROUPS+=\t\tgroup",
+ "_IGN_VARS.group=\tPREFER_*",
+ "",
+ ".if ${PREFER_PKGSRC:U} || ${WRKOBJDIR:U}",
+ ".endif")
+
+ mklines.Check()
+
+ t.CheckOutputLines(
+ "WARN: Makefile:6: Variable WRKOBJDIR is used but not mentioned in the _VARGROUPS section.")
+}
Home |
Main Index |
Thread Index |
Old Index