提交 aada594f 编写于 作者: J Joerg Jaspert

Merge branch 'improve-test-coverage-of-dak' into 'master'

Improve test coverage of dak

See merge request ftp-team/dak!121
......@@ -16,9 +16,25 @@
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <https://www.gnu.org/licenses/>.
_escape_newline() {
echo "$1" | perl -pe 's/\n/\\n/g'
}
assert-equal() {
if [[ "${2}" != "${3}" ]]; then
echo "E: ${1} returned '${2}' (expected: '${3}')" >&2
local actual=$(_escape_newline "$2") expected=$(_escape_newline "$3")
echo "E: ${1} returned '${actual}' (expected: '${expected}')" >&2
exit 1
fi
}
fixture-package-dir() {
packages=${DAK_ROOT:?}/tests/fixtures/packages
echo "${packages}"
}
import-fixture-signing-key() {
packages=$(fixture-package-dir)
ln -sf ${packages:?}/gpg/pubring.gpg ${DAKBASE:?}/keyrings/upload-keyring.gpg
dak import-keyring -U "%s" ${DAKBASE}/keyrings/upload-keyring.gpg
}
......@@ -59,10 +59,10 @@ EOF
)
(
packages=${DAK_ROOT:?}/tests/fixtures/packages
ln -sf ${packages:?}/gpg/pubring.gpg ${DAKBASE:?}/keyrings/upload-keyring.gpg
dak import-keyring -U "%s" ${DAKBASE}/keyrings/upload-keyring.gpg
cp ${packages:?}/nonfree-package_* ${packages:?}/package_* ${DAKBASE}/tmp
packages=$(fixture-package-dir)
import-fixture-signing-key
cp ${packages:?}/nonfree-package_* ${packages:?}/package_0.1* ${DAKBASE}/tmp
dak process-upload -d ${DAKBASE}/tmp --automatic
)
......
#! /bin/bash
#
# © 2019 Niels Thykier <niels@thykier.net>
# License: GPL-2+
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 2 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <https://www.gnu.org/licenses/>.
set -e
set -u
. ${DAK_ROOT:?}/integration-tests/common
. ${DAK_ROOT:?}/integration-tests/setup
import-fixture-signing-key
packages=$(fixture-package-dir)
# add a unstable suite with amd64
dak admin architecture add amd64 AMD64
dak admin suite add unstable "" codename=sid
dak admin suite-architecture add unstable source all amd64
dak admin suite-component add unstable main contrib non-free
dak admin suite add testing "" codename=buster
dak admin suite-architecture add testing source all amd64
dak admin suite-component add testing main contrib non-free
assert-control-suite-list() {
local suite="$1" expected="$2"
actual=$(dak control-suite --list="${suite}")
assert-equal "dak control-suite --list=${suite}" "${actual}" "${expected}"
}
(
dak control-overrides -s unstable -t deb -a << EOF
package required admin
EOF
dak control-overrides -s unstable -t dsc -a << EOF
package admin
EOF
)
(
packages=$(fixture-package-dir)
import-fixture-signing-key
cp ${packages:?}/package_0.1* ${DAKBASE}/tmp
dak process-upload -d ${DAKBASE}/tmp --automatic
)
# unstable should have 0.1
(
expected="$(cat <<EOF
package 0.1-1 all
package 0.1-1 source
EOF
)"
assert-control-suite-list unstable "${expected}"
)
# testing should be empty
(
expected=""
assert-control-suite-list testing "${expected}"
)
# dak ls test just for the sake for it
(
expected="$(cat <<EOF
package | 0.1-1 | unstable | source, all
EOF
)"
actual=$(dak ls -S -s unstable package)
assert-equal "dak ls -S -s unstable -f=control-suite package" "${actual}" "${expected}"
)
# Move package 0.1 to testing
(
dak control-suite --list=unstable | dak control-suite --add=testing
actual=$(dak control-suite --list=testing)
expected=$(dak control-suite --list=unstable)
assert-equal "dak control-suite --list=testing" "${actual}" "${expected}"
)
(
dak contents scan-binary
dak contents scan-source
dak generate-packages-sources2 -s unstable
dak contents generate -a dak-master -s unstable
# TODO: make this work in the CI; needs GnuPG key
#dak generate-release -s unstable
)
(
packages=$(fixture-package-dir)
import-fixture-signing-key
cp ${packages:?}/package_0.2* ${DAKBASE}/tmp
dak process-upload -d ${DAKBASE}/tmp --automatic
)
# unstable currently has both and control-suite should confirm this
(
expected="$(cat <<EOF
package 0.1-1 all
package 0.2-1 all
package 0.1-1 source
package 0.2-1 source
EOF
)"
assert-control-suite-list unstable "${expected}"
)
# testing should be unchanged (i.e. only have 0.1)
(
expected="$(cat <<EOF
package 0.1-1 all
package 0.1-1 source
EOF
)"
assert-control-suite-list testing "${expected}"
)
# dak ls run just for the sake of it
(
expected="$(cat <<EOF
package | 0.1-1 | unstable | source, all
package | 0.2-1 | unstable | source, all
EOF
)"
actual=$(dak ls -S -s unstable package)
assert-equal "dak ls -S -s unstable -f=control-suite package" "${actual}" "${expected}"
)
# Clean up unstable
(
dak dominate
)
# unstable now only has version 0.2
(
expected="$(cat <<EOF
package 0.2-1 all
package 0.2-1 source
EOF
)"
assert-control-suite-list unstable "${expected}"
)
# testing still has version 0.1
(
expected="$(cat <<EOF
package 0.1-1 all
package 0.1-1 source
EOF
)"
assert-control-suite-list testing "${expected}"
)
# dak ls run just for the sake of it
(
expected="$(cat <<EOF
package | 0.2-1 | unstable | source, all
EOF
)"
actual=$(dak ls -S -s unstable package)
assert-equal "dak ls -S -s unstable -f=control-suite package" "${actual}" "${expected}"
)
export GNUPGHOME = $(CURDIR)/gpg
SHELL = /bin/bash
TAR = linux_42.0 nonfree-package_0.1 package_0.1 package-built-using_0.1
TAR = linux_42.0 nonfree-package_0.1 package_0.1 package_0.2 package-built-using_0.1
PACKAGES = $(TAR)
all: packages
......
package (0.2-1) unstable; urgency=medium
* Change something
-- A Maintainer <maint@example.com> Sat, 13 Apr 2019 06:50:19 +0000
package (0.1-1) unstable; urgency=low
* Initial release.
-- A Maintainer <maint@example.com> Fri, 08 Jun 2012 18:10:01 +0200
Source: package
Section: misc
Priority: extra
Maintainer: A Maintainer <maint@example.com>
Uploaders: An Uploader <uploader@example.com>
Build-Depends: debhelper (>= 9)
Rules-Requires-Root: no
Package: package
Architecture: all
Depends: ${misc:Depends}
Description: a package
a package
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册