Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. =================================================================== RCS file: /ftp/cvs/cvsroot/pkgsrc/pkgtools/pkglint/files/Attic/util_test.go,v rcsdiff: /ftp/cvs/cvsroot/pkgsrc/pkgtools/pkglint/files/Attic/util_test.go,v: warning: Unknown phrases like `commitid ...;' are present. retrieving revision 1.46 retrieving revision 1.47 diff -u -p -r1.46 -r1.47 --- pkgsrc/pkgtools/pkglint/files/Attic/util_test.go 2020/01/04 19:53:14 1.46 +++ pkgsrc/pkgtools/pkglint/files/Attic/util_test.go 2020/01/06 20:38:42 1.47 @@ -85,6 +85,34 @@ func (s *Suite) Test_replaceOnce(c *chec test("aaa", "aa", "b", "aaa") } +func (s *Suite) Test_condStr(c *check.C) { + t := s.Init(c) + + t.CheckEquals(condStr(true, "T", "F"), "T") + t.CheckEquals(condStr(false, "T", "F"), "F") +} + +func (s *Suite) Test_condInt(c *check.C) { + t := s.Init(c) + + t.CheckEquals(condInt(true, 123, 456), 123) + t.CheckEquals(condInt(false, 123, 456), 456) +} + +func (s *Suite) Test_imax(c *check.C) { + t := s.Init(c) + + t.CheckEquals(imax(2, 5), 5) + t.CheckEquals(imax(5, 2), 5) +} + +func (s *Suite) Test_imin(c *check.C) { + t := s.Init(c) + + t.CheckEquals(imin(2, 5), 2) + t.CheckEquals(imin(5, 2), 2) +} + func (s *Suite) Test_assertNil(c *check.C) { t := s.Init(c) @@ -108,6 +136,13 @@ func (s *Suite) Test_assertNotNil(c *che "Pkglint internal error: unexpected nil pointer") } +func (s *Suite) Test_assert(c *check.C) { + t := s.Init(c) + + assert(true) + t.ExpectAssert(func() { assert(false) }) +} + func (s *Suite) Test_isEmptyDir(c *check.C) { t := s.Init(c) @@ -656,6 +691,27 @@ func (s *Suite) Test_Scope_LastValue(c * "WARN: file.mk:2: VAR is defined but not used.") } +// Up to 2020-01-06, pkglint wrongly returned "one" as the variable value, +// even though Makefile.common is included before appending "two". +func (s *Suite) Test_Scope_LastValue__append_in_multiple_files(c *check.C) { + t := s.Init(c) + + t.SetUpPackage("category/package", + ".include \"Makefile.common\"", + "PLIST_VARS+=\ttwo", + "PLIST.two=\tyes") + t.CreateFileLines("category/package/Makefile.common", + MkCvsID, + "PLIST_VARS=\tone", + "PLIST.one=\tyes") + pkg := NewPackage(t.File("category/package")) + t.FinishSetUp() + + pkg.Check() + + t.CheckEquals(pkg.vars.LastValue("PLIST_VARS"), "one two") +} + func (s *Suite) Test_Scope_DefineAll(c *check.C) { t := s.Init(c)