]> git.saurik.com Git - apt.git/blobdiff - test/integration/framework
send Alt-* info for uncompressed based on any compressions
[apt.git] / test / integration / framework
index 2c794d1f37877bc8e1cf8e27d3a3415ddb429a1f..994956b74c27de307efff72e63f502b26e834349 100644 (file)
@@ -3,7 +3,7 @@
 EXIT_CODE=0
 
 # we all like colorful messages
 EXIT_CODE=0
 
 # we all like colorful messages
-if [ "$MSGCOLOR" != 'NO' ]; then
+if [ "$MSGCOLOR" != 'NO' ] && [ "$MSGCOLOR" != 'ALWAYS' ]; then
        if [ ! -t 1 ]; then # but check that we output to a terminal
                export MSGCOLOR='NO'
        fi
        if [ ! -t 1 ]; then # but check that we output to a terminal
                export MSGCOLOR='NO'
        fi
@@ -248,7 +248,7 @@ setupenvironment() {
                echo "Dir::Bin::apt-key \"${BUILDDIRECTORY}/apt-key\";" >> aptconfig.conf
        fi
 
                echo "Dir::Bin::apt-key \"${BUILDDIRECTORY}/apt-key\";" >> aptconfig.conf
        fi
 
-       cat > "${TMPWORKINGDIRECTORY}/rootdir/usr/bin/dpkg" <<EOF
+       cat << EOF > "${TMPWORKINGDIRECTORY}/rootdir/usr/bin/dpkg"
 #!/bin/sh
 set -e
 if [ -r "${TMPWORKINGDIRECTORY}/noopchroot.so" ]; then
 #!/bin/sh
 set -e
 if [ -r "${TMPWORKINGDIRECTORY}/noopchroot.so" ]; then
@@ -262,7 +262,6 @@ exec fakeroot dpkg --root="${TMPWORKINGDIRECTORY}/rootdir" \\
        --log=${TMPWORKINGDIRECTORY}/rootdir/var/log/dpkg.log \\
        --force-not-root --force-bad-path "\$@"
 EOF
        --log=${TMPWORKINGDIRECTORY}/rootdir/var/log/dpkg.log \\
        --force-not-root --force-bad-path "\$@"
 EOF
-       cat "${TMPWORKINGDIRECTORY}/rootdir/usr/bin/dpkg"
        chmod +x "${TMPWORKINGDIRECTORY}/rootdir/usr/bin/dpkg"
        echo "Dir::Bin::dpkg \"${TMPWORKINGDIRECTORY}/rootdir/usr/bin/dpkg\";" > rootdir/etc/apt/apt.conf.d/99dpkg
 
        chmod +x "${TMPWORKINGDIRECTORY}/rootdir/usr/bin/dpkg"
        echo "Dir::Bin::dpkg \"${TMPWORKINGDIRECTORY}/rootdir/usr/bin/dpkg\";" > rootdir/etc/apt/apt.conf.d/99dpkg
 
@@ -827,7 +826,7 @@ buildaptarchivefromincoming() {
        [ -e ftparchive.conf ] || createaptftparchiveconfig
        [ -e dists ] || buildaptftparchivedirectorystructure
        msgninfo "\tGenerate Packages, Sources and Contents files… "
        [ -e ftparchive.conf ] || createaptftparchiveconfig
        [ -e dists ] || buildaptftparchivedirectorystructure
        msgninfo "\tGenerate Packages, Sources and Contents files… "
-       aptftparchive -qq generate ftparchive.conf
+       testsuccess aptftparchive generate ftparchive.conf
        cd - > /dev/null
        msgdone "info"
        generatereleasefiles "$@"
        cd - > /dev/null
        msgdone "info"
        generatereleasefiles "$@"
@@ -1126,8 +1125,10 @@ acquire::cdrom::autodetect 0;" > rootdir/etc/apt/apt.conf.d/00cdrom
 
 downloadfile() {
        local PROTO="${1%%:*}"
 
 downloadfile() {
        local PROTO="${1%%:*}"
-       apthelper -o Debug::Acquire::${PROTO}=1 -o Debug::pkgAcquire::Worker=1 \
-               download-file "$1" "$2" 2>&1 || true
+       if ! apthelper -o Debug::Acquire::${PROTO}=1 -o Debug::pkgAcquire::Worker=1 \
+               download-file "$1" "$2" 2>&1 ; then
+               return 1
+       fi
        # only if the file exists the download was successful
        if [ -r "$2" ]; then
                return 0
        # only if the file exists the download was successful
        if [ -r "$2" ]; then
                return 0
@@ -1339,7 +1340,7 @@ testwarning() {
        else
                msgtest 'Test for successful execution with warnings of' "$*"
        fi
        else
                msgtest 'Test for successful execution with warnings of' "$*"
        fi
-       local OUTPUT="${TMPWORKINGDIRECTORY}/rootdir/tmp/testsuccess.output"
+       local OUTPUT="${TMPWORKINGDIRECTORY}/rootdir/tmp/testwarning.output"
        if "$@" >${OUTPUT} 2>&1; then
                if expr match "$1" '^apt.*' >/dev/null; then
                        if grep -q -E ' runtime error: ' "$OUTPUT"; then
        if "$@" >${OUTPUT} 2>&1; then
                if expr match "$1" '^apt.*' >/dev/null; then
                        if grep -q -E ' runtime error: ' "$OUTPUT"; then
@@ -1389,6 +1390,40 @@ testfailure() {
        aptautotest 'testfailure' "$@"
 }
 
        aptautotest 'testfailure' "$@"
 }
 
+testsuccessequal() {
+       local CMP="$1"
+       shift
+       testsuccess "$@"
+       testfileequal "${TMPWORKINGDIRECTORY}/rootdir/tmp/testsuccess.output" "$CMP"
+}
+testwarningequal() {
+       local CMP="$1"
+       shift
+       testwarning "$@"
+       testfileequal "${TMPWORKINGDIRECTORY}/rootdir/tmp/testwarning.output" "$CMP"
+}
+testfailureequal() {
+       local CMP="$1"
+       shift
+       testfailure "$@"
+       testfileequal "${TMPWORKINGDIRECTORY}/rootdir/tmp/testfailure.output" "$CMP"
+}
+
+testfailuremsg() {
+       local CMP="$1"
+       shift
+       testfailure "$@"
+       msgtest 'Check that the output of the previous failed command has expected' 'failures and warnings'
+       grep '^\(W\|E\):' "${TMPWORKINGDIRECTORY}/rootdir/tmp/testfailure.output" > "${TMPWORKINGDIRECTORY}/rootdir/tmp/testfailureequal.output" 2>&1 || true
+       if echo "$CMP" | checkdiff - "${TMPWORKINGDIRECTORY}/rootdir/tmp/testfailureequal.output"; then
+               msgpass
+       else
+               echo '### Complete output ###'
+               cat "${TMPWORKINGDIRECTORY}/rootdir/tmp/testfailure.output"
+               msgfail
+       fi
+}
+
 testfilestats() {
        msgtest "Test that file $1 has $2 $3" "$4"
        if [ "$4" "$3" "$(stat --format "$2" "$1")" ]; then
 testfilestats() {
        msgtest "Test that file $1 has $2 $3" "$4"
        if [ "$4" "$3" "$(stat --format "$2" "$1")" ]; then
@@ -1494,7 +1529,7 @@ aptautotest_apt_update() { aptautotest_aptget_update "$@"; }
 testaptautotestnodpkgwarning() {
        local TESTCALL="$1"
        while [ -n "$2" ]; do
 testaptautotestnodpkgwarning() {
        local TESTCALL="$1"
        while [ -n "$2" ]; do
-               if [ "$2" = '-s' ]; then return; fi
+               if expr match "$2" '^-[a-z]*s' >/dev/null 2>&1; then return; fi
                shift
        done
        testfailure grep '^dpkg: warning:.*ignor.*' "${TMPWORKINGDIRECTORY}/rootdir/tmp-before/${TESTCALL}.output"
                shift
        done
        testfailure grep '^dpkg: warning:.*ignor.*' "${TMPWORKINGDIRECTORY}/rootdir/tmp-before/${TESTCALL}.output"