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 8C8F0431FB6 for ; Sun, 18 Mar 2012 10:23:08 -0700 (PDT) X-Virus-Scanned: Debian amavisd-new at olra.theworths.org X-Spam-Flag: NO X-Spam-Score: 0.201 X-Spam-Level: X-Spam-Status: No, score=0.201 tagged_above=-999 required=5 tests=[DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, FREEMAIL_ENVFROM_END_DIGIT=1, FREEMAIL_FROM=0.001, RCVD_IN_DNSWL_LOW=-0.7] 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 hfMv+QflixxX for ; Sun, 18 Mar 2012 10:23:07 -0700 (PDT) Received: from mail-we0-f181.google.com (mail-we0-f181.google.com [74.125.82.181]) (using TLSv1 with cipher RC4-SHA (128/128 bits)) (No client certificate requested) by olra.theworths.org (Postfix) with ESMTPS id 286DA431FAF for ; Sun, 18 Mar 2012 10:23:07 -0700 (PDT) Received: by werm13 with SMTP id m13so6039192wer.26 for ; Sun, 18 Mar 2012 10:23:04 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=from:to:cc:subject:date:message-id:x-mailer:in-reply-to:references; bh=mwnElj3aj0E3OAL7/9S79Dkzml/fQGY9nS75gBM7DFg=; b=dUrQhslfUtVnhhFX/2W4frfcWs7YDlG88rMei26Ie5MW/vwxeUu+Q0HhhrAucjLzZk l35H3vCLngHoZacjT72FEIflGJwMKmO4v1VxWykJ4gOqZVRvlVeEVQj4B19kmxnq5XsM YL1vOvlzUzmlsf+44i0/cTHJ1U32bBQVDrFLZqNPvlBkhkuhgej6brGSeA6YFGjzaLBk gZ7cn1cfdy3l3bo5bhhg4MA8padJy1+yhktOd5PEkczdwiRSYe6V7gRFxv2kyq7zD5XZ HSyqrdCDwkLg7D9LIjZGsUVxdv8Cu2ZrHR3PWdxQM/7+iuay/D/ezj3zAwmRgM2ngalC KsPw== Received: by 10.180.80.104 with SMTP id q8mr13538470wix.14.1332091384369; Sun, 18 Mar 2012 10:23:04 -0700 (PDT) Received: from localhost (94-192-233-223.zone6.bethere.co.uk. [94.192.233.223]) by mx.google.com with ESMTPS id df3sm18397976wib.1.2012.03.18.10.23.02 (version=TLSv1/SSLv3 cipher=OTHER); Sun, 18 Mar 2012 10:23:03 -0700 (PDT) From: Mark Walters To: notmuch@notmuchmail.org Subject: [PATCH] test: add some exclude tests Date: Sun, 18 Mar 2012 17:23:01 +0000 Message-Id: <1332091381-16797-1-git-send-email-markwalters1009@gmail.com> X-Mailer: git-send-email 1.7.9.1 In-Reply-To: <20120317155023.GH2670@mit.edu> References: <20120317155023.GH2670@mit.edu> 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, 18 Mar 2012 17:23:08 -0000 Here are some tests for search exclude working in a systematic fashion as suggested by Austin. In principle I think something like the generate_thread function could go in to test-lib.sh, but it would need to be written by someone much familiar with bash quoting than I am. At the moment I have left the current exclude tests in the "search" test: should they be moved here? Best wishes Mark --- test/notmuch-test | 1 + test/search-excludes | 160 ++++++++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 161 insertions(+), 0 deletions(-) create mode 100755 test/search-excludes diff --git a/test/notmuch-test b/test/notmuch-test index f03b594..4dcd8c6 100755 --- a/test/notmuch-test +++ b/test/notmuch-test @@ -27,6 +27,7 @@ TESTS=" search-position-overlap-bug search-insufficient-from-quoting search-limiting + search-excludes tagging json multipart diff --git a/test/search-excludes b/test/search-excludes new file mode 100755 index 0000000..81c284e --- /dev/null +++ b/test/search-excludes @@ -0,0 +1,160 @@ +#!/usr/bin/env bash +test_description='"notmuch search" with excludes in several variations' +. ./test-lib.sh + +# Generates a thread of 'length' messages. The subject of the nth +# message in the thread is 'subject: message n' +generate_thread () +{ + local subject="$1" + local length="$2" + generate_message '[subject]="'"${subject}: message 1"'"' + parent_id=$gen_msg_id + for i in `seq 2 $length` + do + generate_message '[subject]="'"${subject}: message $i"'"' \ + "[in-reply-to]=\<$parent_id\>" + parent_id=$gen_msg_id + done + notmuch new > /dev/null +} + +# We construct some threads for the tests. We use the tag "test" to +# indicate which messages we will search for. + +# A thread of deleted messages; test matches one of them. +generate_thread "All messages excluded: single match" 5 +notmuch tag +deleted subject:"All messages excluded: single match*" +notmuch tag +test 'subject:All messages excluded: single match: message 2' + +# A thread of deleted messages; test matches two of them. +generate_thread "All messages excluded: double match" 5 +notmuch tag +deleted subject:"All messages excluded: double match*" +notmuch tag +test 'subject:All messages excluded: double match: message 2' +notmuch tag +test 'subject:All messages excluded: double match: message 4' + +# A thread some messages deleted; test only matches a deleted message. +generate_thread "Some messages excluded: single excluded match" 5 +notmuch tag +deleted +test 'subject:Some messages excluded: single excluded match: message 3' + +# A thread some messages deleted; test only matches a non-deleted message. +generate_thread "Some messages excluded: single non-excluded match" 5 +notmuch tag +deleted 'subject:Some messages excluded: single non-excluded match: message 2' +notmuch tag +test 'subject:Some messages excluded: single non-excluded match: message 4' + +# A thread no messages deleted; test matches a message. +generate_thread "No messages excluded: single match" 5 +notmuch tag +test 'subject:No messages excluded: single match: message 3' + +# Set up excludes +notmuch config set search.exclude_tags deleted + +test_begin_subtest "Default exclusion (thread summary)" +output=$(notmuch search tag:test | notmuch_search_sanitize) +test_expect_equal "$output" "thread:XXX 2001-01-05 [1/5] Notmuch Test Suite; Some messages excluded: single non-excluded match: message 4 (deleted inbox test unread) +thread:XXX 2001-01-05 [1/5] Notmuch Test Suite; No messages excluded: single match: message 3 (inbox test unread)" + +test_begin_subtest "Default exclusion (messages)" +output=$(notmuch search --output=messages tag:test | notmuch_search_sanitize) +test_expect_equal "$output" "id:msg-019@notmuch-test-suite +id:msg-023@notmuch-test-suite" + +test_begin_subtest "exclude=true (thread summary)" +output=$(notmuch search --exclude=true tag:test | notmuch_search_sanitize) +test_expect_equal "$output" "thread:XXX 2001-01-05 [1/5] Notmuch Test Suite; Some messages excluded: single non-excluded match: message 4 (deleted inbox test unread) +thread:XXX 2001-01-05 [1/5] Notmuch Test Suite; No messages excluded: single match: message 3 (inbox test unread)" + +test_begin_subtest "exclude=true (messages)" +output=$(notmuch search --exclude=true --output=messages tag:test | notmuch_search_sanitize) +test_expect_equal "$output" "id:msg-019@notmuch-test-suite +id:msg-023@notmuch-test-suite" + +test_begin_subtest "exclude=false (thread summary)" +output=$(notmuch search --exclude=false tag:test | notmuch_search_sanitize) +test_expect_equal "$output" "thread:XXX 2001-01-05 [1/5] Notmuch Test Suite; All messages excluded: single match: message 2 (deleted inbox test unread) +thread:XXX 2001-01-05 [2/5] Notmuch Test Suite; All messages excluded: double match: message 2 (deleted inbox test unread) +thread:XXX 2001-01-05 [1/5] Notmuch Test Suite; Some messages excluded: single excluded match: message 3 (deleted inbox test unread) +thread:XXX 2001-01-05 [1/5] Notmuch Test Suite; Some messages excluded: single non-excluded match: message 4 (deleted inbox test unread) +thread:XXX 2001-01-05 [1/5] Notmuch Test Suite; No messages excluded: single match: message 3 (inbox test unread)" + +test_begin_subtest "exclude=false (messages)" +output=$(notmuch search --exclude=false --output=messages tag:test | notmuch_search_sanitize) +test_expect_equal "$output" "id:msg-002@notmuch-test-suite +id:msg-007@notmuch-test-suite +id:msg-009@notmuch-test-suite +id:msg-013@notmuch-test-suite +id:msg-019@notmuch-test-suite +id:msg-023@notmuch-test-suite" + +test_begin_subtest "exclude=flag (thread summary)" +output=$(notmuch search --exclude=flag tag:test | notmuch_search_sanitize) +test_expect_equal "$output" "thread:XXX 2001-01-05 [0/5] Notmuch Test Suite; All messages excluded: single match: message 2 (deleted inbox test unread) +thread:XXX 2001-01-05 [0/5] Notmuch Test Suite; All messages excluded: double match: message 4 (deleted inbox test unread) +thread:XXX 2001-01-05 [0/5] Notmuch Test Suite; Some messages excluded: single excluded match: message 3 (deleted inbox test unread) +thread:XXX 2001-01-05 [1/5] Notmuch Test Suite; Some messages excluded: single non-excluded match: message 4 (deleted inbox test unread) +thread:XXX 2001-01-05 [1/5] Notmuch Test Suite; No messages excluded: single match: message 3 (inbox test unread)" + +test_begin_subtest "exclude=flag (messages)" +output=$(notmuch search --exclude=flag --output=messages tag:test | notmuch_search_sanitize) +test_expect_equal "$output" "id:msg-002@notmuch-test-suite +id:msg-007@notmuch-test-suite +id:msg-009@notmuch-test-suite +id:msg-013@notmuch-test-suite +id:msg-019@notmuch-test-suite +id:msg-023@notmuch-test-suite" + +test_begin_subtest "Default exclusion: tag in query (thread summary)" +output=$(notmuch search tag:test and tag:deleted | notmuch_search_sanitize) +test_expect_equal "$output" "thread:XXX 2001-01-05 [1/5] Notmuch Test Suite; All messages excluded: single match: message 2 (deleted inbox test unread) +thread:XXX 2001-01-05 [2/5] Notmuch Test Suite; All messages excluded: double match: message 2 (deleted inbox test unread) +thread:XXX 2001-01-05 [1/5] Notmuch Test Suite; Some messages excluded: single excluded match: message 3 (deleted inbox test unread)" + +test_begin_subtest "Default exclusion: tag in query (messages)" +output=$(notmuch search --output=messages tag:test and tag:deleted | notmuch_search_sanitize) +test_expect_equal "$output" "id:msg-002@notmuch-test-suite +id:msg-007@notmuch-test-suite +id:msg-009@notmuch-test-suite +id:msg-013@notmuch-test-suite" + +test_begin_subtest "exclude=true: tag in query (thread summary)" +output=$(notmuch search --exclude=true tag:test and tag:deleted | notmuch_search_sanitize) +test_expect_equal "$output" "thread:XXX 2001-01-05 [1/5] Notmuch Test Suite; All messages excluded: single match: message 2 (deleted inbox test unread) +thread:XXX 2001-01-05 [2/5] Notmuch Test Suite; All messages excluded: double match: message 2 (deleted inbox test unread) +thread:XXX 2001-01-05 [1/5] Notmuch Test Suite; Some messages excluded: single excluded match: message 3 (deleted inbox test unread)" + +test_begin_subtest "exclude=true: tag in query (messages)" +output=$(notmuch search --exclude=true --output=messages tag:test and tag:deleted | notmuch_search_sanitize) +test_expect_equal "$output" "id:msg-002@notmuch-test-suite +id:msg-007@notmuch-test-suite +id:msg-009@notmuch-test-suite +id:msg-013@notmuch-test-suite" + +test_begin_subtest "exclude=false: tag in query (thread summary)" +output=$(notmuch search --exclude=false tag:test and tag:deleted | notmuch_search_sanitize) +test_expect_equal "$output" "thread:XXX 2001-01-05 [1/5] Notmuch Test Suite; All messages excluded: single match: message 2 (deleted inbox test unread) +thread:XXX 2001-01-05 [2/5] Notmuch Test Suite; All messages excluded: double match: message 2 (deleted inbox test unread) +thread:XXX 2001-01-05 [1/5] Notmuch Test Suite; Some messages excluded: single excluded match: message 3 (deleted inbox test unread)" + +test_begin_subtest "exclude=false: tag in query (messages)" +output=$(notmuch search --exclude=false --output=messages tag:test and tag:deleted | notmuch_search_sanitize) +test_expect_equal "$output" "id:msg-002@notmuch-test-suite +id:msg-007@notmuch-test-suite +id:msg-009@notmuch-test-suite +id:msg-013@notmuch-test-suite" + +test_begin_subtest "exclude=flag: tag in query (thread summary)" +output=$(notmuch search --exclude=flag tag:test and tag:deleted | notmuch_search_sanitize) +test_expect_equal "$output" "thread:XXX 2001-01-05 [1/5] Notmuch Test Suite; All messages excluded: single match: message 2 (deleted inbox test unread) +thread:XXX 2001-01-05 [2/5] Notmuch Test Suite; All messages excluded: double match: message 2 (deleted inbox test unread) +thread:XXX 2001-01-05 [1/5] Notmuch Test Suite; Some messages excluded: single excluded match: message 3 (deleted inbox test unread)" + +test_begin_subtest "exclude=flag: tag in query (messages)" +output=$(notmuch search --exclude=flag --output=messages tag:test and tag:deleted | notmuch_search_sanitize) +test_expect_equal "$output" "id:msg-002@notmuch-test-suite +id:msg-007@notmuch-test-suite +id:msg-009@notmuch-test-suite +id:msg-013@notmuch-test-suite" + + + +test_done -- 1.7.9.1