pkgsrc-WIP-changes archive

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

mk/tests: fix tests for the source code management systems



Module Name:	pkgsrc-wip
Committed By:	Roland Illig <rillig%NetBSD.org@localhost>
Pushed By:	rillig
Date:		Fri Mar 9 07:40:33 2018 +0000
Changeset:	3fa10b73068be51b44dac94e2f33d4d9d24bd245

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

Log Message:
mk/tests: fix tests for the source code management systems

Kyua runs the programs in a temporary directory. Luckily $0 still points
to the source directory and can be used for accessing the related files.

Because Kyua sets the HOME variable to a temporary directory (as it
should), the Git configuration had to be given explicitly.

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

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

diffstat:
 mk/tests/Kyuafile             |  5 +----
 mk/tests/cvs-checkout_date    |  2 +-
 mk/tests/cvs-multi            |  2 +-
 mk/tests/cvs-show-all         |  2 +-
 mk/tests/cvs-single           |  2 +-
 mk/tests/fossil-checkout_date |  2 +-
 mk/tests/fossil-multi         |  2 +-
 mk/tests/fossil-show-all      |  2 +-
 mk/tests/fossil-single        |  2 +-
 mk/tests/git-checkout_date    |  2 +-
 mk/tests/git-multi            |  2 +-
 mk/tests/git-show-all         |  2 +-
 mk/tests/git-single           |  2 +-
 mk/tests/hg-checkout_date     |  2 +-
 mk/tests/hg-multi             |  2 +-
 mk/tests/hg-show-all          |  2 +-
 mk/tests/hg-single            |  2 +-
 mk/tests/svn-checkout_date    |  2 +-
 mk/tests/svn-multi            |  2 +-
 mk/tests/svn-show-all         |  2 +-
 mk/tests/svn-single           |  2 +-
 mk/tests/test.subr            | 16 +++++++++++-----
 mk/tests/zzz-copy-paste       |  2 ++
 23 files changed, 34 insertions(+), 29 deletions(-)

diffs:
diff --git a/mk/tests/Kyuafile b/mk/tests/Kyuafile
index 0735639848..0d0f81a0f8 100644
--- a/mk/tests/Kyuafile
+++ b/mk/tests/Kyuafile
@@ -3,10 +3,7 @@ syntax(2)
 test_suite("pkgsrc_wip_mk_scm")
 
 local function test(name)
-	-- Currently doesn't work because test.subr is not copied to the
-	-- temporary directory.
-	--
-	-- plain_test_program { name = name, required_files = "test.subr" }
+	plain_test_program { name = name }
 end
 
 test "cvs-show-all"
diff --git a/mk/tests/cvs-checkout_date b/mk/tests/cvs-checkout_date
index c7ca91bc4e..4e1408ecf5 100755
--- a/mk/tests/cvs-checkout_date
+++ b/mk/tests/cvs-checkout_date
@@ -1,5 +1,5 @@
 #! /bin/sh
-. "./test.subr"
+. "${0%/*}/test.subr"
 
 setup_package "cvs-checkout_date.mk"
 setup_cvs_repository
diff --git a/mk/tests/cvs-multi b/mk/tests/cvs-multi
index 6d28d48255..74807d0563 100755
--- a/mk/tests/cvs-multi
+++ b/mk/tests/cvs-multi
@@ -1,5 +1,5 @@
 #! /bin/sh
-. "./test.subr"
+. "${0%/*}/test.subr"
 
 setup_package "cvs-multi.mk"
 setup_cvs_repository
diff --git a/mk/tests/cvs-show-all b/mk/tests/cvs-show-all
index 707afeb917..285ce59e5c 100755
--- a/mk/tests/cvs-show-all
+++ b/mk/tests/cvs-show-all
@@ -1,5 +1,5 @@
 #! /bin/sh
-. "./test.subr"
+. "${0%/*}/test.subr"
 
 setup_package "cvs-show-all.mk"
 setup_cvs_repository
diff --git a/mk/tests/cvs-single b/mk/tests/cvs-single
index b555eed055..38ed371d7c 100755
--- a/mk/tests/cvs-single
+++ b/mk/tests/cvs-single
@@ -1,5 +1,5 @@
 #! /bin/sh
-. "./test.subr"
+. "${0%/*}/test.subr"
 
 setup_package "cvs-single.mk"
 setup_cvs_repository
diff --git a/mk/tests/fossil-checkout_date b/mk/tests/fossil-checkout_date
index c3d73752bd..b026cdd53e 100755
--- a/mk/tests/fossil-checkout_date
+++ b/mk/tests/fossil-checkout_date
@@ -1,5 +1,5 @@
 #! /bin/sh
-. "./test.subr"
+. "${0%/*}/test.subr"
 
 setup_package "fossil-checkout_date.mk"
 setup_fossil_repository
