Ver código fonte

tests: trap-adding can be post- as well as prefix

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
David Kalnischkies 13 anos atrás
pai
commit
8437b7d4a6
2 arquivos alterados com 7 adições e 4 exclusões
  1. 6 3
      test/integration/framework
  2. 1 1
      test/integration/test-apt-cdrom

+ 6 - 3
test/integration/framework

@@ -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

+ 1 - 1
test/integration/test-apt-cdrom

@@ -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