]> git.cworth.org Git - notmuch/blob - test/T081-sexpr-search.sh
lib/parse-sexp: stem unquoted atoms
[notmuch] / test / T081-sexpr-search.sh
1 #!/usr/bin/env bash
2 test_description='"notmuch search" in several variations'
3 . $(dirname "$0")/test-lib.sh || exit 1
4
5 if [ $NOTMUCH_HAVE_SFSEXP -ne 1 ]; then
6     printf "Skipping due to missing sfsexp library\n"
7     test_done
8 fi
9
10 add_email_corpus
11
12 test_begin_subtest "all messages: ()"
13 notmuch search '*' > EXPECTED
14 notmuch search --query=sexp "()" > OUTPUT
15 test_expect_equal_file EXPECTED OUTPUT
16
17 test_begin_subtest "single term in body"
18 notmuch search --query=sexp 'wizard' | notmuch_search_sanitize>OUTPUT
19 cat <<EOF > EXPECTED
20 thread:XXX   2009-11-18 [1/3] Carl Worth| Jan Janak; [notmuch] What a great idea! (inbox unread)
21 EOF
22 test_expect_equal_file EXPECTED OUTPUT
23
24 test_begin_subtest "single term in body (case insensitive)"
25 notmuch search --query=sexp 'Wizard' | notmuch_search_sanitize>OUTPUT
26 cat <<EOF > EXPECTED
27 thread:XXX   2009-11-18 [1/3] Carl Worth| Jan Janak; [notmuch] What a great idea! (inbox unread)
28 EOF
29 test_expect_equal_file EXPECTED OUTPUT
30
31 test_begin_subtest "single term in body, stemmed version"
32 notmuch search arriv > EXPECTED
33 notmuch search --query=sexp arriv > OUTPUT
34 test_expect_equal_file EXPECTED OUTPUT
35
36 test_begin_subtest "single term in body, unstemmed version"
37 notmuch search --query=sexp '"arriv"' > OUTPUT
38 test_expect_equal_file /dev/null OUTPUT
39
40 test_begin_subtest "Unbalanced parens"
41 # A code 1 indicates the error was handled (a crash will return e.g. 139).
42 test_expect_code 1 "notmuch search --query=sexp '('"
43
44 test_begin_subtest "Unbalanced parens, error message"
45 notmuch search --query=sexp '(' >OUTPUT 2>&1
46 cat <<EOF > EXPECTED
47 notmuch search: Syntax error in query
48 invalid s-expression: '('
49 EOF
50 test_expect_equal_file EXPECTED OUTPUT
51
52 test_begin_subtest "unknown prefix"
53 notmuch search --query=sexp '(foo)' >OUTPUT 2>&1
54 cat <<EOF > EXPECTED
55 notmuch search: Syntax error in query
56 unknown prefix 'foo'
57 EOF
58 test_expect_equal_file EXPECTED OUTPUT
59
60 test_begin_subtest "list as prefix"
61 notmuch search --query=sexp '((foo))' >OUTPUT 2>&1
62 cat <<EOF > EXPECTED
63 notmuch search: Syntax error in query
64 unexpected list in field/operation position
65 EOF
66 test_expect_equal_file EXPECTED OUTPUT
67
68 test_done