diff --git a/mk/tests/fossil-multi b/mk/tests/fossil-multi
index 9d5b07bcf8..3dcc056fab 100755
--- a/mk/tests/fossil-multi
+++ b/mk/tests/fossil-multi
@@ -1,5 +1,5 @@
 #! /bin/sh
-. "./test.subr"
+. "${0%/*}/test.subr"
 
 setup_package "fossil-multi.mk"
 setup_fossil_repository
diff --git a/mk/tests/fossil-show-all b/mk/tests/fossil-show-all
index 442de02813..32dbd1236c 100755
--- a/mk/tests/fossil-show-all
+++ b/mk/tests/fossil-show-all
@@ -1,5 +1,5 @@
 #! /bin/sh
-. "./test.subr"
+. "${0%/*}/test.subr"
 
 setup_package "fossil-show-all.mk"
 setup_fossil_repository
diff --git a/mk/tests/fossil-single b/mk/tests/fossil-single
index 9f4e6c0e54..156d12d8d2 100755
--- a/mk/tests/fossil-single
+++ b/mk/tests/fossil-single
@@ -1,5 +1,5 @@
 #! /bin/sh
-. "./test.subr"
+. "${0%/*}/test.subr"
 
 setup_package "fossil-single.mk"
 setup_fossil_repository
diff --git a/mk/tests/git-checkout_date b/mk/tests/git-checkout_date
index 8e38add606..4a575fe7b4 100755
--- a/mk/tests/git-checkout_date
+++ b/mk/tests/git-checkout_date
@@ -1,5 +1,5 @@
 #! /bin/sh
-. "./test.subr"
+. "${0%/*}/test.subr"
 
 setup_package "git-checkout_date.mk"
 setup_git_repository
diff --git a/mk/tests/git-multi b/mk/tests/git-multi
index d092107e32..08f392a85f 100755
--- a/mk/tests/git-multi
+++ b/mk/tests/git-multi
@@ -1,5 +1,5 @@
 #! /bin/sh
-. "./test.subr"
+. "${0%/*}/test.subr"
 
 setup_package "git-multi.mk"
 setup_git_repository
diff --git a/mk/tests/git-show-all b/mk/tests/git-show-all
index f9d93009f7..028d8c49a9 100755
--- a/mk/tests/git-show-all
+++ b/mk/tests/git-show-all
@@ -1,5 +1,5 @@
 #! /bin/sh
-. "./test.subr"
+. "${0%/*}/test.subr"
 
 setup_package "git-show-all.mk"
 setup_git_repository
diff --git a/mk/tests/git-single b/mk/tests/git-single
index a8c8682de4..e45c0e43e7 100755
--- a/mk/tests/git-single
+++ b/mk/tests/git-single
@@ -1,5 +1,5 @@
 #! /bin/sh
-. "./test.subr"
+. "${0%/*}/test.subr"
 
 setup_package "git-single.mk"
 setup_git_repository
diff --git a/mk/tests/hg-checkout_date b/mk/tests/hg-checkout_date
index 98b0fb5893..e2003759b5 100755
--- a/mk/tests/hg-checkout_date
+++ b/mk/tests/hg-checkout_date
@@ -1,5 +1,5 @@
 #! /bin/sh
-. "./test.subr"
+. "${0%/*}/test.subr"
 
 setup_package "hg-checkout_date.mk"
 setup_hg_repository
diff --git a/mk/tests/hg-multi b/mk/tests/hg-multi
index 162ca46c9a..e17d8adb77 100755
--- a/mk/tests/hg-multi
+++ b/mk/tests/hg-multi
@@ -1,5 +1,5 @@
 #! /bin/sh
-. "./test.subr"
+. "${0%/*}/test.subr"
 
 setup_package "hg-multi.mk"
 setup_hg_repository
diff --git a/mk/tests/hg-show-all b/mk/tests/hg-show-all
index 51fb4920c7..7cb1a75f21 100755
--- a/mk/tests/hg-show-all
+++ b/mk/tests/hg-show-all
@@ -1,5 +1,5 @@
 #! /bin/sh
-. "./test.subr"
+. "${0%/*}/test.subr"
 
 setup_package "hg-show-all.mk"
 setup_hg_repository
diff --git a/mk/tests/hg-single b/mk/tests/hg-single
index fa7175726a..105e6e9e55 100755
--- a/mk/tests/hg-single
+++ b/mk/tests/hg-single
@@ -1,5 +1,5 @@
 #! /bin/sh
-. "./test.subr"
+. "${0%/*}/test.subr"
 
 setup_package "hg-single.mk"
 setup_hg_repository
