unofficial mirror of notmuch@notmuchmail.org
 help / color / mirror / code / Atom feed
blob 21be1ce5b079b3cbb3a8004449bc338e030d2055 3427 bytes (raw)
name: test/T570-revision-tracking.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
 85
 86
 87
 88
 89
 90
 91
 92
 93
 94
 95
 96
 97
 98
 99
100
101
102
103
104
105
106
107
108
109
110
111
112
 
#!/usr/bin/env bash
test_description="database revision tracking"

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

add_email_corpus

test_begin_subtest "notmuch_database_get_revision"
test_C ${MAIL_DIR} <<'EOF'
#include <stdio.h>
#include <string.h>
#include <notmuch.h>
int main (int argc, char** argv)
{
   notmuch_database_t *db;
   notmuch_status_t stat;
   unsigned long revision;
   const char *uuid;

   unsigned long rev;

   char* msg = NULL;
   stat = notmuch_database_open_with_config (argv[1],
					     NOTMUCH_DATABASE_MODE_READ_ONLY,
					     "", NULL, &db, &msg);
   if (msg) fputs (msg, stderr);

   if (stat)
       fputs ("open failed\n", stderr);
   revision = notmuch_database_get_revision (db, &uuid);
   printf("%s\t%lu\n", uuid, revision);
}
EOF
notmuch_uuid_sanitize < OUTPUT > CLEAN
cat <<'EOF' >EXPECTED
== stdout ==
UUID	53
== stderr ==
EOF
test_expect_equal_file EXPECTED CLEAN

grep '^[0-9a-f]' OUTPUT > INITIAL_OUTPUT

test_begin_subtest "output of count matches test code"
notmuch count --lastmod '*' | cut -f2-3 > OUTPUT
test_expect_equal_file INITIAL_OUTPUT OUTPUT

test_begin_subtest "modification count increases"
before=$(notmuch count --lastmod '*' | cut -f3)
notmuch tag +a-random-tag-8743632 '*'
after=$(notmuch count --lastmod '*' | cut -f3)
result=$(($before < $after))
test_expect_equal 1 ${result}

notmuch count --lastmod '*' | cut -f2 > UUID

test_begin_subtest "search succeeds with correct uuid"
test_expect_success "notmuch search --uuid=$(cat UUID) '*'"

test_begin_subtest "uuid works as global option"
test_expect_success "notmuch --uuid=$(cat UUID) search '*'"

test_begin_subtest "uuid works as global option II"
test_expect_code 1 "notmuch --uuid=this-is-no-uuid search '*'"

test_begin_subtest "search fails with incorrect uuid"
test_expect_code 1 "notmuch search --uuid=this-is-no-uuid '*'"

test_begin_subtest "show succeeds with correct uuid"
test_expect_success "notmuch show --uuid=$(cat UUID) '*'"

test_begin_subtest "show fails with incorrect uuid"
test_expect_code 1 "notmuch show --uuid=this-is-no-uuid '*'"

test_begin_subtest "tag succeeds with correct uuid"
test_expect_success "notmuch tag --uuid=$(cat UUID) +test '*'"

test_begin_subtest "tag fails with incorrect uuid"
test_expect_code 1 "notmuch tag --uuid=this-is-no-uuid '*' +test2"

test_begin_subtest 'lastmod:0.. matches everything'
total=$(notmuch count '*')
modtotal=$(notmuch count lastmod:0..)
test_expect_equal "$total" "$modtotal"

test_begin_subtest 'lastmod:1000000.. matches nothing'
modtotal=$(notmuch count lastmod:1000000..)
test_expect_equal 0 "$modtotal"

test_begin_subtest 'exclude one message using lastmod'
lastmod=$(notmuch count --lastmod '*' | cut -f3)
total=$(notmuch count '*')
notmuch tag +4EFC743A.3060609@april.org id:4EFC743A.3060609@april.org
subtotal=$(notmuch count lastmod:..$lastmod)
result=$(($subtotal == $total-1))
test_expect_equal 1 "$result"

if [ $NOTMUCH_HAVE_SFSEXP -eq 1 ]; then
    test_begin_subtest 'exclude one message using negative lastmod (sexp)'
    total=$(notmuch count '*')
    notmuch tag +${RANDOM} id:4EFC743A.3060609@april.org
    count=$(notmuch count --query=sexp '(lastmod -1 *)')
    test_expect_equal 1 "$count"
fi

test_begin_subtest 'exclude one message using negative lastmod'
total=$(notmuch count '*')
notmuch tag +${RANDOM} id:4EFC743A.3060609@april.org
count=$(notmuch count lastmod:-1..)
test_expect_equal 1 "$count"

test_done

debug log:

solving 067935b2 ...
found 067935b2 in https://yhetil.org/notmuch/20220809112518.1969385-2-david@tethera.net/
found aaa45468 in https://yhetil.org/notmuch.git/
preparing index
index prepared:
100755 aaa45468e5e6fabf3611a351a0dc7f46306fd207	test/T570-revision-tracking.sh

applying [1/1] https://yhetil.org/notmuch/20220809112518.1969385-2-david@tethera.net/
diff --git a/test/T570-revision-tracking.sh b/test/T570-revision-tracking.sh\r
index aaa45468..067935b2 100755\r

Checking patch test/T570-revision-tracking.sh...
Applied patch test/T570-revision-tracking.sh cleanly.

index at:
100755 21be1ce5b079b3cbb3a8004449bc338e030d2055	test/T570-revision-tracking.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).