[pacman-dev] [PATCH 01/11] Add testrunner for makepkg-template
Signed-off-by: Florian Pritz <bluewind@xinu.at> --- Makefile.am | 2 + test/scripts/Makefile.am | 1 + test/scripts/makepkg-template-tests/.gitignore | 3 + test/scripts/makepkg-template_test.sh | 86 ++++++++++++++++++++++++++ 4 files changed, 92 insertions(+) create mode 100644 test/scripts/makepkg-template-tests/.gitignore create mode 100755 test/scripts/makepkg-template_test.sh diff --git a/Makefile.am b/Makefile.am index e9b3dfa..ab669ef 100644 --- a/Makefile.am +++ b/Makefile.am @@ -28,6 +28,7 @@ $(top_srcdir)/test/pacman/tests/TESTS: $(wildcard test/pacman/tests/*.py*) TESTS = test/scripts/parseopts_test.sh \ test/scripts/human_to_size_test.sh \ + test/scripts/makepkg-template_test.sh \ test/scripts/pacman-db-upgrade-v9.py \ test/util/pacsorttest.sh \ test/util/vercmptest.sh @@ -37,6 +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_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/Makefile.am b/test/scripts/Makefile.am index 8d6bc84..ed1a951 100644 --- a/test/scripts/Makefile.am +++ b/test/scripts/Makefile.am @@ -1,6 +1,7 @@ check_SCRIPTS = \ parseopts_test.sh \ pacman-db-upgrade-v9.py \ + makepkg-template_test.sh \ human_to_size_test.sh noinst_SCRIPTS = $(check_SCRIPTS) diff --git a/test/scripts/makepkg-template-tests/.gitignore b/test/scripts/makepkg-template-tests/.gitignore new file mode 100644 index 0000000..c6fc2ee --- /dev/null +++ b/test/scripts/makepkg-template-tests/.gitignore @@ -0,0 +1,3 @@ +result +output +output_full diff --git a/test/scripts/makepkg-template_test.sh b/test/scripts/makepkg-template_test.sh new file mode 100755 index 0000000..b036b74 --- /dev/null +++ b/test/scripts/makepkg-template_test.sh @@ -0,0 +1,86 @@ +#!/bin/bash + +declare -i testcount=0 fail=0 pass=0 total=0 + +# source the library function +scriptdir=${1:-${PMTEST_SCRIPT_DIR}} +if [[ -z $scriptdir || ! -f $scriptdir/makepkg-template ]]; then + printf "Bail out! makepkg-template executable (%s) could not be located\n" "${scriptdir}/makepkg-template" + exit 1 +fi + +testdir="${0%/*}/makepkg-template-tests" + +total=$(find "$testdir" -maxdepth 1 -mindepth 1 -type d | wc -l) + +run_test() { + local testcase=$1 exitcode + local -i failed=0 + + (( ++testcount )) + + local -a arguments + + if [[ -f "$testdir/$testcase/arguments" ]]; then + arguments=($(cat "$testdir/$testcase/arguments")) + fi + + rm -f "$testdir/$testcase/result" + + "$scriptdir/makepkg-template" \ + --template-dir "$testdir/$testcase/templates" \ + -p "$testdir/$testcase/PKGBUILD" \ + -o "$testdir/$testcase/result" \ + &> "$testdir/$testcase/output_full" "${arguments[@]}" + exitcode=$? + + sed "$testdir/$testcase/output_full" >"$testdir/$testcase/output" \ + -e 's|./test/scripts/|./|' \ + -e 's| at '$scriptdir'/makepkg-template line [0-9]\+\.$||' + printf "%s\n" "$exitcode" >> "$testdir/$testcase/output" + + if [[ -f "$testdir/$testcase/result" ]]; then + if ! diff -u "$testdir/$testcase/"{result,expected_result}; then + failed=1 + fi + else + if [[ -f "$testdir/$testcase/expected_result" ]]; then + echo "$testcase: Found expected_result file but no result file" + failed=1 + fi + fi + + if ! diff -u "$testdir/$testcase/"{output,expected_output}; then + failed=1 + fi + + if ((!failed)); then + (( ++pass )) + printf "ok %d - %s\n" "$testcount" "$input" + else + (( ++fail )) + printf "not ok %d - %s\n" "$testcount" "$input" + printf '# [TEST %3s]: FAIL\n' "$testcount" + fi +} + +summarize() { + if (( !fail )); then + printf '# All %s tests successful\n\n' "$testcount" + exit 0 + else + printf '# %s of %s tests failed\n\n' "$fail" "$testcount" + exit 1 + fi +} +trap 'summarize' EXIT + +printf '# Beginning makepkg-template tests\n' + +echo "1..$total" + +for dir in "$testdir/"*; do + if [[ -d "$dir" ]]; then + run_test "${dir##*/}" + fi +done -- 2.2.1
Signed-off-by: Florian Pritz <bluewind@xinu.at> --- test/scripts/makepkg-template-tests/invalid-key/PKGBUILD | 1 + test/scripts/makepkg-template-tests/invalid-key/expected_output | 3 +++ 2 files changed, 4 insertions(+) create mode 100644 test/scripts/makepkg-template-tests/invalid-key/PKGBUILD create mode 100644 test/scripts/makepkg-template-tests/invalid-key/expected_output diff --git a/test/scripts/makepkg-template-tests/invalid-key/PKGBUILD b/test/scripts/makepkg-template-tests/invalid-key/PKGBUILD new file mode 100644 index 0000000..02bfadc --- /dev/null +++ b/test/scripts/makepkg-template-tests/invalid-key/PKGBUILD @@ -0,0 +1 @@ +# template input; []³|>=bar; diff --git a/test/scripts/makepkg-template-tests/invalid-key/expected_output b/test/scripts/makepkg-template-tests/invalid-key/expected_output new file mode 100644 index 0000000..2d9e9b9 --- /dev/null +++ b/test/scripts/makepkg-template-tests/invalid-key/expected_output @@ -0,0 +1,3 @@ +invalid key/value pair +./makepkg-template-tests/invalid-key/PKGBUILD:1: # template input; []³|>=bar; +255 -- 2.2.1
Signed-off-by: Florian Pritz <bluewind@xinu.at> --- .../makepkg-template-tests/invalid-template-line-missing-name/PKGBUILD | 1 + .../invalid-template-line-missing-name/expected_output | 3 +++ 2 files changed, 4 insertions(+) create mode 100644 test/scripts/makepkg-template-tests/invalid-template-line-missing-name/PKGBUILD create mode 100644 test/scripts/makepkg-template-tests/invalid-template-line-missing-name/expected_output diff --git a/test/scripts/makepkg-template-tests/invalid-template-line-missing-name/PKGBUILD b/test/scripts/makepkg-template-tests/invalid-template-line-missing-name/PKGBUILD new file mode 100644 index 0000000..d0a20c1 --- /dev/null +++ b/test/scripts/makepkg-template-tests/invalid-template-line-missing-name/PKGBUILD @@ -0,0 +1 @@ +# template input; diff --git a/test/scripts/makepkg-template-tests/invalid-template-line-missing-name/expected_output b/test/scripts/makepkg-template-tests/invalid-template-line-missing-name/expected_output new file mode 100644 index 0000000..bfb3886 --- /dev/null +++ b/test/scripts/makepkg-template-tests/invalid-template-line-missing-name/expected_output @@ -0,0 +1,3 @@ +invalid template line: can't find template name +./makepkg-template-tests/invalid-template-line-missing-name/PKGBUILD:1: # template input; +255 -- 2.2.1
Signed-off-by: Florian Pritz <bluewind@xinu.at> --- .../invalid-template-line-unknown-marker/PKGBUILD | 9 +++++++++ .../invalid-template-line-unknown-marker/expected_output | 3 +++ 2 files changed, 12 insertions(+) create mode 100644 test/scripts/makepkg-template-tests/invalid-template-line-unknown-marker/PKGBUILD create mode 100644 test/scripts/makepkg-template-tests/invalid-template-line-unknown-marker/expected_output diff --git a/test/scripts/makepkg-template-tests/invalid-template-line-unknown-marker/PKGBUILD b/test/scripts/makepkg-template-tests/invalid-template-line-unknown-marker/PKGBUILD new file mode 100644 index 0000000..645ea37 --- /dev/null +++ b/test/scripts/makepkg-template-tests/invalid-template-line-unknown-marker/PKGBUILD @@ -0,0 +1,9 @@ +pkgname=foo +pkgver=1 + +build() { +# template boom; name=test +perl Makefile.pl +make +# template end; +} diff --git a/test/scripts/makepkg-template-tests/invalid-template-line-unknown-marker/expected_output b/test/scripts/makepkg-template-tests/invalid-template-line-unknown-marker/expected_output new file mode 100644 index 0000000..b233374 --- /dev/null +++ b/test/scripts/makepkg-template-tests/invalid-template-line-unknown-marker/expected_output @@ -0,0 +1,3 @@ +Unknown template marker 'boom' +./makepkg-template-tests/invalid-template-line-unknown-marker/PKGBUILD:5: # template boom; name=test +255 -- 2.2.1
Signed-off-by: Florian Pritz <bluewind@xinu.at> --- .../makepkg-template-tests/keep-old-version/PKGBUILD | 15 +++++++++++++++ .../keep-old-version/expected_output | 1 + .../keep-old-version/expected_result | 15 +++++++++++++++ .../keep-old-version/templates/perl-bla-1.2.template | 1 + .../keep-old-version/templates/perl-bla.template | 1 + .../keep-old-version/templates/perl-module-1.0.template | 6 ++++++ .../keep-old-version/templates/perl-module-1.1.template | 7 +++++++ .../keep-old-version/templates/perl-module.template | 1 + 8 files changed, 47 insertions(+) create mode 100644 test/scripts/makepkg-template-tests/keep-old-version/PKGBUILD create mode 100644 test/scripts/makepkg-template-tests/keep-old-version/expected_output create mode 100644 test/scripts/makepkg-template-tests/keep-old-version/expected_result create mode 100644 test/scripts/makepkg-template-tests/keep-old-version/templates/perl-bla-1.2.template create mode 120000 test/scripts/makepkg-template-tests/keep-old-version/templates/perl-bla.template create mode 100644 test/scripts/makepkg-template-tests/keep-old-version/templates/perl-module-1.0.template create mode 100644 test/scripts/makepkg-template-tests/keep-old-version/templates/perl-module-1.1.template create mode 120000 test/scripts/makepkg-template-tests/keep-old-version/templates/perl-module.template diff --git a/test/scripts/makepkg-template-tests/keep-old-version/PKGBUILD b/test/scripts/makepkg-template-tests/keep-old-version/PKGBUILD new file mode 100644 index 0000000..09da2e0 --- /dev/null +++ b/test/scripts/makepkg-template-tests/keep-old-version/PKGBUILD @@ -0,0 +1,15 @@ +pkgname=foo +pkgver=1 + +build() { +# template start; name=perl-module; version=1.0; +echo "before bla template" +# template start; name=perl-bla; version=1.2; +bla bla +# template end; +echo "after bla template" +perl Makefile.pl +make +make install +# template end; +} diff --git a/test/scripts/makepkg-template-tests/keep-old-version/expected_output b/test/scripts/makepkg-template-tests/keep-old-version/expected_output new file mode 100644 index 0000000..573541a --- /dev/null +++ b/test/scripts/makepkg-template-tests/keep-old-version/expected_output @@ -0,0 +1 @@ +0 diff --git a/test/scripts/makepkg-template-tests/keep-old-version/expected_result b/test/scripts/makepkg-template-tests/keep-old-version/expected_result new file mode 100644 index 0000000..09da2e0 --- /dev/null +++ b/test/scripts/makepkg-template-tests/keep-old-version/expected_result @@ -0,0 +1,15 @@ +pkgname=foo +pkgver=1 + +build() { +# template start; name=perl-module; version=1.0; +echo "before bla template" +# template start; name=perl-bla; version=1.2; +bla bla +# template end; +echo "after bla template" +perl Makefile.pl +make +make install +# template end; +} diff --git a/test/scripts/makepkg-template-tests/keep-old-version/templates/perl-bla-1.2.template b/test/scripts/makepkg-template-tests/keep-old-version/templates/perl-bla-1.2.template new file mode 100644 index 0000000..b72e7d4 --- /dev/null +++ b/test/scripts/makepkg-template-tests/keep-old-version/templates/perl-bla-1.2.template @@ -0,0 +1 @@ +bla bla 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 new file mode 120000 index 0000000..1161447 --- /dev/null +++ b/test/scripts/makepkg-template-tests/keep-old-version/templates/perl-bla.template @@ -0,0 +1 @@ +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-1.0.template b/test/scripts/makepkg-template-tests/keep-old-version/templates/perl-module-1.0.template new file mode 100644 index 0000000..415025a --- /dev/null +++ b/test/scripts/makepkg-template-tests/keep-old-version/templates/perl-module-1.0.template @@ -0,0 +1,6 @@ +echo "before bla template" +# template input; name=perl-bla +echo "after bla template" +perl Makefile.pl +make +make install diff --git a/test/scripts/makepkg-template-tests/keep-old-version/templates/perl-module-1.1.template b/test/scripts/makepkg-template-tests/keep-old-version/templates/perl-module-1.1.template new file mode 100644 index 0000000..5ad32c3 --- /dev/null +++ b/test/scripts/makepkg-template-tests/keep-old-version/templates/perl-module-1.1.template @@ -0,0 +1,7 @@ +echo "perl-module version 1.1" +echo "before bla template" +# template input; name=perl-bla +echo "after bla template" +perl Makefile.pl +make +make install 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 new file mode 120000 index 0000000..f8618e4 --- /dev/null +++ b/test/scripts/makepkg-template-tests/keep-old-version/templates/perl-module.template @@ -0,0 +1 @@ +perl-module-1.1.template \ No newline at end of file -- 2.2.1
Signed-off-by: Florian Pritz <bluewind@xinu.at> --- test/scripts/makepkg-template-tests/missing-template-file/PKGBUILD | 7 +++++++ .../makepkg-template-tests/missing-template-file/expected_output | 2 ++ .../missing-template-file/templates/perl-module.template | 1 + 3 files changed, 10 insertions(+) create mode 100644 test/scripts/makepkg-template-tests/missing-template-file/PKGBUILD create mode 100644 test/scripts/makepkg-template-tests/missing-template-file/expected_output create mode 120000 test/scripts/makepkg-template-tests/missing-template-file/templates/perl-module.template diff --git a/test/scripts/makepkg-template-tests/missing-template-file/PKGBUILD b/test/scripts/makepkg-template-tests/missing-template-file/PKGBUILD new file mode 100644 index 0000000..dbfda1d --- /dev/null +++ b/test/scripts/makepkg-template-tests/missing-template-file/PKGBUILD @@ -0,0 +1,7 @@ +pkgname=foo +pkgver=1 + +build() { +# template start; name=perl-module; version=1.0; +# template end; +} diff --git a/test/scripts/makepkg-template-tests/missing-template-file/expected_output b/test/scripts/makepkg-template-tests/missing-template-file/expected_output new file mode 100644 index 0000000..975fa9d --- /dev/null +++ b/test/scripts/makepkg-template-tests/missing-template-file/expected_output @@ -0,0 +1,2 @@ +failed to open './makepkg-template-tests/missing-template-file/templates/perl-module-1.0.template': No such file or directory +2 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 new file mode 120000 index 0000000..8c2189a --- /dev/null +++ b/test/scripts/makepkg-template-tests/missing-template-file/templates/perl-module.template @@ -0,0 +1 @@ +perl-module-1.0.template \ No newline at end of file -- 2.2.1
Signed-off-by: Florian Pritz <bluewind@xinu.at> --- .../makepkg-template-tests/missing-template-symlink/PKGBUILD | 7 +++++++ .../missing-template-symlink/expected_output | 2 ++ .../missing-template-symlink/templates/perl-module-1.0.template | 1 + 3 files changed, 10 insertions(+) create mode 100644 test/scripts/makepkg-template-tests/missing-template-symlink/PKGBUILD create mode 100644 test/scripts/makepkg-template-tests/missing-template-symlink/expected_output create mode 100644 test/scripts/makepkg-template-tests/missing-template-symlink/templates/perl-module-1.0.template diff --git a/test/scripts/makepkg-template-tests/missing-template-symlink/PKGBUILD b/test/scripts/makepkg-template-tests/missing-template-symlink/PKGBUILD new file mode 100644 index 0000000..8ee94ac --- /dev/null +++ b/test/scripts/makepkg-template-tests/missing-template-symlink/PKGBUILD @@ -0,0 +1,7 @@ +pkgname=foo +pkgver=1 + +build() { +# template start; name=perl-module; +# template end; +} diff --git a/test/scripts/makepkg-template-tests/missing-template-symlink/expected_output b/test/scripts/makepkg-template-tests/missing-template-symlink/expected_output new file mode 100644 index 0000000..17488ac --- /dev/null +++ b/test/scripts/makepkg-template-tests/missing-template-symlink/expected_output @@ -0,0 +1,2 @@ +Couldn't detect version for template 'perl-module' +255 diff --git a/test/scripts/makepkg-template-tests/missing-template-symlink/templates/perl-module-1.0.template b/test/scripts/makepkg-template-tests/missing-template-symlink/templates/perl-module-1.0.template new file mode 100644 index 0000000..f499d25 --- /dev/null +++ b/test/scripts/makepkg-template-tests/missing-template-symlink/templates/perl-module-1.0.template @@ -0,0 +1 @@ +this should not be included -- 2.2.1
Signed-off-by: Florian Pritz <bluewind@xinu.at> --- test/scripts/makepkg-template-tests/name-charset-invalid/PKGBUILD | 8 ++++++++ .../makepkg-template-tests/name-charset-invalid/expected_output | 3 +++ 2 files changed, 11 insertions(+) create mode 100644 test/scripts/makepkg-template-tests/name-charset-invalid/PKGBUILD create mode 100644 test/scripts/makepkg-template-tests/name-charset-invalid/expected_output diff --git a/test/scripts/makepkg-template-tests/name-charset-invalid/PKGBUILD b/test/scripts/makepkg-template-tests/name-charset-invalid/PKGBUILD new file mode 100644 index 0000000..36ed75b --- /dev/null +++ b/test/scripts/makepkg-template-tests/name-charset-invalid/PKGBUILD @@ -0,0 +1,8 @@ +pkgname=foo +pkgver=1 + +build() { +# template start; name=foo/ +make install +# template end; +} diff --git a/test/scripts/makepkg-template-tests/name-charset-invalid/expected_output b/test/scripts/makepkg-template-tests/name-charset-invalid/expected_output new file mode 100644 index 0000000..a8651a9 --- /dev/null +++ b/test/scripts/makepkg-template-tests/name-charset-invalid/expected_output @@ -0,0 +1,3 @@ +invalid chars used in name 'foo/'. allowed: [:alnum:]+_.@- +./makepkg-template-tests/name-charset-invalid/PKGBUILD:5: # template start; name=foo/ +255 -- 2.2.1
Signed-off-by: Florian Pritz <bluewind@xinu.at> --- test/scripts/makepkg-template-tests/name-charset-valid/PKGBUILD | 8 ++++++++ .../makepkg-template-tests/name-charset-valid/expected_output | 1 + .../makepkg-template-tests/name-charset-valid/expected_result | 8 ++++++++ .../name-charset-valid/templates/foo@-_.+a-1.template | 1 + .../name-charset-valid/templates/foo@-_.+a.template | 1 + 5 files changed, 19 insertions(+) create mode 100644 test/scripts/makepkg-template-tests/name-charset-valid/PKGBUILD create mode 100644 test/scripts/makepkg-template-tests/name-charset-valid/expected_output create mode 100644 test/scripts/makepkg-template-tests/name-charset-valid/expected_result create mode 100644 test/scripts/makepkg-template-tests/name-charset-valid/templates/foo@-_.+a-1.template create mode 120000 test/scripts/makepkg-template-tests/name-charset-valid/templates/foo@-_.+a.template diff --git a/test/scripts/makepkg-template-tests/name-charset-valid/PKGBUILD b/test/scripts/makepkg-template-tests/name-charset-valid/PKGBUILD new file mode 100644 index 0000000..ec21cdb --- /dev/null +++ b/test/scripts/makepkg-template-tests/name-charset-valid/PKGBUILD @@ -0,0 +1,8 @@ +pkgname=foo +pkgver=1 + +build() { +# template start; name=foo@-_.+a +make install +# template end; +} diff --git a/test/scripts/makepkg-template-tests/name-charset-valid/expected_output b/test/scripts/makepkg-template-tests/name-charset-valid/expected_output new file mode 100644 index 0000000..573541a --- /dev/null +++ b/test/scripts/makepkg-template-tests/name-charset-valid/expected_output @@ -0,0 +1 @@ +0 diff --git a/test/scripts/makepkg-template-tests/name-charset-valid/expected_result b/test/scripts/makepkg-template-tests/name-charset-valid/expected_result new file mode 100644 index 0000000..25b6869 --- /dev/null +++ b/test/scripts/makepkg-template-tests/name-charset-valid/expected_result @@ -0,0 +1,8 @@ +pkgname=foo +pkgver=1 + +build() { +# template start; name=foo@-_.+a; version=1; +42 cookies +# template end; +} diff --git a/test/scripts/makepkg-template-tests/name-charset-valid/templates/foo@-_.+a-1.template b/test/scripts/makepkg-template-tests/name-charset-valid/templates/foo@-_.+a-1.template new file mode 100644 index 0000000..d0884a6 --- /dev/null +++ b/test/scripts/makepkg-template-tests/name-charset-valid/templates/foo@-_.+a-1.template @@ -0,0 +1 @@ +42 cookies diff --git a/test/scripts/makepkg-template-tests/name-charset-valid/templates/foo@-_.+a.template b/test/scripts/makepkg-template-tests/name-charset-valid/templates/foo@-_.+a.template new file mode 120000 index 0000000..24b333f --- /dev/null +++ b/test/scripts/makepkg-template-tests/name-charset-valid/templates/foo@-_.+a.template @@ -0,0 +1 @@ +foo@-_.+a-1.template \ No newline at end of file -- 2.2.1
Signed-off-by: Florian Pritz <bluewind@xinu.at> --- .../makepkg-template-tests/template-without-version/PKGBUILD | 8 ++++++++ .../template-without-version/expected_output | 2 ++ .../templates/template-without_version.template | 0 3 files changed, 10 insertions(+) create mode 100644 test/scripts/makepkg-template-tests/template-without-version/PKGBUILD create mode 100644 test/scripts/makepkg-template-tests/template-without-version/expected_output create mode 100644 test/scripts/makepkg-template-tests/template-without-version/templates/template-without_version.template diff --git a/test/scripts/makepkg-template-tests/template-without-version/PKGBUILD b/test/scripts/makepkg-template-tests/template-without-version/PKGBUILD new file mode 100644 index 0000000..a4509a1 --- /dev/null +++ b/test/scripts/makepkg-template-tests/template-without-version/PKGBUILD @@ -0,0 +1,8 @@ +pkgname=foo +pkgver=1 + +build() { +# template start; name=template-without_version +make install +# template end; +} diff --git a/test/scripts/makepkg-template-tests/template-without-version/expected_output b/test/scripts/makepkg-template-tests/template-without-version/expected_output new file mode 100644 index 0000000..8f32455 --- /dev/null +++ b/test/scripts/makepkg-template-tests/template-without-version/expected_output @@ -0,0 +1,2 @@ +Couldn't detect version for template 'template-without_version' +255 diff --git a/test/scripts/makepkg-template-tests/template-without-version/templates/template-without_version.template b/test/scripts/makepkg-template-tests/template-without-version/templates/template-without_version.template new file mode 100644 index 0000000..e69de29 -- 2.2.1
Signed-off-by: Florian Pritz <bluewind@xinu.at> --- .../update-version-with-newest-option/PKGBUILD | 7 +++++++ .../update-version-with-newest-option/arguments | 1 + .../update-version-with-newest-option/expected_output | 1 + .../update-version-with-newest-option/expected_result | 16 ++++++++++++++++ .../templates/perl-bla-1.2.template | 1 + .../templates/perl-bla.template | 1 + .../templates/perl-module-1.0.template | 6 ++++++ .../templates/perl-module-1.1.template | 7 +++++++ .../templates/perl-module.template | 1 + 9 files changed, 41 insertions(+) create mode 100644 test/scripts/makepkg-template-tests/update-version-with-newest-option/PKGBUILD create mode 100644 test/scripts/makepkg-template-tests/update-version-with-newest-option/arguments create mode 100644 test/scripts/makepkg-template-tests/update-version-with-newest-option/expected_output create mode 100644 test/scripts/makepkg-template-tests/update-version-with-newest-option/expected_result create mode 100644 test/scripts/makepkg-template-tests/update-version-with-newest-option/templates/perl-bla-1.2.template create mode 120000 test/scripts/makepkg-template-tests/update-version-with-newest-option/templates/perl-bla.template create mode 100644 test/scripts/makepkg-template-tests/update-version-with-newest-option/templates/perl-module-1.0.template create mode 100644 test/scripts/makepkg-template-tests/update-version-with-newest-option/templates/perl-module-1.1.template create mode 120000 test/scripts/makepkg-template-tests/update-version-with-newest-option/templates/perl-module.template diff --git a/test/scripts/makepkg-template-tests/update-version-with-newest-option/PKGBUILD b/test/scripts/makepkg-template-tests/update-version-with-newest-option/PKGBUILD new file mode 100644 index 0000000..e1687cc --- /dev/null +++ b/test/scripts/makepkg-template-tests/update-version-with-newest-option/PKGBUILD @@ -0,0 +1,7 @@ +pkgname=foo +pkgver=1 + +build() { +# template start; name=perl-module; version=1.0 +# template end; +} diff --git a/test/scripts/makepkg-template-tests/update-version-with-newest-option/arguments b/test/scripts/makepkg-template-tests/update-version-with-newest-option/arguments new file mode 100644 index 0000000..e85f5ed --- /dev/null +++ b/test/scripts/makepkg-template-tests/update-version-with-newest-option/arguments @@ -0,0 +1 @@ +-n \ No newline at end of file diff --git a/test/scripts/makepkg-template-tests/update-version-with-newest-option/expected_output b/test/scripts/makepkg-template-tests/update-version-with-newest-option/expected_output new file mode 100644 index 0000000..573541a --- /dev/null +++ b/test/scripts/makepkg-template-tests/update-version-with-newest-option/expected_output @@ -0,0 +1 @@ +0 diff --git a/test/scripts/makepkg-template-tests/update-version-with-newest-option/expected_result b/test/scripts/makepkg-template-tests/update-version-with-newest-option/expected_result new file mode 100644 index 0000000..ea3bbe8 --- /dev/null +++ b/test/scripts/makepkg-template-tests/update-version-with-newest-option/expected_result @@ -0,0 +1,16 @@ +pkgname=foo +pkgver=1 + +build() { +# template start; name=perl-module; version=1.1; +echo "perl-module version 1.1" +echo "before bla template" +# template start; name=perl-bla; version=1.2; +bla bla +# template end; +echo "after bla template" +perl Makefile.pl +make +make install +# template end; +} diff --git a/test/scripts/makepkg-template-tests/update-version-with-newest-option/templates/perl-bla-1.2.template b/test/scripts/makepkg-template-tests/update-version-with-newest-option/templates/perl-bla-1.2.template new file mode 100644 index 0000000..b72e7d4 --- /dev/null +++ b/test/scripts/makepkg-template-tests/update-version-with-newest-option/templates/perl-bla-1.2.template @@ -0,0 +1 @@ +bla bla 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 new file mode 120000 index 0000000..1161447 --- /dev/null +++ b/test/scripts/makepkg-template-tests/update-version-with-newest-option/templates/perl-bla.template @@ -0,0 +1 @@ +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-1.0.template b/test/scripts/makepkg-template-tests/update-version-with-newest-option/templates/perl-module-1.0.template new file mode 100644 index 0000000..415025a --- /dev/null +++ b/test/scripts/makepkg-template-tests/update-version-with-newest-option/templates/perl-module-1.0.template @@ -0,0 +1,6 @@ +echo "before bla template" +# template input; name=perl-bla +echo "after bla template" +perl Makefile.pl +make +make install diff --git a/test/scripts/makepkg-template-tests/update-version-with-newest-option/templates/perl-module-1.1.template b/test/scripts/makepkg-template-tests/update-version-with-newest-option/templates/perl-module-1.1.template new file mode 100644 index 0000000..5ad32c3 --- /dev/null +++ b/test/scripts/makepkg-template-tests/update-version-with-newest-option/templates/perl-module-1.1.template @@ -0,0 +1,7 @@ +echo "perl-module version 1.1" +echo "before bla template" +# template input; name=perl-bla +echo "after bla template" +perl Makefile.pl +make +make install 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 new file mode 120000 index 0000000..f8618e4 --- /dev/null +++ b/test/scripts/makepkg-template-tests/update-version-with-newest-option/templates/perl-module.template @@ -0,0 +1 @@ +perl-module-1.1.template \ No newline at end of file -- 2.2.1
On 21.12.2014 16:11, Florian Pritz wrote:
+ "$scriptdir/makepkg-template" \ + --template-dir "$testdir/$testcase/templates" \ + -p "$testdir/$testcase/PKGBUILD" \ + -o "$testdir/$testcase/result" \ + &> "$testdir/$testcase/output_full" "${arguments[@]}"
Keeping those files in the testcase directory is actually a bad idea since they will be left over if you check out an older commit and they will confuse the test suite. I'll switch this to a tempdir.
+ exitcode=$? + + sed "$testdir/$testcase/output_full" >"$testdir/$testcase/output" \ + -e 's|./test/scripts/|./|' \ + -e 's| at '$scriptdir'/makepkg-template line [0-9]\+\.$||' + printf "%s\n" "$exitcode" >> "$testdir/$testcase/output"
This leads to a magic number in the expected_output file. I'll switch this and all testcases to use "exitcode: $exitcode" for more clarity. (won't resubmit them unless anything else changes)
Signed-off-by: Florian Pritz <bluewind@xinu.at> --- v2: - use a temp dir for output files - mark the exit code in the expected_output file with "exitcode: " (tests are adjusted on my working branch) Makefile.am | 2 + test/scripts/Makefile.am | 1 + test/scripts/makepkg-template_test.sh | 89 +++++++++++++++++++++++++++++++++++ 3 files changed, 92 insertions(+) create mode 100755 test/scripts/makepkg-template_test.sh diff --git a/Makefile.am b/Makefile.am index e9b3dfa..ab669ef 100644 --- a/Makefile.am +++ b/Makefile.am @@ -28,6 +28,7 @@ $(top_srcdir)/test/pacman/tests/TESTS: $(wildcard test/pacman/tests/*.py*) TESTS = test/scripts/parseopts_test.sh \ test/scripts/human_to_size_test.sh \ + test/scripts/makepkg-template_test.sh \ test/scripts/pacman-db-upgrade-v9.py \ test/util/pacsorttest.sh \ test/util/vercmptest.sh @@ -37,6 +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_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/Makefile.am b/test/scripts/Makefile.am index 8d6bc84..ed1a951 100644 --- a/test/scripts/Makefile.am +++ b/test/scripts/Makefile.am @@ -1,6 +1,7 @@ check_SCRIPTS = \ parseopts_test.sh \ pacman-db-upgrade-v9.py \ + makepkg-template_test.sh \ human_to_size_test.sh noinst_SCRIPTS = $(check_SCRIPTS) diff --git a/test/scripts/makepkg-template_test.sh b/test/scripts/makepkg-template_test.sh new file mode 100755 index 0000000..5242f2c --- /dev/null +++ b/test/scripts/makepkg-template_test.sh @@ -0,0 +1,89 @@ +#!/bin/bash + +declare -i testcount=0 fail=0 pass=0 total=0 + +# source the library function +scriptdir=${1:-${PMTEST_SCRIPT_DIR}} +if [[ -z $scriptdir || ! -f $scriptdir/makepkg-template ]]; then + printf "Bail out! makepkg-template executable (%s) could not be located\n" "${scriptdir}/makepkg-template" + exit 1 +fi + +testdir="${0%/*}/makepkg-template-tests" + +total=$(find "$testdir" -maxdepth 1 -mindepth 1 -type d | wc -l) + +run_test() { + local testcase=$1 exitcode + local -i failed=0 + + (( ++testcount )) + + local -a arguments + + if [[ -f "$testdir/$testcase/arguments" ]]; then + arguments=($(cat "$testdir/$testcase/arguments")) + fi + + mkdir "$TMPDIR/$testcase" + + "$scriptdir/makepkg-template" \ + --template-dir "$testdir/$testcase/templates" \ + -p "$testdir/$testcase/PKGBUILD" \ + -o "$TMPDIR/$testcase/result" \ + &> "$TMPDIR/$testcase/output_full" "${arguments[@]}" + exitcode=$? + + sed "$TMPDIR/$testcase/output_full" >"$TMPDIR/$testcase/output" \ + -e 's|./test/scripts/|./|' \ + -e 's| at '$scriptdir'/makepkg-template line [0-9]\+\.$||' + printf "exitcode: %s\n" "$exitcode" >> "$TMPDIR/$testcase/output" + + if [[ -f "$TMPDIR/$testcase/result" ]]; then + if ! diff -u "$TMPDIR/$testcase/result" "$testdir/$testcase/expected_result"; then + failed=1 + fi + else + if [[ -f "$testdir/$testcase/expected_result" ]]; then + echo "$testcase: Found expected_result file but no result file" + failed=1 + fi + fi + + if ! diff -u "$TMPDIR/$testcase/output" "$testdir/$testcase/expected_output"; then + failed=1 + fi + + if ((!failed)); then + (( ++pass )) + printf "ok %d - %s\n" "$testcount" "$input" + else + (( ++fail )) + printf "not ok %d - %s\n" "$testcount" "$input" + printf '# [TEST %3s]: FAIL\n' "$testcount" + fi +} + +summarize() { + rm -rf "$TMPDIR" + + if (( !fail )); then + printf '# All %s tests successful\n\n' "$testcount" + exit 0 + else + printf '# %s of %s tests failed\n\n' "$fail" "$testcount" + exit 1 + fi +} +TMPDIR="$(mktemp -d "/tmp/${0##*/}.XXXXXX")" +trap 'summarize' EXIT + +printf '# Beginning makepkg-template tests\n' + +echo "1..$total" + +for dir in "$testdir/"*; do + if [[ -d "$dir" ]]; then + run_test "${dir##*/}" + fi +done -- 2.2.1
On 12/21/14 at 04:43pm, Florian Pritz wrote:
Signed-off-by: Florian Pritz <bluewind@xinu.at> ---
v2: - use a temp dir for output files - mark the exit code in the expected_output file with "exitcode: " (tests are adjusted on my working branch)
Makefile.am | 2 + test/scripts/Makefile.am | 1 + test/scripts/makepkg-template_test.sh | 89 +++++++++++++++++++++++++++++++++++ 3 files changed, 92 insertions(+) create mode 100755 test/scripts/makepkg-template_test.sh
diff --git a/Makefile.am b/Makefile.am index e9b3dfa..ab669ef 100644 --- a/Makefile.am +++ b/Makefile.am @@ -28,6 +28,7 @@ $(top_srcdir)/test/pacman/tests/TESTS: $(wildcard test/pacman/tests/*.py*)
TESTS = test/scripts/parseopts_test.sh \ test/scripts/human_to_size_test.sh \ + test/scripts/makepkg-template_test.sh \ test/scripts/pacman-db-upgrade-v9.py \ test/util/pacsorttest.sh \ test/util/vercmptest.sh @@ -37,6 +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_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/Makefile.am b/test/scripts/Makefile.am index 8d6bc84..ed1a951 100644 --- a/test/scripts/Makefile.am +++ b/test/scripts/Makefile.am @@ -1,6 +1,7 @@ check_SCRIPTS = \ parseopts_test.sh \ pacman-db-upgrade-v9.py \ + makepkg-template_test.sh \ human_to_size_test.sh
noinst_SCRIPTS = $(check_SCRIPTS) diff --git a/test/scripts/makepkg-template_test.sh b/test/scripts/makepkg-template_test.sh new file mode 100755 index 0000000..5242f2c --- /dev/null +++ b/test/scripts/makepkg-template_test.sh @@ -0,0 +1,89 @@ +#!/bin/bash + +declare -i testcount=0 fail=0 pass=0 total=0 + +# source the library function +scriptdir=${1:-${PMTEST_SCRIPT_DIR}} +if [[ -z $scriptdir || ! -f $scriptdir/makepkg-template ]]; then + printf "Bail out! makepkg-template executable (%s) could not be located\n" "${scriptdir}/makepkg-template" + exit 1 +fi
This does not work the same as our other tests which allow passing the executable as the first argument.
+ +testdir="${0%/*}/makepkg-template-tests" + +total=$(find "$testdir" -maxdepth 1 -mindepth 1 -type d | wc -l) + +run_test() { + local testcase=$1 exitcode + local -i failed=0 + + (( ++testcount )) + + local -a arguments + + if [[ -f "$testdir/$testcase/arguments" ]]; then + arguments=($(cat "$testdir/$testcase/arguments")) + fi + + mkdir "$TMPDIR/$testcase" + + "$scriptdir/makepkg-template" \
makepkg-template uses translated messages; if you're going to check its output you need to set the locale.
+ --template-dir "$testdir/$testcase/templates" \ + -p "$testdir/$testcase/PKGBUILD" \ + -o "$TMPDIR/$testcase/result" \ + &> "$TMPDIR/$testcase/output_full" "${arguments[@]}" + exitcode=$? + + sed "$TMPDIR/$testcase/output_full" >"$TMPDIR/$testcase/output" \ + -e 's|./test/scripts/|./|' \
That should be $testdir or some variation of it.
+ -e 's| at '$scriptdir'/makepkg-template line [0-9]\+\.$||'
makepkg-template should be updated to not include line numbers in error messages rather than trying to filter them out.
+ printf "exitcode: %s\n" "$exitcode" >> "$TMPDIR/$testcase/output"
It would be better if we could test the exit code, output, and result independently.
+ + if [[ -f "$TMPDIR/$testcase/result" ]]; then + if ! diff -u "$TMPDIR/$testcase/result" "$testdir/$testcase/expected_result"; then
The diff output needs to be marked as diagnostic output. I'm working on a TAP generator for bash that we can use that will do that for us as well as taking care of all the counting.
+ failed=1 + fi + else + if [[ -f "$testdir/$testcase/expected_result" ]]; then + echo "$testcase: Found expected_result file but no result file" + failed=1 + fi + fi + + if ! diff -u "$TMPDIR/$testcase/output" "$testdir/$testcase/expected_output"; then + failed=1 + fi + + if ((!failed)); then + (( ++pass )) + printf "ok %d - %s\n" "$testcount" "$input"
I think you mean s/input/testcase/
+ else + (( ++fail )) + printf "not ok %d - %s\n" "$testcount" "$input" + printf '# [TEST %3s]: FAIL\n' "$testcount"
Redundant failure message.
+ fi +} + +summarize() { + rm -rf "$TMPDIR" + + if (( !fail )); then + printf '# All %s tests successful\n\n' "$testcount" + exit 0 + else + printf '# %s of %s tests failed\n\n' "$fail" "$testcount" + exit 1 + fi +} +TMPDIR="$(mktemp -d "/tmp/${0##*/}.XXXXXX")" +trap 'summarize' EXIT + +printf '# Beginning makepkg-template tests\n'
I know we have these messages in other tests, but they are completely useless, let's not add any more.
+ +echo "1..$total" + +for dir in "$testdir/"*; do + if [[ -d "$dir" ]]; then + run_test "${dir##*/}" + fi +done -- 2.2.1
Signed-off-by: Florian Pritz <bluewind@xinu.at> --- v3: + suggested by Andrew - take the executable as $1 rather than just the dir - force C locale - use $testdir when normalizing paths - fix output line of successful testcase - remove useless begin comment + replace $testdir more than once per line (g modifier) + use perl instead of sed and use quotemeta to do simple string replacements without interpreting the variable as a regex + reorder diff arguments so --- points to expected output and +++ to actual On 22.12.2014 05:19, Andrew Gregory wrote:
+ -e 's| at '$scriptdir'/makepkg-template line [0-9]\+\.$||'
makepkg-template should be updated to not include line numbers in error messages rather than trying to filter them out.
I find line numbers rather helpful when debugging (which is also why I keep output-full around even though I currently provide no way to keep the tempdir), but I agree it's not the cleanest check.
+ printf "exitcode: %s\n" "$exitcode" >> "$TMPDIR/$testcase/output"
It would be better if we could test the exit code, output, and result independently.
result and output are already tested independently and adding the exit code to the output means I need less files per test case. Since I sometimes expect exit codes != 0 I need a way to check for a specific one and this seemed easiest. Would you want a dedicated file with just one number inside or maybe some kind of "config" file per testcase? That could also store additional arguments (currently "arguments" file, used only once I believe). It would add an additional file to every test case though.
+ + if [[ -f "$TMPDIR/$testcase/result" ]]; then + if ! diff -u "$TMPDIR/$testcase/result" "$testdir/$testcase/expected_result"; then
The diff output needs to be marked as diagnostic output. I'm working on a TAP generator for bash that we can use that will do that for us as well as taking care of all the counting.
Any ETA? I have not yet changed that. That said the test suite seems to put this output into the log file just fine AFAICT.
+ else + (( ++fail )) + printf "not ok %d - %s\n" "$testcount" "$input" + printf '# [TEST %3s]: FAIL\n' "$testcount"
Redundant failure message.
I copied that from human_to_size_test.sh. I have no idea how the testsuite actually works and why this was there initially. Makefile.am | 2 + test/scripts/Makefile.am | 1 + test/scripts/makepkg-template_test.sh | 91 +++++++++++++++++++++++++++++++++++ 3 files changed, 94 insertions(+) create mode 100755 test/scripts/makepkg-template_test.sh diff --git a/Makefile.am b/Makefile.am index e9b3dfa..ab669ef 100644 --- a/Makefile.am +++ b/Makefile.am @@ -28,6 +28,7 @@ $(top_srcdir)/test/pacman/tests/TESTS: $(wildcard test/pacman/tests/*.py*) TESTS = test/scripts/parseopts_test.sh \ test/scripts/human_to_size_test.sh \ + test/scripts/makepkg-template_test.sh \ test/scripts/pacman-db-upgrade-v9.py \ test/util/pacsorttest.sh \ test/util/vercmptest.sh @@ -37,6 +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_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/Makefile.am b/test/scripts/Makefile.am index 8d6bc84..ed1a951 100644 --- a/test/scripts/Makefile.am +++ b/test/scripts/Makefile.am @@ -1,6 +1,7 @@ check_SCRIPTS = \ parseopts_test.sh \ pacman-db-upgrade-v9.py \ + makepkg-template_test.sh \ human_to_size_test.sh noinst_SCRIPTS = $(check_SCRIPTS) diff --git a/test/scripts/makepkg-template_test.sh b/test/scripts/makepkg-template_test.sh new file mode 100755 index 0000000..46f5929 --- /dev/null +++ b/test/scripts/makepkg-template_test.sh @@ -0,0 +1,91 @@ +#!/bin/bash + +declare -i testcount=0 fail=0 pass=0 total=0 + +# source the library function +script=${1:-${PMTEST_SCRIPT_DIR}/makepkg-template} +if [[ -z $script || ! -f $script ]]; then + printf "Bail out! makepkg-template executable (%s) could not be located\n" "${script}" + exit 1 +fi + +testdir="${0%/*}/makepkg-template-tests" + +total=$(find "$testdir" -maxdepth 1 -mindepth 1 -type d | wc -l) + +run_test() { + local testcase=$1 exitcode + local -i failed=0 + + (( ++testcount )) + + local -a arguments + + if [[ -f "$testdir/$testcase/arguments" ]]; then + arguments=($(cat "$testdir/$testcase/arguments")) + fi + + mkdir "$TMPDIR/$testcase" + + LC_ALL=C "$script" \ + --template-dir "$testdir/$testcase/templates" \ + -p "$testdir/$testcase/PKGBUILD" \ + -o "$TMPDIR/$testcase/result" \ + &> "$TMPDIR/$testcase/output_full" "${arguments[@]}" + exitcode=$? + + perl -p <"$TMPDIR/$testcase/output_full" >"$TMPDIR/$testcase/output" \ + -e 's| at \Q'"$script"'\E line [0-9]+\.$||;' \ + + if [[ "${testdir%/*}" != "." ]]; then + perl -pi -e 's|\Q'"${testdir%/*}"'\E|.|g;' "$TMPDIR/$testcase/output" + fi + + printf "exitcode: %s\n" "$exitcode" >> "$TMPDIR/$testcase/output" + + if [[ -f "$TMPDIR/$testcase/result" ]]; then + if ! diff -u "$testdir/$testcase/expected_result" "$TMPDIR/$testcase/result"; then + failed=1 + fi + else + if [[ -f "$testdir/$testcase/expected_result" ]]; then + echo "$testcase: Found expected_result file but no result file" + failed=1 + fi + fi + + if ! diff -u "$testdir/$testcase/expected_output" "$TMPDIR/$testcase/output"; then + failed=1 + fi + + if ((!failed)); then + (( ++pass )) + printf "ok %d - %s\n" "$testcount" "$testcase" + else + (( ++fail )) + printf "not ok %d - %s\n" "$testcount" "$input" + printf '# [TEST %3s]: FAIL\n' "$testcount" + fi +} + +summarize() { + rm -rf "$TMPDIR" + + if (( !fail )); then + printf '# All %s tests successful\n\n' "$testcount" + exit 0 + else + printf '# %s of %s tests failed\n\n' "$fail" "$testcount" + exit 1 + fi +} +TMPDIR="$(mktemp -d "/tmp/${0##*/}.XXXXXX")" +trap 'summarize' EXIT + +echo "1..$total" + +for dir in "$testdir/"*; do + if [[ -d "$dir" ]]; then + run_test "${dir##*/}" + fi +done -- 2.2.1
Signed-off-by: Florian Pritz <bluewind@xinu.at> --- v4: - adjusted to tap.sh - move expected output/result/exitcode/arguments into a single file called testcase-config - removed line number removal code (depends on "[PATCH] makepkg-template: Remove linenumber/file from errors" to be merged) - normalize paths by cd'ing into the testdir rather than using sed The test files are simply adjusted to the changes to the main script, but I hope this is the last iteration so I'm posting them again for context. Makefile.am | 2 + test/scripts/Makefile.am | 1 + .../testcase-config-template | 9 ++++ test/scripts/makepkg-template_test.sh | 52 ++++++++++++++++++++++ 4 files changed, 64 insertions(+) create mode 100644 test/scripts/makepkg-template-tests/testcase-config-template create mode 100755 test/scripts/makepkg-template_test.sh diff --git a/Makefile.am b/Makefile.am index 01ea4f1..9dbacca 100644 --- a/Makefile.am +++ b/Makefile.am @@ -28,6 +28,7 @@ $(top_srcdir)/test/pacman/tests/TESTS: $(wildcard test/pacman/tests/*.py*) TESTS = test/scripts/parseopts_test.sh \ test/scripts/human_to_size_test.sh \ + test/scripts/makepkg-template_test.sh \ test/scripts/pacman-db-upgrade-v9.py \ test/util/pacsorttest.sh \ test/util/vercmptest.sh @@ -37,6 +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_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/Makefile.am b/test/scripts/Makefile.am index 8d6bc84..ed1a951 100644 --- a/test/scripts/Makefile.am +++ b/test/scripts/Makefile.am @@ -1,6 +1,7 @@ check_SCRIPTS = \ parseopts_test.sh \ pacman-db-upgrade-v9.py \ + makepkg-template_test.sh \ human_to_size_test.sh noinst_SCRIPTS = $(check_SCRIPTS) diff --git a/test/scripts/makepkg-template-tests/testcase-config-template b/test/scripts/makepkg-template-tests/testcase-config-template new file mode 100644 index 0000000..66267d3 --- /dev/null +++ b/test/scripts/makepkg-template-tests/testcase-config-template @@ -0,0 +1,9 @@ +arguments+=() +expected_exitcode=0 + +# set IFS="" if you want trailing new line(s), otherwise remove it +IFS="" read -d '' expected_output <<'EOF' +EOF + +IFS="" read -d '' expected_result <<'EOF' +EOF diff --git a/test/scripts/makepkg-template_test.sh b/test/scripts/makepkg-template_test.sh new file mode 100755 index 0000000..34185db --- /dev/null +++ b/test/scripts/makepkg-template_test.sh @@ -0,0 +1,52 @@ +#!/bin/bash + +source "$(dirname "$0")"/../tap.sh || exit 1 + +# source the library function +script=$(readlink -f "${1:-${PMTEST_SCRIPT_DIR}/makepkg-template}") +if [[ -z $script || ! -f $script ]]; then + tap_bail "makepkg-template executable (%s) could not be located" "${script}" + exit 1 +fi + +# normalize paths +cd "${0%/*}" +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) +[[ -n "$total" ]] || tap_bail "unable to determine total number of tests" +tap_plan "$((total*3))" + +run_test() { + local testcase=$1 exitcode expected_result expected_output + local -a arguments + local -i expected_exitcode=-1 + + [[ -f "$testdir/$testcase/testcase-config" ]] || continue + source "$testdir/$testcase/testcase-config" + + mkdir "$TMPDIR/$testcase" + touch "$TMPDIR/$testcase/result" + + LC_ALL=C "$script" \ + --template-dir "$testdir/$testcase/templates" \ + -p "$testdir/$testcase/PKGBUILD" \ + -o "$TMPDIR/$testcase/result" \ + &> "$TMPDIR/$testcase/output" "${arguments[@]}" + exitcode=$? + + tap_is_int "$exitcode" "$expected_exitcode" "$testcase exitcode" + tap_diff "$TMPDIR/$testcase/output" <(printf "%s" "$expected_output") "$testcase output" + tap_diff "$TMPDIR/$testcase/result" <(printf "%s" "$expected_result") "$testcase resulting PKGBUILD" +} + +for dir in "$testdir/"*; do + if [[ -d "$dir" ]]; then + run_test "${dir##*/}" + fi +done + +tap_finish -- 2.2.1
Signed-off-by: Florian Pritz <bluewind@xinu.at> --- test/scripts/makepkg-template-tests/invalid-key/PKGBUILD | 1 + .../makepkg-template-tests/invalid-key/testcase-config | 11 +++++++++++ 2 files changed, 12 insertions(+) create mode 100644 test/scripts/makepkg-template-tests/invalid-key/PKGBUILD create mode 100644 test/scripts/makepkg-template-tests/invalid-key/testcase-config diff --git a/test/scripts/makepkg-template-tests/invalid-key/PKGBUILD b/test/scripts/makepkg-template-tests/invalid-key/PKGBUILD new file mode 100644 index 0000000..02bfadc --- /dev/null +++ b/test/scripts/makepkg-template-tests/invalid-key/PKGBUILD @@ -0,0 +1 @@ +# template input; []³|>=bar; diff --git a/test/scripts/makepkg-template-tests/invalid-key/testcase-config b/test/scripts/makepkg-template-tests/invalid-key/testcase-config new file mode 100644 index 0000000..4e4725e --- /dev/null +++ b/test/scripts/makepkg-template-tests/invalid-key/testcase-config @@ -0,0 +1,11 @@ +arguments+=() +expected_exitcode=255 + +# set IFS="" if you want trailing new lines, otherwise remove it +IFS="" read -d '' expected_output <<'EOF' +invalid key/value pair +./makepkg-template-tests/invalid-key/PKGBUILD:1: # template input; []³|>=bar; +EOF + +IFS="" read -d '' expected_result <<'EOF' +EOF -- 2.2.1
Signed-off-by: Florian Pritz <bluewind@xinu.at> --- .../invalid-template-line-missing-name/PKGBUILD | 1 + .../invalid-template-line-missing-name/testcase-config | 11 +++++++++++ 2 files changed, 12 insertions(+) create mode 100644 test/scripts/makepkg-template-tests/invalid-template-line-missing-name/PKGBUILD create mode 100644 test/scripts/makepkg-template-tests/invalid-template-line-missing-name/testcase-config diff --git a/test/scripts/makepkg-template-tests/invalid-template-line-missing-name/PKGBUILD b/test/scripts/makepkg-template-tests/invalid-template-line-missing-name/PKGBUILD new file mode 100644 index 0000000..d0a20c1 --- /dev/null +++ b/test/scripts/makepkg-template-tests/invalid-template-line-missing-name/PKGBUILD @@ -0,0 +1 @@ +# template input; diff --git a/test/scripts/makepkg-template-tests/invalid-template-line-missing-name/testcase-config b/test/scripts/makepkg-template-tests/invalid-template-line-missing-name/testcase-config new file mode 100644 index 0000000..6bfda32 --- /dev/null +++ b/test/scripts/makepkg-template-tests/invalid-template-line-missing-name/testcase-config @@ -0,0 +1,11 @@ +arguments+=() +expected_exitcode=255 + +# set IFS="" if you want trailing new lines, otherwise remove it +IFS="" read -d '' expected_output <<'EOF' +invalid template line: can't find template name +./makepkg-template-tests/invalid-template-line-missing-name/PKGBUILD:1: # template input; +EOF + +IFS="" read -d '' expected_result <<'EOF' +EOF -- 2.2.1
Signed-off-by: Florian Pritz <bluewind@xinu.at> --- .../invalid-template-line-unknown-marker/PKGBUILD | 9 +++++++++ .../invalid-template-line-unknown-marker/testcase-config | 11 +++++++++++ 2 files changed, 20 insertions(+) create mode 100644 test/scripts/makepkg-template-tests/invalid-template-line-unknown-marker/PKGBUILD create mode 100644 test/scripts/makepkg-template-tests/invalid-template-line-unknown-marker/testcase-config diff --git a/test/scripts/makepkg-template-tests/invalid-template-line-unknown-marker/PKGBUILD b/test/scripts/makepkg-template-tests/invalid-template-line-unknown-marker/PKGBUILD new file mode 100644 index 0000000..645ea37 --- /dev/null +++ b/test/scripts/makepkg-template-tests/invalid-template-line-unknown-marker/PKGBUILD @@ -0,0 +1,9 @@ +pkgname=foo +pkgver=1 + +build() { +# template boom; name=test +perl Makefile.pl +make +# template end; +} diff --git a/test/scripts/makepkg-template-tests/invalid-template-line-unknown-marker/testcase-config b/test/scripts/makepkg-template-tests/invalid-template-line-unknown-marker/testcase-config new file mode 100644 index 0000000..077a85c --- /dev/null +++ b/test/scripts/makepkg-template-tests/invalid-template-line-unknown-marker/testcase-config @@ -0,0 +1,11 @@ +arguments+=() +expected_exitcode=255 + +# set IFS="" if you want trailing new lines, otherwise remove it +IFS="" read -d '' expected_output <<'EOF' +Unknown template marker 'boom' +./makepkg-template-tests/invalid-template-line-unknown-marker/PKGBUILD:5: # template boom; name=test +EOF + +IFS="" read -d '' expected_result <<'EOF' +EOF -- 2.2.1
Signed-off-by: Florian Pritz <bluewind@xinu.at> --- .../keep-old-version/PKGBUILD | 15 ++++++++++++++ .../templates/perl-bla-1.2.template | 1 + .../keep-old-version/templates/perl-bla.template | 1 + .../templates/perl-module-1.0.template | 6 ++++++ .../templates/perl-module-1.1.template | 7 +++++++ .../templates/perl-module.template | 1 + .../keep-old-version/testcase-config | 24 ++++++++++++++++++++++ 7 files changed, 55 insertions(+) create mode 100644 test/scripts/makepkg-template-tests/keep-old-version/PKGBUILD create mode 100644 test/scripts/makepkg-template-tests/keep-old-version/templates/perl-bla-1.2.template create mode 120000 test/scripts/makepkg-template-tests/keep-old-version/templates/perl-bla.template create mode 100644 test/scripts/makepkg-template-tests/keep-old-version/templates/perl-module-1.0.template create mode 100644 test/scripts/makepkg-template-tests/keep-old-version/templates/perl-module-1.1.template create mode 120000 test/scripts/makepkg-template-tests/keep-old-version/templates/perl-module.template create mode 100644 test/scripts/makepkg-template-tests/keep-old-version/testcase-config diff --git a/test/scripts/makepkg-template-tests/keep-old-version/PKGBUILD b/test/scripts/makepkg-template-tests/keep-old-version/PKGBUILD new file mode 100644 index 0000000..09da2e0 --- /dev/null +++ b/test/scripts/makepkg-template-tests/keep-old-version/PKGBUILD @@ -0,0 +1,15 @@ +pkgname=foo +pkgver=1 + +build() { +# template start; name=perl-module; version=1.0; +echo "before bla template" +# template start; name=perl-bla; version=1.2; +bla bla +# template end; +echo "after bla template" +perl Makefile.pl +make +make install +# template end; +} diff --git a/test/scripts/makepkg-template-tests/keep-old-version/templates/perl-bla-1.2.template b/test/scripts/makepkg-template-tests/keep-old-version/templates/perl-bla-1.2.template new file mode 100644 index 0000000..b72e7d4 --- /dev/null +++ b/test/scripts/makepkg-template-tests/keep-old-version/templates/perl-bla-1.2.template @@ -0,0 +1 @@ +bla bla 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 new file mode 120000 index 0000000..1161447 --- /dev/null +++ b/test/scripts/makepkg-template-tests/keep-old-version/templates/perl-bla.template @@ -0,0 +1 @@ +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-1.0.template b/test/scripts/makepkg-template-tests/keep-old-version/templates/perl-module-1.0.template new file mode 100644 index 0000000..415025a --- /dev/null +++ b/test/scripts/makepkg-template-tests/keep-old-version/templates/perl-module-1.0.template @@ -0,0 +1,6 @@ +echo "before bla template" +# template input; name=perl-bla +echo "after bla template" +perl Makefile.pl +make +make install diff --git a/test/scripts/makepkg-template-tests/keep-old-version/templates/perl-module-1.1.template b/test/scripts/makepkg-template-tests/keep-old-version/templates/perl-module-1.1.template new file mode 100644 index 0000000..5ad32c3 --- /dev/null +++ b/test/scripts/makepkg-template-tests/keep-old-version/templates/perl-module-1.1.template @@ -0,0 +1,7 @@ +echo "perl-module version 1.1" +echo "before bla template" +# template input; name=perl-bla +echo "after bla template" +perl Makefile.pl +make +make install 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 new file mode 120000 index 0000000..f8618e4 --- /dev/null +++ b/test/scripts/makepkg-template-tests/keep-old-version/templates/perl-module.template @@ -0,0 +1 @@ +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 new file mode 100644 index 0000000..241f048 --- /dev/null +++ b/test/scripts/makepkg-template-tests/keep-old-version/testcase-config @@ -0,0 +1,24 @@ +arguments+=() +expected_exitcode=0 + +# set IFS="" if you want trailing new lines, otherwise remove it +IFS="" read -d '' expected_output <<'EOF' +EOF + +IFS="" read -d '' expected_result <<'EOF' +pkgname=foo +pkgver=1 + +build() { +# template start; name=perl-module; version=1.0; +echo "before bla template" +# template start; name=perl-bla; version=1.2; +bla bla +# template end; +echo "after bla template" +perl Makefile.pl +make +make install +# template end; +} +EOF -- 2.2.1
Signed-off-by: Florian Pritz <bluewind@xinu.at> --- .../makepkg-template-tests/missing-template-file/PKGBUILD | 7 +++++++ .../missing-template-file/templates/perl-module.template | 1 + .../missing-template-file/testcase-config | 10 ++++++++++ 3 files changed, 18 insertions(+) create mode 100644 test/scripts/makepkg-template-tests/missing-template-file/PKGBUILD create mode 120000 test/scripts/makepkg-template-tests/missing-template-file/templates/perl-module.template create mode 100644 test/scripts/makepkg-template-tests/missing-template-file/testcase-config diff --git a/test/scripts/makepkg-template-tests/missing-template-file/PKGBUILD b/test/scripts/makepkg-template-tests/missing-template-file/PKGBUILD new file mode 100644 index 0000000..dbfda1d --- /dev/null +++ b/test/scripts/makepkg-template-tests/missing-template-file/PKGBUILD @@ -0,0 +1,7 @@ +pkgname=foo +pkgver=1 + +build() { +# template start; name=perl-module; version=1.0; +# template end; +} 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 new file mode 120000 index 0000000..8c2189a --- /dev/null +++ b/test/scripts/makepkg-template-tests/missing-template-file/templates/perl-module.template @@ -0,0 +1 @@ +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 new file mode 100644 index 0000000..317e77b --- /dev/null +++ b/test/scripts/makepkg-template-tests/missing-template-file/testcase-config @@ -0,0 +1,10 @@ +arguments+=() +expected_exitcode=2 + +# 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 +EOF + +IFS="" read -d '' expected_result <<'EOF' +EOF -- 2.2.1
Signed-off-by: Florian Pritz <bluewind@xinu.at> --- .../makepkg-template-tests/missing-template-symlink/PKGBUILD | 7 +++++++ .../missing-template-symlink/templates/perl-module-1.0.template | 1 + .../missing-template-symlink/testcase-config | 9 +++++++++ 3 files changed, 17 insertions(+) create mode 100644 test/scripts/makepkg-template-tests/missing-template-symlink/PKGBUILD create mode 100644 test/scripts/makepkg-template-tests/missing-template-symlink/templates/perl-module-1.0.template create mode 100644 test/scripts/makepkg-template-tests/missing-template-symlink/testcase-config diff --git a/test/scripts/makepkg-template-tests/missing-template-symlink/PKGBUILD b/test/scripts/makepkg-template-tests/missing-template-symlink/PKGBUILD new file mode 100644 index 0000000..8ee94ac --- /dev/null +++ b/test/scripts/makepkg-template-tests/missing-template-symlink/PKGBUILD @@ -0,0 +1,7 @@ +pkgname=foo +pkgver=1 + +build() { +# template start; name=perl-module; +# template end; +} diff --git a/test/scripts/makepkg-template-tests/missing-template-symlink/templates/perl-module-1.0.template b/test/scripts/makepkg-template-tests/missing-template-symlink/templates/perl-module-1.0.template new file mode 100644 index 0000000..f499d25 --- /dev/null +++ b/test/scripts/makepkg-template-tests/missing-template-symlink/templates/perl-module-1.0.template @@ -0,0 +1 @@ +this should not be included diff --git a/test/scripts/makepkg-template-tests/missing-template-symlink/testcase-config b/test/scripts/makepkg-template-tests/missing-template-symlink/testcase-config new file mode 100644 index 0000000..c0eabe0 --- /dev/null +++ b/test/scripts/makepkg-template-tests/missing-template-symlink/testcase-config @@ -0,0 +1,9 @@ +arguments+=() +expected_exitcode=255 + +IFS="" read -d '' expected_output <<'EOF' +Couldn't detect version for template 'perl-module' +EOF + +IFS="" read -d '' expected_result <<'EOF' +EOF -- 2.2.1
Signed-off-by: Florian Pritz <bluewind@xinu.at> --- .../makepkg-template-tests/name-charset-invalid/PKGBUILD | 8 ++++++++ .../name-charset-invalid/testcase-config | 10 ++++++++++ 2 files changed, 18 insertions(+) create mode 100644 test/scripts/makepkg-template-tests/name-charset-invalid/PKGBUILD create mode 100644 test/scripts/makepkg-template-tests/name-charset-invalid/testcase-config diff --git a/test/scripts/makepkg-template-tests/name-charset-invalid/PKGBUILD b/test/scripts/makepkg-template-tests/name-charset-invalid/PKGBUILD new file mode 100644 index 0000000..36ed75b --- /dev/null +++ b/test/scripts/makepkg-template-tests/name-charset-invalid/PKGBUILD @@ -0,0 +1,8 @@ +pkgname=foo +pkgver=1 + +build() { +# template start; name=foo/ +make install +# template end; +} diff --git a/test/scripts/makepkg-template-tests/name-charset-invalid/testcase-config b/test/scripts/makepkg-template-tests/name-charset-invalid/testcase-config new file mode 100644 index 0000000..7ea9502 --- /dev/null +++ b/test/scripts/makepkg-template-tests/name-charset-invalid/testcase-config @@ -0,0 +1,10 @@ +arguments+=() +expected_exitcode=255 + +IFS="" read -d '' expected_output <<'EOF' +invalid chars used in name 'foo/'. allowed: [:alnum:]+_.@- +./makepkg-template-tests/name-charset-invalid/PKGBUILD:5: # template start; name=foo/ +EOF + +IFS="" read -d '' expected_result <<'EOF' +EOF -- 2.2.1
Signed-off-by: Florian Pritz <bluewind@xinu.at> --- .../makepkg-template-tests/name-charset-valid/PKGBUILD | 8 ++++++++ .../name-charset-valid/templates/foo@-_.+a-1.template | 1 + .../name-charset-valid/templates/foo@-_.+a.template | 1 + .../name-charset-valid/testcase-config | 16 ++++++++++++++++ 4 files changed, 26 insertions(+) create mode 100644 test/scripts/makepkg-template-tests/name-charset-valid/PKGBUILD create mode 100644 test/scripts/makepkg-template-tests/name-charset-valid/templates/foo@-_.+a-1.template create mode 120000 test/scripts/makepkg-template-tests/name-charset-valid/templates/foo@-_.+a.template create mode 100644 test/scripts/makepkg-template-tests/name-charset-valid/testcase-config diff --git a/test/scripts/makepkg-template-tests/name-charset-valid/PKGBUILD b/test/scripts/makepkg-template-tests/name-charset-valid/PKGBUILD new file mode 100644 index 0000000..ec21cdb --- /dev/null +++ b/test/scripts/makepkg-template-tests/name-charset-valid/PKGBUILD @@ -0,0 +1,8 @@ +pkgname=foo +pkgver=1 + +build() { +# template start; name=foo@-_.+a +make install +# template end; +} diff --git a/test/scripts/makepkg-template-tests/name-charset-valid/templates/foo@-_.+a-1.template b/test/scripts/makepkg-template-tests/name-charset-valid/templates/foo@-_.+a-1.template new file mode 100644 index 0000000..d0884a6 --- /dev/null +++ b/test/scripts/makepkg-template-tests/name-charset-valid/templates/foo@-_.+a-1.template @@ -0,0 +1 @@ +42 cookies diff --git a/test/scripts/makepkg-template-tests/name-charset-valid/templates/foo@-_.+a.template b/test/scripts/makepkg-template-tests/name-charset-valid/templates/foo@-_.+a.template new file mode 120000 index 0000000..24b333f --- /dev/null +++ b/test/scripts/makepkg-template-tests/name-charset-valid/templates/foo@-_.+a.template @@ -0,0 +1 @@ +foo@-_.+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 new file mode 100644 index 0000000..6810390 --- /dev/null +++ b/test/scripts/makepkg-template-tests/name-charset-valid/testcase-config @@ -0,0 +1,16 @@ +arguments+=() +expected_exitcode=0 + +IFS="" read -d '' expected_output <<'EOF' +EOF + +IFS="" read -d '' expected_result <<'EOF' +pkgname=foo +pkgver=1 + +build() { +# template start; name=foo@-_.+a; version=1; +42 cookies +# template end; +} +EOF -- 2.2.1
Signed-off-by: Florian Pritz <bluewind@xinu.at> --- .../makepkg-template-tests/template-without-version/PKGBUILD | 8 ++++++++ .../templates/template-without_version.template | 0 .../template-without-version/testcase-config | 9 +++++++++ 3 files changed, 17 insertions(+) create mode 100644 test/scripts/makepkg-template-tests/template-without-version/PKGBUILD create mode 100644 test/scripts/makepkg-template-tests/template-without-version/templates/template-without_version.template create mode 100644 test/scripts/makepkg-template-tests/template-without-version/testcase-config diff --git a/test/scripts/makepkg-template-tests/template-without-version/PKGBUILD b/test/scripts/makepkg-template-tests/template-without-version/PKGBUILD new file mode 100644 index 0000000..a4509a1 --- /dev/null +++ b/test/scripts/makepkg-template-tests/template-without-version/PKGBUILD @@ -0,0 +1,8 @@ +pkgname=foo +pkgver=1 + +build() { +# template start; name=template-without_version +make install +# template end; +} diff --git a/test/scripts/makepkg-template-tests/template-without-version/templates/template-without_version.template b/test/scripts/makepkg-template-tests/template-without-version/templates/template-without_version.template new file mode 100644 index 0000000..e69de29 diff --git a/test/scripts/makepkg-template-tests/template-without-version/testcase-config b/test/scripts/makepkg-template-tests/template-without-version/testcase-config new file mode 100644 index 0000000..ec04f2f --- /dev/null +++ b/test/scripts/makepkg-template-tests/template-without-version/testcase-config @@ -0,0 +1,9 @@ +arguments+=() +expected_exitcode=255 + +IFS="" read -d '' expected_output <<'EOF' +Couldn't detect version for template 'template-without_version' +EOF + +IFS="" read -d '' expected_result <<'EOF' +EOF -- 2.2.1
Signed-off-by: Florian Pritz <bluewind@xinu.at> --- .../update-version-with-newest-option/PKGBUILD | 7 +++++++ .../templates/perl-bla-1.2.template | 1 + .../templates/perl-bla.template | 1 + .../templates/perl-module-1.0.template | 6 ++++++ .../templates/perl-module-1.1.template | 7 +++++++ .../templates/perl-module.template | 1 + .../testcase-config | 24 ++++++++++++++++++++++ 7 files changed, 47 insertions(+) create mode 100644 test/scripts/makepkg-template-tests/update-version-with-newest-option/PKGBUILD create mode 100644 test/scripts/makepkg-template-tests/update-version-with-newest-option/templates/perl-bla-1.2.template create mode 120000 test/scripts/makepkg-template-tests/update-version-with-newest-option/templates/perl-bla.template create mode 100644 test/scripts/makepkg-template-tests/update-version-with-newest-option/templates/perl-module-1.0.template create mode 100644 test/scripts/makepkg-template-tests/update-version-with-newest-option/templates/perl-module-1.1.template create mode 120000 test/scripts/makepkg-template-tests/update-version-with-newest-option/templates/perl-module.template create mode 100644 test/scripts/makepkg-template-tests/update-version-with-newest-option/testcase-config diff --git a/test/scripts/makepkg-template-tests/update-version-with-newest-option/PKGBUILD b/test/scripts/makepkg-template-tests/update-version-with-newest-option/PKGBUILD new file mode 100644 index 0000000..e1687cc --- /dev/null +++ b/test/scripts/makepkg-template-tests/update-version-with-newest-option/PKGBUILD @@ -0,0 +1,7 @@ +pkgname=foo +pkgver=1 + +build() { +# template start; name=perl-module; version=1.0 +# template end; +} diff --git a/test/scripts/makepkg-template-tests/update-version-with-newest-option/templates/perl-bla-1.2.template b/test/scripts/makepkg-template-tests/update-version-with-newest-option/templates/perl-bla-1.2.template new file mode 100644 index 0000000..b72e7d4 --- /dev/null +++ b/test/scripts/makepkg-template-tests/update-version-with-newest-option/templates/perl-bla-1.2.template @@ -0,0 +1 @@ +bla bla 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 new file mode 120000 index 0000000..1161447 --- /dev/null +++ b/test/scripts/makepkg-template-tests/update-version-with-newest-option/templates/perl-bla.template @@ -0,0 +1 @@ +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-1.0.template b/test/scripts/makepkg-template-tests/update-version-with-newest-option/templates/perl-module-1.0.template new file mode 100644 index 0000000..415025a --- /dev/null +++ b/test/scripts/makepkg-template-tests/update-version-with-newest-option/templates/perl-module-1.0.template @@ -0,0 +1,6 @@ +echo "before bla template" +# template input; name=perl-bla +echo "after bla template" +perl Makefile.pl +make +make install diff --git a/test/scripts/makepkg-template-tests/update-version-with-newest-option/templates/perl-module-1.1.template b/test/scripts/makepkg-template-tests/update-version-with-newest-option/templates/perl-module-1.1.template new file mode 100644 index 0000000..5ad32c3 --- /dev/null +++ b/test/scripts/makepkg-template-tests/update-version-with-newest-option/templates/perl-module-1.1.template @@ -0,0 +1,7 @@ +echo "perl-module version 1.1" +echo "before bla template" +# template input; name=perl-bla +echo "after bla template" +perl Makefile.pl +make +make install 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 new file mode 120000 index 0000000..f8618e4 --- /dev/null +++ b/test/scripts/makepkg-template-tests/update-version-with-newest-option/templates/perl-module.template @@ -0,0 +1 @@ +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 new file mode 100644 index 0000000..a6a2f4a --- /dev/null +++ b/test/scripts/makepkg-template-tests/update-version-with-newest-option/testcase-config @@ -0,0 +1,24 @@ +arguments+=(-n) +expected_exitcode=0 + +IFS="" read -d '' expected_output <<'EOF' +EOF + +IFS="" read -d '' expected_result <<'EOF' +pkgname=foo +pkgver=1 + +build() { +# template start; name=perl-module; version=1.1; +echo "perl-module version 1.1" +echo "before bla template" +# template start; name=perl-bla; version=1.2; +bla bla +# template end; +echo "after bla template" +perl Makefile.pl +make +make install +# template end; +} +EOF -- 2.2.1
On 12/28/14 at 04:23pm, Florian Pritz wrote:
Signed-off-by: Florian Pritz <bluewind@xinu.at> ---
v4: - adjusted to tap.sh - move expected output/result/exitcode/arguments into a single file called testcase-config - removed line number removal code (depends on "[PATCH] makepkg-template: Remove linenumber/file from errors" to be merged) - normalize paths by cd'ing into the testdir rather than using sed
The test files are simply adjusted to the changes to the main script, but I hope this is the last iteration so I'm posting them again for context.
Makefile.am | 2 + test/scripts/Makefile.am | 1 + .../testcase-config-template | 9 ++++ test/scripts/makepkg-template_test.sh | 52 ++++++++++++++++++++++ 4 files changed, 64 insertions(+) create mode 100644 test/scripts/makepkg-template-tests/testcase-config-template create mode 100755 test/scripts/makepkg-template_test.sh
diff --git a/Makefile.am b/Makefile.am index 01ea4f1..9dbacca 100644 --- a/Makefile.am +++ b/Makefile.am @@ -28,6 +28,7 @@ $(top_srcdir)/test/pacman/tests/TESTS: $(wildcard test/pacman/tests/*.py*)
TESTS = test/scripts/parseopts_test.sh \ test/scripts/human_to_size_test.sh \ + test/scripts/makepkg-template_test.sh \ test/scripts/pacman-db-upgrade-v9.py \ test/util/pacsorttest.sh \ test/util/vercmptest.sh @@ -37,6 +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_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/Makefile.am b/test/scripts/Makefile.am index 8d6bc84..ed1a951 100644 --- a/test/scripts/Makefile.am +++ b/test/scripts/Makefile.am @@ -1,6 +1,7 @@ check_SCRIPTS = \ parseopts_test.sh \ pacman-db-upgrade-v9.py \ + makepkg-template_test.sh \ human_to_size_test.sh
noinst_SCRIPTS = $(check_SCRIPTS) diff --git a/test/scripts/makepkg-template-tests/testcase-config-template b/test/scripts/makepkg-template-tests/testcase-config-template new file mode 100644 index 0000000..66267d3 --- /dev/null +++ b/test/scripts/makepkg-template-tests/testcase-config-template @@ -0,0 +1,9 @@ +arguments+=() +expected_exitcode=0 + +# set IFS="" if you want trailing new line(s), otherwise remove it +IFS="" read -d '' expected_output <<'EOF' +EOF + +IFS="" read -d '' expected_result <<'EOF' +EOF diff --git a/test/scripts/makepkg-template_test.sh b/test/scripts/makepkg-template_test.sh new file mode 100755 index 0000000..34185db --- /dev/null +++ b/test/scripts/makepkg-template_test.sh @@ -0,0 +1,52 @@ +#!/bin/bash + +source "$(dirname "$0")"/../tap.sh || exit 1 + +# source the library function
This comment does not apply here.
+script=$(readlink -f "${1:-${PMTEST_SCRIPT_DIR}/makepkg-template}")
This doesn't match our other test scripts which all fall back to looking for the program in PATH.
+if [[ -z $script || ! -f $script ]]; then + tap_bail "makepkg-template executable (%s) could not be located" "${script}" + exit 1 +fi + +# normalize paths +cd "${0%/*}" +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) +[[ -n "$total" ]] || tap_bail "unable to determine total number of tests"
You need to exit after tap_bail.
+tap_plan "$((total*3))" + +run_test() { + local testcase=$1 exitcode expected_result expected_output + local -a arguments + local -i expected_exitcode=-1 + + [[ -f "$testdir/$testcase/testcase-config" ]] || continue + source "$testdir/$testcase/testcase-config" + + mkdir "$TMPDIR/$testcase" + touch "$TMPDIR/$testcase/result" + + LC_ALL=C "$script" \ + --template-dir "$testdir/$testcase/templates" \ + -p "$testdir/$testcase/PKGBUILD" \ + -o "$TMPDIR/$testcase/result" \ + &> "$TMPDIR/$testcase/output" "${arguments[@]}" + exitcode=$? + + tap_is_int "$exitcode" "$expected_exitcode" "$testcase exitcode" + tap_diff "$TMPDIR/$testcase/output" <(printf "%s" "$expected_output") "$testcase output" + tap_diff "$TMPDIR/$testcase/result" <(printf "%s" "$expected_result") "$testcase resulting PKGBUILD" +} + +for dir in "$testdir/"*; do + if [[ -d "$dir" ]]; then + run_test "${dir##*/}" + fi +done + +tap_finish -- 2.2.1
Signed-off-by: Florian Pritz <bluewind@xinu.at> --- v5: - remove wrong comment - look for the executable in PATH - exit after tap_bail Makefile.am | 2 + test/scripts/Makefile.am | 1 + .../testcase-config-template | 9 ++++ test/scripts/makepkg-template_test.sh | 56 ++++++++++++++++++++++ 4 files changed, 68 insertions(+) create mode 100644 test/scripts/makepkg-template-tests/testcase-config-template create mode 100755 test/scripts/makepkg-template_test.sh diff --git a/Makefile.am b/Makefile.am index 01ea4f1..9dbacca 100644 --- a/Makefile.am +++ b/Makefile.am @@ -28,6 +28,7 @@ $(top_srcdir)/test/pacman/tests/TESTS: $(wildcard test/pacman/tests/*.py*) TESTS = test/scripts/parseopts_test.sh \ test/scripts/human_to_size_test.sh \ + test/scripts/makepkg-template_test.sh \ test/scripts/pacman-db-upgrade-v9.py \ test/util/pacsorttest.sh \ test/util/vercmptest.sh @@ -37,6 +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_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/Makefile.am b/test/scripts/Makefile.am index 8d6bc84..ed1a951 100644 --- a/test/scripts/Makefile.am +++ b/test/scripts/Makefile.am @@ -1,6 +1,7 @@ check_SCRIPTS = \ parseopts_test.sh \ pacman-db-upgrade-v9.py \ + makepkg-template_test.sh \ human_to_size_test.sh noinst_SCRIPTS = $(check_SCRIPTS) diff --git a/test/scripts/makepkg-template-tests/testcase-config-template b/test/scripts/makepkg-template-tests/testcase-config-template new file mode 100644 index 0000000..66267d3 --- /dev/null +++ b/test/scripts/makepkg-template-tests/testcase-config-template @@ -0,0 +1,9 @@ +arguments+=() +expected_exitcode=0 + +# set IFS="" if you want trailing new line(s), otherwise remove it +IFS="" read -d '' expected_output <<'EOF' +EOF + +IFS="" read -d '' expected_result <<'EOF' +EOF diff --git a/test/scripts/makepkg-template_test.sh b/test/scripts/makepkg-template_test.sh new file mode 100755 index 0000000..60cbb0c --- /dev/null +++ b/test/scripts/makepkg-template_test.sh @@ -0,0 +1,56 @@ +#!/bin/bash + +source "$(dirname "$0")"/../tap.sh || exit 1 + +script=${1:-${PMTEST_SCRIPT_DIR}/makepkg-template} + +if ! type -p "$script" &>/dev/null; then + tap_bail "makepkg-template executable (%s) could not be located" "${script}" + exit 1 +fi + +# normalize paths +script="$(readlink -f $(type -p "$script"))" +cd "${0%/*}" +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 + tap_bail "unable to determine total number of tests" + exit 1 +fi +tap_plan "$((total*3))" + +run_test() { + local testcase=$1 exitcode expected_result expected_output + local -a arguments + local -i expected_exitcode=-1 + + [[ -f "$testdir/$testcase/testcase-config" ]] || continue + source "$testdir/$testcase/testcase-config" + + mkdir "$TMPDIR/$testcase" + touch "$TMPDIR/$testcase/result" + + LC_ALL=C "$script" \ + --template-dir "$testdir/$testcase/templates" \ + -p "$testdir/$testcase/PKGBUILD" \ + -o "$TMPDIR/$testcase/result" \ + &> "$TMPDIR/$testcase/output" "${arguments[@]}" + exitcode=$? + + tap_is_int "$exitcode" "$expected_exitcode" "$testcase exitcode" + tap_diff "$TMPDIR/$testcase/output" <(printf "%s" "$expected_output") "$testcase output" + tap_diff "$TMPDIR/$testcase/result" <(printf "%s" "$expected_result") "$testcase resulting PKGBUILD" +} + +for dir in "$testdir/"*; do + if [[ -d "$dir" ]]; then + run_test "${dir##*/}" + fi +done + +tap_finish -- 2.2.1
On 12/28/14 at 06:17pm, Florian Pritz wrote:
Signed-off-by: Florian Pritz <bluewind@xinu.at> ---
v5: - remove wrong comment - look for the executable in PATH - exit after tap_bail
Makefile.am | 2 + test/scripts/Makefile.am | 1 + .../testcase-config-template | 9 ++++ test/scripts/makepkg-template_test.sh | 56 ++++++++++++++++++++++ 4 files changed, 68 insertions(+) create mode 100644 test/scripts/makepkg-template-tests/testcase-config-template create mode 100755 test/scripts/makepkg-template_test.sh
...
diff --git a/test/scripts/makepkg-template_test.sh b/test/scripts/makepkg-template_test.sh new file mode 100755 index 0000000..60cbb0c --- /dev/null +++ b/test/scripts/makepkg-template_test.sh @@ -0,0 +1,56 @@ +#!/bin/bash + +source "$(dirname "$0")"/../tap.sh || exit 1 + +script=${1:-${PMTEST_SCRIPT_DIR}/makepkg-template}
That slash needs to be removed so that when PMTEST_SCRIPT_DIR isn't defined we'll look for "makepkg-template" not "/makepkg-template".
On 29.12.2014 04:50, Andrew Gregory wrote:
diff --git a/test/scripts/makepkg-template_test.sh b/test/scripts/makepkg-template_test.sh new file mode 100755 index 0000000..60cbb0c --- /dev/null +++ b/test/scripts/makepkg-template_test.sh @@ -0,0 +1,56 @@ +#!/bin/bash + +source "$(dirname "$0")"/../tap.sh || exit 1 + +script=${1:-${PMTEST_SCRIPT_DIR}/makepkg-template}
That slash needs to be removed so that when PMTEST_SCRIPT_DIR isn't defined we'll look for "makepkg-template" not "/makepkg-template".
Fixed on my working branch
On 29/12/14 19:52, Florian Pritz wrote:
On 29.12.2014 04:50, Andrew Gregory wrote:
diff --git a/test/scripts/makepkg-template_test.sh b/test/scripts/makepkg-template_test.sh new file mode 100755 index 0000000..60cbb0c --- /dev/null +++ b/test/scripts/makepkg-template_test.sh @@ -0,0 +1,56 @@ +#!/bin/bash + +source "$(dirname "$0")"/../tap.sh || exit 1 + +script=${1:-${PMTEST_SCRIPT_DIR}/makepkg-template}
That slash needs to be removed so that when PMTEST_SCRIPT_DIR isn't defined we'll look for "makepkg-template" not "/makepkg-template".
Fixed on my working branch
make distcheck: ERROR: test/scripts/makepkg-template_test.sh ============================================ Bail out! makepkg-template executable (../scripts/makepkg-template) could not be located ERROR: test/scripts/makepkg-template_test.sh - Bail out! makepkg-template executable (../scripts/makepkg-template) could not be located
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@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@-_.+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@-_.+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@-_.+a.template b/test/scripts/makepkg-template-tests/name-charset-valid/templates/foo@-_.+a.template deleted file mode 120000 index 24b333f..0000000 --- a/test/scripts/makepkg-template-tests/name-charset-valid/templates/foo@-_.+a.template +++ /dev/null @@ -1 +0,0 @@ -foo@-_.+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
On 09/01/15 08:52, Florian Pritz wrote:
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@xinu.at>
Most of this patch looks like it should be integrated into the original patchset. Allan
participants (3)
-
Allan McRae
-
Andrew Gregory
-
Florian Pritz