diff --git a/mk/tests/svn-checkout_date b/mk/tests/svn-checkout_date
index 3e15cbe5d9..4d758e08d1 100755
--- a/mk/tests/svn-checkout_date
+++ b/mk/tests/svn-checkout_date
@@ -1,5 +1,5 @@
 #! /bin/sh
-. "./test.subr"
+. "${0%/*}/test.subr"
 
 setup_package "svn-checkout_date.mk"
 setup_svn_repository
diff --git a/mk/tests/svn-multi b/mk/tests/svn-multi
index dca7e310cb..7b30d45921 100755
--- a/mk/tests/svn-multi
+++ b/mk/tests/svn-multi
@@ -1,5 +1,5 @@
 #! /bin/sh
-. "./test.subr"
+. "${0%/*}/test.subr"
 
 setup_package "svn-multi.mk"
 setup_svn_repository
diff --git a/mk/tests/svn-show-all b/mk/tests/svn-show-all
index 9e949229cf..1896ee2d9a 100755
--- a/mk/tests/svn-show-all
+++ b/mk/tests/svn-show-all
@@ -1,5 +1,5 @@
 #! /bin/sh
-. "./test.subr"
+. "${0%/*}/test.subr"
 
 setup_package "svn-show-all.mk"
 setup_svn_repository
diff --git a/mk/tests/svn-single b/mk/tests/svn-single
index 3ddbbfeaeb..6d05d1e2fb 100755
--- a/mk/tests/svn-single
+++ b/mk/tests/svn-single
@@ -1,5 +1,5 @@
 #! /bin/sh
-. "./test.subr"
+. "${0%/*}/test.subr"
 
 setup_package "svn-single.mk"
 setup_svn_repository
diff --git a/mk/tests/test.subr b/mk/tests/test.subr
index 18433acb15..1bee0b305b 100644
--- a/mk/tests/test.subr
+++ b/mk/tests/test.subr
@@ -1,6 +1,9 @@
 #! /bin/sh
+
 set -eu
 
+srcdir="${0%/*}"
+
 step() {
 	echo "" 1>&2
 	echo "T: $*" 1>&2
@@ -24,13 +27,13 @@ cvs_admin_set_date() {
 }
 
 setup_package() {
-	pkgsrcdir=`cd "$PWD/../../.." && exec pwd`
+	pkgsrcdir=`cd "$srcdir/../../.." && exec pwd`
 	test -f "$pkgsrcdir/mk/bsd.pkg.mk" || die "This test must be run from inside pkgsrc"
 
 	pkgdir="$pkgsrcdir/mk-scm-tests/mk-scm-tests"
 	rm -rf "$pkgdir"
 	mkdir -p "$pkgdir"
-	cp "$1" "$pkgdir/Makefile"
+	cp "$srcdir/$1" "$pkgdir/Makefile"
 	echo "Dummy description." > "$pkgdir/DESCR"
 	echo "@comment $""NetBSD""$" > "$pkgdir/PLIST"
 	cd "$pkgdir"
@@ -104,17 +107,20 @@ setup_git_repository() {
 	echo "2017-01-01" > today
 	git add today
 	GIT_AUTHOR_DATE="2017-01-01T00:00:00Z" GIT_COMMITTER_DATE="2017-01-01T00:00:00Z" \
-		git commit -m "today is 2017-01-01" -- today
+		git -c user.name="User" -c user.email="user%example.org@localhost" \
+			commit -m "today is 2017-01-01" today
 	git tag v2017
 
 	echo "2018-01-01" > today
 	git add today
 	GIT_AUTHOR_DATE="2018-01-01T00:00:00Z" GIT_COMMITTER_DATE="2018-01-01T00:00:00Z" \
-		git commit -m "today is 2018-01-01" -- today
+		git -c user.name="User" -c user.email="user%example.org@localhost" \
+			commit -m "today is 2018-01-01" today
 
 	echo "2018-03-01" > today
 	GIT_AUTHOR_DATE="2018-03-01T00:00:00Z" GIT_COMMITTER_DATE="2018-03-01T00:00:00Z" \
-		git commit -m "today is 2018-03-01" -- today
+		git -c user.name="User" -c user.email="user%example.org@localhost" \
+			commit -m "today is 2018-03-01" today
 }
 
 setup_hg_repository() {
diff --git a/mk/tests/zzz-copy-paste b/mk/tests/zzz-copy-paste
index 1c536b931a..eb811a0730 100755
--- a/mk/tests/zzz-copy-paste
+++ b/mk/tests/zzz-copy-paste
@@ -1,6 +1,8 @@
 #! /bin/sh
 set -eu
 
+cd "${0%/*}"
+
 # Ensures that the tests and the code don't contain obvious
 # copy-and-paste errors.
 


Home | Main Index | Thread Index | Old Index