pkgsrc-Changes-HG archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
[pkgsrc/trunk]: pkgsrc/pkgtools/pkglint pkgtools/pkglint: update to 5.7.7
details: https://anonhg.NetBSD.org/pkgsrc/rev/c709d3b48c10
branches: trunk
changeset: 332962:c709d3b48c10
user: rillig <rillig%pkgsrc.org@localhost>
date: Sat Apr 27 19:33:56 2019 +0000
description:
pkgtools/pkglint: update to 5.7.7
Changes since 5.7.6:
Warn about packages that override user-settable variables. Packages that
define variables with the same value as the default value only get a
note instead of the warning since these definitions do not cause any
confusion.
Do not suppress technical error messages in autofix mode.
Do not warn about the package version being greater than the latest from
doc/CHANGES if the file defining the package version has been modified
locally and is about to be committed.
diffstat:
pkgtools/pkglint/Makefile | 4 +-
pkgtools/pkglint/files/autofix.go | 6 +-
pkgtools/pkglint/files/autofix_test.go | 18 +-
pkgtools/pkglint/files/category_test.go | 9 -
pkgtools/pkglint/files/check_test.go | 51 ++-
pkgtools/pkglint/files/logging.go | 18 +
pkgtools/pkglint/files/logging_test.go | 11 +
pkgtools/pkglint/files/mkline.go | 2 +-
pkgtools/pkglint/files/mkline_test.go | 1 -
pkgtools/pkglint/files/mklinechecker.go | 63 +++-
pkgtools/pkglint/files/mklinechecker_test.go | 104 +++++-
pkgtools/pkglint/files/mklines.go | 2 +-
pkgtools/pkglint/files/mklines_test.go | 2 +
pkgtools/pkglint/files/mkparser_test.go | 8 +
pkgtools/pkglint/files/package.go | 2 +-
pkgtools/pkglint/files/package_test.go | 5 -
pkgtools/pkglint/files/pkglint.go | 2 +-
pkgtools/pkglint/files/pkglint_test.go | 11 +-
pkgtools/pkglint/files/pkgsrc.go | 23 +-
pkgtools/pkglint/files/pkgsrc_test.go | 46 ++
pkgtools/pkglint/files/shell_test.go | 3 -
pkgtools/pkglint/files/util.go | 59 ++-
pkgtools/pkglint/files/util_test.go | 55 ++
pkgtools/pkglint/files/vardefs.go | 515 +++++++++++++-------------
pkgtools/pkglint/files/vartypecheck.go | 2 +-
pkgtools/pkglint/files/vartypecheck_test.go | 4 +-
26 files changed, 690 insertions(+), 336 deletions(-)
diffs (truncated from 1684 to 300 lines):
diff -r ff671c02608c -r c709d3b48c10 pkgtools/pkglint/Makefile
--- a/pkgtools/pkglint/Makefile Sat Apr 27 19:04:32 2019 +0000
+++ b/pkgtools/pkglint/Makefile Sat Apr 27 19:33:56 2019 +0000
@@ -1,6 +1,6 @@
-# $NetBSD: Makefile,v 1.576 2019/04/23 21:20:49 rillig Exp $
+# $NetBSD: Makefile,v 1.577 2019/04/27 19:33:56 rillig Exp $
-PKGNAME= pkglint-5.7.6
+PKGNAME= pkglint-5.7.7
CATEGORIES= pkgtools
DISTNAME= tools
MASTER_SITES= ${MASTER_SITE_GITHUB:=golang/}
diff -r ff671c02608c -r c709d3b48c10 pkgtools/pkglint/files/autofix.go
--- a/pkgtools/pkglint/files/autofix.go Sat Apr 27 19:04:32 2019 +0000
+++ b/pkgtools/pkglint/files/autofix.go Sat Apr 27 19:33:56 2019 +0000
@@ -455,14 +455,12 @@
}
err := ioutil.WriteFile(tmpName, []byte(text.String()), 0666)
if err != nil {
- G.Logf(Error, tmpName, "", "Cannot write: %s", "Cannot write: "+err.Error())
+ G.Logger.Errorf(tmpName, "Cannot write: %s", err)
continue
}
err = os.Rename(tmpName, filename)
if err != nil {
- G.Logf(Error, tmpName, "",
- "Cannot overwrite with autofixed content: %s",
- "Cannot overwrite with autofixed content: "+err.Error())
+ G.Logger.Errorf(tmpName, "Cannot overwrite with autofixed content: %s", err)
continue
}
autofixed = true
diff -r ff671c02608c -r c709d3b48c10 pkgtools/pkglint/files/autofix_test.go
--- a/pkgtools/pkglint/files/autofix_test.go Sat Apr 27 19:04:32 2019 +0000
+++ b/pkgtools/pkglint/files/autofix_test.go Sat Apr 27 19:33:56 2019 +0000
@@ -1098,9 +1098,9 @@
SaveAutofixChanges(lines)
- c.Check(t.Output(), check.Matches, ""+
- "AUTOFIX: ~/subdir/file.txt:1: Replacing \"line\" with \"Line\".\n"+
- "ERROR: ~/subdir/file.txt.pkglint.tmp: Cannot write: .*\n")
+ t.CheckOutputMatches(
+ "AUTOFIX: ~/subdir/file.txt:1: Replacing \"line\" with \"Line\".",
+ `ERROR: ~/subdir/file.txt.pkglint.tmp: Cannot write: .*`)
}
func (s *Suite) Test_SaveAutofixChanges__file_busy_Windows(c *check.C) {
@@ -1126,9 +1126,9 @@
SaveAutofixChanges(lines)
- c.Check(t.Output(), check.Matches, ""+
- "AUTOFIX: ~/subdir/file.txt:1: Replacing \"line\" with \"Line\".\n"+
- "ERROR: ~/subdir/file.txt.pkglint.tmp: Cannot overwrite with autofixed content: .*\n")
+ t.CheckOutputMatches(
+ "AUTOFIX: ~/subdir/file.txt:1: Replacing \"line\" with \"Line\".",
+ `ERROR: ~/subdir/file.txt.pkglint.tmp: Cannot overwrite with autofixed content: .*`)
}
// This test covers the highly unlikely situation in which a file is loaded
@@ -1153,9 +1153,9 @@
SaveAutofixChanges(lines)
- c.Check(t.Output(), check.Matches, ""+
- "AUTOFIX: ~/file.txt:1: Replacing \"line\" with \"Line\".\n"+
- "ERROR: ~/file.txt.pkglint.tmp: Cannot overwrite with autofixed content: .*\n")
+ t.CheckOutputMatches(
+ "AUTOFIX: ~/file.txt:1: Replacing \"line\" with \"Line\".",
+ `ERROR: ~/file.txt.pkglint.tmp: Cannot overwrite with autofixed content: .*`)
}
// Up to 2018-11-25, pkglint in some cases logged only the source without
diff -r ff671c02608c -r c709d3b48c10 pkgtools/pkglint/files/category_test.go
--- a/pkgtools/pkglint/files/category_test.go Sat Apr 27 19:04:32 2019 +0000
+++ b/pkgtools/pkglint/files/category_test.go Sat Apr 27 19:33:56 2019 +0000
@@ -69,7 +69,6 @@
t := s.Init(c)
t.SetUpPkgsrc()
- t.SetUpVartypes()
t.CreateFileLines("mk/misc/category.mk")
t.CreateFileLines("wip/package/Makefile")
t.CreateFileLines("wip/Makefile",
@@ -95,7 +94,6 @@
t := s.Init(c)
t.SetUpPkgsrc()
- t.SetUpVartypes()
t.CreateFileLines("mk/misc/category.mk")
t.CreateFileLines("category/in-wrong-order/Makefile")
t.CreateFileLines("category/duplicate/Makefile")
@@ -136,7 +134,6 @@
t := s.Init(c)
t.SetUpPkgsrc()
- t.SetUpVartypes()
t.CreateFileLines("mk/misc/category.mk")
t.CreateFileLines("category/both/Makefile")
t.CreateFileLines("category/Makefile",
@@ -164,7 +161,6 @@
t := s.Init(c)
t.SetUpPkgsrc()
- t.SetUpVartypes()
t.CreateFileLines("mk/misc/category.mk")
t.CreateFileLines("category/above-only-in-fs/Makefile")
t.CreateFileLines("category/both/Makefile")
@@ -193,7 +189,6 @@
t.SetUpCommandLine("-r")
t.SetUpPkgsrc()
- t.SetUpVartypes()
t.CreateFileLines("mk/misc/category.mk")
t.CreateFileLines("category/commented/Makefile")
t.CreateFileLines("category/package/Makefile")
@@ -231,7 +226,6 @@
t.SetUpCommandLine("-Wall", "--show-autofix")
t.SetUpPkgsrc()
- t.SetUpVartypes()
t.CreateFileLines("mk/misc/category.mk")
t.CreateFileLines("category/mk-and-fs/Makefile")
t.CreateFileLines("category/zzz-fs-only/Makefile")
@@ -256,7 +250,6 @@
t := s.Init(c)
t.SetUpPkgsrc()
- t.SetUpVartypes()
t.CreateFileLines("mk/misc/category.mk")
t.CreateFileLines("category/package1/Makefile")
t.CreateFileLines("category/package2/Makefile")
@@ -281,7 +274,6 @@
t := s.Init(c)
t.SetUpPkgsrc()
- t.SetUpVartypes()
t.CreateFileLines("mk/misc/category.mk")
t.CreateFileLines("category/package/Makefile")
t.CreateFileLines("category/Makefile",
@@ -317,7 +309,6 @@
t := s.Init(c)
t.SetUpPkgsrc()
- t.SetUpVartypes()
t.CreateFileLines("mk/misc/category.mk")
t.CreateFileLines("category/package/Makefile")
t.CreateFileLines("category/Makefile",
diff -r ff671c02608c -r c709d3b48c10 pkgtools/pkglint/files/check_test.go
--- a/pkgtools/pkglint/files/check_test.go Sat Apr 27 19:04:32 2019 +0000
+++ b/pkgtools/pkglint/files/check_test.go Sat Apr 27 19:33:56 2019 +0000
@@ -9,6 +9,7 @@
"os"
"path"
"path/filepath"
+ "regexp"
"strings"
"testing"
@@ -339,7 +340,6 @@
}
t.SetUpPkgsrc()
- t.SetUpVartypes()
t.SetUpCategory(category)
t.CreateFileLines(pkgpath+"/DESCR",
@@ -723,7 +723,8 @@
if r == nil {
panic("Expected a pkglint fatal error but didn't get one.")
} else if _, ok := r.(pkglintFatal); ok {
- t.Check(t.Output(), check.Matches, string(expected))
+ pattern := `^(?:` + string(expected) + `)$`
+ t.Check(t.Output(), check.Matches, pattern)
} else {
panic(r)
}
@@ -780,7 +781,10 @@
func (t *Tester) NewMkLine(filename string, lineno int, text string) MkLine {
basename := path.Base(filename)
G.Assertf(
- hasSuffix(basename, ".mk") || basename == "Makefile" || hasPrefix(basename, "Makefile."),
+ hasSuffix(basename, ".mk") ||
+ basename == "Makefile" ||
+ hasPrefix(basename, "Makefile.") ||
+ basename == "mk.conf",
"filename %q must be realistic, otherwise the variable permissions are wrong", filename)
return MkLineParser{}.Parse(t.NewLine(filename, lineno, text))
@@ -869,6 +873,47 @@
t.CheckOutput(expectedLines)
}
+// CheckOutputMatches checks that the output up to now matches the given lines.
+// Each line may either be an exact string or a regular expression.
+// By convention, regular expressions are written in backticks.
+//
+// After the comparison, the output buffers are cleared so that later
+// calls only check against the newly added output.
+//
+// See CheckOutputEmpty.
+func (t *Tester) CheckOutputMatches(expectedLines ...regex.Pattern) {
+ output := t.Output()
+ actualLines := strings.Split(output, "\n")
+ actualLines = actualLines[:len(actualLines)-1]
+
+ ok := func(actualLine string, expectedLine regex.Pattern) bool {
+ if actualLine == string(expectedLine) {
+ return true
+ }
+
+ pattern := `^(?:` + string(expectedLine) + `)$`
+ re, err := regexp.Compile(pattern)
+ if err != nil {
+ return false
+ }
+
+ return re.MatchString(actualLine)
+ }
+
+ // If a line matches the corresponding pattern, make them equal in the
+ // comparison output, in order to concentrate on the lines that don't match.
+ var patterns []string
+ for i, expectedLine := range expectedLines {
+ if i < len(actualLines) && ok(actualLines[i], expectedLine) {
+ patterns = append(patterns, actualLines[i])
+ } else {
+ patterns = append(patterns, string(expectedLine))
+ }
+ }
+
+ t.Check(emptyToNil(actualLines), deepEquals, emptyToNil(patterns))
+}
+
// CheckOutput checks that the output up to now equals the given lines.
// After the comparison, the output buffers are cleared so that later
// calls only check against the newly added output.
diff -r ff671c02608c -r c709d3b48c10 pkgtools/pkglint/files/logging.go
--- a/pkgtools/pkglint/files/logging.go Sat Apr 27 19:04:32 2019 +0000
+++ b/pkgtools/pkglint/files/logging.go Sat Apr 27 19:33:56 2019 +0000
@@ -234,6 +234,24 @@
}
}
+// Errorf logs a technical error on the error output.
+//
+// location must be either an empty string or a slash-separated filename,
+// such as the one in Location.Filename. It may be followed by the usual
+// ":123" for line numbers.
+//
+// For diagnostics, use Logf instead.
+func (l *Logger) Errorf(location string, format string, args ...interface{}) {
+ msg := sprintf(format, args...)
+ var diag string
+ if l.Opts.GccOutput {
+ diag = sprintf("%s: %s: %s\n", location, Error.GccName, msg)
+ } else {
+ diag = sprintf("%s: %s: %s\n", Error.TraditionalName, location, msg)
+ }
+ l.err.Write(escapePrintable(diag))
+}
+
// SeparatorWriter writes output, occasionally separated by an
// empty line. This is used for separating the diagnostics when
// --source is combined with --show-autofix, where each
diff -r ff671c02608c -r c709d3b48c10 pkgtools/pkglint/files/logging_test.go
--- a/pkgtools/pkglint/files/logging_test.go Sat Apr 27 19:04:32 2019 +0000
+++ b/pkgtools/pkglint/files/logging_test.go Sat Apr 27 19:33:56 2019 +0000
@@ -676,6 +676,17 @@
"NOTE: Neither filename nor line number.")
}
+func (s *Suite) Test_Logger_Errorf__gcc_format(c *check.C) {
+ t := s.Init(c)
+
+ t.SetUpCommandLine("--gcc-output-format")
+
+ G.Errorf("filename", "Cannot be opened for %s.", "reading")
+
+ t.CheckOutputLines(
+ "filename: error: Cannot be opened for reading.")
+}
+
// Ensures that pkglint never destroys the terminal emulator by sending unintended escape sequences.
func (s *Suite) Test_Logger_Logf__strange_characters(c *check.C) {
t := s.Init(c)
diff -r ff671c02608c -r c709d3b48c10 pkgtools/pkglint/files/mkline.go
--- a/pkgtools/pkglint/files/mkline.go Sat Apr 27 19:04:32 2019 +0000
+++ b/pkgtools/pkglint/files/mkline.go Sat Apr 27 19:33:56 2019 +0000
@@ -548,7 +548,7 @@
// For variable assignments, it returns the right-hand side, properly split into words.
// For .for loops, it returns all arguments (including variable names), properly split into words.
func (mkline *MkLineImpl) Fields() []string {
- if mkline.IsVarassign() {
+ if mkline.IsVarassign() || mkline.IsCommentedVarassign() {
value := mkline.Value()
if value == "" {
return nil
diff -r ff671c02608c -r c709d3b48c10 pkgtools/pkglint/files/mkline_test.go
Home |
Main Index |
Thread Index |
Old Index