Re: [PATCH 0/4] Allow specifying alternate names for addresses in other_email
[notmuch-archives.git] / 65 / ef494a2180597c892570e7fbc1c744019b152a
1 Return-Path: <bremner@pivot.cs.unb.ca>\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 9A25E429E2F\r
6         for <notmuch@notmuchmail.org>; Wed,  7 Dec 2011 11:26:56 -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: -2.3\r
10 X-Spam-Level: \r
11 X-Spam-Status: No, score=-2.3 tagged_above=-999 required=5\r
12         tests=[RCVD_IN_DNSWL_MED=-2.3] 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 IK7hF3hxj5So for <notmuch@notmuchmail.org>;\r
16         Wed,  7 Dec 2011 11:26:54 -0800 (PST)\r
17 Received: from tempo.its.unb.ca (tempo.its.unb.ca [131.202.1.21])\r
18         (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits))\r
19         (No client certificate requested)\r
20         by olra.theworths.org (Postfix) with ESMTPS id C8D76429E35\r
21         for <notmuch@notmuchmail.org>; Wed,  7 Dec 2011 11:26:49 -0800 (PST)\r
22 Received: from convex-new.cs.unb.ca ([131.202.13.154])\r
23         by tempo.its.unb.ca (8.13.8/8.13.8) with ESMTP id pB7JQhTw021339;\r
24         Wed, 7 Dec 2011 15:26:46 -0400\r
25 Received: from bremner by convex-new.cs.unb.ca with local (Exim 4.72)\r
26         (envelope-from <bremner@pivot.cs.unb.ca>)\r
27         id 1RYN8d-0004Pj-T0; Wed, 07 Dec 2011 15:26:43 -0400\r
28 From: David Bremner <david@tethera.net>\r
29 To: notmuch@notmuchmail.org\r
30 Subject: [PATCH v4 2/5] test: tests for command-line-arguments.c\r
31 Date: Wed,  7 Dec 2011 15:26:36 -0400\r
32 Message-Id: <1323285999-16870-3-git-send-email-david@tethera.net>\r
33 X-Mailer: git-send-email 1.7.5.4\r
34 In-Reply-To: <1323285999-16870-1-git-send-email-david@tethera.net>\r
35 References: <87iplso9c9.fsf@zancas.localnet>\r
36         <1323285999-16870-1-git-send-email-david@tethera.net>\r
37 Cc: David Bremner <bremner@debian.org>\r
38 X-BeenThere: notmuch@notmuchmail.org\r
39 X-Mailman-Version: 2.1.13\r
40 Precedence: list\r
41 List-Id: "Use and development of the notmuch mail system."\r
42         <notmuch.notmuchmail.org>\r
43 List-Unsubscribe: <http://notmuchmail.org/mailman/options/notmuch>,\r
44         <mailto:notmuch-request@notmuchmail.org?subject=unsubscribe>\r
45 List-Archive: <http://notmuchmail.org/pipermail/notmuch>\r
46 List-Post: <mailto:notmuch@notmuchmail.org>\r
47 List-Help: <mailto:notmuch-request@notmuchmail.org?subject=help>\r
48 List-Subscribe: <http://notmuchmail.org/mailman/listinfo/notmuch>,\r
49         <mailto:notmuch-request@notmuchmail.org?subject=subscribe>\r
50 X-List-Received-Date: Wed, 07 Dec 2011 19:26:57 -0000\r
51 \r
52 From: David Bremner <bremner@debian.org>\r
53 \r
54 This was needed because no current notmuch code exercises the\r
55 NOTMUCH_OPT_STRING style arguments.\r
56 ---\r
57  test/Makefile.local   |   11 ++++++++-\r
58  test/arg-test.c       |   52 +++++++++++++++++++++++++++++++++++++++++++++++++\r
59  test/argument-parsing |   16 +++++++++++++++\r
60  test/basic            |    2 +-\r
61  test/notmuch-test     |    1 +\r
62  5 files changed, 79 insertions(+), 3 deletions(-)\r
63  create mode 100644 test/arg-test.c\r
64  create mode 100755 test/argument-parsing\r
65 \r
66 diff --git a/test/Makefile.local b/test/Makefile.local\r
67 index bffbbdb..6cb6c82 100644\r
68 --- a/test/Makefile.local\r
69 +++ b/test/Makefile.local\r
70 @@ -2,12 +2,17 @@\r
71  \r
72  dir := test\r
73  \r
74 +extra_cflags += -I.\r
75 +\r
76  smtp_dummy_srcs =              \\r
77         $(notmuch_compat_srcs)  \\r
78         $(dir)/smtp-dummy.c\r
79  \r
80  smtp_dummy_modules = $(smtp_dummy_srcs:.c=.o)\r
81  \r
82 +$(dir)/arg-test: $(dir)/arg-test.o command-line-arguments.o util/libutil.a\r
83 +       $(call quiet,CC) -I. $^ -o $@\r
84 +\r
85  $(dir)/smtp-dummy: $(smtp_dummy_modules)\r
86         $(call quiet,CC) $^ -o $@\r
87  \r
88 @@ -16,11 +21,13 @@ $(dir)/symbol-test: $(dir)/symbol-test.o\r
89  \r
90  .PHONY: test check\r
91  \r
92 -test-binaries: $(dir)/smtp-dummy $(dir)/symbol-test\r
93 +test-binaries: $(dir)/arg-test $(dir)/smtp-dummy $(dir)/symbol-test\r
94  \r
95  test:  all test-binaries\r
96         @${dir}/notmuch-test $(OPTIONS)\r
97  \r
98  check: test\r
99  \r
100 -CLEAN := $(CLEAN) $(dir)/smtp-dummy $(dir)/smtp-dummy.o $(dir)/symbol-test $(dir)/symbol-test.o\r
101 +CLEAN := $(CLEAN) $(dir)/smtp-dummy $(dir)/smtp-dummy.o \\r
102 +        $(dir)/symbol-test $(dir)/symbol-test.o \\r
103 +        $(dir)/arg-test $(dir)/arg-test.o\r
104 diff --git a/test/arg-test.c b/test/arg-test.c\r
105 new file mode 100644\r
106 index 0000000..adc56e3\r
107 --- /dev/null\r
108 +++ b/test/arg-test.c\r
109 @@ -0,0 +1,52 @@\r
110 +#include <stdio.h>\r
111 +#include "command-line-arguments.h"\r
112 +\r
113 +\r
114 +int main(int argc, char **argv){\r
115 +\r
116 +    int opt_index=1;\r
117 +\r
118 +    int kw_val=0;\r
119 +    int int_val=0;\r
120 +    char *pos_arg1=NULL;\r
121 +    char *pos_arg2=NULL;\r
122 +    char *string_val=NULL;\r
123 +\r
124 +    notmuch_opt_desc_t options[] = {\r
125 +       { NOTMUCH_OPT_KEYWORD, &kw_val, "keyword", 'k',\r
126 +         (notmuch_keyword_t []){ { "one", 1 },\r
127 +                                 { "two", 2 },\r
128 +                                 { 0, 0 } } },\r
129 +       { NOTMUCH_OPT_INT, &int_val, "int", 'i', 0},\r
130 +       { NOTMUCH_OPT_STRING, &string_val, "string", 's', 0},\r
131 +       { NOTMUCH_OPT_POSITION, &pos_arg1, 0,0, 0},\r
132 +       { NOTMUCH_OPT_POSITION, &pos_arg2, 0,0, 0},\r
133 +       { 0, 0, 0, 0, 0 } };\r
134 +\r
135 +    opt_index = parse_arguments(argc, argv, options, 1);\r
136 +\r
137 +    if (opt_index < 0)\r
138 +       return 1;\r
139 +\r
140 +    if (kw_val)\r
141 +       printf("keyword %d\n", kw_val);\r
142 +\r
143 +    if (int_val)\r
144 +       printf("int %d\n", int_val);\r
145 +\r
146 +    if (string_val)\r
147 +       printf("string %s\n", string_val);\r
148 +\r
149 +    if (pos_arg1)\r
150 +       printf("positional arg 1 %s\n", pos_arg1);\r
151 +\r
152 +    if (pos_arg2)\r
153 +       printf("positional arg 2 %s\n", pos_arg1);\r
154 +\r
155 +\r
156 +    for ( ; opt_index < argc ; opt_index ++) {\r
157 +       printf("non parsed arg %d = %s\n", opt_index, argv[opt_index]);\r
158 +    }\r
159 +\r
160 +    return 0;\r
161 +}\r
162 diff --git a/test/argument-parsing b/test/argument-parsing\r
163 new file mode 100755\r
164 index 0000000..672de0b\r
165 --- /dev/null\r
166 +++ b/test/argument-parsing\r
167 @@ -0,0 +1,16 @@\r
168 +#!/usr/bin/env bash\r
169 +test_description="argument parsing"\r
170 +. ./test-lib.sh\r
171 +\r
172 +test_begin_subtest "sanity check"\r
173 +$TEST_DIRECTORY/arg-test  pos1  --keyword=one --string=foo pos2 --int=7 > OUTPUT\r
174 +cat <<EOF > EXPECTED\r
175 +keyword 1\r
176 +int 7\r
177 +string foo\r
178 +positional arg 1 pos1\r
179 +positional arg 2 pos1\r
180 +EOF\r
181 +test_expect_equal_file OUTPUT EXPECTED\r
182 +\r
183 +test_done\r
184 diff --git a/test/basic b/test/basic\r
185 index 4edf831..d6aed24 100755\r
186 --- a/test/basic\r
187 +++ b/test/basic\r
188 @@ -54,7 +54,7 @@ test_begin_subtest 'Ensure that all available tests will be run by notmuch-test'\r
189  eval $(sed -n -e '/^TESTS="$/,/^"$/p' $TEST_DIRECTORY/notmuch-test)\r
190  tests_in_suite=$(for i in $TESTS; do echo $i; done | sort)\r
191  available=$(find "$TEST_DIRECTORY" -maxdepth 1 -type f -executable -printf '%f\n' | \\r
192 -    sed -r -e "/^(aggregate-results.sh|notmuch-test|smtp-dummy|test-verbose|symbol-test)$/d" | \\r
193 +    sed -r -e "/^(aggregate-results.sh|notmuch-test|smtp-dummy|test-verbose|symbol-test|arg-test)$/d" | \\r
194      sort)\r
195  test_expect_equal "$tests_in_suite" "$available"\r
196  \r
197 diff --git a/test/notmuch-test b/test/notmuch-test\r
198 index 53ce355..d05bb38 100755\r
199 --- a/test/notmuch-test\r
200 +++ b/test/notmuch-test\r
201 @@ -48,6 +48,7 @@ TESTS="\r
202    search-folder-coherence\r
203    atomicity\r
204    python\r
205 +  argument-parsing\r
206  "\r
207  TESTS=${NOTMUCH_TESTS:=$TESTS}\r
208  \r
209 -- \r
210 1.7.5.4\r
211 \r