[PATCH] test: rearrange the test corpus into subfolders, fix tests
[notmuch-archives.git] / f4 / 4351fd81f4fe2f75112a0386d5a5b1f58397dc
1 Return-Path: <nex@nexoid.at>\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 77F7E431FD6\r
6         for <notmuch@notmuchmail.org>; Wed,  5 Dec 2012 23:33:19 -0800 (PST)\r
7 X-Virus-Scanned: Debian amavisd-new at olra.theworths.org\r
8 X-Amavis-Alert: BAD HEADER SECTION, Duplicate header field: "References"\r
9 X-Spam-Flag: NO\r
10 X-Spam-Score: 0.001\r
11 X-Spam-Level: \r
12 X-Spam-Status: No, score=0.001 tagged_above=-999 required=5\r
13         tests=[FREEMAIL_FROM=0.001] autolearn=disabled\r
14 Received: from olra.theworths.org ([127.0.0.1])\r
15         by localhost (olra.theworths.org [127.0.0.1]) (amavisd-new, port 10024)\r
16         with ESMTP id mkmiqSabtOl8 for <notmuch@notmuchmail.org>;\r
17         Wed,  5 Dec 2012 23:33:16 -0800 (PST)\r
18 Received: from mail.nexoid.at (www.nexoid.at [178.79.130.240])\r
19         (using TLSv1 with cipher ADH-AES256-SHA (256/256 bits))\r
20         (No client certificate requested)\r
21         by olra.theworths.org (Postfix) with ESMTPS id D40D2431FAE\r
22         for <notmuch@notmuchmail.org>; Wed,  5 Dec 2012 23:33:15 -0800 (PST)\r
23 Received: by mail.nexoid.at (Postfix, from userid 1000)\r
24         id A9EA711C10E; Thu,  6 Dec 2012 08:33:12 +0100 (CET)\r
25 From: Peter Feigl <craven@gmx.net>\r
26 To: notmuch@notmuchmail.org\r
27 Subject: [PATCH v3 2/5] Rename the -json printer functions in notmuch-reply\r
28         and notmuch-show to generic -sprinter functions.\r
29 Date: Thu,  6 Dec 2012 08:33:06 +0100\r
30 Message-Id: <1354779189-12231-3-git-send-email-craven@gmx.net>\r
31 X-Mailer: git-send-email 1.8.0\r
32 In-Reply-To: <1354779189-12231-1-git-send-email-craven@gmx.net>\r
33 References: <1354779189-12231-1-git-send-email-craven@gmx.net>\r
34 In-Reply-To: <1354632382-15609-1-git-send-email-craven@gmx.net>\r
35 References: <1354632382-15609-1-git-send-email-craven@gmx.net>\r
36 X-BeenThere: notmuch@notmuchmail.org\r
37 X-Mailman-Version: 2.1.13\r
38 Precedence: list\r
39 List-Id: "Use and development of the notmuch mail system."\r
40         <notmuch.notmuchmail.org>\r
41 List-Unsubscribe: <http://notmuchmail.org/mailman/options/notmuch>,\r
42         <mailto:notmuch-request@notmuchmail.org?subject=unsubscribe>\r
43 List-Archive: <http://notmuchmail.org/pipermail/notmuch>\r
44 List-Post: <mailto:notmuch@notmuchmail.org>\r
45 List-Help: <mailto:notmuch-request@notmuchmail.org?subject=help>\r
46 List-Subscribe: <http://notmuchmail.org/mailman/listinfo/notmuch>,\r
47         <mailto:notmuch-request@notmuchmail.org?subject=subscribe>\r
48 X-List-Received-Date: Thu, 06 Dec 2012 07:33:19 -0000\r
49 \r
50 All the structured output functions in notmuch-reply and notmuch-show\r
51 are renamed to a generic name (as they do not contain any json-specific\r
52 code anyway). This patch is a preparation to actually using the new\r
53 S-Expression sprinter in notmuch-reply and notmuch-show.\r
54 ---\r
55  notmuch-client.h |  8 ++++----\r
56  notmuch-reply.c  | 43 ++++++++++++++++++++++++++-----------------\r
57  notmuch-show.c   | 30 +++++++++++++++---------------\r
58  3 files changed, 45 insertions(+), 36 deletions(-)\r
59 \r
60 diff --git a/notmuch-client.h b/notmuch-client.h\r
61 index ae9344b..1c336dc 100644\r
62 --- a/notmuch-client.h\r
63 +++ b/notmuch-client.h\r
64 @@ -175,12 +175,12 @@ notmuch_status_t\r
65  show_one_part (const char *filename, int part);\r
66  \r
67  void\r
68 -format_part_json (const void *ctx, struct sprinter *sp, mime_node_t *node,\r
69 -                 notmuch_bool_t first, notmuch_bool_t output_body);\r
70 +format_part_sprinter (const void *ctx, struct sprinter *sp, mime_node_t *node,\r
71 +                     notmuch_bool_t first, notmuch_bool_t output_body);\r
72  \r
73  void\r
74 -format_headers_json (struct sprinter *sp, GMimeMessage *message,\r
75 -                    notmuch_bool_t reply);\r
76 +format_headers_sprinter (struct sprinter *sp, GMimeMessage *message,\r
77 +                        notmuch_bool_t reply);\r
78  \r
79  typedef enum {\r
80      NOTMUCH_SHOW_TEXT_PART_REPLY = 1 << 0,\r
81 diff --git a/notmuch-reply.c b/notmuch-reply.c\r
82 index e60a264..6103d6e 100644\r
83 --- a/notmuch-reply.c\r
84 +++ b/notmuch-reply.c\r
85 @@ -548,7 +548,8 @@ notmuch_reply_format_default(void *ctx,\r
86                              notmuch_config_t *config,\r
87                              notmuch_query_t *query,\r
88                              notmuch_show_params_t *params,\r
89 -                            notmuch_bool_t reply_all)\r
90 +                            notmuch_bool_t reply_all,\r
91 +                            unused (sprinter_t *sp))\r
92  {\r
93      GMimeMessage *reply;\r
94      notmuch_messages_t *messages;\r
95 @@ -587,17 +588,17 @@ notmuch_reply_format_default(void *ctx,\r
96  }\r
97  \r
98  static int\r
99 -notmuch_reply_format_json(void *ctx,\r
100 -                         notmuch_config_t *config,\r
101 -                         notmuch_query_t *query,\r
102 -                         notmuch_show_params_t *params,\r
103 -                         notmuch_bool_t reply_all)\r
104 +notmuch_reply_format_sprinter(void *ctx,\r
105 +                             notmuch_config_t *config,\r
106 +                             notmuch_query_t *query,\r
107 +                             notmuch_show_params_t *params,\r
108 +                             notmuch_bool_t reply_all,\r
109 +                             sprinter_t *sp)\r
110  {\r
111      GMimeMessage *reply;\r
112      notmuch_messages_t *messages;\r
113      notmuch_message_t *message;\r
114      mime_node_t *node;\r
115 -    sprinter_t *sp;\r
116  \r
117      if (notmuch_query_count_messages (query) != 1) {\r
118         fprintf (stderr, "Error: search term did not match precisely one message.\n");\r
119 @@ -613,18 +614,17 @@ notmuch_reply_format_json(void *ctx,\r
120      if (!reply)\r
121         return 1;\r
122  \r
123 -    sp = sprinter_json_create (ctx, stdout);\r
124      sp->begin_map (sp);\r
125  \r
126      /* The headers of the reply message we've created */\r
127      sp->map_key (sp, "reply-headers");\r
128 -    format_headers_json (sp, reply, TRUE);\r
129 +    format_headers_sprinter (sp, reply, TRUE);\r
130      g_object_unref (G_OBJECT (reply));\r
131      reply = NULL;\r
132  \r
133      /* Start the original */\r
134      sp->map_key (sp, "original");\r
135 -    format_part_json (ctx, sp, node, TRUE, TRUE);\r
136 +    format_part_sprinter (ctx, sp, node, TRUE, TRUE);\r
137  \r
138      /* End */\r
139      sp->end (sp);\r
140 @@ -639,7 +639,8 @@ notmuch_reply_format_headers_only(void *ctx,\r
141                                   notmuch_config_t *config,\r
142                                   notmuch_query_t *query,\r
143                                   unused (notmuch_show_params_t *params),\r
144 -                                 notmuch_bool_t reply_all)\r
145 +                                 notmuch_bool_t reply_all,\r
146 +                                 unused (sprinter_t *sp))\r
147  {\r
148      GMimeMessage *reply;\r
149      notmuch_messages_t *messages;\r
150 @@ -707,7 +708,12 @@ notmuch_reply_command (void *ctx, int argc, char *argv[])\r
151      notmuch_query_t *query;\r
152      char *query_string;\r
153      int opt_index, ret = 0;\r
154 -    int (*reply_format_func)(void *ctx, notmuch_config_t *config, notmuch_query_t *query, notmuch_show_params_t *params, notmuch_bool_t reply_all);\r
155 +    int (*reply_format_func)(void *ctx,\r
156 +                            notmuch_config_t *config,\r
157 +                            notmuch_query_t *query,\r
158 +                            notmuch_show_params_t *params,\r
159 +                            notmuch_bool_t reply_all,\r
160 +                            struct sprinter *sp);\r
161      notmuch_show_params_t params = {\r
162         .part = -1,\r
163         .crypto = {\r
164 @@ -717,6 +723,7 @@ notmuch_reply_command (void *ctx, int argc, char *argv[])\r
165      };\r
166      int format = FORMAT_DEFAULT;\r
167      int reply_all = TRUE;\r
168 +    struct sprinter *sp = NULL;\r
169  \r
170      notmuch_opt_desc_t options[] = {\r
171         { NOTMUCH_OPT_KEYWORD, &format, "format", 'f',\r
172 @@ -738,12 +745,14 @@ notmuch_reply_command (void *ctx, int argc, char *argv[])\r
173         return 1;\r
174      }\r
175  \r
176 -    if (format == FORMAT_HEADERS_ONLY)\r
177 +    if (format == FORMAT_HEADERS_ONLY) {\r
178         reply_format_func = notmuch_reply_format_headers_only;\r
179 -    else if (format == FORMAT_JSON)\r
180 -       reply_format_func = notmuch_reply_format_json;\r
181 -    else\r
182 +    } else if (format == FORMAT_JSON) {\r
183 +       reply_format_func = notmuch_reply_format_sprinter;\r
184 +       sp = sprinter_json_create (ctx, stdout);\r
185 +    } else {\r
186         reply_format_func = notmuch_reply_format_default;\r
187 +    }\r
188  \r
189      config = notmuch_config_open (ctx, NULL, NULL);\r
190      if (config == NULL)\r
191 @@ -770,7 +779,7 @@ notmuch_reply_command (void *ctx, int argc, char *argv[])\r
192         return 1;\r
193      }\r
194  \r
195 -    if (reply_format_func (ctx, config, query, &params, reply_all) != 0)\r
196 +    if (reply_format_func (ctx, config, query, &params, reply_all, sp) != 0)\r
197         return 1;\r
198  \r
199      notmuch_crypto_cleanup (&params.crypto);\r
200 diff --git a/notmuch-show.c b/notmuch-show.c\r
201 index 2fa2292..38c621f 100644\r
202 --- a/notmuch-show.c\r
203 +++ b/notmuch-show.c\r
204 @@ -32,12 +32,12 @@ static const notmuch_show_format_t format_text = {\r
205  };\r
206  \r
207  static notmuch_status_t\r
208 -format_part_json_entry (const void *ctx, sprinter_t *sp, mime_node_t *node,\r
209 +format_part_sprinter_entry (const void *ctx, sprinter_t *sp, mime_node_t *node,\r
210                         int indent, const notmuch_show_params_t *params);\r
211  \r
212  static const notmuch_show_format_t format_json = {\r
213      .new_sprinter = sprinter_json_create,\r
214 -    .part = format_part_json_entry,\r
215 +    .part = format_part_sprinter_entry,\r
216  };\r
217  \r
218  static notmuch_status_t\r
219 @@ -108,7 +108,7 @@ _get_one_line_summary (const void *ctx, notmuch_message_t *message)\r
220  /* Emit a sequence of key/value pairs for the metadata of message.\r
221   * The caller should begin a map before calling this. */\r
222  static void\r
223 -format_message_json (sprinter_t *sp, notmuch_message_t *message)\r
224 +format_message_sprinter (sprinter_t *sp, notmuch_message_t *message)\r
225  {\r
226      /* Any changes to the JSON format should be reflected in the file\r
227       * devel/schemata. */\r
228 @@ -208,7 +208,7 @@ _is_from_line (const char *line)\r
229  }\r
230  \r
231  void\r
232 -format_headers_json (sprinter_t *sp, GMimeMessage *message,\r
233 +format_headers_sprinter (sprinter_t *sp, GMimeMessage *message,\r
234                      notmuch_bool_t reply)\r
235  {\r
236      /* Any changes to the JSON format should be reflected in the file\r
237 @@ -363,7 +363,7 @@ signer_status_to_string (GMimeSignerStatus x)\r
238  \r
239  #ifdef GMIME_ATLEAST_26\r
240  static void\r
241 -format_part_sigstatus_json (sprinter_t *sp, mime_node_t *node)\r
242 +format_part_sigstatus_sprinter (sprinter_t *sp, mime_node_t *node)\r
243  {\r
244      /* Any changes to the JSON format should be reflected in the file\r
245       * devel/schemata. */\r
246 @@ -438,7 +438,7 @@ format_part_sigstatus_json (sprinter_t *sp, mime_node_t *node)\r
247  }\r
248  #else\r
249  static void\r
250 -format_part_sigstatus_json (sprinter_t *sp, mime_node_t *node)\r
251 +format_part_sigstatus_sprinter (sprinter_t *sp, mime_node_t *node)\r
252  {\r
253      const GMimeSignatureValidity* validity = node->sig_validity;\r
254  \r
255 @@ -595,7 +595,7 @@ format_part_text (const void *ctx, sprinter_t *sp, mime_node_t *node,\r
256  }\r
257  \r
258  void\r
259 -format_part_json (const void *ctx, sprinter_t *sp, mime_node_t *node,\r
260 +format_part_sprinter (const void *ctx, sprinter_t *sp, mime_node_t *node,\r
261                   notmuch_bool_t first, notmuch_bool_t output_body)\r
262  {\r
263      /* Any changes to the JSON format should be reflected in the file\r
264 @@ -603,15 +603,15 @@ format_part_json (const void *ctx, sprinter_t *sp, mime_node_t *node,\r
265  \r
266      if (node->envelope_file) {\r
267         sp->begin_map (sp);\r
268 -       format_message_json (sp, node->envelope_file);\r
269 +       format_message_sprinter (sp, node->envelope_file);\r
270  \r
271         sp->map_key (sp, "headers");\r
272 -       format_headers_json (sp, GMIME_MESSAGE (node->part), FALSE);\r
273 +       format_headers_sprinter (sp, GMIME_MESSAGE (node->part), FALSE);\r
274  \r
275         if (output_body) {\r
276             sp->map_key (sp, "body");\r
277             sp->begin_list (sp);\r
278 -           format_part_json (ctx, sp, mime_node_child (node, 0), first, TRUE);\r
279 +           format_part_sprinter (ctx, sp, mime_node_child (node, 0), first, TRUE);\r
280             sp->end (sp);\r
281         }\r
282         sp->end (sp);\r
283 @@ -646,7 +646,7 @@ format_part_json (const void *ctx, sprinter_t *sp, mime_node_t *node,\r
284  \r
285      if (node->verify_attempted) {\r
286         sp->map_key (sp, "sigstatus");\r
287 -       format_part_sigstatus_json (sp, node);\r
288 +       format_part_sigstatus_sprinter (sp, node);\r
289      }\r
290  \r
291      sp->map_key (sp, "content-type");\r
292 @@ -698,7 +698,7 @@ format_part_json (const void *ctx, sprinter_t *sp, mime_node_t *node,\r
293         sp->begin_map (sp);\r
294  \r
295         sp->map_key (sp, "headers");\r
296 -       format_headers_json (sp, GMIME_MESSAGE (node->part), FALSE);\r
297 +       format_headers_sprinter (sp, GMIME_MESSAGE (node->part), FALSE);\r
298  \r
299         sp->map_key (sp, "body");\r
300         sp->begin_list (sp);\r
301 @@ -706,7 +706,7 @@ format_part_json (const void *ctx, sprinter_t *sp, mime_node_t *node,\r
302      }\r
303  \r
304      for (i = 0; i < node->nchildren; i++)\r
305 -       format_part_json (ctx, sp, mime_node_child (node, i), i == 0, TRUE);\r
306 +       format_part_sprinter (ctx, sp, mime_node_child (node, i), i == 0, TRUE);\r
307  \r
308      /* Close content structures */\r
309      for (i = 0; i < nclose; i++)\r
310 @@ -716,11 +716,11 @@ format_part_json (const void *ctx, sprinter_t *sp, mime_node_t *node,\r
311  }\r
312  \r
313  static notmuch_status_t\r
314 -format_part_json_entry (const void *ctx, sprinter_t *sp,\r
315 +format_part_sprinter_entry (const void *ctx, sprinter_t *sp,\r
316                         mime_node_t *node, unused (int indent),\r
317                         const notmuch_show_params_t *params)\r
318  {\r
319 -    format_part_json (ctx, sp, node, TRUE, params->output_body);\r
320 +    format_part_sprinter (ctx, sp, node, TRUE, params->output_body);\r
321  \r
322      return NOTMUCH_STATUS_SUCCESS;\r
323  }\r
324 -- \r
325 1.8.0\r
326 \r