tests: do not overwrite 'errlist' on hard exit
authorJean-Sebastien Gelinas <calestar@gmail.com>
Fri, 24 Jul 2009 05:15:39 +0000 (01:15 -0400)
committerJean Privat <jean@pryen.org>
Tue, 28 Jul 2009 13:38:30 +0000 (09:38 -0400)
Signed-off-by: Jean-Sebastien Gelinas <calestar@gmail.com>
Signed-off-by: Jean Privat <jean@pryen.org>

tests/tests.sh

index 36d501d..4314ea9 100755 (executable)
@@ -99,19 +99,18 @@ done
 # File where error tests are outputed
 # Old ERRLIST is backuped
 ERRLIST=${ERRLIST:-errlist}
+ERRLIST_TARGET=$ERRLIST
 
 if [ $# = 0 ]; then
        usage;
        exit
 fi
 
-# Backup and initiate new ERRLIST
+# Initiate new ERRLIST
 if [ "x$ERRLIST" = "x" ]; then
        ERRLIST=/dev=null
 else
-       if [ -x "$ERRLIST" ]; then
-               mv "$ERRLIST" "${ERRLIST}.bak"
-       fi
+       ERRLIST=$ERRLIST.tmp
        > "$ERRLIST"
 fi
 
@@ -226,6 +225,14 @@ if [ -n "$nos" ]; then
        echo "no sav: $nos"
 fi
 
+# write $ERRLIST
+if [ "x$ERRLIST" != "x" ]; then
+       if [ -x "$ERRLIST_TARGET" ]; then
+               mv "$ERRLIST_TARGET" "${ERRLIST_TARGET}.bak"
+       fi
+       mv $ERRLIST $ERRLIST_TARGET
+fi
+
 if [ -n "$nok" ]; then
        exit 1
 else