Return-Path: X-Original-To: notmuch@notmuchmail.org Delivered-To: notmuch@notmuchmail.org Received: from localhost (localhost [127.0.0.1]) by olra.theworths.org (Postfix) with ESMTP id CDCB540D16B for ; Sun, 31 Oct 2010 14:49:04 -0700 (PDT) X-Virus-Scanned: Debian amavisd-new at olra.theworths.org X-Spam-Flag: NO X-Spam-Score: -1.9 X-Spam-Level: X-Spam-Status: No, score=-1.9 tagged_above=-999 required=5 tests=[BAYES_00=-1.9] autolearn=unavailable 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 055PvEuhsgn7 for ; Sun, 31 Oct 2010 14:48:49 -0700 (PDT) Received: from smtp.nextra.cz (smtp.nextra.cz [212.65.193.3]) by olra.theworths.org (Postfix) with ESMTP id 7554240D16C for ; Sun, 31 Oct 2010 14:48:02 -0700 (PDT) Received: from resox.2x.cz (unknown [213.29.198.144]) by smtp.nextra.cz (Postfix) with ESMTP id A3D2188D35; Sun, 31 Oct 2010 22:30:36 +0100 (CET) Received: from wsh by resox.2x.cz with local (Exim 4.72) (envelope-from ) id 1PCfTu-0004wr-Dp; Sun, 31 Oct 2010 22:30:26 +0100 From: Michal Sojka To: notmuch@notmuchmail.org Subject: [PATCH v4 4/4] Tests for maildir synchronization Date: Sun, 31 Oct 2010 22:29:18 +0100 Message-Id: <1288560558-18915-5-git-send-email-sojkam1@fel.cvut.cz> X-Mailer: git-send-email 1.7.1 In-Reply-To: <87tyk3vpxd.fsf@wsheee.2x.cz> References: <87tyk3vpxd.fsf@wsheee.2x.cz> 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: Sun, 31 Oct 2010 21:49:05 -0000 Signed-off-by: Michal Sojka --- test/maildir-sync | 231 +++++++++++++++++++++++++++++++++++++++++++++++++++++ test/notmuch-test | 2 +- test/test-lib.sh | 14 +++- 3 files changed, 244 insertions(+), 3 deletions(-) create mode 100755 test/maildir-sync diff --git a/test/maildir-sync b/test/maildir-sync new file mode 100755 index 0000000..23d612e --- /dev/null +++ b/test/maildir-sync @@ -0,0 +1,231 @@ +#!/bin/bash + +test_description="Test maildir synchronization" + +. ./test-lib.sh + +filter_show() { + sed -e 's/, /,\n/g'|sed -e "s|${MAIL_DIR}/||" -e '/^"tags"/d' + echo +} + +cat >> "$NOTMUCH_CONFIG" < expected < actual && +test_cmp expected actual +#emacs --eval "(gdb \"gdb --annotate=3 --args $(which notmuch) new\")" +' +cat > expected < actual && +test_cmp expected actual +' +cat > expected < actual && +test_cmp expected actual +' +cat > expected < actual && +test_cmp expected actual +' +cat > expected < actual && +test_cmp expected actual +' +cat > expected < actual && +test_cmp expected actual +' +test_expect_success 'Tag the seen messages as replied' ' +notmuch tag +replied -inbox tag:inbox and not tag:unread +' + +cat > expected < actual && +test_cmp expected actual +' +cat < show-expected +[[[{"id": "msg-001@notmuch-test-suite", +"match": true, +"filename": "msg-001:2,RS", +"timestamp": 946728000, +"date_relative": "2000-01-01", +"headers": {"Subject": "test message", +"From": "Notmuch Test Suite ", +"To": "Notmuch Test Suite ", +"Cc": "", +"Bcc": "", +"Date": "Sat, +01 Jan 2000 12:00:00 -0000"}, +"body": [{"id": 1, +"content-type": "text/plain", +"content": "This is just a test message (#1)\n"}]}, +[]]]] +EOF + +test_expect_success 'Message renamed due to changed flags can be shown without running notmuch new' ' +notmuch show --format=json id:msg-001@notmuch-test-suite | filter_show > show-actual && +test_cmp show-expected show-actual +' + +test_expect_success 'Test that we can reply to the renamed message' ' +notmuch reply id:msg-001@notmuch-test-suite +' + +echo "No new mail." > expected +test_expect_success 'No rename should be detected by notmuch new' ' +increment_mtime "$(dirname "${gen_msg_filename}")" && +notmuch new > actual && +test_cmp expected actual +' +test_expect_success "Add a message to new/ without info" ' +generate_message [subject]="\"test message 3\"" [date]="\"Sat, 01 Jan 2000 12:00:00 -0000\"" [dir]=new && +NOTMUCH_NEW > actual && +test_cmp - actual < actual && +test_cmp - actual < expected && +notmuch show id:$gen_msg_id|grep -o "filename:.*$" > actual && +test_cmp expected actual && +test -f "$gen_msg_filename" +' +test_expect_success "Check that the message was not renamed" ' +ls "${MAIL_DIR}/new" > actual && +test_cmp - actual < actual && +test_cmp - actual < actual && +test_cmp - actual < actual && +test_cmp - actual < actual +test_cmp - actual < actual && +test_cmp - actual < actual && +test_cmp - actual < actual && +test_cmp - actual < actual && +test_cmp - actual < expected && +mv $MAIL_DIR/msg-001:2,RS $MAIL_DIR/msg-001:2, && +mv $MAIL_DIR/msg-002:2,RS $MAIL_DIR/msg-002:2, && +increment_mtime $MAIL_DIR +' + +test_expect_success 'Test whether dump/new/restore synchronizes the maildir flags with the database' ' +notmuch dump dump.txt && +notmuch new && +notmuch restore dump.txt && +ls $MAIL_DIR > actual && +test_cmp expected actual +' + +test_done diff --git a/test/notmuch-test b/test/notmuch-test index 60c3ecb..3691f0d 100755 --- a/test/notmuch-test +++ b/test/notmuch-test @@ -16,7 +16,7 @@ fi cd $(dirname "$0") -TESTS="basic new search json thread-naming reply dump-restore uuencode thread-order author-order from-guessing long-id encoding emacs" +TESTS="basic new search json thread-naming reply dump-restore uuencode thread-order author-order from-guessing long-id encoding emacs maildir-sync" # Clean up any results from a previous run rm -r test-results >/dev/null 2>/dev/null diff --git a/test/test-lib.sh b/test/test-lib.sh index 8f39aa7..43a1314 100644 --- a/test/test-lib.sh +++ b/test/test-lib.sh @@ -245,6 +245,12 @@ increment_mtime () # Generate the message in directory 'directory/of/choice' within # the mail store. The directory will be created if necessary. # +# [filename]=name +# +# Store the message in file 'name'. The default is to store it +# in 'msg-', where is three-digit number of the +# message. +# # [body]=text # # Text to use as the body of the email message @@ -281,10 +287,14 @@ generate_message () local additional_headers gen_msg_cnt=$((gen_msg_cnt + 1)) - gen_msg_name=msg-$(printf "%03d" $gen_msg_cnt) + if [ -z "${template[filename]}" ]; then + gen_msg_name="msg-$(printf "%03d" $gen_msg_cnt)" + else + gen_msg_name=${template[filename]} + fi if [ -z "${template[id]}" ]; then - gen_msg_id="${gen_msg_name}@notmuch-test-suite" + gen_msg_id="${gen_msg_name%:2,*}@notmuch-test-suite" else gen_msg_id="${template[id]}" fi -- 1.7.1