]> git.notmuchmail.org Git - notmuch/blob - test/count
test: wrap 'wc -l' results in arithmetic evaluation to strip whitespace
[notmuch] / test / count
1 #!/usr/bin/env bash
2 test_description='"notmuch count" for messages and threads'
3 . ./test-lib.sh
4
5 add_email_corpus
6
7 # Note: The 'wc -l' results below are wrapped in arithmetic evaluation
8 # $((...)) to strip whitespace. This is for portability, as 'wc -l'
9 # emits whitespace on some BSD variants.
10
11 test_begin_subtest "message count is the default for notmuch count"
12 test_expect_equal \
13     "$((`notmuch search --output=messages '*' | wc -l`))" \
14     "`notmuch count '*'`"
15
16 test_begin_subtest "message count with --output=messages"
17 test_expect_equal \
18     "$((`notmuch search --output=messages '*' | wc -l`))" \
19     "`notmuch count --output=messages '*'`"
20
21 test_begin_subtest "thread count with --output=threads"
22 test_expect_equal \
23     "$((`notmuch search --output=threads '*' | wc -l`))" \
24     "`notmuch count --output=threads '*'`"
25
26 test_begin_subtest "thread count is the default for notmuch search"
27 test_expect_equal \
28     "$((`notmuch search '*' | wc -l`))" \
29     "`notmuch count --output=threads '*'`"
30
31 test_begin_subtest "count with no matching messages"
32 test_expect_equal \
33     "0" \
34     "`notmuch count --output=messages from:cworth and not from:cworth`"
35
36 test_begin_subtest "count with no matching threads"
37 test_expect_equal \
38     "0" \
39     "`notmuch count --output=threads from:cworth and not from:cworth`"
40
41 test_done