summaryrefslogtreecommitdiff
path: root/pkgtools/pkglint/files/distinfo_test.go
diff options
context:
space:
mode:
Diffstat (limited to 'pkgtools/pkglint/files/distinfo_test.go')
-rw-r--r--pkgtools/pkglint/files/distinfo_test.go117
1 files changed, 93 insertions, 24 deletions
diff --git a/pkgtools/pkglint/files/distinfo_test.go b/pkgtools/pkglint/files/distinfo_test.go
index 7290e469fbf..3a42088858a 100644
--- a/pkgtools/pkglint/files/distinfo_test.go
+++ b/pkgtools/pkglint/files/distinfo_test.go
@@ -5,27 +5,28 @@ import "gopkg.in/check.v1"
func (s *Suite) Test_ChecklinesDistinfo(c *check.C) {
t := s.Init(c)
- t.SetupFileLines("patches/patch-aa",
+ t.SetupFileLines("category/package/patches/patch-aa",
"$"+"NetBSD$ line is ignored",
"patch contents")
- t.SetupFileLines("patches/patch-ab",
+ t.SetupFileLines("category/package/patches/patch-ab",
"patch contents")
- G.CurrentDir = t.TmpDir()
-
- ChecklinesDistinfo(t.NewLines("distinfo",
+ lines := t.SetupFileLines("category/package/distinfo",
"should be the RCS ID",
"should be empty",
"MD5 (distfile.tar.gz) = 12345678901234567890123456789012",
"SHA1 (distfile.tar.gz) = 1234567890123456789012345678901234567890",
"SHA1 (patch-aa) = 6b98dd609f85a9eb9c4c1e4e7055a6aaa62b7cc7",
"SHA1 (patch-ab) = 6b98dd609f85a9eb9c4c1e4e7055a6aaa62b7cc7",
- "SHA1 (patch-nonexistent) = 1234"))
+ "SHA1 (patch-nonexistent) = 1234")
+ G.Pkg = NewPackage("category/package")
+
+ ChecklinesDistinfo(lines)
t.CheckOutputLines(
- "ERROR: distinfo:1: Expected \"$"+"NetBSD$\".",
- "NOTE: distinfo:2: Empty line expected.",
- "ERROR: distinfo:5: Expected SHA1, RMD160, SHA512, Size checksums for \"distfile.tar.gz\", got MD5, SHA1.",
- "WARN: distinfo:7: Patch file \"patch-nonexistent\" does not exist in directory \"patches\".")
+ "ERROR: ~/category/package/distinfo:1: Expected \"$"+"NetBSD$\".",
+ "NOTE: ~/category/package/distinfo:2: Empty line expected.",
+ "ERROR: ~/category/package/distinfo:5: Expected SHA1, RMD160, SHA512, Size checksums for \"distfile.tar.gz\", got MD5, SHA1.",
+ "WARN: ~/category/package/distinfo:7: Patch file \"patch-nonexistent\" does not exist in directory \"patches\".")
}
func (s *Suite) Test_ChecklinesDistinfo_global_hash_mismatch(c *check.C) {
@@ -48,7 +49,7 @@ func (s *Suite) Test_ChecklinesDistinfo_global_hash_mismatch(c *check.C) {
func (s *Suite) Test_ChecklinesDistinfo_uncommitted_patch(c *check.C) {
t := s.Init(c)
- t.SetupFileLines("patches/patch-aa",
+ t.SetupFileLines("category/package/patches/patch-aa",
RcsID,
"",
"--- oldfile",
@@ -56,54 +57,122 @@ func (s *Suite) Test_ChecklinesDistinfo_uncommitted_patch(c *check.C) {
"@@ -1,1 +1,1 @@",
"-old",
"+new")
- t.SetupFileLines("CVS/Entries",
+ t.SetupFileLines("category/package/CVS/Entries",
"/distinfo/...")
- lines := t.SetupFileLines("distinfo",
+ lines := t.SetupFileLines("category/package/distinfo",
RcsID,
"",
"SHA1 (patch-aa) = 5ad1fb9b3c328fff5caa1a23e8f330e707dd50c0")
- G.CurrentDir = t.TmpDir()
+ G.Pkg = NewPackage("category/package")
ChecklinesDistinfo(lines)
t.CheckOutputLines(
- "WARN: ~/distinfo:3: patches/patch-aa is registered in distinfo but not added to CVS.")
+ "WARN: ~/category/package/distinfo:3: patches/patch-aa is registered in distinfo but not added to CVS.")
}
func (s *Suite) Test_ChecklinesDistinfo_unrecorded_patches(c *check.C) {
t := s.Init(c)
- t.SetupFileLines("patches/CVS/Entries")
- t.SetupFileLines("patches/patch-aa")
- t.SetupFileLines("patches/patch-src-Makefile")
- lines := t.SetupFileLines("distinfo",
+ t.SetupFileLines("category/package/patches/CVS/Entries")
+ t.SetupFileLines("category/package/patches/patch-aa")
+ t.SetupFileLines("category/package/patches/patch-src-Makefile")
+ lines := t.SetupFileLines("category/package/distinfo",
RcsID,
"",
"SHA1 (distfile.tar.gz) = ...",
"RMD160 (distfile.tar.gz) = ...",
"SHA512 (distfile.tar.gz) = ...",
"Size (distfile.tar.gz) = 1024 bytes")
- G.CurrentDir = t.TmpDir()
+ G.Pkg = NewPackage("category/package")
ChecklinesDistinfo(lines)
t.CheckOutputLines(
- "ERROR: ~/distinfo: patch \"patches/patch-aa\" is not recorded. Run \""+confMake+" makepatchsum\".",
- "ERROR: ~/distinfo: patch \"patches/patch-src-Makefile\" is not recorded. Run \""+confMake+" makepatchsum\".")
+ "ERROR: ~/category/package/distinfo: patch \"patches/patch-aa\" is not recorded. Run \""+confMake+" makepatchsum\".",
+ "ERROR: ~/category/package/distinfo: patch \"patches/patch-src-Makefile\" is not recorded. Run \""+confMake+" makepatchsum\".")
}
func (s *Suite) Test_ChecklinesDistinfo_manual_patches(c *check.C) {
t := s.Init(c)
- t.SetupFileLines("patches/manual-libtool.m4")
+ t.CreateFileLines("patches/manual-libtool.m4")
lines := t.SetupFileLines("distinfo",
RcsID,
"",
"SHA1 (patch-aa) = ...")
- G.CurrentDir = t.TmpDir()
ChecklinesDistinfo(lines)
+ // When a distinfo file is checked on its own, without belonging to a package,
+ // the PATCHDIR is not known and therefore no diagnostics are logged.
+ t.CheckOutputEmpty()
+
+ G.Pkg = NewPackage(".")
+
+ ChecklinesDistinfo(lines)
+
+ // When a distinfo file is checked in the context of a package,
+ // the PATCHDIR is known, therefore the checks are active.
t.CheckOutputLines(
"WARN: ~/distinfo:3: Patch file \"patch-aa\" does not exist in directory \"patches\".")
}
+
+// PHP modules that are not PECL use the distinfo file from lang/php* but
+// their own patches directory. Therefore the distinfo file refers to missing
+// patches. Since this strange situation is caused by the pkgsrc
+// infrastructure, there is nothing a package author can do about.
+func (s *Suite) Test_ChecklinesDistinfo__missing_php_patches(c *check.C) {
+ t := s.Init(c)
+
+ t.SetupPkgsrc()
+ t.SetupCommandLine("-Wall,no-space")
+ t.CreateFileLines("licenses/unknown-license")
+ t.CreateFileLines("lang/php/ext.mk",
+ MkRcsID,
+ "",
+ "PHPEXT_MK= # defined",
+ "PHPPKGSRCDIR= lang/php72",
+ "LICENSE?= unknown-license",
+ "COMMENT?= Some PHP package",
+ "GENERATE_PLIST+=# none",
+ "",
+ ".if !defined(PECL_VERSION)",
+ "DISTINFO_FILE= ${.CURDIR}/${PHPPKGSRCDIR}/distinfo",
+ ".endif",
+ ".if defined(USE_PHP_EXT_PATCHES)",
+ "PATCHDIR= ${.CURDIR}/${PHPPKGSRCDIR}/patches",
+ ".endif")
+ t.CreateFileLines("lang/php72/patches/patch-php72",
+ RcsID,
+ "",
+ "Documentation",
+ "",
+ "--- old file",
+ "+++ new file",
+ "@@ -1,1 +1,1 @@",
+ "-old",
+ "+new")
+ t.SetupFileLines("lang/php72/distinfo",
+ RcsID,
+ "",
+ "SHA1 (patch-php72) = c109b2089f5ddbc5372b2ab28115ff558ee4187d")
+
+ t.CreateFileLines("archivers/php-bz2/Makefile",
+ MkRcsID,
+ "",
+ "USE_PHP_EXT_PATCHES= yes",
+ "",
+ ".include \"../../lang/php/ext.mk\"",
+ ".include \"../../mk/bsd.pkg.mk\"")
+ t.CreateFileLines("archivers/php-zlib/Makefile",
+ MkRcsID,
+ "",
+ ".include \"../../lang/php/ext.mk\"",
+ ".include \"../../mk/bsd.pkg.mk\"")
+
+ G.CheckDirent(t.File("archivers/php-bz2"))
+ G.CheckDirent(t.File("archivers/php-zlib"))
+
+ t.CheckOutputEmpty()
+}