* [PATCH v2] test/search: add check for slightly trick search
@ 2011-05-04 20:26 Felipe Contreras
2011-05-04 20:46 ` Austin Clements
0 siblings, 1 reply; 5+ messages in thread
From: Felipe Contreras @ 2011-05-04 20:26 UTC (permalink / raw)
To: notmuch
It's not really tricky, there are many addresses with a '-' in them. I
personally really want to differentiate between foo@bar.com,
foo-testing@bar.com, and foo-patches@bar.com.
This fails, but it shouldn't:
FAIL Search by from (tricky):
--- search.17.expected 2011-05-04 20:23:41.408279424 +0000
+++ search.17.output 2011-05-04 20:23:41.408279424 +0000
@@ -1 +1,3 @@
+thread:XXX 2000-01-01 [1/1] Search By From Name; search by from (name) (inbox unread)
+thread:XXX 2000-01-01 [1/1] search-by-from-trick@foo.com; search by from (tricky trick) (inbox unread)
thread:XXX 2000-01-01 [1/1] search-by-from@foo.com; search by from (tricky) (inbox unread)
One possibility to make this work is to translate @ to -at- in the
database, so search-by-from@foo.com becomes search-by-from-trick-at-foo.com,
therefore searching for search-by-from-at- would not be confused.
Signed-off-by: Felipe Contreras <felipe.contreras@gmail.com>
---
test/search | 6 ++++++
1 files changed, 6 insertions(+), 0 deletions(-)
diff --git a/test/search b/test/search
index b180c7f..4c7600e 100755
--- a/test/search
+++ b/test/search
@@ -123,4 +123,10 @@ echo -n > expected &&
notmuch search "no-message-matches-this" > actual &&
test_cmp expected actual'
+test_begin_subtest "Search by from (tricky):"
+add_message '[subject]="search by from (tricky trick)"' '[date]="Sat, 01 Jan 2000 12:00:00 -0000"' '[from]=search-by-from-trick@foo.com'
+add_message '[subject]="search by from (tricky)"' '[date]="Sat, 01 Jan 2000 12:00:00 -0000"' '[from]=search-by-from@foo.com'
+output=$(notmuch search from:'search-by-from@' | notmuch_search_sanitize)
+test_expect_equal "$output" "thread:XXX 2000-01-01 [1/1] search-by-from@foo.com; search by from (tricky) (inbox unread)"
+
test_done
--
1.7.5
^ permalink raw reply related [flat|nested] 5+ messages in thread
* Re: [PATCH v2] test/search: add check for slightly trick search
2011-05-04 20:26 [PATCH v2] test/search: add check for slightly trick search Felipe Contreras
@ 2011-05-04 20:46 ` Austin Clements
2011-05-04 20:54 ` Felipe Contreras
0 siblings, 1 reply; 5+ messages in thread
From: Austin Clements @ 2011-05-04 20:46 UTC (permalink / raw)
To: Felipe Contreras; +Cc: notmuch
On Wed, May 4, 2011 at 4:26 PM, Felipe Contreras
<felipe.contreras@gmail.com> wrote:
> +output=$(notmuch search from:'search-by-from@' | notmuch_search_sanitize)
I don't think this does what you think it does. Xapian only
understands double quotes around phrases, not single quotes.
Furthermore, a single quote after a prefix prevents that token from
acting as a prefix, so you search is finding messages containing the
*word* "from" and the phrase "search by from" *anywhere* (which is a
phrase not because of the quotes, but because of the hyphens).
The test results happen to be the same if you use single quotes or
double quotes, but for very different reasons.
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [PATCH v2] test/search: add check for slightly trick search
2011-05-04 20:46 ` Austin Clements
@ 2011-05-04 20:54 ` Felipe Contreras
2011-05-04 21:26 ` Austin Clements
0 siblings, 1 reply; 5+ messages in thread
From: Felipe Contreras @ 2011-05-04 20:54 UTC (permalink / raw)
To: Austin Clements; +Cc: notmuch
On Wed, May 4, 2011 at 11:46 PM, Austin Clements <amdragon@mit.edu> wrote:
> On Wed, May 4, 2011 at 4:26 PM, Felipe Contreras
> <felipe.contreras@gmail.com> wrote:
>> +output=$(notmuch search from:'search-by-from@' | notmuch_search_sanitize)
>
> I don't think this does what you think it does. Xapian only
> understands double quotes around phrases, not single quotes.
> Furthermore, a single quote after a prefix prevents that token from
> acting as a prefix, so you search is finding messages containing the
> *word* "from" and the phrase "search by from" *anywhere* (which is a
> phrase not because of the quotes, but because of the hyphens).
>
> The test results happen to be the same if you use single quotes or
> double quotes, but for very different reasons.
Ok, how about:
search from:search-by-from@
Would that be better?
--
Felipe Contreras
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [PATCH v2] test/search: add check for slightly trick search
2011-05-04 20:54 ` Felipe Contreras
@ 2011-05-04 21:26 ` Austin Clements
2011-05-04 21:55 ` [PATCH v3] test/search: add check for slightly tricky search Felipe Contreras
0 siblings, 1 reply; 5+ messages in thread
From: Austin Clements @ 2011-05-04 21:26 UTC (permalink / raw)
To: Felipe Contreras; +Cc: notmuch
Quoth Felipe Contreras on May 04 at 11:54 pm:
> On Wed, May 4, 2011 at 11:46 PM, Austin Clements <amdragon@mit.edu> wrote:
> > On Wed, May 4, 2011 at 4:26 PM, Felipe Contreras
> > <felipe.contreras@gmail.com> wrote:
> >> +output=$(notmuch search from:'search-by-from@' | notmuch_search_sanitize)
> >
> > I don't think this does what you think it does. Xapian only
> > understands double quotes around phrases, not single quotes.
> > Furthermore, a single quote after a prefix prevents that token from
> > acting as a prefix, so you search is finding messages containing the
> > *word* "from" and the phrase "search by from" *anywhere* (which is a
> > phrase not because of the quotes, but because of the hyphens).
> >
> > The test results happen to be the same if you use single quotes or
> > double quotes, but for very different reasons.
>
> Ok, how about:
> search from:search-by-from@
>
> Would that be better?
from:"search-by-from@" would be the fail-safe, since that's clearly a
prefixed phrase query in Xapian syntax. from:search-by-from@ depends
on the parsing of @, which is precisely what I think you're proposing
should be changed (though your commit message talks about hyphens, not
@), so in some sense from:search-by-from@ is up to you. It probably
*should* work, given that @ happens to be classified the same way as
hyphen by the Xapian parser (or, in the custom query parser, because @
isn't whitespace).
^ permalink raw reply [flat|nested] 5+ messages in thread
* [PATCH v3] test/search: add check for slightly tricky search
2011-05-04 21:26 ` Austin Clements
@ 2011-05-04 21:55 ` Felipe Contreras
0 siblings, 0 replies; 5+ messages in thread
From: Felipe Contreras @ 2011-05-04 21:55 UTC (permalink / raw)
To: notmuch
It's not really tricky, there are many addresses with a '-' in them. I
personally really want to differentiate between foo@bar.com,
foo-testing@bar.com, and foo-patches@bar.com.
This fails, but it shouldn't:
FAIL Search by from (tricky):
--- search.17.expected 2011-05-04 21:52:52.913218077 +0000
+++ search.17.output 2011-05-04 21:52:52.913218077 +0000
@@ -1 +1,3 @@
+thread:XXX 2000-01-01 [1/1] Search By From Name; search by from (name) (inbox unread)
+thread:XXX 2000-01-01 [1/1] search-by-from-trick@foo.com; search by from (tricky trick) (inbox unread)
thread:XXX 2000-01-01 [1/1] search-by-from@foo.com; search by from (tricky) (inbox unread)
One possibility to make this work is to translate @ to -at- in the
database, so search-by-from@foo.com becomes search-by-from-trick-at-foo.com,
therefore searching for search-by-from-at- would not be confused.
Signed-off-by: Felipe Contreras <felipe.contreras@gmail.com>
---
test/search | 6 ++++++
1 files changed, 6 insertions(+), 0 deletions(-)
diff --git a/test/search b/test/search
index b180c7f..c6223f4 100755
--- a/test/search
+++ b/test/search
@@ -123,4 +123,10 @@ echo -n > expected &&
notmuch search "no-message-matches-this" > actual &&
test_cmp expected actual'
+test_begin_subtest "Search by from (tricky):"
+add_message '[subject]="search by from (tricky trick)"' '[date]="Sat, 01 Jan 2000 12:00:00 -0000"' '[from]=search-by-from-trick@foo.com'
+add_message '[subject]="search by from (tricky)"' '[date]="Sat, 01 Jan 2000 12:00:00 -0000"' '[from]=search-by-from@foo.com'
+output=$(notmuch search from:"search-by-from@" | notmuch_search_sanitize)
+test_expect_equal "$output" "thread:XXX 2000-01-01 [1/1] search-by-from@foo.com; search by from (tricky) (inbox unread)"
+
test_done
--
1.7.5
^ permalink raw reply related [flat|nested] 5+ messages in thread
end of thread, other threads:[~2011-05-04 21:56 UTC | newest]
Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2011-05-04 20:26 [PATCH v2] test/search: add check for slightly trick search Felipe Contreras
2011-05-04 20:46 ` Austin Clements
2011-05-04 20:54 ` Felipe Contreras
2011-05-04 21:26 ` Austin Clements
2011-05-04 21:55 ` [PATCH v3] test/search: add check for slightly tricky search Felipe Contreras
Code repositories for project(s) associated with this public inbox
https://yhetil.org/notmuch.git/
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).