[PATCH] test/thread-order: more robust loop exit in case of broken input

Subject: [PATCH] test/thread-order: more robust loop exit in case of broken input

Date: Sun, 29 Mar 2015 18:30:36 +0300

To: notmuch@notmuchmail.org

Cc: tomi.ollila@iki.fi

From: Tomi Ollila


When creating $THREADS data it may end of not having 'None' at all
or the numbers in line output yields a loop.

To avoid loop the value in current array index is set to 'None'
so that if the same item is reached again the loop will end.

Also empty string as next array index will end the loop.
---

This is v2 of id:1427310460-15801-1-git-send-email-tomi.ollila@iki.fi

Tested loop termination by setting THREADS='0 0 0 0'


 test/T260-thread-order.sh | 5 ++++-
 1 file changed, 4 insertions(+), 1 deletion(-)

diff --git a/test/T260-thread-order.sh b/test/T260-thread-order.sh
index 99f5833..5239bd4 100755
--- a/test/T260-thread-order.sh
+++ b/test/T260-thread-order.sh
@@ -45,9 +45,12 @@ for ((n = 0; n < 4; n++)); do
     while read -a parents; do
         references=""
         parent=${parents[$n]}
-        while [[ $parent != None ]]; do
+        while [[ ${parent:-None} != None ]]; do
             references="<m$parent@t$thread> $references"
+            pp=$parent
             parent=${parents[$parent]}
+            # Avoid looping over broken input (if ever)
+            parents[$pp]="None"
         done
 
         generate_message \
-- 
2.1.0


Thread: