[PATCH] test/thread-order: more robust loop exit in case of broken input
authorTomi Ollila <tomi.ollila@iki.fi>
Sun, 29 Mar 2015 15:30:36 +0000 (18:30 +0300)
committerW. Trevor King <wking@tremily.us>
Sat, 20 Aug 2016 21:48:38 +0000 (14:48 -0700)
20/82b59ab47450c3560e24eb6c83327b3f3fa536 [new file with mode: 0644]

diff --git a/20/82b59ab47450c3560e24eb6c83327b3f3fa536 b/20/82b59ab47450c3560e24eb6c83327b3f3fa536
new file mode 100644 (file)
index 0000000..125c062
--- /dev/null
@@ -0,0 +1,81 @@
+Return-Path: <too@guru-group.fi>\r
+X-Original-To: notmuch@notmuchmail.org\r
+Delivered-To: notmuch@notmuchmail.org\r
+Received: from localhost (localhost [127.0.0.1])\r
+       by olra.theworths.org (Postfix) with ESMTP id 1906D431FBF\r
+       for <notmuch@notmuchmail.org>; Sun, 29 Mar 2015 08:31:07 -0700 (PDT)\r
+X-Virus-Scanned: Debian amavisd-new at olra.theworths.org\r
+X-Spam-Flag: NO\r
+X-Spam-Score: 2.438\r
+X-Spam-Level: **\r
+X-Spam-Status: No, score=2.438 tagged_above=-999 required=5\r
+       tests=[DNS_FROM_AHBL_RHSBL=2.438] autolearn=disabled\r
+Received: from olra.theworths.org ([127.0.0.1])\r
+       by localhost (olra.theworths.org [127.0.0.1]) (amavisd-new, port 10024)\r
+       with ESMTP id yajM-yjnMyKD for <notmuch@notmuchmail.org>;\r
+       Sun, 29 Mar 2015 08:31:03 -0700 (PDT)\r
+Received: from guru.guru-group.fi (guru.guru-group.fi [46.183.73.34])\r
+       by olra.theworths.org (Postfix) with ESMTP id C0A38431FAE\r
+       for <notmuch@notmuchmail.org>; Sun, 29 Mar 2015 08:31:03 -0700 (PDT)\r
+Received: by guru.guru-group.fi (Postfix, from userid 501)\r
+       id 1C4C510009D; Sun, 29 Mar 2015 18:30:38 +0300 (EEST)\r
+From: Tomi Ollila <tomi.ollila@iki.fi>\r
+To: notmuch@notmuchmail.org\r
+Subject: [PATCH] test/thread-order: more robust loop exit in case of broken\r
+       input\r
+Date: Sun, 29 Mar 2015 18:30:36 +0300\r
+Message-Id: <1427643036-7171-1-git-send-email-tomi.ollila@iki.fi>\r
+X-Mailer: git-send-email 2.0.0\r
+Cc: tomi.ollila@iki.fi\r
+X-BeenThere: notmuch@notmuchmail.org\r
+X-Mailman-Version: 2.1.13\r
+Precedence: list\r
+List-Id: "Use and development of the notmuch mail system."\r
+       <notmuch.notmuchmail.org>\r
+List-Unsubscribe: <http://notmuchmail.org/mailman/options/notmuch>,\r
+       <mailto:notmuch-request@notmuchmail.org?subject=unsubscribe>\r
+List-Archive: <http://notmuchmail.org/pipermail/notmuch>\r
+List-Post: <mailto:notmuch@notmuchmail.org>\r
+List-Help: <mailto:notmuch-request@notmuchmail.org?subject=help>\r
+List-Subscribe: <http://notmuchmail.org/mailman/listinfo/notmuch>,\r
+       <mailto:notmuch-request@notmuchmail.org?subject=subscribe>\r
+X-List-Received-Date: Sun, 29 Mar 2015 15:31:07 -0000\r
+\r
+When creating $THREADS data it may end of not having 'None' at all\r
+or the numbers in line output yields a loop.\r
+\r
+To avoid loop the value in current array index is set to 'None'\r
+so that if the same item is reached again the loop will end.\r
+\r
+Also empty string as next array index will end the loop.\r
+---\r
+\r
+This is v2 of id:1427310460-15801-1-git-send-email-tomi.ollila@iki.fi\r
+\r
+Tested loop termination by setting THREADS='0 0 0 0'\r
+\r
+\r
+ test/T260-thread-order.sh | 5 ++++-\r
+ 1 file changed, 4 insertions(+), 1 deletion(-)\r
+\r
+diff --git a/test/T260-thread-order.sh b/test/T260-thread-order.sh\r
+index 99f5833..5239bd4 100755\r
+--- a/test/T260-thread-order.sh\r
++++ b/test/T260-thread-order.sh\r
+@@ -45,9 +45,12 @@ for ((n = 0; n < 4; n++)); do\r
+     while read -a parents; do\r
+         references=""\r
+         parent=${parents[$n]}\r
+-        while [[ $parent != None ]]; do\r
++        while [[ ${parent:-None} != None ]]; do\r
+             references="<m$parent@t$thread> $references"\r
++            pp=$parent\r
+             parent=${parents[$parent]}\r
++            # Avoid looping over broken input (if ever)\r
++            parents[$pp]="None"\r
+         done\r
\r
+         generate_message \\r
+-- \r
+2.1.0\r
+\r