diff options
author | rillig <rillig@pkgsrc.org> | 2019-09-12 21:15:48 +0000 |
---|---|---|
committer | rillig <rillig@pkgsrc.org> | 2019-09-12 21:15:48 +0000 |
commit | c13c5875b08139c1c1668bcd37e70ed248356c65 (patch) | |
tree | a3899befa6caa73cfcff11d4cfa854d9bd38274f /pkgtools/pkglint/files | |
parent | c6b5c0c210aed4ef50fb97e6e910d32b02086c35 (diff) | |
download | pkgsrc-c13c5875b08139c1c1668bcd37e70ed248356c65.tar.gz |
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)
Diffstat (limited to 'pkgtools/pkglint/files')
-rw-r--r-- | pkgtools/pkglint/files/logging.go | 4 | ||||
-rw-r--r-- | pkgtools/pkglint/files/logging_test.go | 12 | ||||
-rw-r--r-- | pkgtools/pkglint/files/mkline.go | 17 | ||||
-rw-r--r-- | pkgtools/pkglint/files/mkline_test.go | 26 | ||||
-rw-r--r-- | pkgtools/pkglint/files/mklinechecker.go | 8 | ||||
-rw-r--r-- | pkgtools/pkglint/files/mklinechecker_test.go | 4 | ||||
-rw-r--r-- | pkgtools/pkglint/files/mktypes.go | 9 | ||||
-rw-r--r-- | pkgtools/pkglint/files/shell_test.go | 10 | ||||
-rw-r--r-- | pkgtools/pkglint/files/util.go | 2 | ||||
-rw-r--r-- | pkgtools/pkglint/files/vardefs.go | 6 | ||||
-rw-r--r-- | pkgtools/pkglint/files/vardefs_test.go | 2 | ||||
-rw-r--r-- | pkgtools/pkglint/files/vargroups.go | 50 | ||||
-rw-r--r-- | pkgtools/pkglint/files/vargroups_test.go | 93 |
13 files changed, 190 insertions, 53 deletions
diff --git a/pkgtools/pkglint/files/logging.go b/pkgtools/pkglint/files/logging.go index 53bc5219a20..e066a8743ba 100644 --- a/pkgtools/pkglint/files/logging.go +++ b/pkgtools/pkglint/files/logging.go @@ -180,7 +180,7 @@ func (l *Logger) shallBeLogged(format string) bool { // // 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 *LogLevel, format string, args ...interf } if l.Opts.ShowSource { - if !l.IsAutofix() && line != l.prevLine && level != Fatal { + if line != l.prevLine { l.out.Separate() } l.showSource(line) diff --git a/pkgtools/pkglint/files/logging_test.go b/pkgtools/pkglint/files/logging_test.go index 835c448749c..2a56c159738 100644 --- a/pkgtools/pkglint/files/logging_test.go +++ b/pkgtools/pkglint/files/logging_test.go @@ -1071,3 +1071,15 @@ func (s *Suite) Test_SeparatorWriter_Separate(c *check.C) { 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") +} diff --git a/pkgtools/pkglint/files/mkline.go b/pkgtools/pkglint/files/mkline.go index 1876f3c1da7..32122cfa262 100644 --- a/pkgtools/pkglint/files/mkline.go +++ b/pkgtools/pkglint/files/mkline.go @@ -920,12 +920,12 @@ func (p MkLineParser) parseDirective(line *Line, data mkLineSplitResult) *MkLine 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) VariableNeedsQuoting(mklines *MkLines, varuse *MkVarUse, v // 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 diff --git a/pkgtools/pkglint/files/mkline_test.go b/pkgtools/pkglint/files/mkline_test.go index 36e1eeba162..de5d4f73496 100644 --- a/pkgtools/pkglint/files/mkline_test.go +++ b/pkgtools/pkglint/files/mkline_test.go @@ -648,7 +648,7 @@ func (s *Suite) Test_MkLine_VariableNeedsQuoting__eval_shell(c *check.C) { 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_VariableNeedsQuoting__tool_in_CONFIGURE_ENV(c *check // 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_VariableNeedsQuoting__tool_in_shell_command(c *check 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) { diff --git a/pkgtools/pkglint/files/mklinechecker.go b/pkgtools/pkglint/files/mklinechecker.go index cd6931ed3c6..3c51f25cb90 100644 --- a/pkgtools/pkglint/files/mklinechecker.go +++ b/pkgtools/pkglint/files/mklinechecker.go @@ -847,11 +847,11 @@ func (ck MkLineChecker) checkVarUseQuoting(varUse *MkVarUse, vartype *Vartype, v 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) checkVarUseQuoting(varUse *MkVarUse, vartype *Vartype, v 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:", "", diff --git a/pkgtools/pkglint/files/mklinechecker_test.go b/pkgtools/pkglint/files/mklinechecker_test.go index e891ba78edf..f8868ce2627 100644 --- a/pkgtools/pkglint/files/mklinechecker_test.go +++ b/pkgtools/pkglint/files/mklinechecker_test.go @@ -1191,7 +1191,7 @@ func (s *Suite) Test_MkLineChecker_checkVarassignRightVaruse(c *check.C) { 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_checkVarUseQuoting__q_not_needed(c *check.C) 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) { diff --git a/pkgtools/pkglint/files/mktypes.go b/pkgtools/pkglint/files/mktypes.go index 77bd1c4b527..8212d3ff34e 100644 --- a/pkgtools/pkglint/files/mktypes.go +++ b/pkgtools/pkglint/files/mktypes.go @@ -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 +} diff --git a/pkgtools/pkglint/files/shell_test.go b/pkgtools/pkglint/files/shell_test.go index 081c1fa68fc..8e761018fce 100644 --- a/pkgtools/pkglint/files/shell_test.go +++ b/pkgtools/pkglint/files/shell_test.go @@ -180,7 +180,7 @@ func (s *Suite) Test_ShellLineChecker_CheckShellCommandLine(c *check.C) { "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_CheckShellCommandLine__nofix(c *check.C) { 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_CheckShellCommandLine__show_autofix(c *che 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_CheckWord(c *check.C) { 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...) diff --git a/pkgtools/pkglint/files/util.go b/pkgtools/pkglint/files/util.go index 3e9c20648f6..413b1c29ce6 100644 --- a/pkgtools/pkglint/files/util.go +++ b/pkgtools/pkglint/files/util.go @@ -267,7 +267,7 @@ func isIgnoredFilename(filename string) bool { case ".", "..", "CVS", ".svn", ".git", ".hg", ".idea": return true } - return false + return hasPrefix(filename, ".#") } func dirglob(dirname string) []string { diff --git a/pkgtools/pkglint/files/vardefs.go b/pkgtools/pkglint/files/vardefs.go index a7e71f923e4..1a752b150d3 100644 --- a/pkgtools/pkglint/files/vardefs.go +++ b/pkgtools/pkglint/files/vardefs.go @@ -305,7 +305,7 @@ func (reg *VarTypeRegistry) cmdline(varname string, basicType *BasicType) { 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 *Pkgsrc) { 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 *Pkgsrc) { 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 *Pkgsrc) { 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) } diff --git a/pkgtools/pkglint/files/vardefs_test.go b/pkgtools/pkglint/files/vardefs_test.go index eaf2a31b073..55f62921fc7 100644 --- a/pkgtools/pkglint/files/vardefs_test.go +++ b/pkgtools/pkglint/files/vardefs_test.go @@ -185,7 +185,7 @@ func (s *Suite) Test_VarTypeRegistry_Init__LP64PLATFORMS(c *check.C) { G.Check(pkg) - // No warning about a missing :Q operator. + // No warning about a missing :Q modifier. t.CheckOutputEmpty() } diff --git a/pkgtools/pkglint/files/vargroups.go b/pkgtools/pkglint/files/vargroups.go index 8fc17242d0b..7734daa35a5 100644 --- a/pkgtools/pkglint/files/vargroups.go +++ b/pkgtools/pkglint/files/vargroups.go @@ -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(mkline *MkLine) { varname := mkline.Varname() delete(ck.undefinedVars, varname) - if ck.ignoreDef(varname) { + if ck.ignore(varname) { return } @@ -156,19 +159,6 @@ func (ck *VargroupsChecker) checkDef(mkline *MkLine) { } } -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(mkline *MkLine, varUse *MkVarUse) { varname := varUse.varname delete(ck.unusedVars, varname) - if ck.ignoreUse(varname) { + if ck.ignore(varname) { return } @@ -186,30 +176,36 @@ func (ck *VargroupsChecker) checkUseVar(mkline *MkLine, varUse *MkVarUse) { } } -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 { diff --git a/pkgtools/pkglint/files/vargroups_test.go b/pkgtools/pkglint/files/vargroups_test.go index 6978fe3d973..a86d52ee04b 100644 --- a/pkgtools/pkglint/files/vargroups_test.go +++ b/pkgtools/pkglint/files/vargroups_test.go @@ -61,15 +61,16 @@ func (s *Suite) Test_VargroupsChecker__variable_reference(c *check.C) { "", "_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__declared_but_undefined(c *check.C) { "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__declared_but_unused(c *check.C) { "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.") +} |