Package: debomatic Severity: wishlist Tags: patch Hello. In #983538, the maintainer has requested a patch improving all tests instead of a single one. Such a suggestion is attached.
>From 91c5a43e121b8eb2cd68c32d01165ef4cadf2abc Mon Sep 17 00:00:00 2001 From: Nicolas Boulenguez <nico...@debian.org> Date: Sun, 21 Feb 2021 11:40:25 +0100 Subject: Reduce redundancy in test scripts
diff --git a/debian/tests/build b/debian/tests/build index 82dea60..9aa7c52 100755 --- a/debian/tests/build +++ b/debian/tests/build @@ -1,39 +1,7 @@ #!/bin/sh -set -e +. debian/tests/debomatictest.sh -cd "$AUTOPKGTEST_TMP" - -sed -i 's/modules: True/modules: False/' /etc/debomatic/debomatic.conf -grep /etc/debomatic/debomatic.conf -e "modules: False" || exit 1 -sed -i "s|incoming: /incoming|incoming: $AUTOPKGTEST_TMP/incoming|" /etc/debomatic/debomatic.conf -grep /etc/debomatic/debomatic.conf -e "incoming: $AUTOPKGTEST_TMP/incoming" || exit 1 -sed -i "s|loglevel: info|loglevel: debug|" /etc/debomatic/debomatic.conf -grep /etc/debomatic/debomatic.conf -e "loglevel: debug" || exit 1 - -mkdir -p $HOME/.dput.d/profiles -cat > $HOME/.dput.d/profiles/local.json << EOF -{ - "meta": "debomatic", - "incoming": "$AUTOPKGTEST_TMP/incoming", - "method": "local", - "check-debs": { - "skip": true - } -} -EOF - -mkdir "$AUTOPKGTEST_TMP"/incoming -version=$(rmadison -u debian -a source -s unstable hello | cut -d"|" -f 2 | xargs) -upstream=$(echo $version | cut -d"-" -f1 | xargs) -component=$(rmadison -u debian -a source -s unstable hello | cut -d"|" -f 3 | cut -d"/" -f2 | sed 's/unstable/main/' | xargs) -dget -u http://deb.debian.org/debian/pool/$component/h/hello/hello_$version.dsc -cd hello-$upstream/ -debuild -S -d -uc -us -dput local ../hello_"$version"_source.changes -debomatic -c /etc/debomatic/debomatic.conf -o "$AUTOPKGTEST_TMP"/incoming/hello_"$version"_source.changes -i -cat "$AUTOPKGTEST_TMP"/incoming/unstable/pool/hello_$version/hello_$version.buildlog -grep "$AUTOPKGTEST_TMP"/incoming/unstable/pool/hello_$version/hello_$version.buildlog -e "Status: successful" || exit 1 - -rm -fr /etc/schroot/chroot.d/unstable-*-debomatic-* -rm -fr /etc/sbuild/chroot/unstable-*-debomatic -rm -fr /$AUTOPKGTEST_TMP/incoming/unstable/unstable +debomatictest_rebuild +debomatictest_create_conf +debomatic -c $conf -o incoming/${pkg}_${version}_source.changes -i +debomatictest_check_log diff --git a/debian/tests/command-binnmu b/debian/tests/command-binnmu index f19a72e..05d424f 100755 --- a/debian/tests/command-binnmu +++ b/debian/tests/command-binnmu @@ -1,26 +1,13 @@ #!/bin/sh -set -e - -cd "$AUTOPKGTEST_TMP" - -sed -i 's/modules: True/modules: False/' /etc/debomatic/debomatic.conf -grep /etc/debomatic/debomatic.conf -e "modules: False" || exit 1 -sed -i "s|incoming: /incoming|incoming: $AUTOPKGTEST_TMP/incoming|" /etc/debomatic/debomatic.conf -grep /etc/debomatic/debomatic.conf -e "incoming: $AUTOPKGTEST_TMP/incoming" || exit 1 -sed -i "s|loglevel: info|loglevel: debug|" /etc/debomatic/debomatic.conf -grep /etc/debomatic/debomatic.conf -e "loglevel: debug" || exit 1 - -mkdir "$AUTOPKGTEST_TMP"/incoming -version=$(rmadison -u debian -a source -s unstable hello | cut -d"|" -f 2 | xargs) -echo "binnmu hello_$version unstable 1 \"Deb-o-Matic test suite\" Luca Falavigna <dktrkr...@debian.org>" > "$AUTOPKGTEST_TMP"/incoming/binnmu.commands -debomatic -c /etc/debomatic/debomatic.conf -o /$AUTOPKGTEST_TMP/incoming/binnmu.commands -i -cat /$AUTOPKGTEST_TMP/incoming/unstable/pool/hello_$version/hello_$version.buildlog -grep /$AUTOPKGTEST_TMP/incoming/unstable/pool/hello_$version/hello_$version.buildlog -e "Status: successful" || exit 1 -grep /$AUTOPKGTEST_TMP/incoming/unstable/pool/hello_$version/hello_$version.buildlog -e "Maintainer: Luca Falavigna <dktrkr...@debian.org>" || exit 1 -grep /$AUTOPKGTEST_TMP/incoming/unstable/pool/hello_$version/hello_$version.buildlog -e "hello ($version+b1) unstable" || exit 1 -grep /$AUTOPKGTEST_TMP/incoming/unstable/pool/hello_$version/hello_$version.buildlog -e "* Binary-only non-maintainer upload for" || exit 1 -grep /$AUTOPKGTEST_TMP/incoming/unstable/pool/hello_$version/hello_$version.buildlog -e "* Deb-o-Matic test suite" || exit 1 - -rm -fr /etc/schroot/chroot.d/unstable-*-debomatic-* -rm -fr /etc/sbuild/chroot/unstable-*-debomatic -rm -fr /$AUTOPKGTEST_TMP/incoming/unstable/unstable +. debian/tests/debomatictest.sh + +commands=incoming/binnmu.commands +maintainer='Luca Falavigna <dktrkr...@debian.org>' +desc='Deb-o-Matic test suite' +echo "binnmu ${pkg}_$version unstable 1 \"$desc\" $maintainer" > $commands +debomatictest_create_conf +debomatic -c $conf -o $commands -i +debomatictest_check_log "Maintainer: $maintainer" \ + "$pkg ($version+b1) unstable" \ + '* Binary-only non-maintainer upload for' \ + "* $desc" diff --git a/debian/tests/command-builddep b/debian/tests/command-builddep index 8712c7f..2058e2f 100755 --- a/debian/tests/command-builddep +++ b/debian/tests/command-builddep @@ -1,24 +1,9 @@ #!/bin/sh -set -e - -cd "$AUTOPKGTEST_TMP" - -sed -i 's/modules: True/modules: False/' /etc/debomatic/debomatic.conf -grep /etc/debomatic/debomatic.conf -e "modules: False" || exit 1 -sed -i "s|incoming: /incoming|incoming: $AUTOPKGTEST_TMP/incoming|" /etc/debomatic/debomatic.conf -grep /etc/debomatic/debomatic.conf -e "incoming: $AUTOPKGTEST_TMP/incoming" || exit 1 -sed -i "s|loglevel: info|loglevel: debug|" /etc/debomatic/debomatic.conf -grep /etc/debomatic/debomatic.conf -e "loglevel: debug" || exit 1 - -mkdir "$AUTOPKGTEST_TMP"/incoming -version=$(rmadison -u debian -a source -s unstable hello | cut -d"|" -f 2 | xargs) -bdversion=$(rmadison -u debian -a source -s unstable lintian | cut -d"|" -f 2 | xargs) -echo "builddep hello_$version unstable lintian (>= $bdversion)" > "$AUTOPKGTEST_TMP"/incoming/builddep.commands -debomatic -c /etc/debomatic/debomatic.conf -o /$AUTOPKGTEST_TMP/incoming/builddep.commands -i -cat /$AUTOPKGTEST_TMP/incoming/unstable/pool/hello_$version/hello_$version.buildlog -grep /$AUTOPKGTEST_TMP/incoming/unstable/pool/hello_$version/hello_$version.buildlog -e "Status: successful" || exit 1 -grep /$AUTOPKGTEST_TMP/incoming/unstable/pool/hello_$version/hello_$version.buildlog -e "Setting up lintian ($bdversion)" || exit 1 - -rm -fr /etc/schroot/chroot.d/unstable-*-debomatic-* -rm -fr /etc/sbuild/chroot/unstable-*-debomatic -rm -fr /$AUTOPKGTEST_TMP/incoming/unstable/unstable +. debian/tests/debomatictest.sh + +commands=incoming/builddep.commands +bdversion=$(debomatictest_version lintian) +echo "builddep ${pkg}_$version unstable lintian (>= $bdversion)" > $commands +debomatictest_create_conf +debomatic -c $conf -o $commands -i +debomatictest_check_log "Setting up lintian ($bdversion)" diff --git a/debian/tests/command-porter b/debian/tests/command-porter index ac48a20..fbf9091 100755 --- a/debian/tests/command-porter +++ b/debian/tests/command-porter @@ -1,23 +1,9 @@ #!/bin/sh -set -e - -cd "$AUTOPKGTEST_TMP" - -sed -i 's/modules: True/modules: False/' /etc/debomatic/debomatic.conf -grep /etc/debomatic/debomatic.conf -e "modules: False" || exit 1 -sed -i "s|incoming: /incoming|incoming: $AUTOPKGTEST_TMP/incoming|" /etc/debomatic/debomatic.conf -grep /etc/debomatic/debomatic.conf -e "incoming: $AUTOPKGTEST_TMP/incoming" || exit 1 -sed -i "s|loglevel: info|loglevel: debug|" /etc/debomatic/debomatic.conf -grep /etc/debomatic/debomatic.conf -e "loglevel: debug" || exit 1 - -mkdir "$AUTOPKGTEST_TMP"/incoming -version=$(rmadison -u debian -a source -s unstable hello | cut -d"|" -f 2 | xargs) -echo "porter hello_$version unstable Luca Falavigna <dktrkr...@debian.org>" > "$AUTOPKGTEST_TMP"/incoming/porter.commands -debomatic -c /etc/debomatic/debomatic.conf -o /$AUTOPKGTEST_TMP/incoming/porter.commands -i -cat /$AUTOPKGTEST_TMP/incoming/unstable/pool/hello_$version/hello_$version.buildlog -grep /$AUTOPKGTEST_TMP/incoming/unstable/pool/hello_$version/hello_$version.buildlog -e "Status: successful" || exit 1 -grep /$AUTOPKGTEST_TMP/incoming/unstable/pool/hello_$version/hello_$version.buildlog -e "Maintainer: Luca Falavigna <dktrkr...@debian.org>" || exit 1 - -rm -fr /etc/schroot/chroot.d/unstable-*-debomatic-* -rm -fr /etc/sbuild/chroot/unstable-*-debomatic -rm -fr /$AUTOPKGTEST_TMP/incoming/unstable/unstable +. debian/tests/debomatictest.sh + +commands=incoming/porter.commands +maintainer='Luca Falavigna <dktrkr...@debian.org>' +echo "porter ${pkg}_$version unstable $maintainer" > $commands +debomatictest_create_conf +debomatic -c $conf -o $commands -i +debomatictest_check_log "Maintainer: $maintainer" diff --git a/debian/tests/command-rebuild b/debian/tests/command-rebuild index 1978014..d4bcd9f 100755 --- a/debian/tests/command-rebuild +++ b/debian/tests/command-rebuild @@ -1,22 +1,8 @@ #!/bin/sh -set -e +. debian/tests/debomatictest.sh -cd "$AUTOPKGTEST_TMP" - -sed -i 's/modules: True/modules: False/' /etc/debomatic/debomatic.conf -grep /etc/debomatic/debomatic.conf -e "modules: False" || exit 1 -sed -i "s|incoming: /incoming|incoming: $AUTOPKGTEST_TMP/incoming|" /etc/debomatic/debomatic.conf -grep /etc/debomatic/debomatic.conf -e "incoming: $AUTOPKGTEST_TMP/incoming" || exit 1 -sed -i "s|loglevel: info|loglevel: debug|" /etc/debomatic/debomatic.conf -grep /etc/debomatic/debomatic.conf -e "loglevel: debug" || exit 1 - -mkdir "$AUTOPKGTEST_TMP"/incoming -version=$(rmadison -u debian -a source -s unstable hello | cut -d"|" -f 2 | xargs) -echo "rebuild hello_$version unstable" > "$AUTOPKGTEST_TMP"/incoming/rebuild.commands -debomatic -c /etc/debomatic/debomatic.conf -o /$AUTOPKGTEST_TMP/incoming/rebuild.commands -i -cat /$AUTOPKGTEST_TMP/incoming/unstable/pool/hello_$version/hello_$version.buildlog -grep /$AUTOPKGTEST_TMP/incoming/unstable/pool/hello_$version/hello_$version.buildlog -e "Status: successful" || exit 1 - -rm -fr /etc/schroot/chroot.d/unstable-*-debomatic-* -rm -fr /etc/sbuild/chroot/unstable-*-debomatic -rm -fr /$AUTOPKGTEST_TMP/incoming/unstable/unstable +commands=incoming/rebuild.commands +echo "rebuild ${pkg}_$version unstable" > $commands +debomatictest_create_conf +debomatic -c $conf -o $commands -i +debomatictest_check_log diff --git a/debian/tests/control b/debian/tests/control index 495d20f..226b7e4 100644 --- a/debian/tests/control +++ b/debian/tests/control @@ -10,31 +10,10 @@ Depends: debomatic, dput-ng Restrictions: needs-root, allow-stderr -Tests: command-rebuild -Depends: debomatic, - devscripts, - wget, - liburi-perl, - ca-certificates -Restrictions: needs-root, allow-stderr - -Tests: command-porter -Depends: debomatic, - devscripts, - wget, - liburi-perl, - ca-certificates -Restrictions: needs-root, allow-stderr - Tests: command-binnmu -Depends: debomatic, - devscripts, - wget, - liburi-perl, - ca-certificates -Restrictions: needs-root, allow-stderr - -Tests: command-builddep + command-builddep + command-porter + command-rebuild Depends: debomatic, devscripts, wget, diff --git a/debian/tests/crossbuild b/debian/tests/crossbuild index 01d8448..ba04786 100755 --- a/debian/tests/crossbuild +++ b/debian/tests/crossbuild @@ -1,55 +1,15 @@ #!/bin/sh -set -e -cd "$AUTOPKGTEST_TMP" - -sed -i 's/modules: True/modules: False/' /etc/debomatic/debomatic.conf -grep /etc/debomatic/debomatic.conf -e "modules: False" || exit 1 -sed -i "s|incoming: /incoming|incoming: $AUTOPKGTEST_TMP/incoming|" /etc/debomatic/debomatic.conf -grep /etc/debomatic/debomatic.conf -e "incoming: $AUTOPKGTEST_TMP/incoming" || exit 1 -sed -i "s|loglevel: info|loglevel: debug|" /etc/debomatic/debomatic.conf -grep /etc/debomatic/debomatic.conf -e "loglevel: debug" || exit 1 -sed -i "s|crossbuild: False|crossbuild: True|" /etc/debomatic/debomatic.conf -grep /etc/debomatic/debomatic.conf -e "crossbuild: True" || exit 1 -if [ $(dpkg-architecture -qDEB_HOST_ARCH) = "arm64" ] -then - sed -i "s|hostarchitecture: None|hostarchitecture: amd64|" /etc/debomatic/debomatic.conf - grep /etc/debomatic/debomatic.conf -e "hostarchitecture: amd64" || exit 1 +if [ $(dpkg-architecture -qDEB_HOST_ARCH) = arm64 ]; then + hostarchitecture=amd64 else - sed -i "s|hostarchitecture: None|hostarchitecture: arm64|" /etc/debomatic/debomatic.conf - grep /etc/debomatic/debomatic.conf -e "hostarchitecture: arm64" || exit 1 + hostarchitecture=arm64 fi +pkg=hello-traditional -mkdir -p $HOME/.dput.d/profiles -cat > $HOME/.dput.d/profiles/local.json << EOF -{ - "meta": "debomatic", - "incoming": "$AUTOPKGTEST_TMP/incoming", - "method": "local", - "check-debs": { - "skip": true - } -} -EOF - -mkdir "$AUTOPKGTEST_TMP"/incoming -version=$(rmadison -u debian -a source -s unstable hello-traditional | cut -d"|" -f 2 | xargs) -upstream=$(echo $version | cut -d"-" -f1 | xargs) -component=$(rmadison -u debian -a source -s unstable hello-traditional | cut -d"|" -f 3 | cut -d"/" -f2 | sed 's/unstable/main/' | xargs) -dget -u http://deb.debian.org/debian/pool/$component/h/hello-traditional/hello-traditional_$version.dsc -cd hello-traditional-$upstream/ -debuild -S -d -uc -us -dput local ../hello-traditional_"$version"_source.changes -debomatic -c /etc/debomatic/debomatic.conf -o "$AUTOPKGTEST_TMP"/incoming/hello-traditional_"$version"_source.changes -i -cat "$AUTOPKGTEST_TMP"/incoming/unstable/pool/hello-traditional_$version/hello-traditional_$version.buildlog -grep "$AUTOPKGTEST_TMP"/incoming/unstable/pool/hello-traditional_$version/hello-traditional_$version.buildlog -e "Status: successful" || exit 1 -if [ $(dpkg-architecture -qDEB_HOST_ARCH) = "arm64" ] -then - grep "$AUTOPKGTEST_TMP"/incoming/unstable/pool/hello-traditional_$version/hello-traditional_$version.buildlog -e "hello-traditional_"$version"_amd64.changes:$" || exit 1 -else - grep "$AUTOPKGTEST_TMP"/incoming/unstable/pool/hello-traditional_$version/hello-traditional_$version.buildlog -e "hello-traditional_"$version"_arm64.changes:$" || exit 1 -fi +. debian/tests/debomatictest.sh -rm -fr /etc/schroot/chroot.d/unstable-*-debomatic-* -rm -fr /etc/sbuild/chroot/unstable-*-debomatic -rm -fr /$AUTOPKGTEST_TMP/incoming/unstable/unstable +debomatictest_rebuild +debomatictest_create_conf +debomatic -c $conf -o incoming/${pkg}_${version}_source.changes -i +debomatictest_check_log ${pkg}_${version}_$hostarchitecture.changes: diff --git a/debian/tests/debomatictest.sh b/debian/tests/debomatictest.sh new file mode 100644 index 0000000..ca8e79d --- /dev/null +++ b/debian/tests/debomatictest.sh @@ -0,0 +1,100 @@ +# Helper for the debomatic tests in this directory. +set -Ceu + +# Environment variables: AUTOPKGTEST_TMP HOME + +debomatictest_version() { + # 1: source package name + # -> currently available version + rmadison -u debian -a source -s unstable $1 \ + | cut -d\| -f2 \ + | xargs +} +debomatictest_rebuild() { + # Get the source. + local component=$(rmadison -u debian -a source -s unstable $pkg \ + | cut -d\| -f3 \ + | cut -d/ -f2 \ + | sed s/unstable/main/ \ + | xargs) + local initial=${pkg%${pkg#?}} + local dsc=${pkg}_$version.dsc + dget -u http://deb.debian.org/debian/pool/$component/$initial/$pkg/$dsc + + # Rebuild it. + cd $pkg-${version%%-*} + debuild -S -d -uc -us + cd .. + + # Add to local repository. + local profiles="$HOME"/.dput.d/profiles + + mkdir -p "$profiles" + cat >| "$profiles"/local.json << EOF +{ + "meta": "debomatic", + "incoming": "$AUTOPKGTEST_TMP/incoming", + "method": "local", + "check-debs": { + "skip": true + } +} +EOF + + dput local ${pkg}_${version}_source.changes +} +debomatictest_create_conf() { + if [ $hostarchitecture = None ]; then + local crossbuild=False + else + local crossbuild=True + fi + + sed /etc/debomatic/debomatic.conf \ + -e 's/^modules: True/modules: False/' \ + -e "s|^incoming: .*|incoming: $AUTOPKGTEST_TMP/incoming|" \ + -e 's|^loglevel: .*|loglevel: debug|' \ + -e "s|^crossbuild: .*|crossbuild: $crossbuild|" \ + -e "s|^hostarchitecture: .*|hostarchitecture: $hostarchitecture|" \ + > $conf + + grep -F 'modules: False' $conf + grep -F "incoming: $AUTOPKGTEST_TMP/incoming" $conf + grep -F 'loglevel: debug' $conf + grep -F "crossbuild: $crossbuild" $conf + grep -F "hostarchitecture: $hostarchitecture" $conf +} +debomatictest_check_log() { + # Check status in the log. Each argument is also checked. + local log=incoming/unstable/pool/${pkg}_$version/${pkg}_$version.buildlog + local line + + cat $log + + for line in 'Status: successful' "$@"; do + grep -F "$line" $log + done +} +debomatictest_clean() { + rm -fr /etc/schroot/chroot.d/unstable-*-debomatic-* \ + /etc/sbuild/chroot/unstable-*-debomatic +} + +# Common initialization + +# Files created by tests outside AUTOPKGTEST_TMP must be removed both +# before the test (in case another test run manually has just failed +# without cleaning) and after the test (in case the test is not run in +# a throwable chroot). +debomatictest_clean +trap debomatictest_clean EXIT + +cd "$AUTOPKGTEST_TMP" +mkdir incoming + +# Non-default values may be set *before* inclusion of this file. +hostarchitecture=${hostarchitecture:-None} +pkg=${pkg:-hello} + +version=`debomatictest_version $pkg` +conf=debomatic.conf