unofficial mirror of notmuch@notmuchmail.org
 help / color / mirror / code / Atom feed
blob 5931b1475e0b3d7358d84c2692dee3b72f2af517 13769 bytes (raw)
name: test/T095-address.sh 	 # note: path name is non-authoritative(*)

  1
  2
  3
  4
  5
  6
  7
  8
  9
 10
 11
 12
 13
 14
 15
 16
 17
 18
 19
 20
 21
 22
 23
 24
 25
 26
 27
 28
 29
 30
 31
 32
 33
 34
 35
 36
 37
 38
 39
 40
 41
 42
 43
 44
 45
 46
 47
 48
 49
 50
 51
 52
 53
 54
 55
 56
 57
 58
 59
 60
 61
 62
 63
 64
 65
 66
 67
 68
 69
 70
 71
 72
 73
 74
 75
 76
 77
 78
 79
 80
 81
 82
 83
 84
 85
 86
 87
 88
 89
 90
 91
 92
 93
 94
 95
 96
 97
 98
 99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
 
#!/usr/bin/env bash
test_description='"notmuch address" in several variants'
. ./test-lib.sh || exit 1

add_email_corpus

test_begin_subtest "--output=sender"
notmuch address --output=sender '*' >OUTPUT
cat <<EOF >EXPECTED
François Boulogne <boulogne.f@gmail.com>
Olivier Berger <olivier.berger@it-sudparis.eu>
Chris Wilson <chris@chris-wilson.co.uk>
Carl Worth <cworth@cworth.org>
Alexander Botero-Lowry <alex.boterolowry@gmail.com>
Keith Packard <keithp@keithp.com>
Jjgod Jiang <gzjjgod@gmail.com>
Rolland Santimano <rollandsantimano@yahoo.com>
Jan Janak <jan@ryngle.com>
Stewart Smith <stewart@flamingspork.com>
Lars Kellogg-Stedman <lars@seas.harvard.edu>
Alex Botero-Lowry <alex.boterolowry@gmail.com>
Ingmar Vanhassel <ingmar@exherbo.org>
Aron Griffis <agriffis@n01se.net>
Adrian Perez de Castro <aperez@igalia.com>
Israel Herraiz <isra@herraiz.org>
Mikhail Gusarov <dottedmag@dottedmag.net>
EOF
test_expect_equal_file EXPECTED OUTPUT

test_begin_subtest "without --output"
notmuch address '*' >OUTPUT
# Use EXPECTED from previous subtest
test_expect_equal_file EXPECTED OUTPUT

test_begin_subtest "--output=sender --format=json"
notmuch address --output=sender --format=json '*' >OUTPUT
cat <<EOF >EXPECTED
[{"name": "François Boulogne", "address": "boulogne.f@gmail.com", "name-addr": "François Boulogne <boulogne.f@gmail.com>"},
{"name": "Olivier Berger", "address": "olivier.berger@it-sudparis.eu", "name-addr": "Olivier Berger <olivier.berger@it-sudparis.eu>"},
{"name": "Chris Wilson", "address": "chris@chris-wilson.co.uk", "name-addr": "Chris Wilson <chris@chris-wilson.co.uk>"},
{"name": "Carl Worth", "address": "cworth@cworth.org", "name-addr": "Carl Worth <cworth@cworth.org>"},
{"name": "Alexander Botero-Lowry", "address": "alex.boterolowry@gmail.com", "name-addr": "Alexander Botero-Lowry <alex.boterolowry@gmail.com>"},
{"name": "Keith Packard", "address": "keithp@keithp.com", "name-addr": "Keith Packard <keithp@keithp.com>"},
{"name": "Jjgod Jiang", "address": "gzjjgod@gmail.com", "name-addr": "Jjgod Jiang <gzjjgod@gmail.com>"},
{"name": "Rolland Santimano", "address": "rollandsantimano@yahoo.com", "name-addr": "Rolland Santimano <rollandsantimano@yahoo.com>"},
{"name": "Jan Janak", "address": "jan@ryngle.com", "name-addr": "Jan Janak <jan@ryngle.com>"},
{"name": "Stewart Smith", "address": "stewart@flamingspork.com", "name-addr": "Stewart Smith <stewart@flamingspork.com>"},
{"name": "Lars Kellogg-Stedman", "address": "lars@seas.harvard.edu", "name-addr": "Lars Kellogg-Stedman <lars@seas.harvard.edu>"},
{"name": "Alex Botero-Lowry", "address": "alex.boterolowry@gmail.com", "name-addr": "Alex Botero-Lowry <alex.boterolowry@gmail.com>"},
{"name": "Ingmar Vanhassel", "address": "ingmar@exherbo.org", "name-addr": "Ingmar Vanhassel <ingmar@exherbo.org>"},
{"name": "Aron Griffis", "address": "agriffis@n01se.net", "name-addr": "Aron Griffis <agriffis@n01se.net>"},
{"name": "Adrian Perez de Castro", "address": "aperez@igalia.com", "name-addr": "Adrian Perez de Castro <aperez@igalia.com>"},
{"name": "Israel Herraiz", "address": "isra@herraiz.org", "name-addr": "Israel Herraiz <isra@herraiz.org>"},
{"name": "Mikhail Gusarov", "address": "dottedmag@dottedmag.net", "name-addr": "Mikhail Gusarov <dottedmag@dottedmag.net>"}]
EOF
test_expect_equal_file EXPECTED OUTPUT

test_begin_subtest "--output=recipients"
notmuch address --output=recipients '*' >OUTPUT
cat <<EOF >EXPECTED
Allan McRae <allan@archlinux.org>
"Discussion about the Arch User Repository (AUR)" <aur-general@archlinux.org>
olivier.berger@it-sudparis.eu
notmuch@notmuchmail.org
notmuch <notmuch@notmuchmail.org>
Keith Packard <keithp@keithp.com>
Mikhail Gusarov <dottedmag@dottedmag.net>
EOF
test_expect_equal_file EXPECTED OUTPUT

test_begin_subtest "--output=sender --output=recipients"
notmuch address --output=sender --output=recipients '*' >OUTPUT
cat <<EOF >EXPECTED
François Boulogne <boulogne.f@gmail.com>
Allan McRae <allan@archlinux.org>
"Discussion about the Arch User Repository (AUR)" <aur-general@archlinux.org>
Olivier Berger <olivier.berger@it-sudparis.eu>
olivier.berger@it-sudparis.eu
Chris Wilson <chris@chris-wilson.co.uk>
notmuch@notmuchmail.org
Carl Worth <cworth@cworth.org>
Alexander Botero-Lowry <alex.boterolowry@gmail.com>
Keith Packard <keithp@keithp.com>
Jjgod Jiang <gzjjgod@gmail.com>
Rolland Santimano <rollandsantimano@yahoo.com>
Jan Janak <jan@ryngle.com>
Stewart Smith <stewart@flamingspork.com>
Lars Kellogg-Stedman <lars@seas.harvard.edu>
notmuch <notmuch@notmuchmail.org>
Alex Botero-Lowry <alex.boterolowry@gmail.com>
Ingmar Vanhassel <ingmar@exherbo.org>
Aron Griffis <agriffis@n01se.net>
Adrian Perez de Castro <aperez@igalia.com>
Israel Herraiz <isra@herraiz.org>
Mikhail Gusarov <dottedmag@dottedmag.net>
EOF
test_expect_equal_file EXPECTED OUTPUT

test_begin_subtest "--output=sender --output=count"
notmuch address --output=sender --output=count '*' | sort -n >OUTPUT
cat <<EOF >EXPECTED
1	Adrian Perez de Castro <aperez@igalia.com>
1	Aron Griffis <agriffis@n01se.net>
1	Chris Wilson <chris@chris-wilson.co.uk>
1	François Boulogne <boulogne.f@gmail.com>
1	Ingmar Vanhassel <ingmar@exherbo.org>
1	Israel Herraiz <isra@herraiz.org>
1	Olivier Berger <olivier.berger@it-sudparis.eu>
1	Rolland Santimano <rollandsantimano@yahoo.com>
2	Alex Botero-Lowry <alex.boterolowry@gmail.com>
2	Jjgod Jiang <gzjjgod@gmail.com>
3	Stewart Smith <stewart@flamingspork.com>
4	Alexander Botero-Lowry <alex.boterolowry@gmail.com>
4	Jan Janak <jan@ryngle.com>
5	Lars Kellogg-Stedman <lars@seas.harvard.edu>
5	Mikhail Gusarov <dottedmag@dottedmag.net>
7	Keith Packard <keithp@keithp.com>
12	Carl Worth <cworth@cworth.org>
EOF
test_expect_equal_file EXPECTED OUTPUT

test_begin_subtest "--output=count --format=json"
# Since the iteration order of GHashTable is not specified, we
# preprocess and sort the results to keep the order stable here.
notmuch address --output=count --format=json '*' | \
    sed -e 's/^\[//' -e 's/]$//' -e 's/,$//' | sort >OUTPUT
cat <<EOF >EXPECTED
{"name": "Adrian Perez de Castro", "address": "aperez@igalia.com", "name-addr": "Adrian Perez de Castro <aperez@igalia.com>", "count": 1}
{"name": "Alex Botero-Lowry", "address": "alex.boterolowry@gmail.com", "name-addr": "Alex Botero-Lowry <alex.boterolowry@gmail.com>", "count": 2}
{"name": "Alexander Botero-Lowry", "address": "alex.boterolowry@gmail.com", "name-addr": "Alexander Botero-Lowry <alex.boterolowry@gmail.com>", "count": 4}
{"name": "Aron Griffis", "address": "agriffis@n01se.net", "name-addr": "Aron Griffis <agriffis@n01se.net>", "count": 1}
{"name": "Carl Worth", "address": "cworth@cworth.org", "name-addr": "Carl Worth <cworth@cworth.org>", "count": 12}
{"name": "Chris Wilson", "address": "chris@chris-wilson.co.uk", "name-addr": "Chris Wilson <chris@chris-wilson.co.uk>", "count": 1}
{"name": "François Boulogne", "address": "boulogne.f@gmail.com", "name-addr": "François Boulogne <boulogne.f@gmail.com>", "count": 1}
{"name": "Ingmar Vanhassel", "address": "ingmar@exherbo.org", "name-addr": "Ingmar Vanhassel <ingmar@exherbo.org>", "count": 1}
{"name": "Israel Herraiz", "address": "isra@herraiz.org", "name-addr": "Israel Herraiz <isra@herraiz.org>", "count": 1}
{"name": "Jan Janak", "address": "jan@ryngle.com", "name-addr": "Jan Janak <jan@ryngle.com>", "count": 4}
{"name": "Jjgod Jiang", "address": "gzjjgod@gmail.com", "name-addr": "Jjgod Jiang <gzjjgod@gmail.com>", "count": 2}
{"name": "Keith Packard", "address": "keithp@keithp.com", "name-addr": "Keith Packard <keithp@keithp.com>", "count": 7}
{"name": "Lars Kellogg-Stedman", "address": "lars@seas.harvard.edu", "name-addr": "Lars Kellogg-Stedman <lars@seas.harvard.edu>", "count": 5}
{"name": "Mikhail Gusarov", "address": "dottedmag@dottedmag.net", "name-addr": "Mikhail Gusarov <dottedmag@dottedmag.net>", "count": 5}
{"name": "Olivier Berger", "address": "olivier.berger@it-sudparis.eu", "name-addr": "Olivier Berger <olivier.berger@it-sudparis.eu>", "count": 1}
{"name": "Rolland Santimano", "address": "rollandsantimano@yahoo.com", "name-addr": "Rolland Santimano <rollandsantimano@yahoo.com>", "count": 1}
{"name": "Stewart Smith", "address": "stewart@flamingspork.com", "name-addr": "Stewart Smith <stewart@flamingspork.com>", "count": 3}
EOF
test_expect_equal_file EXPECTED OUTPUT

test_begin_subtest "--deduplicate=no --sort=oldest-first --output=sender"
notmuch address --deduplicate=no --sort=oldest-first --output=sender '*' >OUTPUT
cat <<EOF >EXPECTED
Mikhail Gusarov <dottedmag@dottedmag.net>
Mikhail Gusarov <dottedmag@dottedmag.net>
Carl Worth <cworth@cworth.org>
Lars Kellogg-Stedman <lars@seas.harvard.edu>
Mikhail Gusarov <dottedmag@dottedmag.net>
Alex Botero-Lowry <alex.boterolowry@gmail.com>
Carl Worth <cworth@cworth.org>
Lars Kellogg-Stedman <lars@seas.harvard.edu>
Mikhail Gusarov <dottedmag@dottedmag.net>
Mikhail Gusarov <dottedmag@dottedmag.net>
Keith Packard <keithp@keithp.com>
Keith Packard <keithp@keithp.com>
Keith Packard <keithp@keithp.com>
Jan Janak <jan@ryngle.com>
Jan Janak <jan@ryngle.com>
Jan Janak <jan@ryngle.com>
Israel Herraiz <isra@herraiz.org>
Adrian Perez de Castro <aperez@igalia.com>
Aron Griffis <agriffis@n01se.net>
Ingmar Vanhassel <ingmar@exherbo.org>
Alex Botero-Lowry <alex.boterolowry@gmail.com>
Lars Kellogg-Stedman <lars@seas.harvard.edu>
Lars Kellogg-Stedman <lars@seas.harvard.edu>
Lars Kellogg-Stedman <lars@seas.harvard.edu>
Stewart Smith <stewart@flamingspork.com>
Stewart Smith <stewart@flamingspork.com>
Keith Packard <keithp@keithp.com>
Keith Packard <keithp@keithp.com>
Keith Packard <keithp@keithp.com>
Stewart Smith <stewart@flamingspork.com>
Jjgod Jiang <gzjjgod@gmail.com>
Jan Janak <jan@ryngle.com>
Rolland Santimano <rollandsantimano@yahoo.com>
Alexander Botero-Lowry <alex.boterolowry@gmail.com>
Jjgod Jiang <gzjjgod@gmail.com>
Alexander Botero-Lowry <alex.boterolowry@gmail.com>
Alexander Botero-Lowry <alex.boterolowry@gmail.com>
Keith Packard <keithp@keithp.com>
Alexander Botero-Lowry <alex.boterolowry@gmail.com>
Carl Worth <cworth@cworth.org>
Carl Worth <cworth@cworth.org>
Carl Worth <cworth@cworth.org>
Carl Worth <cworth@cworth.org>
Carl Worth <cworth@cworth.org>
Carl Worth <cworth@cworth.org>
Carl Worth <cworth@cworth.org>
Carl Worth <cworth@cworth.org>
Carl Worth <cworth@cworth.org>
Carl Worth <cworth@cworth.org>
Chris Wilson <chris@chris-wilson.co.uk>
Olivier Berger <olivier.berger@it-sudparis.eu>
François Boulogne <boulogne.f@gmail.com>
EOF
test_expect_equal_file EXPECTED OUTPUT

test_begin_subtest "--deduplicate=no --sort=newest-first --output=sender --output=recipients"
notmuch address --deduplicate=no --sort=newest-first --output=sender --output=recipients path:foo/new >OUTPUT
cat <<EOF >EXPECTED
Mikhail Gusarov <dottedmag@dottedmag.net>
notmuch@notmuchmail.org
Mikhail Gusarov <dottedmag@dottedmag.net>
notmuch@notmuchmail.org
Lars Kellogg-Stedman <lars@seas.harvard.edu>
notmuch@notmuchmail.org
EOF
test_expect_equal_file EXPECTED OUTPUT

test_begin_subtest "--deduplicate=address --output=sender --output=recipients"
notmuch address --deduplicate=address --output=sender --output=recipients '*' | sort >OUTPUT
cat <<EOF >EXPECTED
"Discussion about the Arch User Repository (AUR)" <aur-general@archlinux.org>
Adrian Perez de Castro <aperez@igalia.com>
Alexander Botero-Lowry <alex.boterolowry@gmail.com>
Allan McRae <allan@archlinux.org>
Aron Griffis <agriffis@n01se.net>
Carl Worth <cworth@cworth.org>
Chris Wilson <chris@chris-wilson.co.uk>
François Boulogne <boulogne.f@gmail.com>
Ingmar Vanhassel <ingmar@exherbo.org>
Israel Herraiz <isra@herraiz.org>
Jan Janak <jan@ryngle.com>
Jjgod Jiang <gzjjgod@gmail.com>
Keith Packard <keithp@keithp.com>
Lars Kellogg-Stedman <lars@seas.harvard.edu>
Mikhail Gusarov <dottedmag@dottedmag.net>
Olivier Berger <olivier.berger@it-sudparis.eu>
Rolland Santimano <rollandsantimano@yahoo.com>
Stewart Smith <stewart@flamingspork.com>
notmuch@notmuchmail.org
EOF
test_expect_equal_file EXPECTED OUTPUT

generate_message '[from]="Foo Bar <foo.bar@example.com>"'
generate_message '[from]="Foo Bar <Foo.Bar@Example.Com>"'
generate_message '[from]="Foo Bar <foo.bar@example.com>"'
generate_message '[from]="Bar <Foo.Bar@Example.Com>"'
generate_message '[from]="Foo <foo.bar@example.com>"'
generate_message '[from]="<foo.bar@example.com>"'
generate_message '[from]="foo.bar@example.com"'
generate_message '[from]="Baz <foo.bar+baz@example.com>"'
generate_message '[from]="Foo Bar <foo.bar+baz@example.com>"'
generate_message '[from]="Baz <foo.bar+baz@example.com>"'
notmuch new > /dev/null

test_begin_subtest "--deduplicate=no --output=sender"
notmuch address --deduplicate=no --output=sender from:example.com | sort >OUTPUT
cat <<EOF >EXPECTED
Bar <Foo.Bar@Example.Com>
Baz <foo.bar+baz@example.com>
Baz <foo.bar+baz@example.com>
Foo <foo.bar@example.com>
Foo Bar <Foo.Bar@Example.Com>
Foo Bar <foo.bar+baz@example.com>
Foo Bar <foo.bar@example.com>
Foo Bar <foo.bar@example.com>
foo.bar@example.com
foo.bar@example.com
EOF
test_expect_equal_file EXPECTED OUTPUT

test_begin_subtest "--deduplicate=mailbox --output=sender --output=count"
notmuch address --deduplicate=mailbox --output=sender --output=count from:example.com | sort -n >OUTPUT
cat <<EOF >EXPECTED
1	Bar <Foo.Bar@Example.Com>
1	Foo <foo.bar@example.com>
1	Foo Bar <Foo.Bar@Example.Com>
1	Foo Bar <foo.bar+baz@example.com>
2	Baz <foo.bar+baz@example.com>
2	Foo Bar <foo.bar@example.com>
2	foo.bar@example.com
EOF
test_expect_equal_file EXPECTED OUTPUT

test_begin_subtest "--deduplicate=address --output=sender --output=count"
notmuch address --deduplicate=address --output=sender --output=count from:example.com | sort -n >OUTPUT
cat <<EOF >EXPECTED
3	Baz <foo.bar+baz@example.com>
7	Foo Bar <foo.bar@example.com>
EOF
test_expect_equal_file EXPECTED OUTPUT

test_done

debug log:

solving 5931b147 ...
found 5931b147 in https://yhetil.org/notmuch.git/

(*) Git path names are given by the tree(s) the blob belongs to.
    Blobs themselves have no identifier aside from the hash of its contents.^

Code repositories for project(s) associated with this public inbox

	https://yhetil.org/notmuch.git/

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).