From 21e7613047ed72cef98162c2a732a7dc3c081250 Mon Sep 17 00:00:00 2001 From: Tomi Ollila Date: Sun, 29 Mar 2015 18:30:36 +0300 Subject: [PATCH] [PATCH] test/thread-order: more robust loop exit in case of broken input --- 20/82b59ab47450c3560e24eb6c83327b3f3fa536 | 81 +++++++++++++++++++++++ 1 file changed, 81 insertions(+) create mode 100644 20/82b59ab47450c3560e24eb6c83327b3f3fa536 diff --git a/20/82b59ab47450c3560e24eb6c83327b3f3fa536 b/20/82b59ab47450c3560e24eb6c83327b3f3fa536 new file mode 100644 index 000000000..125c06299 --- /dev/null +++ b/20/82b59ab47450c3560e24eb6c83327b3f3fa536 @@ -0,0 +1,81 @@ +Return-Path: +X-Original-To: notmuch@notmuchmail.org +Delivered-To: notmuch@notmuchmail.org +Received: from localhost (localhost [127.0.0.1]) + by olra.theworths.org (Postfix) with ESMTP id 1906D431FBF + for ; Sun, 29 Mar 2015 08:31:07 -0700 (PDT) +X-Virus-Scanned: Debian amavisd-new at olra.theworths.org +X-Spam-Flag: NO +X-Spam-Score: 2.438 +X-Spam-Level: ** +X-Spam-Status: No, score=2.438 tagged_above=-999 required=5 + tests=[DNS_FROM_AHBL_RHSBL=2.438] autolearn=disabled +Received: from olra.theworths.org ([127.0.0.1]) + by localhost (olra.theworths.org [127.0.0.1]) (amavisd-new, port 10024) + with ESMTP id yajM-yjnMyKD for ; + Sun, 29 Mar 2015 08:31:03 -0700 (PDT) +Received: from guru.guru-group.fi (guru.guru-group.fi [46.183.73.34]) + by olra.theworths.org (Postfix) with ESMTP id C0A38431FAE + for ; Sun, 29 Mar 2015 08:31:03 -0700 (PDT) +Received: by guru.guru-group.fi (Postfix, from userid 501) + id 1C4C510009D; Sun, 29 Mar 2015 18:30:38 +0300 (EEST) +From: Tomi Ollila +To: notmuch@notmuchmail.org +Subject: [PATCH] test/thread-order: more robust loop exit in case of broken + input +Date: Sun, 29 Mar 2015 18:30:36 +0300 +Message-Id: <1427643036-7171-1-git-send-email-tomi.ollila@iki.fi> +X-Mailer: git-send-email 2.0.0 +Cc: tomi.ollila@iki.fi +X-BeenThere: notmuch@notmuchmail.org +X-Mailman-Version: 2.1.13 +Precedence: list +List-Id: "Use and development of the notmuch mail system." + +List-Unsubscribe: , + +List-Archive: +List-Post: +List-Help: +List-Subscribe: , + +X-List-Received-Date: Sun, 29 Mar 2015 15:31:07 -0000 + +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=" $references" ++ pp=$parent + parent=${parents[$parent]} ++ # Avoid looping over broken input (if ever) ++ parents[$pp]="None" + done + + generate_message \ +-- +2.1.0 + -- 2.26.2