From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from localhost (localhost [127.0.0.1]) by olra.theworths.org (Postfix) with ESMTP id 20F1A431FD0 for ; Thu, 29 Sep 2011 10:37:24 -0700 (PDT) X-Virus-Scanned: Debian amavisd-new at olra.theworths.org X-Spam-Flag: NO X-Spam-Score: 0 X-Spam-Level: X-Spam-Status: No, score=0 tagged_above=-999 required=5 tests=[RCVD_IN_DNSWL_NONE=-0.0001] autolearn=disabled Received: from olra.theworths.org ([127.0.0.1]) by localhost (olra.theworths.org [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id qn+LuFcffirk for ; Thu, 29 Sep 2011 10:37:23 -0700 (PDT) Received: from smtprelay02.ispgateway.de (smtprelay02.ispgateway.de [80.67.31.29]) by olra.theworths.org (Postfix) with ESMTP id 0D9A1431FB6 for ; Thu, 29 Sep 2011 10:37:23 -0700 (PDT) Received: from [87.180.87.168] (helo=stokes.schwinge.homeip.net) by smtprelay02.ispgateway.de with esmtpa (Exim 4.68) (envelope-from ) id 1R9KXw-00081v-IR for notmuch@notmuchmail.org; Thu, 29 Sep 2011 19:37:20 +0200 Received: (qmail 24609 invoked from network); 29 Sep 2011 17:37:14 -0000 Received: from kepler.schwinge.homeip.net (192.168.111.7) by stokes.schwinge.homeip.net with QMQP; 29 Sep 2011 17:37:14 -0000 Received: (nullmailer pid 29574 invoked by uid 1000); Thu, 29 Sep 2011 17:37:13 -0000 From: Thomas Schwinge To: notmuch@notmuchmail.org Subject: [PATCH, v2] notmuch restore --accumulate Date: Thu, 29 Sep 2011 19:36:51 +0200 Message-Id: <1317317811-29540-1-git-send-email-thomas@schwinge.name> X-Mailer: git-send-email 1.7.5.4 In-Reply-To: <1315249637-20179-1-git-send-email-thomas@schwinge.name> References: <1315249637-20179-1-git-send-email-thomas@schwinge.name> X-Df-Sender: dGhvbWFzQHNjaHdpbmdlLm5hbWU= X-BeenThere: notmuch@notmuchmail.org X-Mailman-Version: 2.1.13 Precedence: list List-Id: "Use and development of the notmuch mail system." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 29 Sep 2011 17:37:24 -0000 From: Thomas Schwinge Flesh out what ``notmuch restore --accumulate'' is supposed to do. Its tests are currently XFAILed; the functionality will be added in another patch. Also generally enhance the dump-restore testsuite, and make it more failure-proof. --- test/dump-restore | 77 ++++++++++++++++++++++++++++++++++++++++++----------- test/test-lib.sh | 3 +- 2 files changed, 63 insertions(+), 17 deletions(-) diff --git a/test/dump-restore b/test/dump-restore index a4de370..d253756 100755 --- a/test/dump-restore +++ b/test/dump-restore @@ -4,21 +4,66 @@ test_description="\"notmuch dump\" and \"notmuch restore\"" add_email_corpus -test_expect_success "Dumping all tags" "generate_message && -notmuch new && -notmuch dump dump.expected" - -test_begin_subtest "Clearing all tags" -sed -e "s/(\([^(]*\))$/()/" < dump.expected > clear.expected -notmuch restore clear.expected -notmuch dump clear.actual -test_expect_equal "$(< clear.actual)" "$(< clear.expected)" - -test_begin_subtest "Restoring original tags" -notmuch restore dump.expected -notmuch dump dump.actual -test_expect_equal "$(< dump.actual)" "$(< dump.expected)" - -test_expect_success "Restore with nothing to do" "notmuch restore dump.expected" +test_expect_success 'Dumping all tags' \ + 'generate_message && + notmuch new && + notmuch dump dump.expected' + +# This is rather arbitrary: it matches some of the email corpus' messages, but +# not all of them. +search_term=from:worth + +test_expect_success 'Dumping all tags to stdout' \ + 'notmuch tag +ABC +DEF -- $search_term && + notmuch dump > dump-ABC_DEF.expected && + ! cmp dump.expected dump-ABC_DEF.expected' + +test_expect_success 'Clearing all tags' \ + 'sed -e "s/(\([^(]*\))$/()/" < dump.expected > clear.expected && + notmuch restore clear.expected && + notmuch dump clear.actual && + test_cmp clear.expected clear.actual' + +# Missing notmuch restore --accumulate. +test_subtest_known_broken +test_expect_success 'Accumulate original tags' \ + 'notmuch tag +ABC +DEF -- $search_term && + notmuch restore --accumulate < dump.expected && + notmuch dump dump.actual && + test_cmp dump-ABC_DEF.expected dump.actual' + +test_expect_success 'Restoring original tags' \ + 'notmuch restore dump.expected && + notmuch dump dump.actual && + test_cmp dump.expected dump.actual' + +test_expect_success 'Restore with nothing to do' \ + 'notmuch restore < dump.expected && + notmuch dump > dump.actual && + test_cmp dump.expected dump.actual' + +# Missing notmuch restore --accumulate. +test_subtest_known_broken +test_expect_success 'Restore with nothing to do, II' \ + 'notmuch restore --accumulate dump.expected && + notmuch dump dump.actual && + test_cmp dump.expected dump.actual' + +# Missing notmuch restore --accumulate. +test_subtest_known_broken +test_expect_success 'Restore with nothing to do, III' \ + 'notmuch restore --accumulate < clear.expected && + notmuch dump dump.actual && + test_cmp dump.expected dump.actual' + +# notmuch restore currently only considers the first argument. +test_subtest_known_broken +test_expect_success 'Invalid restore invocation' \ + 'test_must_fail notmuch restore dump.expected another_one' + +# The follwing test already succeeds due to notmuch restore currently only +# considering the first argument. +test_expect_success 'Invalid restore invocation, II' \ + 'test_must_fail notmuch restore --accumulate dump.expected another_one' test_done diff --git a/test/test-lib.sh b/test/test-lib.sh index f8df6a5..f524ebf 100755 --- a/test/test-lib.sh +++ b/test/test-lib.sh @@ -462,6 +462,7 @@ test_expect_equal () fi } +# Like test_expect_equal, but takes two filenames. test_expect_equal_file () { exec 1>&6 2>&7 # Restore stdout and stderr @@ -724,7 +725,7 @@ test_external_without_stderr () { fi } -# This is not among top-level (test_expect_success | test_expect_failure) +# This is not among top-level (test_expect_success) # but is a prefix that can be used in the test script, like: # # test_expect_success 'complain and die' ' -- tg: (f63d605..) t/restore-accumulate-test (depends on: master)