unofficial mirror of notmuch@notmuchmail.org
 help / color / mirror / code / Atom feed
blob 9b6851e5b4ee6b61e9fb992baa64c00c9ed52a5f 3140 bytes (raw)
name: test/T520-show.sh 	 # note: path name is non-authoritative(*)

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
 
#!/usr/bin/env bash
test_description='"notmuch show"'

. $(dirname "$0")/test-lib.sh || exit 1

test_query_syntax () {
    test_begin_subtest "sexpr query: $1"
    sexp=$(notmuch show --format=json --query=sexp "$1")
    infix=$(notmuch show --format=json "$2")
    test_expect_equal_json "$sexp" "$infix"
}

add_email_corpus

test_begin_subtest "exit code for show invalid query"
notmuch show foo..
exit_code=$?
test_expect_equal 1 $exit_code

test_begin_subtest "notmuch show --sort=newest-first"
notmuch show --entire-thread=true '*' > EXPECTED
notmuch show --entire-thread=true --sort=newest-first '*' > OUTPUT
test_expect_equal_file EXPECTED OUTPUT

test_begin_subtest "notmuch show --sort=oldest-first"
notmuch show --entire-thread=true '*' | grep ^depth:0 > EXPECTED
notmuch show --entire-thread=true --sort=oldest-first '*' | grep ^depth:0 > OLDEST
perl -e 'print reverse<>' OLDEST > OUTPUT
test_expect_equal_file EXPECTED OUTPUT

test_begin_subtest "notmuch show --sort for single thread"
QUERY="id:yun1vjwegii.fsf@aiko.keithp.com"
notmuch show --entire-thread=true --sort=newest-first $QUERY > EXPECTED
notmuch show --entire-thread=true --sort=oldest-first $QUERY > OUTPUT
test_expect_equal_file EXPECTED OUTPUT


if [ $NOTMUCH_HAVE_SFSEXP -eq 1 ]; then

    test_query_syntax '(and "wonderful" "wizard")' 'wonderful and wizard'
    test_query_syntax '(or "php" "wizard")' 'php or wizard'
    test_query_syntax 'wizard' 'wizard'
    test_query_syntax 'Wizard' 'Wizard'
    test_query_syntax '(attachment notmuch-help.patch)' 'attachment:notmuch-help.patch'

fi

add_email_corpus duplicate

ID1=debian/2.6.1.dfsg-4-1-g87ea161@87ea161e851dfb1ea324af00e4ecfccc18875e15

test_begin_subtest "format json, --duplicate=2, duplicate key"
output=$(notmuch show --format=json --duplicate=2 id:${ID1})
test_json_nodes <<<"$output" "dup:['duplicate']=2"

test_begin_subtest "format json, subject, --duplicate=1"
output=$(notmuch show --format=json --duplicate=1 id:${ID1})
file=$(notmuch search --output=files id:${ID1} | head -n 1)
subject=$(sed -n 's/^Subject: \(.*\)$/\1/p' < $file)
test_json_nodes <<<"$output" "subject:['headers']['Subject']=\"$subject\""

test_begin_subtest "format json, subject, --duplicate=2"
output=$(notmuch show --format=json --duplicate=2 id:${ID1})
file=$(notmuch search --output=files id:${ID1} | tail -n 1)
subject=$(sed -n 's/^Subject: \(.*\)$/\1/p' < $file)
test_json_nodes <<<"$output" "subject:['headers']['Subject']=\"$subject\""

ID2=87r2geywh9.fsf@tethera.net
for dup in {1..2}; do
    test_begin_subtest "format json, body, --duplicate=${dup}"
    output=$(notmuch show --format=json --duplicate=${dup} id:${ID2} | \
	     python $NOTMUCH_SRCDIR/test/json_check_nodes.py "body:['body'][0]['content']" | \
	     grep '^# body')
    test_expect_equal "$output" "# body ${dup}"
done

ID3=87r2ecrr6x.fsf@zephyr.silentflame.com
for dup in {1..5}; do
    test_begin_subtest "format json, --duplicate=${dup}, 'duplicate' key"
    output=$(notmuch show --format=json --duplicate=${dup} id:${ID3})
    test_json_nodes <<<"$output" "dup:['duplicate']=${dup}"
done

test_done

debug log:

solving c40a1b64 ...
found c40a1b64 in https://yhetil.org/notmuch/20220619232152.846823-6-david@tethera.net/
found 12bde6c7 in https://yhetil.org/notmuch.git/
preparing index
index prepared:
100755 12bde6c78f8912140fd2ec0fe276a0247caaf8c2	test/T520-show.sh

applying [1/1] https://yhetil.org/notmuch/20220619232152.846823-6-david@tethera.net/
diff --git a/test/T520-show.sh b/test/T520-show.sh\r
index 12bde6c7..c40a1b64 100755\r

Checking patch test/T520-show.sh...
Applied patch test/T520-show.sh cleanly.

index at:
100755 9b6851e5b4ee6b61e9fb992baa64c00c9ed52a5f	test/T520-show.sh

(*) Git path names are given by the tree(s) the blob belongs to.
    Blobs themselves have no identifier aside from the hash of its contents.^

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).