1 Return-Path: <amdragon@mit.edu>
\r
2 X-Original-To: notmuch@notmuchmail.org
\r
3 Delivered-To: notmuch@notmuchmail.org
\r
4 Received: from localhost (localhost [127.0.0.1])
\r
5 by olra.theworths.org (Postfix) with ESMTP id D0E03431FD0
\r
6 for <notmuch@notmuchmail.org>; Thu, 20 Jan 2011 22:40:07 -0800 (PST)
\r
7 X-Virus-Scanned: Debian amavisd-new at olra.theworths.org
\r
11 X-Spam-Status: No, score=0 tagged_above=-999 required=5 tests=[none]
\r
13 Received: from olra.theworths.org ([127.0.0.1])
\r
14 by localhost (olra.theworths.org [127.0.0.1]) (amavisd-new, port 10024)
\r
15 with ESMTP id jA8UcThkPqfM for <notmuch@notmuchmail.org>;
\r
16 Thu, 20 Jan 2011 22:40:07 -0800 (PST)
\r
17 Received: from dmz-mailsec-scanner-2.mit.edu (DMZ-MAILSEC-SCANNER-2.MIT.EDU
\r
19 by olra.theworths.org (Postfix) with ESMTP id 48926431FB6
\r
20 for <notmuch@notmuchmail.org>; Thu, 20 Jan 2011 22:40:07 -0800 (PST)
\r
21 X-AuditID: 1209190d-b7cacae000000a14-5b-4d392a46dc74
\r
22 Received: from mailhub-auth-2.mit.edu ( [18.7.62.36])
\r
23 by dmz-mailsec-scanner-2.mit.edu (Symantec Brightmail Gateway) with
\r
24 SMTP id 68.9C.02580.64A293D4; Fri, 21 Jan 2011 01:40:06 -0500 (EST)
\r
25 Received: from outgoing.mit.edu (OUTGOING-AUTH.MIT.EDU [18.7.22.103])
\r
26 by mailhub-auth-2.mit.edu (8.13.8/8.9.2) with ESMTP id p0L6e5JS018056;
\r
27 Fri, 21 Jan 2011 01:40:05 -0500
\r
28 Received: from awakening.csail.mit.edu (awakening.csail.mit.edu [18.26.4.91])
\r
29 (authenticated bits=0)
\r
30 (User authenticated as amdragon@ATHENA.MIT.EDU)
\r
31 by outgoing.mit.edu (8.13.6/8.12.4) with ESMTP id p0L6e4Sh004864
\r
32 (version=TLSv1/SSLv3 cipher=AES256-SHA bits=256 verify=NOT);
\r
33 Fri, 21 Jan 2011 01:40:04 -0500 (EST)
\r
34 Received: from amthrax by awakening.csail.mit.edu with local (Exim 4.72)
\r
35 (envelope-from <amdragon@mit.edu>)
\r
36 id 1PgAfE-0000zj-08; Fri, 21 Jan 2011 01:40:04 -0500
\r
37 Date: Fri, 21 Jan 2011 01:40:03 -0500
\r
38 From: Austin Clements <amdragon@MIT.EDU>
\r
39 To: notmuch@notmuchmail.org
\r
40 Subject: [PATCH 3.5/8] Query parser tests for wildcard queries.
\r
41 Message-ID: <20110121064003.GK13226@mit.edu>
\r
42 References: <1295165458-9573-1-git-send-email-amdragon@mit.edu>
\r
43 <1295165458-9573-4-git-send-email-amdragon@mit.edu>
\r
45 Content-Type: text/plain; charset=us-ascii
\r
46 Content-Disposition: inline
\r
47 In-Reply-To: <1295165458-9573-4-git-send-email-amdragon@mit.edu>
\r
48 User-Agent: Mutt/1.5.20 (2009-06-14)
\r
49 X-Brightmail-Tracker: AAAAAA==
\r
50 Cc: amdragon@mit.edu
\r
51 X-BeenThere: notmuch@notmuchmail.org
\r
52 X-Mailman-Version: 2.1.13
\r
54 List-Id: "Use and development of the notmuch mail system."
\r
55 <notmuch.notmuchmail.org>
\r
56 List-Unsubscribe: <http://notmuchmail.org/mailman/options/notmuch>,
\r
57 <mailto:notmuch-request@notmuchmail.org?subject=unsubscribe>
\r
58 List-Archive: <http://notmuchmail.org/pipermail/notmuch>
\r
59 List-Post: <mailto:notmuch@notmuchmail.org>
\r
60 List-Help: <mailto:notmuch-request@notmuchmail.org?subject=help>
\r
61 List-Subscribe: <http://notmuchmail.org/mailman/listinfo/notmuch>,
\r
62 <mailto:notmuch-request@notmuchmail.org?subject=subscribe>
\r
63 X-List-Received-Date: Fri, 21 Jan 2011 06:40:08 -0000
\r
65 Since wildcard queries require a database, qparser-test can now open a
\r
68 This is intended to be applied after patch 3/5 in this series,
\r
69 id:1295165458-9573-4-git-send-email-amdragon@mit.edu
\r
71 test/qparser | 7 +++++++
\r
72 test/qparser-test.cc | 25 ++++++++++++++++++++++++-
\r
73 test/qparser.expected-output/wildcards | 20 ++++++++++++++++++++
\r
74 3 files changed, 51 insertions(+), 1 deletions(-)
\r
75 create mode 100644 test/qparser.expected-output/wildcards
\r
77 diff --git a/test/qparser b/test/qparser
\r
78 index 7ed5c97..d77e2b2 100755
\r
81 @@ -34,4 +34,11 @@ output=$(../qparser-test < $EXPECTED/probs)
\r
82 expected=$(cat $EXPECTED/probs)
\r
83 test_expect_equal "$output" "$expected"
\r
85 +add_message '[body]="Peter Piper picked a peck of pickled peppers"'
\r
87 +test_begin_subtest "Wildcards"
\r
88 +output=$(../qparser-test -d < $EXPECTED/wildcards)
\r
89 +expected=$(cat $EXPECTED/wildcards)
\r
90 +test_expect_equal "$output" "$expected"
\r
93 diff --git a/test/qparser-test.cc b/test/qparser-test.cc
\r
94 index 01d6bae..ae6c8b9 100644
\r
95 --- a/test/qparser-test.cc
\r
96 +++ b/test/qparser-test.cc
\r
97 @@ -42,6 +42,7 @@ extern "C" {
\r
98 #include "../notmuch-client.h"
\r
101 +static notmuch_database_t *notmuch;
\r
102 static _notmuch_qparser_t *qparser;
\r
103 static Xapian::QueryParser xqparser;
\r
105 @@ -98,7 +99,7 @@ test_one (void *ctx, const char *query_str)
\r
106 static _notmuch_qparser_t *
\r
107 create_qparser (void *ctx)
\r
109 - _notmuch_qparser_t *qparser = _notmuch_qparser_create (ctx, NULL);
\r
110 + _notmuch_qparser_t *qparser = _notmuch_qparser_create (ctx, notmuch);
\r
111 _notmuch_qparser_add_db_prefix (qparser, "prob", "P", FALSE);
\r
112 _notmuch_qparser_add_db_prefix (qparser, "lit", "L", TRUE);
\r
113 _notmuch_qparser_add_db_prefix (qparser, "tag", "K", TRUE);
\r
114 @@ -109,6 +110,8 @@ static Xapian::QueryParser
\r
115 create_xapian_qparser (void)
\r
117 Xapian::QueryParser xq;
\r
119 + xq.set_database (*notmuch->xapian_db);
\r
120 xq.set_default_op (Xapian::Query::OP_AND);
\r
121 xq.add_prefix ("prob", "P");
\r
122 xq.add_boolean_prefix ("lit", "L");
\r
123 @@ -120,9 +123,27 @@ int
\r
124 main (int argc, char **argv)
\r
127 + notmuch_config_t *config;
\r
129 ctx = talloc_new (NULL);
\r
131 + if (argc > 1 && strcmp(argv[1], "-d") == 0) {
\r
135 + /* Open the database */
\r
136 + config = notmuch_config_open (ctx, NULL, NULL);
\r
137 + if (config == NULL)
\r
140 + notmuch = notmuch_database_open (notmuch_config_get_database_path (config),
\r
141 + NOTMUCH_DATABASE_MODE_READ_ONLY);
\r
142 + if (notmuch == NULL)
\r
148 qparser = create_qparser (ctx);
\r
149 xqparser = create_xapian_qparser ();
\r
151 @@ -149,5 +170,7 @@ main (int argc, char **argv)
\r
156 + notmuch_database_close (notmuch);
\r
159 diff --git a/test/qparser.expected-output/wildcards b/test/qparser.expected-output/wildcards
\r
160 new file mode 100644
\r
161 index 0000000..6f62829
\r
163 +++ b/test/qparser.expected-output/wildcards
\r
165 +# Basic wildcard expansion
\r
167 +[lex] "p"* AND "x"
\r
168 +[parse] (AND "p"* "x")
\r
169 +[gen] ((peck:(pos=1) SYNONYM peppers:(pos=1) SYNONYM peter:(pos=1) SYNONYM picked:(pos=1) SYNONYM pickled:(pos=1) SYNONYM piper:(pos=1)) AND x:(pos=2))
\r
171 +# Incompatible; Xapian considers this a syntax error
\r
175 +[gen] <alldocuments>
\r
178 +# Wildcard that matches nothing. Xapian handles this differently
\r
179 +# but equivalently.
\r
181 +[lex] "nosuchterm"* AND "x"
\r
182 +[parse] (AND "nosuchterm"* "x")
\r
183 +[gen] (nosuchterm AND x:(pos=1))
\r