]> git.cworth.org Git - notmuch/blob - test/T081-sexpr-search.sh
lib/parse-sexp: parse single terms and the empty list.
[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 test_subtest_known_broken
33 notmuch search arriv > EXPECTED
34 notmuch search --query=sexp arriv > OUTPUT
35 test_expect_equal_file EXPECTED OUTPUT
36
37 test_begin_subtest "Unbalanced parens"
38 # A code 1 indicates the error was handled (a crash will return e.g. 139).
39 test_expect_code 1 "notmuch search --query=sexp '('"
40
41 test_begin_subtest "Unbalanced parens, error message"
42 notmuch search --query=sexp '(' >OUTPUT 2>&1
43 cat <<EOF > EXPECTED
44 notmuch search: Syntax error in query
45 invalid s-expression: '('
46 EOF
47 test_expect_equal_file EXPECTED OUTPUT
48
49 test_begin_subtest "unknown prefix"
50 notmuch search --query=sexp '(foo)' >OUTPUT 2>&1
51 cat <<EOF > EXPECTED
52 notmuch search: Syntax error in query
53 unknown prefix 'foo'
54 EOF
55 test_expect_equal_file EXPECTED OUTPUT
56
57 test_begin_subtest "list as prefix"
58 notmuch search --query=sexp '((foo))' >OUTPUT 2>&1
59 cat <<EOF > EXPECTED
60 notmuch search: Syntax error in query
61 unexpected list in field/operation position
62 EOF
63 test_expect_equal_file EXPECTED OUTPUT
64
65 test_done