unofficial mirror of notmuch@notmuchmail.org
 help / color / mirror / code / Atom feed
blob a3da35944a3ef2fb3ba458e5d27a8949c93437bb 2699 bytes (raw)
name: test/T131-show-limiting.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
 
#!/usr/bin/env bash
test_description='"notmuch show" --offset and --limit parameters'
. $(dirname "$0")/test-lib.sh || exit 1

add_email_corpus

function show() {
    local kind="$1"
    shift
    if [ "$kind" = messages ]; then
        set -- --unthreaded "$@"
    fi
    notmuch show --body=false --format=text --entire-thread=false "$@" "*" |
        sed -nre 's/^.message\{.*\<depth:0\>.*/&/p'
}

for outp in messages threads; do
    test_begin_subtest "$outp: limit does the right thing"
    show $outp | head -n 20 >expected
    show $outp --limit=20 >output
    test_expect_equal_file expected output

    test_begin_subtest "$outp: concatenation of limited shows"
    show $outp | head -n 20 >expected
    show $outp --limit=10 >output
    show $outp --limit=10 --offset=10 >>output
    test_expect_equal_file expected output

    test_begin_subtest "$outp: limit larger than result set"
    N=$(notmuch count --output=$outp "*")
    show $outp >expected
    show $outp --limit=$((1 + N)) >output
    test_expect_equal_file expected output

    test_begin_subtest "$outp: limit = 0"
    test_expect_equal "$(show $outp --limit=0)" ""

    test_begin_subtest "$outp: offset does the right thing"
    # note: tail -n +N is 1-based
    show $outp | tail -n +21 >expected
    show $outp --offset=20 >output
    test_expect_equal_file expected output

    test_begin_subtest "${outp}: offset = 0"
    show $outp >expected
    show $outp --offset=0 >output
    test_expect_equal_file expected output

    test_begin_subtest "${outp}: negative offset"
    show $outp | tail -n 20 >expected
    show $outp --offset=-20 >output
    test_expect_equal_file expected output

    test_begin_subtest "${outp}: negative offset"
    show $outp | tail -n 1 >expected
    show $outp --offset=-1 >output
    test_expect_equal_file expected output

    test_begin_subtest "${outp}: negative offset combined with limit"
    show $outp | tail -n 20 | head -n 10 >expected
    show $outp --offset=-20 --limit=10 >output
    test_expect_equal_file expected output

    test_begin_subtest "${outp}: negative offset combined with equal limit"
    show $outp | tail -n 20 >expected
    show $outp --offset=-20 --limit=20 >output
    test_expect_equal_file expected output

    test_begin_subtest "${outp}: negative offset combined with large limit"
    show $outp | tail -n 20 >expected
    show $outp --offset=-20 --limit=50 >output
    test_expect_equal_file expected output

    test_begin_subtest "${outp}: negative offset larger than results"
    N=$(notmuch count --output=$outp "*")
    show $outp >expected
    show $outp --offset=-$((1 + N)) >output
    test_expect_equal_file expected output
done

test_done

debug log:

solving a3da35944a3e ...
found a3da35944a3e in https://yhetil.org/notmuch/20221011221942.341732-1-robin@jarry.cc/

applying [1/1] https://yhetil.org/notmuch/20221011221942.341732-1-robin@jarry.cc/
diff --git a/test/T131-show-limiting.sh b/test/T131-show-limiting.sh
new file mode 100755
index 000000000000..a3da35944a3e

Checking patch test/T131-show-limiting.sh...
Applied patch test/T131-show-limiting.sh cleanly.

index at:
100755 a3da35944a3ef2fb3ba458e5d27a8949c93437bb	test/T131-show-limiting.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).