Package: reprepro Version: 5.1.1-1 Severity: wishlist Hi,
reprepro contains a tests directory with many tests, but there is no documentation how to run these test and they are not run on package build time. tests/test.inc refers to $TESTTOOL, but there is no hint how to find that tool. Is that a custom script? Please run the test suite on package build time to show how to run the tests and to verify the test cases. While developing the patch for #570623, I added shunit2-based tests. shunit2 is available as Debian package and can be easily integrated in the package build. Patches for some smoke tests are attached (in case you consider using shunit2). -- Benjamin Drung System Developer Debian & Ubuntu Developer ProfitBricks GmbH Greifswalder Str. 207 D - 10405 Berlin Email: benjamin.dr...@profitbricks.com URL: http://www.profitbricks.com Sitz der Gesellschaft: Berlin. Registergericht: Amtsgericht Charlottenburg, HRB 125506B. Geschäftsführer: Andreas Gauger, Achim Weiss.
>From aa30c40b40a1c05d87c6802f2d3c7055d2e2f4f6 Mon Sep 17 00:00:00 2001 From: Benjamin Drung <benjamin.dr...@profitbricks.com> Date: Mon, 6 Feb 2017 17:49:07 +0100 Subject: [PATCH 2/3] [testsuite] Use the host architecture by default To be able to build packages for the tests, use the host architecture (to avoid requiring a cross-compiler). --- tests/genpackage.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/genpackage.sh b/tests/genpackage.sh index ee21890..ff18103 100755 --- a/tests/genpackage.sh +++ b/tests/genpackage.sh @@ -19,7 +19,7 @@ Maintainer: me <guess@who> Standards-Version: 0.0 Package: $PACKAGE -Architecture: abacus +Architecture: ${ARCH:-$(dpkg-architecture -qDEB_HOST_ARCH)} Description: bla blub -- 2.9.3
>From 6123d145779b461865e5ef9b470ee3e8080c1c05 Mon Sep 17 00:00:00 2001 From: Benjamin Drung <benjamin.dr...@profitbricks.com> Date: Mon, 6 Feb 2017 17:47:38 +0100 Subject: [PATCH 1/3] [testsuite] Use dpkg-source format 1.0 To silence dpkg-source, use source format 1.0 --- tests/genpackage.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/genpackage.sh b/tests/genpackage.sh index ac8ffec..ee21890 100755 --- a/tests/genpackage.sh +++ b/tests/genpackage.sh @@ -39,7 +39,7 @@ $PACKAGE ($EPOCH$VERSION$REVISION) $DISTRI; urgency=critical -- me <guess@who> Mon, 01 Jan 1980 01:02:02 +0000 END -dpkg-source -b "$DIR" +dpkg-source --format=1.0 -b "$DIR" mkdir -p "$DIR"/debian/tmp/DEBIAN touch "$DIR"/debian/tmp/x mkdir "$DIR"/debian/tmp/a -- 2.9.3
>From b96309dc8c8d7725e3477afecb75e06aabb4c030 Mon Sep 17 00:00:00 2001 From: Benjamin Drung <benjamin.dr...@profitbricks.com> Date: Mon, 6 Feb 2017 17:44:16 +0100 Subject: [PATCH 3/3] [testsuite] Add basic shunit2 based tests Signed-off-by: Benjamin Drung <benjamin.dr...@profitbricks.com> --- tests/Makefile.am | 10 +++++++- tests/basic.sh | 51 +++++++++++++++++++++++++++++++++++++++ tests/shunit2-helper-functions.sh | 44 +++++++++++++++++++++++++++++++++ 3 files changed, 104 insertions(+), 1 deletion(-) create mode 100755 tests/basic.sh create mode 100644 tests/shunit2-helper-functions.sh diff --git a/tests/Makefile.am b/tests/Makefile.am index 901b302..78cb38a 100644 --- a/tests/Makefile.am +++ b/tests/Makefile.am @@ -45,5 +45,13 @@ good.key \ revoked.key \ revoked.pkey \ withsubkeys.key \ -withsubkeys-works.key +withsubkeys-works.key \ +basic.sh \ +shunit2-helper-functions.sh MAINTAINERCLEANFILES = $(srcdir)/Makefile.in + +check: + ./basic.sh + +clean-local: + rm -rf testrepo testpkgs diff --git a/tests/basic.sh b/tests/basic.sh new file mode 100755 index 0000000..e466f14 --- /dev/null +++ b/tests/basic.sh @@ -0,0 +1,51 @@ +#!/bin/sh +set -u + +# Copyright (C) 2017, Benjamin Drung <benjamin.dr...@profitbricks.com> +# +# Permission to use, copy, modify, and/or distribute this software for any +# purpose with or without fee is hereby granted, provided that the above +# copyright notice and this permission notice appear in all copies. +# +# THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES +# WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF +# MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR +# ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES +# WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN +# ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF +# OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. + +. "${0%/*}/shunit2-helper-functions.sh" + +setUp() { + create_repo +} + +test_empty() { + $REPREPRO -b $REPO export + call $REPREPRO -b $REPO list buster + assertEquals "" "$($REPREPRO -b $REPO list buster)" +} + +test_list() { + (cd $PKGS && PACKAGE=hello SECTION=main DISTRI=buster VERSION=1.0 REVISION=-1 ../genpackage.sh) + call $REPREPRO -b $REPO -V -C main includedeb buster $PKGS/hello_1.0-1_${ARCH}.deb + assertEquals "buster|main|$ARCH: hello 1.0-1" "$($REPREPRO -b $REPO list buster)" +} + +test_ls() { + (cd $PKGS && PACKAGE=hello SECTION=main DISTRI=buster EPOCH="1:" VERSION=2.5 REVISION=-3 ../genpackage.sh) + call $REPREPRO -b $REPO -V -C main includedeb buster $PKGS/hello_2.5-3_${ARCH}.deb + assertEquals "hello | 1:2.5-3 | buster | $ARCH" "$($REPREPRO -b $REPO ls hello)" +} + +test_include_changes() { + (cd $PKGS && PACKAGE=sl SECTION=main DISTRI=buster EPOCH="" VERSION=3.03 REVISION=-1 ../genpackage.sh) + call $REPREPRO -b $REPO -V -C main include buster $PKGS/test.changes + assertEquals "\ +buster|main|amd64: sl 3.03-1 +buster|main|amd64: sl-addons 3.03-1 +buster|main|source: sl 3.03-1" "$($REPREPRO -b $REPO list buster)" +} + +. shunit2 diff --git a/tests/shunit2-helper-functions.sh b/tests/shunit2-helper-functions.sh new file mode 100644 index 0000000..49319ae --- /dev/null +++ b/tests/shunit2-helper-functions.sh @@ -0,0 +1,44 @@ +# Copyright (C) 2017, Benjamin Drung <benjamin.dr...@profitbricks.com> +# +# Permission to use, copy, modify, and/or distribute this software for any +# purpose with or without fee is hereby granted, provided that the above +# copyright notice and this permission notice appear in all copies. +# +# THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES +# WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF +# MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR +# ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES +# WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN +# ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF +# OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. + +REPO="${0%/*}/testrepo" +PKGS="${0%/*}/testpkgs" +ARCH=${ARCH:-$(dpkg-architecture -qDEB_HOST_ARCH)} +REPREPRO=$(realpath -m "${0%/*}/.." --relative-base=.)/reprepro + +call() { + echo "I: Calling $@" + "$@" || fail "Command '$@' failed with exit code $?." +} + +create_repo() { + rm -rf $REPO + mkdir -p $REPO/conf + cat > $REPO/conf/distributions <<EOF +Codename: buster +Architectures: $ARCH source +Components: main non-free +EOF + mkdir -p $PKGS + $REPREPRO -b $REPO export +} + +# See https://github.com/wting/shunit2/issues/23 +if test -n "${TEST_CASES-}"; then + suite() { + for testcase in "${TEST_CASES}" ; do + suite_addTest $testcase + done + } +fi -- 2.9.3