pkgsrc-Changes-HG archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
[pkgsrc/trunk]: pkgsrc/pkgtools/pkglint/files Refactored the code into separa...
details: https://anonhg.NetBSD.org/pkgsrc/rev/ab7516ddc201
branches: trunk
changeset: 357826:ab7516ddc201
user: rillig <rillig%pkgsrc.org@localhost>
date: Sun Jan 29 14:27:48 2017 +0000
description:
Refactored the code into separate packages. No functional changes.
diffstat:
pkgtools/pkglint/files/buildlink3.go | 22 +-
pkgtools/pkglint/files/buildlink3_test.go | 71 ++++---
pkgtools/pkglint/files/category.go | 18 +-
pkgtools/pkglint/files/category_test.go | 3 +-
pkgtools/pkglint/files/check_test.go | 17 +-
pkgtools/pkglint/files/distinfo.go | 15 +-
pkgtools/pkglint/files/distinfo_test.go | 31 +-
pkgtools/pkglint/files/files.go | 15 +-
pkgtools/pkglint/files/files_test.go | 12 +-
pkgtools/pkglint/files/globaldata.go | 15 +-
pkgtools/pkglint/files/globaldata_test.go | 4 +-
pkgtools/pkglint/files/globalvars.go | 5 +-
pkgtools/pkglint/files/licenses.go | 4 +-
pkgtools/pkglint/files/licenses_test.go | 23 +-
pkgtools/pkglint/files/line.go | 37 +---
pkgtools/pkglint/files/line/line.go | 30 +++
pkgtools/pkglint/files/line_test.go | 38 ++--
pkgtools/pkglint/files/linechecker.go | 3 +-
pkgtools/pkglint/files/linechecker_test.go | 17 +-
pkgtools/pkglint/files/mkline.go | 144 ++++++++++-----
pkgtools/pkglint/files/mkline_test.go | 181 +++++++++++--------
pkgtools/pkglint/files/mklinechecker.go | 64 +++---
pkgtools/pkglint/files/mklinechecker_test.go | 90 +++++----
pkgtools/pkglint/files/mklines.go | 53 +++--
pkgtools/pkglint/files/mklines_test.go | 129 +++++++------
pkgtools/pkglint/files/mkparser.go | 3 +-
pkgtools/pkglint/files/mkparser_test.go | 19 +-
pkgtools/pkglint/files/mkshparser.go | 3 +-
pkgtools/pkglint/files/package.go | 99 +++++-----
pkgtools/pkglint/files/package_test.go | 52 +++--
pkgtools/pkglint/files/parser.go | 5 +-
pkgtools/pkglint/files/patches.go | 30 +-
pkgtools/pkglint/files/patches_test.go | 83 +++++---
pkgtools/pkglint/files/pkglint.go | 7 +-
pkgtools/pkglint/files/pkglint_test.go | 47 +++--
pkgtools/pkglint/files/plist.go | 17 +-
pkgtools/pkglint/files/plist_test.go | 87 +++++----
pkgtools/pkglint/files/shell.go | 77 ++++----
pkgtools/pkglint/files/shell_test.go | 221 +++++++++++++-----------
pkgtools/pkglint/files/shtokenizer.go | 7 +-
pkgtools/pkglint/files/shtokenizer_test.go | 6 +-
pkgtools/pkglint/files/substcontext.go | 8 +-
pkgtools/pkglint/files/substcontext_test.go | 18 +-
pkgtools/pkglint/files/textproc/expecter.go | 112 ++++++++++++
pkgtools/pkglint/files/toplevel.go | 7 +-
pkgtools/pkglint/files/toplevel_test.go | 10 +-
pkgtools/pkglint/files/util.go | 5 +-
pkgtools/pkglint/files/vardefs.go | 2 +-
pkgtools/pkglint/files/vartypecheck.go | 11 +-
pkgtools/pkglint/files/vartypecheck_test.go | 243 ++++++++++++++++----------
50 files changed, 1318 insertions(+), 902 deletions(-)
diffs (truncated from 5745 to 300 lines):
diff -r ac719c1adb54 -r ab7516ddc201 pkgtools/pkglint/files/buildlink3.go
--- a/pkgtools/pkglint/files/buildlink3.go Sun Jan 29 12:48:09 2017 +0000
+++ b/pkgtools/pkglint/files/buildlink3.go Sun Jan 29 14:27:48 2017 +0000
@@ -1,7 +1,9 @@
package main
import (
+ "netbsd.org/pkglint/line"
"netbsd.org/pkglint/pkgver"
+ "netbsd.org/pkglint/textproc"
"netbsd.org/pkglint/trace"
"strings"
)
@@ -13,7 +15,7 @@
mklines.Check()
- exp := NewExpecter(mklines.lines)
+ exp := textproc.NewExpecter(mklines.lines)
for exp.AdvanceIfPrefix("#") {
line := exp.PreviousLine()
@@ -23,7 +25,7 @@
}
}
- exp.ExpectEmptyLine()
+ exp.ExpectEmptyLine(G.opts.WarnSpace)
if exp.AdvanceIfMatches(`^BUILDLINK_DEPMETHOD\.(\S+)\?=.*$`) {
exp.PreviousLine().Warnf("This line belongs inside the .ifdef block.")
@@ -32,7 +34,7 @@
}
pkgbaseLine, pkgbase := exp.CurrentLine(), ""
- var abiLine, apiLine Line
+ var abiLine, apiLine line.Line
var abi, api *DependencyPattern
// First paragraph: Introduction of the package identifier
@@ -40,7 +42,7 @@
exp.CurrentLine().Warnf("Expected a BUILDLINK_TREE line.")
return
}
- pkgbase = exp.m[1]
+ pkgbase = exp.Group(1)
if containsVarRef(pkgbase) {
warned := false
for _, pair := range [...]struct{ varuse, simple string }{
@@ -70,19 +72,19 @@
}
}
- exp.ExpectEmptyLine()
+ exp.ExpectEmptyLine(G.opts.WarnSpace)
// Second paragraph: multiple inclusion protection and introduction
// of the uppercase package identifier.
if !exp.AdvanceIfMatches(`^\.if !defined\((\S+)_BUILDLINK3_MK\)$`) {
return
}
- pkgupperLine, pkgupper := exp.PreviousLine(), exp.m[1]
+ pkgupperLine, pkgupper := exp.PreviousLine(), exp.Group(1)
if !exp.ExpectText(pkgupper + "_BUILDLINK3_MK:=") {
return
}
- exp.ExpectEmptyLine()
+ exp.ExpectEmptyLine(G.opts.WarnSpace)
// See pkgtools/createbuildlink/files/createbuildlink, keyword PKGUPPER
ucPkgbase := strings.ToUpper(strings.Replace(pkgbase, "-", "_", -1))
@@ -93,7 +95,7 @@
if G.Pkg != nil {
if mkbase := G.Pkg.EffectivePkgbase; mkbase != "" && mkbase != pkgbase {
pkgbaseLine.Errorf("Package name mismatch between %q in this file and %q from %s.",
- pkgbase, mkbase, G.Pkg.EffectivePkgnameLine.Line.ReferenceFrom(pkgbaseLine))
+ pkgbase, mkbase, G.Pkg.EffectivePkgnameLine.ReferenceFrom(pkgbaseLine))
}
}
@@ -106,7 +108,7 @@
}
line := exp.CurrentLine()
- mkline := mklines.mklines[exp.index]
+ mkline := mklines.mklines[exp.Index()]
if mkline.IsVarassign() {
exp.Advance()
@@ -185,7 +187,7 @@
if apiLine == nil {
exp.CurrentLine().Warnf("Definition of BUILDLINK_API_DEPENDS is missing.")
}
- exp.ExpectEmptyLine()
+ exp.ExpectEmptyLine(G.opts.WarnSpace)
// Fourth paragraph: Cleanup, corresponding to the first paragraph.
if !exp.ExpectText("BUILDLINK_TREE+=\t-" + pkgbase) {
diff -r ac719c1adb54 -r ab7516ddc201 pkgtools/pkglint/files/buildlink3_test.go
--- a/pkgtools/pkglint/files/buildlink3_test.go Sun Jan 29 12:48:09 2017 +0000
+++ b/pkgtools/pkglint/files/buildlink3_test.go Sun Jan 29 14:27:48 2017 +0000
@@ -5,6 +5,7 @@
)
func (s *Suite) Test_ChecklinesBuildlink3Mk(c *check.C) {
+ s.Init(c)
G.globalData.InitVartypes()
mklines := s.NewMkLines("buildlink3.mk",
mkrcsid,
@@ -27,17 +28,18 @@
ChecklinesBuildlink3Mk(mklines)
- c.Check(s.Output(), equals, ""+
- "ERROR: buildlink3.mk:12: \"/x11/Xbae\" does not exist.\n"+
- "ERROR: buildlink3.mk:12: There is no package in \"x11/Xbae\".\n"+
- "ERROR: buildlink3.mk:14: \"/mk/motif.buildlink3.mk\" does not exist.\n"+
- "ERROR: buildlink3.mk:2: This comment indicates unfinished work (url2pkg).\n")
+ s.CheckOutputLines(
+ "ERROR: buildlink3.mk:12: \"/x11/Xbae\" does not exist.",
+ "ERROR: buildlink3.mk:12: There is no package in \"x11/Xbae\".",
+ "ERROR: buildlink3.mk:14: \"/mk/motif.buildlink3.mk\" does not exist.",
+ "ERROR: buildlink3.mk:2: This comment indicates unfinished work (url2pkg).")
}
// Before version 5.3, pkglint wrongly warned here.
// The mk/haskell.mk file takes care of constructing the correct PKGNAME,
// but pkglint had not looked at that file.
func (s *Suite) Test_ChecklinesBuildlink3Mk_name_mismatch(c *check.C) {
+ s.Init(c)
G.globalData.InitVartypes()
G.Pkg = NewPackage("x11/hs-X11")
G.Pkg.EffectivePkgbase = "X11"
@@ -59,10 +61,12 @@
ChecklinesBuildlink3Mk(mklines)
- c.Check(s.Output(), equals, "ERROR: buildlink3.mk:3: Package name mismatch between \"hs-X11\" in this file and \"X11\" from Makefile:3.\n")
+ s.CheckOutputLines(
+ "ERROR: buildlink3.mk:3: Package name mismatch between \"hs-X11\" in this file and \"X11\" from Makefile:3.")
}
func (s *Suite) Test_ChecklinesBuildlink3Mk_name_mismatch_multiple_inclusion(c *check.C) {
+ s.Init(c)
G.globalData.InitVartypes()
mklines := s.NewMkLines("buildlink3.mk",
mkrcsid,
@@ -78,12 +82,13 @@
ChecklinesBuildlink3Mk(mklines)
- c.Check(s.Output(), equals, ""+
- "ERROR: buildlink3.mk:5: Package name mismatch between multiple-inclusion guard \"PKGBASE2\" (expected \"PKGBASE1\") and package name \"pkgbase1\" (from line 3).\n"+
- "WARN: buildlink3.mk:9: Definition of BUILDLINK_API_DEPENDS is missing.\n")
+ s.CheckOutputLines(
+ "ERROR: buildlink3.mk:5: Package name mismatch between multiple-inclusion guard \"PKGBASE2\" (expected \"PKGBASE1\") and package name \"pkgbase1\" (from line 3).",
+ "WARN: buildlink3.mk:9: Definition of BUILDLINK_API_DEPENDS is missing.")
}
func (s *Suite) Test_ChecklinesBuildlink3Mk_name_mismatch_abi_api(c *check.C) {
+ s.Init(c)
G.globalData.InitVartypes()
mklines := s.NewMkLines("buildlink3.mk",
mkrcsid,
@@ -102,10 +107,12 @@
ChecklinesBuildlink3Mk(mklines)
- c.Check(s.Output(), equals, "WARN: buildlink3.mk:9: Package name mismatch between ABI \"hs-X12\" and API \"hs-X11\" (from line 8).\n")
+ s.CheckOutputLines(
+ "WARN: buildlink3.mk:9: Package name mismatch between ABI \"hs-X12\" and API \"hs-X11\" (from line 8).")
}
func (s *Suite) Test_ChecklinesBuildlink3Mk_abi_api_versions(c *check.C) {
+ s.Init(c)
G.globalData.InitVartypes()
mklines := s.NewMkLines("buildlink3.mk",
mkrcsid,
@@ -124,11 +131,12 @@
ChecklinesBuildlink3Mk(mklines)
- c.Check(s.Output(), equals, ""+
- "WARN: buildlink3.mk:9: ABI version \"1.6.0\" should be at least API version \"1.6.1\" (see line 8).\n")
+ s.CheckOutputLines(
+ "WARN: buildlink3.mk:9: ABI version \"1.6.0\" should be at least API version \"1.6.1\" (see line 8).")
}
func (s *Suite) Test_ChecklinesBuildlink3Mk_no_BUILDLINK_TREE_at_beginning(c *check.C) {
+ s.Init(c)
G.globalData.InitVartypes()
mklines := s.NewMkLines("buildlink3.mk",
mkrcsid,
@@ -146,10 +154,12 @@
ChecklinesBuildlink3Mk(mklines)
- c.Check(s.Output(), equals, "WARN: buildlink3.mk:3: Expected a BUILDLINK_TREE line.\n")
+ s.CheckOutputLines(
+ "WARN: buildlink3.mk:3: Expected a BUILDLINK_TREE line.")
}
func (s *Suite) Test_ChecklinesBuildlink3Mk_no_BUILDLINK_TREE_at_end(c *check.C) {
+ s.Init(c)
G.globalData.InitVartypes()
mklines := s.NewMkLines("buildlink3.mk",
mkrcsid,
@@ -171,12 +181,13 @@
ChecklinesBuildlink3Mk(mklines)
- c.Check(s.Output(), equals, ""+
- "WARN: buildlink3.mk:3: This line belongs inside the .ifdef block.\n"+
- "WARN: buildlink3.mk:15: This line should contain the following text: BUILDLINK_TREE+=\t-hs-X11\n")
+ s.CheckOutputLines(
+ "WARN: buildlink3.mk:3: This line belongs inside the .ifdef block.",
+ "WARN: buildlink3.mk:15: This line should contain the following text: BUILDLINK_TREE+=\t-hs-X11")
}
func (s *Suite) Test_ChecklinesBuildlink3Mk_multiple_inclusion_wrong(c *check.C) {
+ s.Init(c)
G.globalData.InitVartypes()
mklines := s.NewMkLines("buildlink3.mk",
mkrcsid,
@@ -188,12 +199,13 @@
ChecklinesBuildlink3Mk(mklines)
- c.Check(s.Output(), equals, ""+
- "WARN: buildlink3.mk:6: UNRELATED_BUILDLINK3_MK is defined but not used. Spelling mistake?\n"+
- "WARN: buildlink3.mk:6: This line should contain the following text: HS_X11_BUILDLINK3_MK:=\n")
+ s.CheckOutputLines(
+ "WARN: buildlink3.mk:6: UNRELATED_BUILDLINK3_MK is defined but not used. Spelling mistake?",
+ "WARN: buildlink3.mk:6: This line should contain the following text: HS_X11_BUILDLINK3_MK:=")
}
func (s *Suite) Test_ChecklinesBuildlink3Mk_missing_endif(c *check.C) {
+ s.Init(c)
G.globalData.InitVartypes()
mklines := s.NewMkLines("buildlink3.mk",
mkrcsid,
@@ -205,10 +217,12 @@
ChecklinesBuildlink3Mk(mklines)
- c.Check(s.Output(), equals, "WARN: buildlink3.mk:EOF: Expected .endif\n")
+ s.CheckOutputLines(
+ "WARN: buildlink3.mk:EOF: Expected .endif")
}
func (s *Suite) Test_ChecklinesBuildlink3Mk_unknown_dependency_patterns(c *check.C) {
+ s.Init(c)
G.globalData.InitVartypes()
mklines := s.NewMkLines("buildlink3.mk",
mkrcsid,
@@ -228,12 +242,13 @@
ChecklinesBuildlink3Mk(mklines)
- c.Check(s.Output(), equals, ""+
- "WARN: buildlink3.mk:9: Unknown dependency pattern \"hs-X11!=1.6.1\".\n"+
- "WARN: buildlink3.mk:10: Unknown dependency pattern \"hs-X11!=1.6.1.2nb2\".\n")
+ s.CheckOutputLines(
+ "WARN: buildlink3.mk:9: Unknown dependency pattern \"hs-X11!=1.6.1\".",
+ "WARN: buildlink3.mk:10: Unknown dependency pattern \"hs-X11!=1.6.1.2nb2\".")
}
func (s *Suite) Test_ChecklinesBuildlink3Mk_PKGBASE_with_variable(c *check.C) {
+ s.Init(c)
G.globalData.InitVartypes()
mklines := s.NewMkLines("buildlink3.mk",
mkrcsid,
@@ -252,10 +267,12 @@
ChecklinesBuildlink3Mk(mklines)
- c.Check(s.Output(), equals, "WARN: buildlink3.mk:3: Please use \"py\" instead of \"${PYPKGPREFIX}\" (also in other variables in this file).\n")
+ s.CheckOutputLines(
+ "WARN: buildlink3.mk:3: Please use \"py\" instead of \"${PYPKGPREFIX}\" (also in other variables in this file).")
}
func (s *Suite) Test_ChecklinesBuildlink3Mk_PKGBASE_with_unknown_variable(c *check.C) {
+ s.Init(c)
G.globalData.InitVartypes()
mklines := s.NewMkLines("buildlink3.mk",
mkrcsid,
@@ -274,7 +291,7 @@
ChecklinesBuildlink3Mk(mklines)
- c.Check(s.Output(), equals, ""+
- "WARN: buildlink3.mk:3: Please replace \"${LICENSE}\" with a simple string (also in other variables in this file).\n"+
- "WARN: buildlink3.mk:13: This line should contain the following text: BUILDLINK_TREE+=\t-${LICENSE}-wxWidgets\n")
+ s.CheckOutputLines(
+ "WARN: buildlink3.mk:3: Please replace \"${LICENSE}\" with a simple string (also in other variables in this file).",
+ "WARN: buildlink3.mk:13: This line should contain the following text: BUILDLINK_TREE+=\t-${LICENSE}-wxWidgets")
}
diff -r ac719c1adb54 -r ab7516ddc201 pkgtools/pkglint/files/category.go
--- a/pkgtools/pkglint/files/category.go Sun Jan 29 12:48:09 2017 +0000
Home |
Main Index |
Thread Index |
Old Index