2 test_description='"notmuch show"'
4 . $(dirname "$0")/test-lib.sh || exit 1
7 test_begin_subtest "sexpr query: $1"
8 sexp=$(notmuch show --format=json --query=sexp "$1")
9 infix=$(notmuch show --format=json "$2")
10 test_expect_equal_json "$sexp" "$infix"
15 test_begin_subtest "exit code for show invalid query"
18 test_expect_equal 1 $exit_code
20 test_begin_subtest "notmuch show --sort=newest-first"
21 notmuch show --entire-thread=true '*' > EXPECTED
22 notmuch show --entire-thread=true --sort=newest-first '*' > OUTPUT
23 test_expect_equal_file EXPECTED OUTPUT
25 test_begin_subtest "notmuch show --sort=oldest-first"
26 notmuch show --entire-thread=true '*' | grep ^depth:0 > EXPECTED
27 notmuch show --entire-thread=true --sort=oldest-first '*' | grep ^depth:0 > OLDEST
28 perl -e 'print reverse<>' OLDEST > OUTPUT
29 test_expect_equal_file EXPECTED OUTPUT
31 test_begin_subtest "notmuch show --sort for single thread"
32 QUERY="id:yun1vjwegii.fsf@aiko.keithp.com"
33 notmuch show --entire-thread=true --sort=newest-first $QUERY > EXPECTED
34 notmuch show --entire-thread=true --sort=oldest-first $QUERY > OUTPUT
35 test_expect_equal_file EXPECTED OUTPUT
38 if [ "${NOTMUCH_HAVE_SFSEXP-0}" = "1" ]; then
40 test_query_syntax '(and "wonderful" "wizard")' 'wonderful and wizard'
41 test_query_syntax '(or "php" "wizard")' 'php or wizard'
42 test_query_syntax 'wizard' 'wizard'
43 test_query_syntax 'Wizard' 'Wizard'
44 test_query_syntax '(attachment notmuch-help.patch)' 'attachment:notmuch-help.patch'
48 add_email_corpus duplicate
50 ID1=debian/2.6.1.dfsg-4-1-g87ea161@87ea161e851dfb1ea324af00e4ecfccc18875e15
52 test_begin_subtest "format json, --duplicate=2, duplicate key"
53 output=$(notmuch show --format=json --duplicate=2 id:${ID1})
54 test_json_nodes <<<"$output" "dup:['duplicate']=2"
56 test_begin_subtest "format json, subject, --duplicate=1"
57 output=$(notmuch show --format=json --duplicate=1 id:${ID1})
58 file=$(notmuch search --output=files id:${ID1} | head -n 1)
59 subject=$(sed -n 's/^Subject: \(.*\)$/\1/p' < $file)
60 test_json_nodes <<<"$output" "subject:['headers']['Subject']=\"$subject\""
62 test_begin_subtest "format json, subject, --duplicate=2"
63 output=$(notmuch show --format=json --duplicate=2 id:${ID1})
64 file=$(notmuch search --output=files id:${ID1} | tail -n 1)
65 subject=$(sed -n 's/^Subject: \(.*\)$/\1/p' < $file)
66 test_json_nodes <<<"$output" "subject:['headers']['Subject']=\"$subject\""
68 ID2=87r2geywh9.fsf@tethera.net
70 test_begin_subtest "format json, body, --duplicate=${dup}"
71 output=$(notmuch show --format=json --duplicate=${dup} id:${ID2} | \
72 $NOTMUCH_PYTHON -B "$NOTMUCH_SRCDIR"/test/json_check_nodes.py "body:['body'][0]['content']" | \
74 test_expect_equal "$output" "# body ${dup}"
77 ID3=87r2ecrr6x.fsf@zephyr.silentflame.com
79 test_begin_subtest "format json, --duplicate=${dup}, 'duplicate' key"
80 output=$(notmuch show --format=json --duplicate=${dup} id:${ID3})
81 test_json_nodes <<<"$output" "dup:['duplicate']=${dup}"