summaryrefslogtreecommitdiff
path: root/pkgtools/pkglint/files/check_test.go
diff options
context:
space:
mode:
Diffstat (limited to 'pkgtools/pkglint/files/check_test.go')
-rw-r--r--pkgtools/pkglint/files/check_test.go21
1 files changed, 14 insertions, 7 deletions
diff --git a/pkgtools/pkglint/files/check_test.go b/pkgtools/pkglint/files/check_test.go
index e96c133ce18..a9b75f48681 100644
--- a/pkgtools/pkglint/files/check_test.go
+++ b/pkgtools/pkglint/files/check_test.go
@@ -104,7 +104,6 @@ func (s *Suite) TearDownTest(c *check.C) {
func Test__qa(t *testing.T) {
ck := intqa.NewQAChecker(t.Errorf)
- ck.Configure("autofix.go", "*", "*", -intqa.EMissingTest) // TODO
ck.Configure("buildlink3.go", "*", "*", -intqa.EMissingTest) // TODO
ck.Configure("distinfo.go", "*", "*", -intqa.EMissingTest) // TODO
ck.Configure("files.go", "*", "*", -intqa.EMissingTest) // TODO
@@ -300,8 +299,12 @@ func (t *Tester) SetUpFileLines(filename RelPath, lines ...string) *Lines {
//
// If the filename is irrelevant for the particular test, take filename.mk.
func (t *Tester) SetUpFileMkLines(filename RelPath, lines ...string) *MkLines {
+ return t.SetUpFileMkLinesPkg(filename, nil, lines...)
+}
+
+func (t *Tester) SetUpFileMkLinesPkg(filename RelPath, pkg *Package, lines ...string) *MkLines {
abs := t.CreateFileLines(filename, lines...)
- return LoadMk(abs, MustSucceed)
+ return LoadMk(abs, pkg, MustSucceed)
}
// LoadMkInclude loads the given Makefile fragment and all the files it includes,
@@ -313,11 +316,11 @@ func (t *Tester) LoadMkInclude(filename RelPath) *MkLines {
// TODO: Include files with multiple-inclusion guard only once.
// TODO: Include files without multiple-inclusion guard as often as needed.
- // TODO: Set an upper limit, to prevent denial of service.
var load func(filename CurrPath)
load = func(filename CurrPath) {
- for _, mkline := range NewMkLines(Load(filename, MustSucceed)).mklines {
+ mklines := NewMkLines(Load(filename, MustSucceed), nil)
+ for _, mkline := range mklines.mklines {
lines = append(lines, mkline.Line)
if mkline.IsInclude() {
@@ -330,7 +333,7 @@ func (t *Tester) LoadMkInclude(filename RelPath) *MkLines {
// This assumes that the test files do not contain parse errors.
// Otherwise the diagnostics would appear twice.
- return NewMkLines(NewLines(t.File(filename), lines))
+ return NewMkLines(NewLines(t.File(filename), lines), nil)
}
// SetUpPkgsrc sets up a minimal but complete pkgsrc installation in the
@@ -747,7 +750,7 @@ func (t *Tester) SetUpHierarchy() (
}
}
- mklines := NewMkLines(NewLines(NewCurrPath(relFilename.AsPath()), lines))
+ mklines := NewMkLines(NewLines(NewCurrPath(relFilename.AsPath()), lines), nil)
assertf(files[filename] == nil, "MkLines with name %q already exists.", filename)
files[filename] = mklines
return mklines
@@ -1053,6 +1056,10 @@ func (t *Tester) NewLinesAt(filename CurrPath, firstLine int, texts ...string) *
//
// If the filename is irrelevant for the particular test, take filename.mk.
func (t *Tester) NewMkLines(filename CurrPath, lines ...string) *MkLines {
+ return t.NewMkLinesPkg(filename, nil, lines...)
+}
+
+func (t *Tester) NewMkLinesPkg(filename CurrPath, pkg *Package, lines ...string) *MkLines {
basename := filename.Base()
assertf(
hasSuffix(basename, ".mk") || basename == "Makefile" || hasPrefix(basename, "Makefile."),
@@ -1063,7 +1070,7 @@ func (t *Tester) NewMkLines(filename CurrPath, lines ...string) *MkLines {
rawText.WriteString(line)
rawText.WriteString("\n")
}
- return NewMkLines(convertToLogicalLines(filename, rawText.String(), true))
+ return NewMkLines(convertToLogicalLines(filename, rawText.String(), true), pkg)
}
// Returns and consumes the output from both stdout and stderr.