pkgtools/pkglint: update to 19.4.9
Changes since 19.4.8: Packages that include omf-scrollkeeper.mk even though their PLIST doesn't contain any .omf files will generate an error message, suggesting that the .include line be removed.
This commit is contained in:
parent
e8dee3aa69
commit
27fa54b11d
8 changed files with 158 additions and 17 deletions
|
@ -1,6 +1,6 @@
|
|||
# $NetBSD: Makefile,v 1.631 2020/02/15 13:48:40 rillig Exp $
|
||||
# $NetBSD: Makefile,v 1.632 2020/02/17 20:22:21 rillig Exp $
|
||||
|
||||
PKGNAME= pkglint-19.4.8
|
||||
PKGNAME= pkglint-19.4.9
|
||||
CATEGORIES= pkgtools
|
||||
DISTNAME= tools
|
||||
MASTER_SITES= ${MASTER_SITE_GITHUB:=golang/}
|
||||
|
|
|
@ -219,7 +219,7 @@ func (fix *Autofix) Delete() {
|
|||
// and if so, call Describef to describe the actual fix.
|
||||
//
|
||||
// If autofix is false, the fix should be applied, as far as only
|
||||
// in-memory data structures are effected, and these are not written
|
||||
// in-memory data structures are affected, and these are not written
|
||||
// back to disk. No externally observable modification must be done.
|
||||
// For example, changing the text of Line.raw is appropriate,
|
||||
// but changing files in the file system is not.
|
||||
|
|
|
@ -651,7 +651,7 @@ func (pkg *Package) checkfilePackageMakefile(filename CurrPath, mklines *MkLines
|
|||
// This check is experimental because it's not yet clear how to
|
||||
// classify the various Python packages and whether all Python
|
||||
// packages really need the prefix.
|
||||
if G.Experimental && pkg.EffectivePkgname != "" && pkg.Includes("../../lang/python/extension.mk") {
|
||||
if G.Experimental && pkg.EffectivePkgname != "" && pkg.Includes("../../lang/python/extension.mk") != nil {
|
||||
pkg.EffectivePkgnameLine.Warnf("The PKGNAME of Python extensions should start with ${PYPKGPREFIX}.")
|
||||
}
|
||||
|
||||
|
@ -1529,9 +1529,12 @@ func (pkg *Package) Rel(filename CurrPath) PackagePath {
|
|||
|
||||
// Returns whether the given file (relative to the package directory)
|
||||
// is included somewhere in the package, either directly or indirectly.
|
||||
func (pkg *Package) Includes(filename PackagePath) bool {
|
||||
return pkg.unconditionalIncludes[filename] != nil ||
|
||||
pkg.conditionalIncludes[filename] != nil
|
||||
func (pkg *Package) Includes(filename PackagePath) *MkLine {
|
||||
mkline := pkg.unconditionalIncludes[filename]
|
||||
if mkline == nil {
|
||||
mkline = pkg.conditionalIncludes[filename]
|
||||
}
|
||||
return mkline
|
||||
}
|
||||
|
||||
// PlistContent lists the directories and files that appear in the
|
||||
|
|
|
@ -3525,9 +3525,9 @@ func (s *Suite) Test_Package_Includes(c *check.C) {
|
|||
|
||||
pkg.load()
|
||||
|
||||
t.CheckEquals(pkg.Includes("unconditionally.mk"), true)
|
||||
t.CheckEquals(pkg.Includes("conditionally.mk"), true)
|
||||
t.CheckEquals(pkg.Includes("other.mk"), false)
|
||||
t.CheckEquals(pkg.Includes("unconditionally.mk") != nil, true)
|
||||
t.CheckEquals(pkg.Includes("conditionally.mk") != nil, true)
|
||||
t.CheckEquals(pkg.Includes("other.mk") != nil, false)
|
||||
|
||||
// The file never.mk is in conditionalIncludes since pkglint only
|
||||
// analyzes on the syntactical level. It doesn't evaluate the
|
||||
|
|
|
@ -1407,6 +1407,24 @@ func (s *Suite) Test_Pkgsrc_File(c *check.C) {
|
|||
test("filename", "filename")
|
||||
}
|
||||
|
||||
func (s *Suite) Test_Pkgsrc_FilePkg(c *check.C) {
|
||||
t := s.Init(c)
|
||||
|
||||
t.Chdir(".")
|
||||
|
||||
test := func(rel PackagePath, abs CurrPath) {
|
||||
actual := G.Pkgsrc.FilePkg(rel)
|
||||
t.CheckEquals(actual, abs)
|
||||
}
|
||||
|
||||
test("", "")
|
||||
test("category/package", "")
|
||||
test("../package", "")
|
||||
test("../../category", "")
|
||||
test("../../category/package", "category/package")
|
||||
test("../../../something", "")
|
||||
}
|
||||
|
||||
func (s *Suite) Test_Change_Version(c *check.C) {
|
||||
t := s.Init(c)
|
||||
|
||||
|
|
|
@ -72,6 +72,7 @@ func (ck *PlistChecker) Check(plainLines *Lines) {
|
|||
ck.checkLine(pline)
|
||||
pline.CheckTrailingWhitespace()
|
||||
}
|
||||
ck.checkOmf(plines)
|
||||
CheckLinesTrailingEmptyLines(plainLines)
|
||||
|
||||
sorter := NewPlistLineSorter(plines)
|
||||
|
@ -498,6 +499,29 @@ func (ck *PlistChecker) checkCond(pline *PlistLine, cond string) {
|
|||
cond)
|
||||
}
|
||||
|
||||
func (ck *PlistChecker) checkOmf(plines []*PlistLine) {
|
||||
if ck.pkg == nil {
|
||||
return
|
||||
}
|
||||
mkline := ck.pkg.Includes("../../mk/omf-scrollkeeper.mk")
|
||||
if mkline == nil {
|
||||
return
|
||||
}
|
||||
|
||||
for _, pline := range plines {
|
||||
if hasSuffix(pline.text, ".omf") {
|
||||
return
|
||||
}
|
||||
}
|
||||
|
||||
fix := mkline.Autofix()
|
||||
fix.Errorf("Only packages that have .omf files in their PLIST may include omf-scrollkeeper.mk.")
|
||||
if !mkline.HasRationale() {
|
||||
fix.Delete()
|
||||
}
|
||||
fix.Apply()
|
||||
}
|
||||
|
||||
type PlistLine struct {
|
||||
*Line
|
||||
conditions []string // e.g. PLIST.docs
|
||||
|
|
|
@ -1106,6 +1106,58 @@ func (s *Suite) Test_PlistChecker_checkCond__hacks_mk(c *check.C) {
|
|||
"in the package Makefile.")
|
||||
}
|
||||
|
||||
func (s *Suite) Test_PlistChecker_checkOmf__autofix(c *check.C) {
|
||||
t := s.Init(c)
|
||||
|
||||
t.CreateFileLines("mk/omf-scrollkeeper.mk",
|
||||
MkCvsID)
|
||||
t.SetUpPackage("category/package",
|
||||
".include \"../../mk/omf-scrollkeeper.mk\"")
|
||||
t.Chdir("category/package")
|
||||
t.FinishSetUp()
|
||||
|
||||
t.ExpectDiagnosticsAutofix(
|
||||
func(bool) { G.checkdirPackage(".") },
|
||||
"ERROR: Makefile:20: Only packages that have .omf files in "+
|
||||
"their PLIST may include omf-scrollkeeper.mk.",
|
||||
"AUTOFIX: Makefile:20: Deleting this line.")
|
||||
}
|
||||
|
||||
func (s *Suite) Test_PlistChecker_checkOmf__rationale(c *check.C) {
|
||||
t := s.Init(c)
|
||||
|
||||
t.CreateFileLines("mk/omf-scrollkeeper.mk",
|
||||
MkCvsID)
|
||||
t.SetUpPackage("category/package",
|
||||
".include \"../../mk/omf-scrollkeeper.mk\" # needs to stay")
|
||||
t.Chdir("category/package")
|
||||
t.FinishSetUp()
|
||||
|
||||
t.ExpectDiagnosticsAutofix(
|
||||
func(bool) { G.checkdirPackage(".") },
|
||||
"ERROR: Makefile:20: Only packages that have .omf files in "+
|
||||
"their PLIST may include omf-scrollkeeper.mk.")
|
||||
}
|
||||
|
||||
func (s *Suite) Test_PlistChecker_checkOmf__ok(c *check.C) {
|
||||
t := s.Init(c)
|
||||
|
||||
t.CreateFileLines("mk/omf-scrollkeeper.mk",
|
||||
MkCvsID)
|
||||
t.SetUpPackage("category/package",
|
||||
".include \"../../mk/omf-scrollkeeper.mk\" # needs to stay")
|
||||
t.Chdir("category/package")
|
||||
t.CreateFileLines("PLIST",
|
||||
PlistCvsID,
|
||||
"bin/program",
|
||||
"share/omf/documentation.omf")
|
||||
t.FinishSetUp()
|
||||
|
||||
t.ExpectDiagnosticsAutofix(
|
||||
func(bool) { G.checkdirPackage(".") },
|
||||
nil...)
|
||||
}
|
||||
|
||||
func (s *Suite) Test_PlistLine_Path(c *check.C) {
|
||||
t := s.Init(c)
|
||||
|
||||
|
|
|
@ -3134,11 +3134,28 @@ func (s *Suite) Test_VaralignBlock_Finish__continuation_beyond_right_margin(c *c
|
|||
}
|
||||
|
||||
func (s *Suite) Test_varalignLine_realignDetails(c *check.C) {
|
||||
t := s.Init(c)
|
||||
vt := NewVaralignTester(s, c)
|
||||
|
||||
// FIXME
|
||||
|
||||
t.CheckOutputEmpty()
|
||||
// Just a random example to exercise some of the code paths,
|
||||
// with no particular intention.
|
||||
vt.Input(
|
||||
"VAR=\t\tvalue",
|
||||
"VAR= \\",
|
||||
"\t\t ..24 \\",
|
||||
"\t..12")
|
||||
vt.Diagnostics(
|
||||
"NOTE: Makefile:2: This variable value should be aligned "+
|
||||
"with tabs, not spaces, to column 17 instead of 6.",
|
||||
"NOTE: Makefile:3: This continuation line should be indented with \"\\t\\t\".")
|
||||
vt.Autofixes(
|
||||
"AUTOFIX: Makefile:2: Replacing \" \" with \"\\t\\t\".",
|
||||
"AUTOFIX: Makefile:3: Replacing \"\\t\\t \" with \"\\t\\t\".")
|
||||
vt.Fixed(
|
||||
"VAR= value",
|
||||
"VAR= \\",
|
||||
" ..24 \\",
|
||||
" ..12")
|
||||
vt.Run()
|
||||
}
|
||||
|
||||
func (s *Suite) Test_VaralignSplitter_split(c *check.C) {
|
||||
|
@ -4391,15 +4408,42 @@ func (s *Suite) Test_varalignLine_alignContinuation(c *check.C) {
|
|||
func (s *Suite) Test_varalignLine_replaceSpaceBeforeValue(c *check.C) {
|
||||
t := s.Init(c)
|
||||
|
||||
// FIXME
|
||||
t.SetUpCommandLine("--autofix", "--show-autofix")
|
||||
mklines := t.NewMkLines("filename.mk",
|
||||
"VAR= \t value")
|
||||
line := mklines.lines.Lines[0]
|
||||
parts := NewVaralignSplitter().split(line.RawText(0), true)
|
||||
info := varalignLine{line, 0, false, parts}
|
||||
fix := line.Autofix()
|
||||
fix.Warnf("Warning.")
|
||||
|
||||
t.CheckOutputEmpty()
|
||||
info.replaceSpaceBeforeValue(fix, "\t\t")
|
||||
fix.Apply()
|
||||
|
||||
t.CheckOutputLines(
|
||||
"WARN: filename.mk:1: Warning.",
|
||||
"AUTOFIX: filename.mk:1: Replacing \" \\t \" with \"\\t\\t\".")
|
||||
}
|
||||
|
||||
func (s *Suite) Test_varalignLine_replaceSpaceBeforeContinuationSilently(c *check.C) {
|
||||
t := s.Init(c)
|
||||
|
||||
// FIXME
|
||||
t.SetUpCommandLine("--autofix", "--show-autofix")
|
||||
mklines := t.NewMkLines("filename.mk",
|
||||
"VAR= \t value \\",
|
||||
"\\tend")
|
||||
line := mklines.lines.Lines[0]
|
||||
parts := NewVaralignSplitter().split(line.RawText(0), true)
|
||||
info := varalignLine{line, 0, false, parts}
|
||||
fix := line.Autofix()
|
||||
fix.Warnf("Warning.")
|
||||
|
||||
info.replaceSpaceBeforeContinuationSilently(fix, 32)
|
||||
fix.Apply()
|
||||
|
||||
t.CheckOutputLines(
|
||||
"WARN: filename.mk:1: Warning.",
|
||||
"AUTOFIX: filename.mk:1: Replacing \" \\\\\" with \"\\t\\t\\t\\\\\".")
|
||||
|
||||
t.CheckOutputEmpty()
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue