#!/usr/bin/env bash test_description='"notmuch address" in several variants' . $(dirname "$0")/test-lib.sh || exit 1 add_email_corpus test_begin_subtest "--output=sender" notmuch address --output=sender '*' >OUTPUT cat <EXPECTED François Boulogne Olivier Berger Chris Wilson Carl Worth Alexander Botero-Lowry Keith Packard Jjgod Jiang Rolland Santimano Jan Janak Stewart Smith Lars Kellogg-Stedman Alex Botero-Lowry Ingmar Vanhassel Aron Griffis Adrian Perez de Castro Israel Herraiz Mikhail Gusarov 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 <EXPECTED [{"name": "François Boulogne", "address": "boulogne.f@gmail.com", "name-addr": "François Boulogne "}, {"name": "Olivier Berger", "address": "olivier.berger@it-sudparis.eu", "name-addr": "Olivier Berger "}, {"name": "Chris Wilson", "address": "chris@chris-wilson.co.uk", "name-addr": "Chris Wilson "}, {"name": "Carl Worth", "address": "cworth@cworth.org", "name-addr": "Carl Worth "}, {"name": "Alexander Botero-Lowry", "address": "alex.boterolowry@gmail.com", "name-addr": "Alexander Botero-Lowry "}, {"name": "Keith Packard", "address": "keithp@keithp.com", "name-addr": "Keith Packard "}, {"name": "Jjgod Jiang", "address": "gzjjgod@gmail.com", "name-addr": "Jjgod Jiang "}, {"name": "Rolland Santimano", "address": "rollandsantimano@yahoo.com", "name-addr": "Rolland Santimano "}, {"name": "Jan Janak", "address": "jan@ryngle.com", "name-addr": "Jan Janak "}, {"name": "Stewart Smith", "address": "stewart@flamingspork.com", "name-addr": "Stewart Smith "}, {"name": "Lars Kellogg-Stedman", "address": "lars@seas.harvard.edu", "name-addr": "Lars Kellogg-Stedman "}, {"name": "Alex Botero-Lowry", "address": "alex.boterolowry@gmail.com", "name-addr": "Alex Botero-Lowry "}, {"name": "Ingmar Vanhassel", "address": "ingmar@exherbo.org", "name-addr": "Ingmar Vanhassel "}, {"name": "Aron Griffis", "address": "agriffis@n01se.net", "name-addr": "Aron Griffis "}, {"name": "Adrian Perez de Castro", "address": "aperez@igalia.com", "name-addr": "Adrian Perez de Castro "}, {"name": "Israel Herraiz", "address": "isra@herraiz.org", "name-addr": "Israel Herraiz "}, {"name": "Mikhail Gusarov", "address": "dottedmag@dottedmag.net", "name-addr": "Mikhail Gusarov "}] EOF test_expect_equal_file EXPECTED OUTPUT test_begin_subtest "--output=recipients" notmuch address --output=recipients '*' >OUTPUT cat <EXPECTED Allan McRae "Discussion about the Arch User Repository (AUR)" olivier.berger@it-sudparis.eu notmuch@notmuchmail.org notmuch Keith Packard Mikhail Gusarov EOF test_expect_equal_file EXPECTED OUTPUT test_begin_subtest "--output=sender --output=recipients" notmuch address --output=sender --output=recipients '*' >OUTPUT cat <EXPECTED François Boulogne Allan McRae "Discussion about the Arch User Repository (AUR)" Olivier Berger olivier.berger@it-sudparis.eu Chris Wilson notmuch@notmuchmail.org Carl Worth Alexander Botero-Lowry Keith Packard Jjgod Jiang Rolland Santimano Jan Janak Stewart Smith Lars Kellogg-Stedman notmuch Alex Botero-Lowry Ingmar Vanhassel Aron Griffis Adrian Perez de Castro Israel Herraiz Mikhail Gusarov EOF test_expect_equal_file EXPECTED OUTPUT test_begin_subtest "--output=sender --output=count" notmuch address --output=sender --output=count '*' | sort -n >OUTPUT cat <EXPECTED 1 Adrian Perez de Castro 1 Aron Griffis 1 Chris Wilson 1 François Boulogne 1 Ingmar Vanhassel 1 Israel Herraiz 1 Olivier Berger 1 Rolland Santimano 2 Alex Botero-Lowry 2 Jjgod Jiang 3 Stewart Smith 4 Alexander Botero-Lowry 4 Jan Janak 5 Lars Kellogg-Stedman 5 Mikhail Gusarov 7 Keith Packard 12 Carl Worth 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 <EXPECTED {"name": "Adrian Perez de Castro", "address": "aperez@igalia.com", "name-addr": "Adrian Perez de Castro ", "count": 1} {"name": "Alex Botero-Lowry", "address": "alex.boterolowry@gmail.com", "name-addr": "Alex Botero-Lowry ", "count": 2} {"name": "Alexander Botero-Lowry", "address": "alex.boterolowry@gmail.com", "name-addr": "Alexander Botero-Lowry ", "count": 4} {"name": "Aron Griffis", "address": "agriffis@n01se.net", "name-addr": "Aron Griffis ", "count": 1} {"name": "Carl Worth", "address": "cworth@cworth.org", "name-addr": "Carl Worth ", "count": 12} {"name": "Chris Wilson", "address": "chris@chris-wilson.co.uk", "name-addr": "Chris Wilson ", "count": 1} {"name": "François Boulogne", "address": "boulogne.f@gmail.com", "name-addr": "François Boulogne ", "count": 1} {"name": "Ingmar Vanhassel", "address": "ingmar@exherbo.org", "name-addr": "Ingmar Vanhassel ", "count": 1} {"name": "Israel Herraiz", "address": "isra@herraiz.org", "name-addr": "Israel Herraiz ", "count": 1} {"name": "Jan Janak", "address": "jan@ryngle.com", "name-addr": "Jan Janak ", "count": 4} {"name": "Jjgod Jiang", "address": "gzjjgod@gmail.com", "name-addr": "Jjgod Jiang ", "count": 2} {"name": "Keith Packard", "address": "keithp@keithp.com", "name-addr": "Keith Packard ", "count": 7} {"name": "Lars Kellogg-Stedman", "address": "lars@seas.harvard.edu", "name-addr": "Lars Kellogg-Stedman ", "count": 5} {"name": "Mikhail Gusarov", "address": "dottedmag@dottedmag.net", "name-addr": "Mikhail Gusarov ", "count": 5} {"name": "Olivier Berger", "address": "olivier.berger@it-sudparis.eu", "name-addr": "Olivier Berger ", "count": 1} {"name": "Rolland Santimano", "address": "rollandsantimano@yahoo.com", "name-addr": "Rolland Santimano ", "count": 1} {"name": "Stewart Smith", "address": "stewart@flamingspork.com", "name-addr": "Stewart Smith ", "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 <EXPECTED Mikhail Gusarov Mikhail Gusarov Carl Worth Lars Kellogg-Stedman Mikhail Gusarov Alex Botero-Lowry Carl Worth Lars Kellogg-Stedman Mikhail Gusarov Mikhail Gusarov Keith Packard Keith Packard Keith Packard Jan Janak Jan Janak Jan Janak Israel Herraiz Adrian Perez de Castro Aron Griffis Ingmar Vanhassel Alex Botero-Lowry Lars Kellogg-Stedman Lars Kellogg-Stedman Lars Kellogg-Stedman Stewart Smith Stewart Smith Keith Packard Keith Packard Keith Packard Stewart Smith Jjgod Jiang Jan Janak Rolland Santimano Alexander Botero-Lowry Jjgod Jiang Alexander Botero-Lowry Alexander Botero-Lowry Keith Packard Alexander Botero-Lowry Carl Worth Carl Worth Carl Worth Carl Worth Carl Worth Carl Worth Carl Worth Carl Worth Carl Worth Carl Worth Chris Wilson Olivier Berger François Boulogne 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 <EXPECTED Mikhail Gusarov notmuch@notmuchmail.org Mikhail Gusarov notmuch@notmuchmail.org Lars Kellogg-Stedman 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 <EXPECTED "Discussion about the Arch User Repository (AUR)" Adrian Perez de Castro Alexander Botero-Lowry Allan McRae Aron Griffis Carl Worth Chris Wilson François Boulogne Ingmar Vanhassel Israel Herraiz Jan Janak Jjgod Jiang Keith Packard Lars Kellogg-Stedman Mikhail Gusarov Olivier Berger Rolland Santimano Stewart Smith notmuch@notmuchmail.org EOF test_expect_equal_file EXPECTED OUTPUT generate_message '[from]="Foo Bar "' generate_message '[from]="Foo Bar "' generate_message '[from]="Foo Bar "' generate_message '[from]="Bar "' generate_message '[from]="Foo "' generate_message '[from]=""' generate_message '[from]="foo.bar@example.com"' generate_message '[from]="Baz "' generate_message '[from]="Foo Bar "' generate_message '[from]="Baz "' notmuch new > /dev/null test_begin_subtest "--deduplicate=no --output=sender" notmuch address --deduplicate=no --output=sender from:example.com | sort >OUTPUT cat <EXPECTED Bar Baz Baz Foo Foo Bar Foo Bar Foo Bar Foo Bar 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 <EXPECTED 1 Bar 1 Foo 1 Foo Bar 1 Foo Bar 2 Baz 2 Foo Bar 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 <EXPECTED 3 Baz 7 Foo Bar EOF test_expect_equal_file EXPECTED OUTPUT test_done