[pacman-dev] [PATCH] Fix makepkg-template tests for make distcheck

Florian Pritz bluewind at xinu.at
Thu Jan 8 22:52:32 UTC 2015


autotools dislikes having symlinks in the tarball so create those
during testing. Also fix the value of PMTEST_SCRIPT_DIR to actually
point to the correct dir in the distcheck case (different build dir).

Signed-off-by: Florian Pritz <bluewind at xinu.at>
---
 Makefile.am                                              |  2 +-
 .../keep-old-version/templates/perl-bla.template         |  1 -
 .../keep-old-version/templates/perl-module.template      |  1 -
 .../keep-old-version/testcase-config                     |  5 +++++
 .../missing-template-file/templates/perl-module.template |  1 -
 .../missing-template-file/testcase-config                |  4 ++++
 .../name-charset-valid/templates/foo at -_.+a.template      |  1 -
 .../name-charset-valid/testcase-config                   |  3 +++
 .../templates/perl-bla.template                          |  1 -
 .../templates/perl-module.template                       |  1 -
 .../update-version-with-newest-option/testcase-config    |  5 +++++
 test/scripts/makepkg-template_test.sh                    | 16 +++++++++++++---
 12 files changed, 31 insertions(+), 10 deletions(-)
 delete mode 120000 test/scripts/makepkg-template-tests/keep-old-version/templates/perl-bla.template
 delete mode 120000 test/scripts/makepkg-template-tests/keep-old-version/templates/perl-module.template
 delete mode 120000 test/scripts/makepkg-template-tests/missing-template-file/templates/perl-module.template
 delete mode 120000 test/scripts/makepkg-template-tests/name-charset-valid/templates/foo at -_.+a.template
 delete mode 120000 test/scripts/makepkg-template-tests/update-version-with-newest-option/templates/perl-bla.template
 delete mode 120000 test/scripts/makepkg-template-tests/update-version-with-newest-option/templates/perl-module.template

diff --git a/Makefile.am b/Makefile.am
index 9dbacca..d2a11eb 100644
--- a/Makefile.am
+++ b/Makefile.am
@@ -38,7 +38,7 @@ TEST_SUITE_LOG = test/test-suite.log
 TEST_EXTENSIONS = .py
 AM_TESTS_ENVIRONMENT = \
 	PMTEST_UTIL_DIR=$(top_builddir)/src/util/; export PMTEST_UTIL_DIR; \
-	PMTEST_SCRIPT_DIR=$(top_srcdir)/scripts/; export PMTEST_SCRIPT_DIR; \
+	PMTEST_SCRIPT_DIR=$(top_builddir)/scripts/; export PMTEST_SCRIPT_DIR; \
 	PMTEST_SCRIPTLIB_DIR=$(top_srcdir)/scripts/library/; export PMTEST_SCRIPTLIB_DIR;
 LOG_DRIVER = env AM_TAP_AWK='$(AWK)' $(SHELL) \
 								 $(top_srcdir)/build-aux/tap-driver.sh
diff --git a/test/scripts/makepkg-template-tests/keep-old-version/templates/perl-bla.template b/test/scripts/makepkg-template-tests/keep-old-version/templates/perl-bla.template
deleted file mode 120000
index 1161447..0000000
--- a/test/scripts/makepkg-template-tests/keep-old-version/templates/perl-bla.template
+++ /dev/null
@@ -1 +0,0 @@
-perl-bla-1.2.template
\ No newline at end of file
diff --git a/test/scripts/makepkg-template-tests/keep-old-version/templates/perl-module.template b/test/scripts/makepkg-template-tests/keep-old-version/templates/perl-module.template
deleted file mode 120000
index f8618e4..0000000
--- a/test/scripts/makepkg-template-tests/keep-old-version/templates/perl-module.template
+++ /dev/null
@@ -1 +0,0 @@
-perl-module-1.1.template
\ No newline at end of file
diff --git a/test/scripts/makepkg-template-tests/keep-old-version/testcase-config b/test/scripts/makepkg-template-tests/keep-old-version/testcase-config
index 241f048..b9448a0 100644
--- a/test/scripts/makepkg-template-tests/keep-old-version/testcase-config
+++ b/test/scripts/makepkg-template-tests/keep-old-version/testcase-config
@@ -1,6 +1,11 @@
 arguments+=()
 expected_exitcode=0
 
+_setup_testcase() {
+	ln -sr "templates/"{perl-bla-1.2.template,perl-bla.template}
+	ln -sr "templates/"{perl-module-1.1.template,perl-module.template}
+}
+
 # set IFS="" if you want trailing new lines, otherwise remove it
 IFS="" read -d '' expected_output <<'EOF'
 EOF
diff --git a/test/scripts/makepkg-template-tests/missing-template-file/templates/perl-module.template b/test/scripts/makepkg-template-tests/missing-template-file/templates/perl-module.template
deleted file mode 120000
index 8c2189a..0000000
--- a/test/scripts/makepkg-template-tests/missing-template-file/templates/perl-module.template
+++ /dev/null
@@ -1 +0,0 @@
-perl-module-1.0.template
\ No newline at end of file
diff --git a/test/scripts/makepkg-template-tests/missing-template-file/testcase-config b/test/scripts/makepkg-template-tests/missing-template-file/testcase-config
index 317e77b..bdfde40 100644
--- a/test/scripts/makepkg-template-tests/missing-template-file/testcase-config
+++ b/test/scripts/makepkg-template-tests/missing-template-file/testcase-config
@@ -1,6 +1,10 @@
 arguments+=()
 expected_exitcode=2
 
