Re: [PATCH] emacs: wash: make word-wrap bound message width
[notmuch-archives.git] / 78 / 0d4c652c0013d456ee34db766691cd37a32298
1 Return-Path: <tomi.ollila@iki.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 27AFC431FAF\r
6         for <notmuch@notmuchmail.org>; Wed, 28 Nov 2012 00:00:29 -0800 (PST)\r
7 X-Virus-Scanned: Debian amavisd-new at olra.theworths.org\r
8 X-Spam-Flag: NO\r
9 X-Spam-Score: 0\r
10 X-Spam-Level: \r
11 X-Spam-Status: No, score=0 tagged_above=-999 required=5 tests=[none]\r
12         autolearn=disabled\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 TtG09iC90fNU for <notmuch@notmuchmail.org>;\r
16         Wed, 28 Nov 2012 00:00:27 -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 74D63431FAE\r
19         for <notmuch@notmuchmail.org>; Wed, 28 Nov 2012 00:00:27 -0800 (PST)\r
20 Received: from guru.guru-group.fi (localhost [IPv6:::1])\r
21         by guru.guru-group.fi (Postfix) with ESMTP id 5E7271000E5;\r
22         Wed, 28 Nov 2012 10:00:25 +0200 (EET)\r
23 From: Tomi Ollila <tomi.ollila@iki.fi>\r
24 To: Austin Clements <amdragon@MIT.EDU>, notmuch@notmuchmail.org\r
25 Subject: Re: [PATCH] test: Use associative arrays to track external prereqs\r
26 In-Reply-To: <1354078441-20788-1-git-send-email-amdragon@mit.edu>\r
27 References: <1354078441-20788-1-git-send-email-amdragon@mit.edu>\r
28 User-Agent: Notmuch/0.14+116~g29fcdb5 (http://notmuchmail.org) Emacs/24.2.1\r
29         (x86_64-unknown-linux-gnu)\r
30 X-Face: HhBM'cA~<r"^Xv\KRN0P{vn'Y"Kd;zg_y3S[4)KSN~s?O\"QPoL\r
31         $[Xv_BD:i/F$WiEWax}R(MPS`^UaptOGD`*/=@\1lKoVa9tnrg0TW?"r7aRtgk[F\r
32         !)g;OY^,BjTbr)Np:%c_o'jj,Z\r
33 Date: Wed, 28 Nov 2012 10:00:25 +0200\r
34 Message-ID: <m2624qxili.fsf@guru.guru-group.fi>\r
35 MIME-Version: 1.0\r
36 Content-Type: text/plain\r
37 X-BeenThere: notmuch@notmuchmail.org\r
38 X-Mailman-Version: 2.1.13\r
39 Precedence: list\r
40 List-Id: "Use and development of the notmuch mail system."\r
41         <notmuch.notmuchmail.org>\r
42 List-Unsubscribe: <http://notmuchmail.org/mailman/options/notmuch>,\r
43         <mailto:notmuch-request@notmuchmail.org?subject=unsubscribe>\r
44 List-Archive: <http://notmuchmail.org/pipermail/notmuch>\r
45 List-Post: <mailto:notmuch@notmuchmail.org>\r
46 List-Help: <mailto:notmuch-request@notmuchmail.org?subject=help>\r
47 List-Subscribe: <http://notmuchmail.org/mailman/listinfo/notmuch>,\r
48         <mailto:notmuch-request@notmuchmail.org?subject=subscribe>\r
49 X-List-Received-Date: Wed, 28 Nov 2012 08:00:29 -0000\r
50 \r
51 On Wed, Nov 28 2012, Austin Clements <amdragon@MIT.EDU> wrote:\r
52 \r
53 > Previously, the test framework generated a variable name for each\r
54 > external prereq as a poor man's associative array.  Unfortunately,\r
55 > prereqs names may not be legal variable names, leading to\r
56 > unintelligible bash errors like\r
57 >   test_missing_external_prereq_emacsclient.emacs24_=t: command not found\r
58 >\r
59 > Using proper associative arrays to track prereqs, in addition to being\r
60 > much cleaner than generating variable names and using grep to\r
61 > carefully construct unique string lists, removes restrictions on\r
62 > prereq names.\r
63 > ---\r
64 \r
65 That looks good and something like I once attempted\r
66 (at that time this would have make tests fail as this\r
67 speeds up the script execution so much that smtp-dummy\r
68 may not have time to start before it was used -- now\r
69 that is taken care by smtp-dummy --background feature :)\r
70 \r
71 +1\r
72 \r
73 Tomi\r
74 \r
75 \r
76 \r
77 >  test/test-lib.sh |   24 ++++++++++++++----------\r
78 >  1 file changed, 14 insertions(+), 10 deletions(-)\r
79 >\r
80 > diff --git a/test/test-lib.sh b/test/test-lib.sh\r
81 > index 77063a4..f169785 100644\r
82 > --- a/test/test-lib.sh\r
83 > +++ b/test/test-lib.sh\r
84 > @@ -625,18 +625,22 @@ test_have_prereq () {\r
85 >       esac\r
86 >  }\r
87 >  \r
88 > +declare -A test_missing_external_prereq_\r
89 > +declare -A test_subtest_missing_external_prereq_\r
90 > +\r
91 >  # declare prerequisite for the given external binary\r
92 >  test_declare_external_prereq () {\r
93 >       binary="$1"\r
94 >       test "$#" = 2 && name=$2 || name="$binary(1)"\r
95 >  \r
96 > -     hash $binary 2>/dev/null || eval "\r
97 > -     test_missing_external_prereq_${binary}_=t\r
98 > +     if ! hash $binary 2>/dev/null; then\r
99 > +             test_missing_external_prereq_["${binary}"]=t\r
100 > +             eval "\r
101 >  $binary () {\r
102 > -     echo -n \"\$test_subtest_missing_external_prereqs_ \" | grep -qe \" $name \" ||\r
103 > -     test_subtest_missing_external_prereqs_=\"\$test_subtest_missing_external_prereqs_ $name\"\r
104 > +     test_subtest_missing_external_prereq_[\"${name}\"]=t\r
105 >       false\r
106 >  }"\r
107 > +     fi\r
108 >  }\r
109 >  \r
110 >  # Explicitly require external prerequisite.  Useful when binary is\r
111 > @@ -644,7 +648,7 @@ $binary () {\r
112 >  # Returns success if dependency is available, failure otherwise.\r
113 >  test_require_external_prereq () {\r
114 >       binary="$1"\r
115 > -     if [ "$(eval echo -n \$test_missing_external_prereq_${binary}_)" = t ]; then\r
116 > +     if [[ ${test_missing_external_prereq_["${binary}"]} == t ]]; then\r
117 >               # dependency is missing, call the replacement function to note it\r
118 >               eval "$binary"\r
119 >       else\r
120 > @@ -737,9 +741,9 @@ test_skip () {\r
121 >  }\r
122 >  \r
123 >  test_check_missing_external_prereqs_ () {\r
124 > -     if test -n "$test_subtest_missing_external_prereqs_"; then\r
125 > -             say_color skip >&1 "missing prerequisites:"\r
126 > -             echo "$test_subtest_missing_external_prereqs_" >&1\r
127 > +     if [[ ${#test_subtest_missing_external_prereq_[@]} != 0 ]]; then\r
128 > +             say_color skip >&1 "missing prerequisites: "\r
129 > +             echo ${!test_subtest_missing_external_prereq_[@]} >&1\r
130 >               test_report_skip_ "$@"\r
131 >       else\r
132 >               false\r
133 > @@ -1022,7 +1026,7 @@ test_python() {\r
134 >       # most others as /usr/bin/python. So first try python2, and fallback to\r
135 >       # python if python2 doesn't exist.\r
136 >       cmd=python2\r
137 > -     [[ "$test_missing_external_prereq_python2_" = t ]] && cmd=python\r
138 > +     [[ ${test_missing_external_prereq_[python2]} == t ]] && cmd=python\r
139 >  \r
140 >       (echo "import sys; _orig_stdout=sys.stdout; sys.stdout=open('OUTPUT', 'w')"; cat) \\r
141 >               | $cmd -\r
142 > @@ -1064,7 +1068,7 @@ test_reset_state_ () {\r
143 >       test -z "$test_init_done_" && test_init_\r
144 >  \r
145 >       test_subtest_known_broken_=\r
146 > -     test_subtest_missing_external_prereqs_=\r
147 > +     test_subtest_missing_external_prereq_=()\r
148 >  }\r
149 >  \r
150 >  # called once before the first subtest\r
151 > -- \r
152 > 1.7.10.4\r
153 >\r
154 > _______________________________________________\r
155 > notmuch mailing list\r
156 > notmuch@notmuchmail.org\r
157 > http://notmuchmail.org/mailman/listinfo/notmuch\r