pkgsrc-WIP-changes archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

mk/*-package: add tests for CHECKOUT_DATE and the API



Module Name:	pkgsrc-wip
Committed By:	Roland Illig <rillig%NetBSD.org@localhost>
Pushed By:	rillig
Date:		Fri Mar 9 01:08:16 2018 +0000
Changeset:	a2fe9e6a9847dd753dd0fccd5415344d3ba4298f

Modified Files:
	mk/svn-package.mk
	mk/tests/Kyuafile
	mk/tests/svn-multi.mk
	mk/tests/test.subr
Added Files:
	mk/tests/cvs-checkout_date
	mk/tests/cvs-checkout_date.mk
	mk/tests/cvs-show-all
	mk/tests/cvs-show-all.mk
	mk/tests/fossil-checkout_date
	mk/tests/fossil-checkout_date.mk
	mk/tests/fossil-show-all
	mk/tests/fossil-show-all.mk
	mk/tests/git-checkout_date
	mk/tests/git-checkout_date.mk
	mk/tests/git-show-all
	mk/tests/git-show-all.mk
	mk/tests/hg-checkout_date
	mk/tests/hg-checkout_date.mk
	mk/tests/hg-show-all
	mk/tests/hg-show-all.mk
	mk/tests/svn-checkout_date
	mk/tests/svn-checkout_date.mk
	mk/tests/svn-show-all
	mk/tests/svn-show-all.mk
	mk/tests/zzz-copy-paste

Log Message:
mk/*-package: add tests for CHECKOUT_DATE and the API

To see a diff of this commit:
https://wip.pkgsrc.org/cgi-bin/gitweb.cgi?p=pkgsrc-wip.git;a=commitdiff;h=a2fe9e6a9847dd753dd0fccd5415344d3ba4298f

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

diffstat:
 mk/svn-package.mk                |  7 +++---
 mk/tests/Kyuafile                | 12 ++++++++++
 mk/tests/cvs-checkout_date       | 10 ++++++++
 mk/tests/cvs-checkout_date.mk    | 15 ++++++++++++
 mk/tests/cvs-show-all            |  8 +++++++
 mk/tests/cvs-show-all.mk         | 22 +++++++++++++++++
 mk/tests/fossil-checkout_date    | 10 ++++++++
 mk/tests/fossil-checkout_date.mk | 15 ++++++++++++
 mk/tests/fossil-show-all         |  8 +++++++
 mk/tests/fossil-show-all.mk      | 20 ++++++++++++++++
 mk/tests/git-checkout_date       | 10 ++++++++
 mk/tests/git-checkout_date.mk    | 15 ++++++++++++
 mk/tests/git-show-all            |  8 +++++++
 mk/tests/git-show-all.mk         | 20 ++++++++++++++++
 mk/tests/hg-checkout_date        | 10 ++++++++
 mk/tests/hg-checkout_date.mk     | 15 ++++++++++++
 mk/tests/hg-show-all             |  8 +++++++
 mk/tests/hg-show-all.mk          | 20 ++++++++++++++++
 mk/tests/svn-checkout_date       | 10 ++++++++
 mk/tests/svn-checkout_date.mk    | 15 ++++++++++++
 mk/tests/svn-multi.mk            |  2 +-
 mk/tests/svn-show-all            |  8 +++++++
 mk/tests/svn-show-all.mk         | 20 ++++++++++++++++
 mk/tests/test.subr               | 10 ++++++++
 mk/tests/zzz-copy-paste          | 51 ++++++++++++++++++++++++++++++++++++++++
 25 files changed, 345 insertions(+), 4 deletions(-)

diffs:
diff --git a/mk/svn-package.mk b/mk/svn-package.mk
index 3e8bea63d1..7746388d83 100644
--- a/mk/svn-package.mk
+++ b/mk/svn-package.mk
@@ -27,9 +27,10 @@
 #	${WRKDIR}.
 #
 #	Default:
-#		For SVN_EXTRACTDIR, the default value is derived
-#		from the last path component of GIT_REPO (so for
-#		git://git%github.com@localhost:NetBSD/pkgsrc.git, it becomes pkgsrc).
+#		For SVN_EXTRACTDIR, the default value is derived from SVN_REPO
+#		(so for https://svn.example.org/repos/project/trunk, it becomes
+#		project).
+#
 #		For SVN_EXTRACTDIR.${repo}, the default is ${repo}.
 #
 # SVN_REVISION (optional)
diff --git a/mk/tests/Kyuafile b/mk/tests/Kyuafile
index efa88767f3..0735639848 100644
--- a/mk/tests/Kyuafile
+++ b/mk/tests/Kyuafile
@@ -9,17 +9,29 @@ local function test(name)
 	-- plain_test_program { name = name, required_files = "test.subr" }
 end
 
+test "cvs-show-all"
 test "cvs-single"
+test "cvs-checkout_date"
 test "cvs-multi"
 
+test "fossil-show-all"
 test "fossil-single"
+test "fossil-checkout_date"
 test "fossil-multi"
 
+test "git-show-all"
 test "git-single"
+test "git-checkout_date"
 test "git-multi"
 
+test "hg-show-all"
 test "hg-single"
+test "hg-checkout_date"
 test "hg-multi"
 
+test "svn-show-all"
 test "svn-single"
+test "svn-checkout_date"
 test "svn-multi"
+
+test "zzz-copy-paste"
diff --git a/mk/tests/cvs-checkout_date b/mk/tests/cvs-checkout_date
new file mode 100755
index 0000000000..c7ca91bc4e
--- /dev/null
+++ b/mk/tests/cvs-checkout_date
@@ -0,0 +1,10 @@
+#! /bin/sh
+. "./test.subr"
+
+setup_package "cvs-checkout_date.mk"
+setup_cvs_repository
+
+step "Testing CVS with CHECKOUT_DATE"
+CHECKOUT_DATE="2018-02-01" package_make patch
+
+assert_that --file "$wrkdir/pkgbase/today" --has-content "2018-01-01"
diff --git a/mk/tests/cvs-checkout_date.mk b/mk/tests/cvs-checkout_date.mk
new file mode 100644
index 0000000000..783d453a43
--- /dev/null
+++ b/mk/tests/cvs-checkout_date.mk
@@ -0,0 +1,15 @@
+# $NetBSD$
+
+DISTNAME=	pkgbase-1.0
+CATEGORIES=	pkgtools
+CVS_ROOT=	${.CURDIR}/files/repo
+
+MAINTAINER=	rillig%NetBSD.org@localhost
+HOMEPAGE=	https://www.pkgsrc.org/
+COMMENT=	Test for CVS with CHECKOUT_DATE
+LICENSE=	2-clause-bsd
+
+NO_CHECKSUM=	yes
+
+.include "../../wip/mk/cvs-package.mk"
+.include "../../mk/bsd.pkg.mk"
diff --git a/mk/tests/cvs-show-all b/mk/tests/cvs-show-all
new file mode 100755
index 0000000000..707afeb917
--- /dev/null
+++ b/mk/tests/cvs-show-all
@@ -0,0 +1,8 @@
+#! /bin/sh
+. "./test.subr"
+
+setup_package "cvs-show-all.mk"
+setup_cvs_repository
+
+step "Testing show-all-cvs"
+package_make show-all-cvs
diff --git a/mk/tests/cvs-show-all.mk b/mk/tests/cvs-show-all.mk
new file mode 100644
index 0000000000..f6a551fa47
--- /dev/null
+++ b/mk/tests/cvs-show-all.mk
@@ -0,0 +1,22 @@
+# $NetBSD$
+
+DISTNAME=	pkgbase-1.0
+CATEGORIES=	pkgtools
+
+MAINTAINER=	rillig%NetBSD.org@localhost
+HOMEPAGE=	https://www.pkgsrc.org/
+COMMENT=	Test for show-all-cvs
+LICENSE=	2-clause-bsd
+
+NO_CHECKSUM=	yes
+
+CVS_ROOT=		${.CURDIR}/files/repo
+CVS_REPOSITORIES=	2017 current
+CVS_ROOT.2017=		${CVS_ROOT}
+CVS_MODULE.2017=	${CVS_MODULE}
+CVS_TAG.2017=		v2017
+CVS_ROOT.current=	${CVS_ROOT}
+CVS_MODULE.current=	${CVS_MODULE}
+
+.include "../../wip/mk/cvs-package.mk"
+.include "../../mk/bsd.pkg.mk"
diff --git a/mk/tests/fossil-checkout_date b/mk/tests/fossil-checkout_date
new file mode 100755
index 0000000000..c3d73752bd
--- /dev/null
+++ b/mk/tests/fossil-checkout_date
@@ -0,0 +1,10 @@
+#! /bin/sh
+. "./test.subr"
+
+setup_package "fossil-checkout_date.mk"
+setup_fossil_repository
+
+step "Testing Fossil with CHECKOUT_DATE"
+CHECKOUT_DATE="2018-02-01" package_make patch
+
+assert_that --file "$wrkdir/pkgbase/today" --has-content "2018-01-01"
diff --git a/mk/tests/fossil-checkout_date.mk b/mk/tests/fossil-checkout_date.mk
new file mode 100644
index 0000000000..9055119650
--- /dev/null
+++ b/mk/tests/fossil-checkout_date.mk
@@ -0,0 +1,15 @@
+# $NetBSD$
+
+DISTNAME=	pkgbase-1.0
+CATEGORIES=	pkgtools
+FOSSIL_REPO=	${.CURDIR}/files/repo/pkgbase.fossil
+
+MAINTAINER=	rillig%NetBSD.org@localhost
+HOMEPAGE=	https://www.pkgsrc.org/
+COMMENT=	Test for Fossil with CHECKOUT_DATE
+LICENSE=	2-clause-bsd
+
+NO_CHECKSUM=	yes
+
+.include "../../wip/mk/fossil-package.mk"
+.include "../../mk/bsd.pkg.mk"
diff --git a/mk/tests/fossil-show-all b/mk/tests/fossil-show-all
new file mode 100755
index 0000000000..442de02813
--- /dev/null
+++ b/mk/tests/fossil-show-all
@@ -0,0 +1,8 @@
+#! /bin/sh
+. "./test.subr"
+
+setup_package "fossil-show-all.mk"
+setup_fossil_repository
+
+step "Testing show-all-fossil"
+package_make show-all-fossil
diff --git a/mk/tests/fossil-show-all.mk b/mk/tests/fossil-show-all.mk
new file mode 100644
index 0000000000..e97ba7e7f3
--- /dev/null
+++ b/mk/tests/fossil-show-all.mk
@@ -0,0 +1,20 @@
+# $NetBSD$
+
+DISTNAME=	pkgbase-1.0
+CATEGORIES=	pkgtools
+
+MAINTAINER=	rillig%NetBSD.org@localhost
+HOMEPAGE=	https://www.pkgsrc.org/
+COMMENT=	Test for show-all-fossil
+LICENSE=	2-clause-bsd
+
+NO_CHECKSUM=	yes
+
+FOSSIL_REPO=		${.CURDIR}/files/repo/pkgbase.fossil
+FOSSIL_REPOSITORIES=	2017 current
+FOSSIL_REPO.2017=	${FOSSIL_REPO}
+FOSSIL_VERSION.2017=	v2017
+FOSSIL_REPO.current=	${FOSSIL_REPO}
+
+.include "../../wip/mk/fossil-package.mk"
+.include "../../mk/bsd.pkg.mk"
diff --git a/mk/tests/git-checkout_date b/mk/tests/git-checkout_date
new file mode 100755
index 0000000000..8e38add606
--- /dev/null
+++ b/mk/tests/git-checkout_date
@@ -0,0 +1,10 @@
+#! /bin/sh
+. "./test.subr"
+
+setup_package "git-checkout_date.mk"
+setup_git_repository
+
+step "Testing Git with CHECKOUT_DATE"
+CHECKOUT_DATE="2018-02-01" package_make patch
+
+assert_that --file "$wrkdir/pkgbase/today" --has-content "2018-01-01"
diff --git a/mk/tests/git-checkout_date.mk b/mk/tests/git-checkout_date.mk
new file mode 100644
index 0000000000..69f509d570
--- /dev/null
+++ b/mk/tests/git-checkout_date.mk
@@ -0,0 +1,15 @@
+# $NetBSD$
+
+DISTNAME=	pkgbase-1.0
+CATEGORIES=	pkgtools
+GIT_REPO=	${.CURDIR}/files/repo/pkgbase
+
+MAINTAINER=	rillig%NetBSD.org@localhost
+HOMEPAGE=	https://www.pkgsrc.org/
+COMMENT=	Test for Git with CHECKOUT_DATE
+LICENSE=	2-clause-bsd
+
+NO_CHECKSUM=	yes
+
+.include "../../wip/mk/git-package.mk"
+.include "../../mk/bsd.pkg.mk"
diff --git a/mk/tests/git-show-all b/mk/tests/git-show-all
new file mode 100755
index 0000000000..f9d93009f7
--- /dev/null
+++ b/mk/tests/git-show-all
@@ -0,0 +1,8 @@
+#! /bin/sh
+. "./test.subr"
+
+setup_package "git-show-all.mk"
+setup_git_repository
+
+step "Testing show-all-git"
+package_make show-all-git
diff --git a/mk/tests/git-show-all.mk b/mk/tests/git-show-all.mk
new file mode 100644
index 0000000000..644c707b4e
--- /dev/null
+++ b/mk/tests/git-show-all.mk
@@ -0,0 +1,20 @@
+# $NetBSD$
+
+DISTNAME=	pkgbase-1.0
+CATEGORIES=	pkgtools
+
+MAINTAINER=	rillig%NetBSD.org@localhost
+HOMEPAGE=	https://www.pkgsrc.org/
+COMMENT=	Test for show-all-git
+LICENSE=	2-clause-bsd
+
+NO_CHECKSUM=	yes
+
+GIT_REPO=		${.CURDIR}/files/repo/pkgbase
+GIT_REPOSITORIES=	2017 current
+GIT_REPO.2017=		${GIT_REPO}
+GIT_TAG.2017=		v2017
+GIT_REPO.current=	${GIT_REPO}
+
+.include "../../wip/mk/git-package.mk"
+.include "../../mk/bsd.pkg.mk"
diff --git a/mk/tests/hg-checkout_date b/mk/tests/hg-checkout_date
new file mode 100755
index 0000000000..98b0fb5893
--- /dev/null
+++ b/mk/tests/hg-checkout_date
@@ -0,0 +1,10 @@
+#! /bin/sh
+. "./test.subr"
+
+setup_package "hg-checkout_date.mk"
+setup_hg_repository
+
+step "Testing Mercurial with CHECKOUT_DATE"
+CHECKOUT_DATE="2018-02-01" package_make patch
+
+assert_that --file "$wrkdir/pkgbase/today" --has-content "2018-01-01"
diff --git a/mk/tests/hg-checkout_date.mk b/mk/tests/hg-checkout_date.mk
new file mode 100644
index 0000000000..0153f78f76
--- /dev/null
+++ b/mk/tests/hg-checkout_date.mk
@@ -0,0 +1,15 @@
+# $NetBSD$
+
+DISTNAME=	pkgbase-1.0
+CATEGORIES=	pkgtools
+HG_REPO=	${.CURDIR}/files/repo/pkgbase
+
+MAINTAINER=	rillig%NetBSD.org@localhost
+HOMEPAGE=	https://www.pkgsrc.org/
+COMMENT=	Test for Mercurial with CHECKOUT_DATE
+LICENSE=	2-clause-bsd
+
+NO_CHECKSUM=	yes
+
+.include "../../wip/mk/hg-package.mk"
+.include "../../mk/bsd.pkg.mk"
diff --git a/mk/tests/hg-show-all b/mk/tests/hg-show-all
new file mode 100755
index 0000000000..51fb4920c7
--- /dev/null
+++ b/mk/tests/hg-show-all
@@ -0,0 +1,8 @@
+#! /bin/sh
+. "./test.subr"
+
+setup_package "hg-show-all.mk"
+setup_hg_repository
+
+step "Testing show-all-hg"
+package_make show-all-hg
diff --git a/mk/tests/hg-show-all.mk b/mk/tests/hg-show-all.mk
new file mode 100644
index 0000000000..60100a797c
--- /dev/null
+++ b/mk/tests/hg-show-all.mk
@@ -0,0 +1,20 @@
+# $NetBSD$
+
+DISTNAME=	pkgbase-1.0
+CATEGORIES=	pkgtools
+
+MAINTAINER=	rillig%NetBSD.org@localhost
+HOMEPAGE=	https://www.pkgsrc.org/
+COMMENT=	Test for show-all-hg
+LICENSE=	2-clause-bsd
+
+NO_CHECKSUM=	yes
+
+HG_REPO=		${.CURDIR}/files/repo/pkgbase
+HG_REPOSITORIES=	2017 current
+HG_REPO.2017=		${HG_REPO}
+HG_TAG.2017=		v2017
+HG_REPO.current=	${HG_REPO}
+
+.include "../../wip/mk/hg-package.mk"
+.include "../../mk/bsd.pkg.mk"
diff --git a/mk/tests/svn-checkout_date b/mk/tests/svn-checkout_date
new file mode 100755
index 0000000000..3e15cbe5d9
--- /dev/null
+++ b/mk/tests/svn-checkout_date
@@ -0,0 +1,10 @@
+#! /bin/sh
+. "./test.subr"
+
+setup_package "svn-checkout_date.mk"
+setup_svn_repository
+
+step "Testing Subversion with CHECKOUT_DATE"
+CHECKOUT_DATE="2018-02-01" package_make patch
+
+assert_that --file "$wrkdir/pkgbase/today" --has-content "2018-01-01"
diff --git a/mk/tests/svn-checkout_date.mk b/mk/tests/svn-checkout_date.mk
new file mode 100644
index 0000000000..8959a9eab7
--- /dev/null
+++ b/mk/tests/svn-checkout_date.mk
@@ -0,0 +1,15 @@
+# $NetBSD$
+
+DISTNAME=	pkgbase-1.0
+CATEGORIES=	pkgtools
+SVN_REPO=	file://${.CURDIR}/files/repo/pkgbase/trunk
+
+MAINTAINER=	rillig%NetBSD.org@localhost
+HOMEPAGE=	https://www.pkgsrc.org/
+COMMENT=	Test for Subversion with CHECKOUT_DATE
+LICENSE=	2-clause-bsd
+
+NO_CHECKSUM=	yes
+
+.include "../../wip/mk/svn-package.mk"
+.include "../../mk/bsd.pkg.mk"
diff --git a/mk/tests/svn-multi.mk b/mk/tests/svn-multi.mk
index 6ffa39d405..5a1fcab3be 100644
--- a/mk/tests/svn-multi.mk
+++ b/mk/tests/svn-multi.mk
@@ -5,7 +5,7 @@ CATEGORIES=	pkgtools
 
 MAINTAINER=	rillig%NetBSD.org@localhost
 HOMEPAGE=	https://www.pkgsrc.org/
-COMMENT=	Test for Mercurial with multiple repositories
+COMMENT=	Test for Subversion with multiple repositories
 LICENSE=	2-clause-bsd
 
 NO_CHECKSUM=	yes
diff --git a/mk/tests/svn-show-all b/mk/tests/svn-show-all
new file mode 100755
index 0000000000..9e949229cf
--- /dev/null
+++ b/mk/tests/svn-show-all
@@ -0,0 +1,8 @@
+#! /bin/sh
+. "./test.subr"
+
+setup_package "svn-show-all.mk"
+setup_svn_repository
+
+step "Testing show-all-svn"
+package_make show-all-svn
diff --git a/mk/tests/svn-show-all.mk b/mk/tests/svn-show-all.mk
new file mode 100644
index 0000000000..8b019b8c84
--- /dev/null
+++ b/mk/tests/svn-show-all.mk
@@ -0,0 +1,20 @@
+# $NetBSD$
+
+DISTNAME=	pkgbase-1.0
+CATEGORIES=	pkgtools
+
+MAINTAINER=	rillig%NetBSD.org@localhost
+HOMEPAGE=	https://www.pkgsrc.org/
+COMMENT=	Test for show-all-svn
+LICENSE=	2-clause-bsd
+
+NO_CHECKSUM=	yes
+
+SVN_REPO=		file://${.CURDIR}/files/repo/pkgbase/trunk
+SVN_REPOSITORIES=	2017 current
+SVN_REPO.2017=		${SVN_REPO}
+SVN_REVISION.2017=	1
+SVN_REPO.current=	${SVN_REPO}
+
+.include "../../wip/mk/svn-package.mk"
+.include "../../mk/bsd.pkg.mk"
diff --git a/mk/tests/test.subr b/mk/tests/test.subr
index b3966c6af2..0ca674717d 100644
--- a/mk/tests/test.subr
+++ b/mk/tests/test.subr
@@ -51,6 +51,8 @@ setup_package() {
 # - at 2018-03-01TZ, the file "today" contains "2018-03-01".
 
 setup_cvs_repository() {
+	step "Setting up CVS repository"
+
 	cvs -d "$repodir" init
 	mkdir "$repodir/pkgbase"
 
@@ -73,6 +75,8 @@ setup_cvs_repository() {
 }
 
 setup_fossil_repository() {
+	step "Setting up Fossil repository"
+
 	mkdir -p "$repodir"
 	cd "$repodir"
 	fossil init --date-override "2017-01-01" pkgbase.fossil
@@ -92,6 +96,8 @@ setup_fossil_repository() {
 }
 
 setup_git_repository() {
+	step "Setting up Git repository"
+
 	git init "$repodir/pkgbase"
 	cd "$repodir/pkgbase"
 
@@ -112,6 +118,8 @@ setup_git_repository() {
 }
 
 setup_hg_repository() {
+	step "Setting up Mercurial repository"
+
 	hg init "$repodir/pkgbase"
 	cd "$repodir/pkgbase"
 
@@ -128,6 +136,8 @@ setup_hg_repository() {
 }
 
 setup_svn_repository() {
+	step "Setting up Subversion repository"
+
 	mkdir "$repodir"
 	svnadmin create "$repodir/pkgbase"
 	hook="$repodir/pkgbase/hooks/pre-revprop-change"
diff --git a/mk/tests/zzz-copy-paste b/mk/tests/zzz-copy-paste
new file mode 100755
index 0000000000..1c536b931a
--- /dev/null
+++ b/mk/tests/zzz-copy-paste
@@ -0,0 +1,51 @@
+#! /bin/sh
+set -eu
+
+# Ensures that the tests and the code don't contain obvious
+# copy-and-paste errors.
+
+scms="cvs fossil git hg svn"
+keywords_hg="Mercurial"
+keywords_svn="Subversion"
+
+for haystack in $scms; do
+	for needle in $scms; do
+		if [ "$haystack" != "$needle" ]; then
+			eval "keywords=\"\${keywords_$needle-} $needle\""
+
+			for keyword in $keywords; do
+				eval "filemask=./\${filemask_$haystack:-$haystack}-*"
+
+				for file in $filemask ../$haystack-package.mk; do
+					if grep -Hi "$keyword" "$file"; then
+						error=1
+					fi
+				done
+			done
+		fi
+	done
+done
+
+tests="show_all single multi checkout_date"
+filemask_show_all="show-all"
+keywords_show_all="show-all"
+
+for haystack in $tests; do
+	for needle in $tests; do
+		if [ "$needle" != "$haystack" ]; then
+			eval "keywords=\"\${keywords_$needle-} $needle\""
+
+			for keyword in $keywords; do
+				eval "filemask=./*-\${filemask_$haystack:-$haystack}*"
+
+				for file in $filemask; do
+					if grep -Hi "$keyword" "$file"; then
+						error=1
+					fi
+				done
+			done
+		fi
+	done
+done
+
+exit ${error-0}


Home | Main Index | Thread Index | Old Index