+_setup_testcase() {
+	ln -sr "templates/"{perl-module-1.0.template,perl-module.template}
+}
+
 # set IFS="" if you want trailing new lines, otherwise remove it
 IFS="" read -d '' expected_output <<'EOF'
 failed to open './makepkg-template-tests/missing-template-file/templates/perl-module-1.0.template': No such file or directory
diff --git a/test/scripts/makepkg-template-tests/name-charset-valid/templates/foo at -_.+a.template b/test/scripts/makepkg-template-tests/name-charset-valid/templates/foo at -_.+a.template
deleted file mode 120000
index 24b333f..0000000
--- a/test/scripts/makepkg-template-tests/name-charset-valid/templates/foo at -_.+a.template
+++ /dev/null
@@ -1 +0,0 @@
-foo at -_.+a-1.template
\ No newline at end of file
diff --git a/test/scripts/makepkg-template-tests/name-charset-valid/testcase-config b/test/scripts/makepkg-template-tests/name-charset-valid/testcase-config
index 6810390..409444a 100644
--- a/test/scripts/makepkg-template-tests/name-charset-valid/testcase-config
+++ b/test/scripts/makepkg-template-tests/name-charset-valid/testcase-config
@@ -1,6 +1,9 @@
 arguments+=()
 expected_exitcode=0
 
+_setup_testcase() {
+	ln -sr "templates/"{foo\@-_.+a-1.template,foo\@-_.+a.template}
+}
 IFS="" read -d '' expected_output <<'EOF'
 EOF
 
diff --git a/test/scripts/makepkg-template-tests/update-version-with-newest-option/templates/perl-bla.template b/test/scripts/makepkg-template-tests/update-version-with-newest-option/templates/perl-bla.template
deleted file mode 120000
index 1161447..0000000
--- a/test/scripts/makepkg-template-tests/update-version-with-newest-option/templates/perl-bla.template
+++ /dev/null
@@ -1 +0,0 @@
-perl-bla-1.2.template
\ No newline at end of file
diff --git a/test/scripts/makepkg-template-tests/update-version-with-newest-option/templates/perl-module.template b/test/scripts/makepkg-template-tests/update-version-with-newest-option/templates/perl-module.template
deleted file mode 120000
index f8618e4..0000000
--- a/test/scripts/makepkg-template-tests/update-version-with-newest-option/templates/perl-module.template
+++ /dev/null
@@ -1 +0,0 @@
-perl-module-1.1.template
\ No newline at end of file
diff --git a/test/scripts/makepkg-template-tests/update-version-with-newest-option/testcase-config b/test/scripts/makepkg-template-tests/update-version-with-newest-option/testcase-config
index a6a2f4a..5956a0a 100644
--- a/test/scripts/makepkg-template-tests/update-version-with-newest-option/testcase-config
+++ b/test/scripts/makepkg-template-tests/update-version-with-newest-option/testcase-config
@@ -1,6 +1,11 @@
 arguments+=(-n)
 expected_exitcode=0
 
+_setup_testcase() {
+	ln -sr "templates/"{perl-bla-1.2.template,perl-bla.template}
+	ln -sr "templates/"{perl-module-1.1.template,perl-module.template}
+}
+
 IFS="" read -d '' expected_output <<'EOF'
 EOF
 
diff --git a/test/scripts/makepkg-template_test.sh b/test/scripts/makepkg-template_test.sh
index 6d0f0e7..3a98bf2 100755
--- a/test/scripts/makepkg-template_test.sh
+++ b/test/scripts/makepkg-template_test.sh
@@ -9,13 +9,15 @@ if ! type -p "$script" &>/dev/null; then
 	exit 1
 fi
 
+TMPDIR="$(mktemp -d "/tmp/${0##*/}.XXXXXX")"
+trap "rm -rf '${TMPDIR}'" EXIT TERM
+cp -r "${0%/*}/makepkg-template-tests" "$TMPDIR/makepkg-template-tests"
+
 # normalize paths
 script="$(readlink -f $(type -p "$script"))"
-cd "${0%/*}"
+cd "$TMPDIR"
 testdir="./makepkg-template-tests"
 
-TMPDIR="$(mktemp -d "/tmp/${0##*/}.XXXXXX")"
-trap "rm -rf '${TMPDIR}'" EXIT TERM
 
 total=$(find "$testdir" -maxdepth 1 -mindepth 1 -type d | wc -l)
 if [[ -z "$total" ]]; then
@@ -35,6 +37,14 @@ run_test() {
 	mkdir "$TMPDIR/$testcase"
 	touch "$TMPDIR/$testcase/result"
 
+	# work around autotools not putting symlinks into the release tarball
+	if type -t _setup_testcase >/dev/null; then
+		cd "$TMPDIR/$testdir/$testcase"
+		_setup_testcase
+		unset -f _setup_testcase
+		cd "$TMPDIR"
+	fi
+
 	LC_ALL=C "$script" \
 		--template-dir "$testdir/$testcase/templates" \
 		-p "$testdir/$testcase/PKGBUILD" \
-- 
2.2.1


More information about the pacman-dev mailing list