diff options
author | rillig <rillig@pkgsrc.org> | 2016-03-13 13:40:10 +0000 |
---|---|---|
committer | rillig <rillig@pkgsrc.org> | 2016-03-13 13:40:10 +0000 |
commit | cd863bd7043352ecc8d465d221bf1d4a7d6e829e (patch) | |
tree | ca2af3cf939d541a4377327fe61091a23ab2e02a /pkgtools/pkglint/files/parser_test.go | |
parent | 198763f69be08a1990016e1baf768705ab1264a0 (diff) | |
download | pkgsrc-cd863bd7043352ecc8d465d221bf1d4a7d6e829e.tar.gz |
Updated pkglint to 5.3.6.
Changes since 5.3.5:
* Warn about !empty(${VARNAME}), which should be !empty(VARNAME)
* Distinguish ${VARNAME} == "value" and ${VARNAME:Mpattern}
* Corrected isQuotingNecessary for some variable types
* Generally, parse files from mk/, since they define variables
used by packages. This avoids wrong warnings about possible
spelling mistakes.
* Warn about $(VARNAME) (with parentheses instead of braces)
* Warn about missing final @ in ${VAR:@var@...@}
* Updated list of hardware architectures
* Enabled CPU profiling on NetBSD
Diffstat (limited to 'pkgtools/pkglint/files/parser_test.go')
-rw-r--r-- | pkgtools/pkglint/files/parser_test.go | 19 |
1 files changed, 14 insertions, 5 deletions
diff --git a/pkgtools/pkglint/files/parser_test.go b/pkgtools/pkglint/files/parser_test.go index 72dd8b8d12f..d094250b682 100644 --- a/pkgtools/pkglint/files/parser_test.go +++ b/pkgtools/pkglint/files/parser_test.go @@ -6,7 +6,7 @@ import ( func (s *Suite) TestParser_PkgbasePattern(c *check.C) { test := func(pattern, expected, rest string) { - parser := NewParser(pattern) + parser := NewParser(dummyLine, pattern) actual := parser.PkgbasePattern() c.Check(actual, equals, expected) c.Check(parser.Rest(), equals, rest) @@ -22,7 +22,7 @@ func (s *Suite) TestParser_PkgbasePattern(c *check.C) { func (s *Suite) TestParser_Dependency(c *check.C) { testDependencyRest := func(pattern string, expected DependencyPattern, rest string) { - parser := NewParser(pattern) + parser := NewParser(dummyLine, pattern) dp := parser.Dependency() if c.Check(dp, check.NotNil) { c.Check(*dp, equals, expected) @@ -53,7 +53,7 @@ func (s *Suite) TestParser_Dependency(c *check.C) { func (s *Suite) TestParser_MkTokens(c *check.C) { parse := func(input string, expectedTokens []*MkToken, expectedRest string) { - p := NewParser(input) + p := NewParser(dummyLine, input) actualTokens := p.MkTokens() c.Check(actualTokens, deepEquals, expectedTokens) for i, expectedToken := range expectedTokens { @@ -109,7 +109,6 @@ func (s *Suite) TestParser_MkTokens(c *check.C) { token("${_PERL5_VARS_OUT:M${_var_:tl}=*:S/^${_var_:tl}=${_PERL5_PREFIX:=/}//}", varuse("_PERL5_VARS_OUT", "M${_var_:tl}=*", "S/^${_var_:tl}=${_PERL5_PREFIX:=/}//")) token("${RUBY${RUBY_VER}_PATCHLEVEL}", varuse("RUBY${RUBY_VER}_PATCHLEVEL")) token("${DISTFILES:M*.gem}", varuse("DISTFILES", "M*.gem")) - token("$(GNUSTEP_USER_ROOT)", varuse("GNUSTEP_USER_ROOT")) token("${LOCALBASE:S^/^_^}", varuse("LOCALBASE", "S^/^_^")) token("${SOURCES:%.c=%.o}", varuse("SOURCES", "%.c=%.o")) token("${GIT_TEMPLATES:@.t.@ ${EGDIR}/${GIT_TEMPLATEDIR}/${.t.} ${PREFIX}/${GIT_CORE_TEMPLATEDIR}/${.t.} @:M*}", @@ -135,13 +134,21 @@ func (s *Suite) TestParser_MkTokens(c *check.C) { token("${VAR:ts\\000012}", varuse("VAR", "ts\\000012")) // The separator character can be a long octal number. token("${VAR:ts\\124}", varuse("VAR", "ts\\124")) // Or even decimal. + token("$(GNUSTEP_USER_ROOT)", varuse("GNUSTEP_USER_ROOT")) + c.Check(s.Output(), equals, "WARN: Please use curly braces {} instead of round parentheses () for GNUSTEP_USER_ROOT.\n") + parse("${VAR)", nil, "${VAR)") // Opening brace, closing parenthesis parse("$(VAR}", nil, "$(VAR}") // Opening parenthesis, closing brace + c.Check(s.Output(), equals, "WARN: Please use curly braces {} instead of round parentheses () for VAR.\n") + + token("${PLIST_SUBST_VARS:@var@${var}=${${var}:Q}@}", varuse("PLIST_SUBST_VARS", "@var@${var}=${${var}:Q}@")) + token("${PLIST_SUBST_VARS:@var@${var}=${${var}:Q}}", varuse("PLIST_SUBST_VARS", "@var@${var}=${${var}:Q}")) // Missing @ at the end + c.Check(s.Output(), equals, "WARN: Modifier ${PLIST_SUBST_VARS:@var@...@} is missing the final \"@\".\n") } func (s *Suite) TestParser_MkCond_Basics(c *check.C) { condrest := func(input string, expectedTree *Tree, expectedRest string) { - p := NewParser(input) + p := NewParser(dummyLine, input) actualTree := p.MkCond() c.Check(actualTree, deepEquals, expectedTree) c.Check(p.Rest(), equals, expectedRest) @@ -209,6 +216,8 @@ func (s *Suite) TestParser_MkCond_Basics(c *check.C) { NewTree("compareVarNum", varuse("OS_VERSION"), ">=", "6.5")) cond("${OS_VERSION} == 5.3", NewTree("compareVarNum", varuse("OS_VERSION"), "==", "5.3")) + cond("!empty(${OS_VARIANT:MIllumos})", // Probably not intended + NewTree("not", NewTree("empty", varuse("${OS_VARIANT:MIllumos}")))) // Errors condrest("!empty(PKG_OPTIONS:Msndfile) || defined(PKG_OPTIONS:Msamplerate)", |