1 Return-Path: <too@guru-group.fi>
\r
2 X-Original-To: notmuch@notmuchmail.org
\r
3 Delivered-To: notmuch@notmuchmail.org
\r
4 Received: from localhost (localhost [127.0.0.1])
\r
5 by olra.theworths.org (Postfix) with ESMTP id 2EB17431FC0
\r
6 for <notmuch@notmuchmail.org>; Wed, 1 Jan 2014 08:26:07 -0800 (PST)
\r
7 X-Virus-Scanned: Debian amavisd-new at olra.theworths.org
\r
11 X-Spam-Status: No, score=0 tagged_above=-999 required=5 tests=[none]
\r
13 Received: from olra.theworths.org ([127.0.0.1])
\r
14 by localhost (olra.theworths.org [127.0.0.1]) (amavisd-new, port 10024)
\r
15 with ESMTP id JtGXSmDYFxsH for <notmuch@notmuchmail.org>;
\r
16 Wed, 1 Jan 2014 08:26:00 -0800 (PST)
\r
17 Received: from guru.guru-group.fi (guru.guru-group.fi [46.183.73.34])
\r
18 by olra.theworths.org (Postfix) with ESMTP id 812B2431FAF
\r
19 for <notmuch@notmuchmail.org>; Wed, 1 Jan 2014 08:26:00 -0800 (PST)
\r
20 Received: by guru.guru-group.fi (Postfix, from userid 501)
\r
21 id 3811E10014F; Wed, 1 Jan 2014 18:25:54 +0200 (EET)
\r
22 From: Tomi Ollila <tomi.ollila@iki.fi>
\r
23 To: notmuch@notmuchmail.org
\r
24 Subject: [PATCH 1/1] test: support for generating decreasing dates with bash
\r
26 Date: Wed, 1 Jan 2014 18:25:52 +0200
\r
27 Message-Id: <1388593552-25920-1-git-send-email-tomi.ollila@iki.fi>
\r
28 X-Mailer: git-send-email 1.8.0
\r
29 Cc: tomi.ollila@iki.fi
\r
30 X-BeenThere: notmuch@notmuchmail.org
\r
31 X-Mailman-Version: 2.1.13
\r
33 List-Id: "Use and development of the notmuch mail system."
\r
34 <notmuch.notmuchmail.org>
\r
35 List-Unsubscribe: <http://notmuchmail.org/mailman/options/notmuch>,
\r
36 <mailto:notmuch-request@notmuchmail.org?subject=unsubscribe>
\r
37 List-Archive: <http://notmuchmail.org/pipermail/notmuch>
\r
38 List-Post: <mailto:notmuch@notmuchmail.org>
\r
39 List-Help: <mailto:notmuch-request@notmuchmail.org?subject=help>
\r
40 List-Subscribe: <http://notmuchmail.org/mailman/listinfo/notmuch>,
\r
41 <mailto:notmuch-request@notmuchmail.org?subject=subscribe>
\r
42 X-List-Received-Date: Wed, 01 Jan 2014 16:26:07 -0000
\r
44 The printf builtin "%(fmt)T" specifier (which allows time values
\r
45 to use strftime-like formatting) is introduced in bash 4.2.
\r
47 Added a new function `secs_to_rfc2822date` which uses the above specifier
\r
48 with post 4.1 bash and perl(1) construct with pre-4.2 bash.
\r
50 test/test-lib.sh | 19 +++++++++++++++++--
\r
51 1 file changed, 17 insertions(+), 2 deletions(-)
\r
53 diff --git a/test/test-lib.sh b/test/test-lib.sh
\r
54 index 2fcaba6..7d88867 100644
\r
55 --- a/test/test-lib.sh
\r
56 +++ b/test/test-lib.sh
\r
57 @@ -272,6 +272,21 @@ remove_cr () {
\r
58 tr '\015' Q | sed -e 's/Q$//'
\r
61 +# The printf '%(fmt)T' specifier is bash 4.2+ feature.
\r
62 +if [[ ${BASH_VERSINFO[0]} -gt 4 || ${BASH_VERSINFO[1]} -ge 2 ]]
\r
64 + secs_to_rfc2822date ()
\r
66 + TZ=UTC printf "%(%a, %d %b %Y %T %z)T\n" "$1"
\r
69 + secs_to_rfc2822date ()
\r
71 + perl -le 'use POSIX "strftime"; @time = gmtime $ARGV[0];
\r
72 + print strftime "%a, %d %b %Y %T +0000", @time' "$1"
\r
76 # Generate a new message in the mail directory, with a unique message
\r
77 # ID and subject. The message is not added to the index.
\r
79 @@ -373,8 +388,8 @@ generate_message ()
\r
80 # we use decreasing timestamps here for historical reasons;
\r
81 # the existing test suite when we converted to unique timestamps just
\r
82 # happened to have signicantly fewer failures with that choice.
\r
83 - template[date]=$(TZ=UTC printf "%(%a, %d %b %Y %T %z)T\n" \
\r
84 - $((978709437 - gen_msg_cnt)))
\r
86 + template[date]=$(secs_to_rfc2822date $((978709437 - gen_msg_cnt)))
\r
89 additional_headers=""
\r