]> git.saurik.com Git - apt.git/commitdiff
tests: trap-adding can be post- as well as prefix
authorDavid Kalnischkies <kalnischkies@gmail.com>
Tue, 28 May 2013 16:08:32 +0000 (18:08 +0200)
committerDavid Kalnischkies <kalnischkies@gmail.com>
Sun, 9 Jun 2013 13:12:32 +0000 (15:12 +0200)
For testcases it might sometimes be handy to add trap-actions
before the general cleanup, e.g. if it has set directories read-
only which rm doesn't want to remove even with --force applied
(its fine with files though)

Git-Dch: Ignore

test/integration/framework
test/integration/test-apt-cdrom

index e3e868d45246940709ef24ec561eec7f44cc283b..7c2aed592cdee2fed0edbc573f7960a66b3c3817 100644 (file)
@@ -125,7 +125,11 @@ exitwithstatus() {
 }
 
 addtrap() {
-       CURRENTTRAP="$CURRENTTRAP $1"
+       if [ "$1" = 'prefix' ]; then
+               CURRENTTRAP="$2 $CURRENTTRAP"
+       else
+               CURRENTTRAP="$CURRENTTRAP $1"
+       fi
        trap "$CURRENTTRAP exitwithstatus;" 0 HUP INT QUIT ILL ABRT FPE SEGV PIPE TERM
 }
 
@@ -135,8 +139,7 @@ setupenvironment() {
        msgninfo "Preparing environment for ${CCMD}$(basename $0)${CINFO} in ${TMPWORKINGDIRECTORY}… "
        BUILDDIRECTORY="${TESTDIRECTORY}/../../build/bin"
        test -x "${BUILDDIRECTORY}/apt-get" || msgdie "You need to build tree first"
-       local OLDWORKINGDIRECTORY=$(pwd)
-       addtrap "cd /; rm -rf $TMPWORKINGDIRECTORY; cd $OLDWORKINGDIRECTORY;"
+       addtrap "cd /; rm -rf $TMPWORKINGDIRECTORY;"
        cd $TMPWORKINGDIRECTORY
        mkdir rootdir aptarchive keys
        cd rootdir
index f1c4fd9d32daec40f912b3cea220724fd59c83f7..3394aa505a8cf865f512ef2b9cd15509b8c8ebc6 100755 (executable)
@@ -24,7 +24,7 @@ cat Translation-de | xz --format=lzma > Translation-de.lzma
 cat Translation-de | xz > Translation-de.xz
 rm Translation-en Translation-de
 cd - > /dev/null
-addtrap "chmod -R +w $PWD/rootdir/media/cdrom/dists/;"
+addtrap 'prefix' "chmod -R +w $PWD/rootdir/media/cdrom/dists/;"
 chmod -R -w rootdir/media/cdrom/dists
 
 aptcdrom add -m -o quiet=1 > apt-cdrom.log 2>&1