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
113
114
115
| | #!/usr/bin/env bash
test_description='git-remote-notmuch'
. $(dirname "$0")/test-lib.sh || exit 1
notmuch_sanitize_git() {
sed 's/^committer \(.*\) \(<[^>]*>\) [1-9][0-9]* [-+][0-9]*/committer \1 \2 TIMESTAMP TIMEZONE/'
}
add_email_corpus
mkdir repo
git_tmp=$(mktemp -d gitXXXXXXXX)
run_helper () {
env -u NOTMUCH_CONFIG GIT_DIR=${git_tmp} git-remote-notmuch dummy-alias "?config=${NOTMUCH_CONFIG}"
}
export GIT_COMMITTER_NAME="Notmuch Test Suite"
export GIT_COMMITTER_EMAIL="notmuch@example.com"
export GIT_REMOTE_NM_DEBUG="s"
export GIT_REMOTE_NM_LOG=grn-log.txt
EXPECTED=$NOTMUCH_SRCDIR/test/git-remote.expected-output
MAKE_EXPORT_PY=$NOTMUCH_SRCDIR/test/make-export.py
TAG_FILE="87/b1/4EFC743A.3060609@april.org/tags"
test_begin_subtest 'capabilities'
echo capabilities | run_helper > OUTPUT
cat <<EOF > EXPECTED
import
export
refspec refs/heads/*:refs/notmuch/*
EOF
test_expect_equal_file EXPECTED OUTPUT
test_begin_subtest 'list'
echo list | run_helper > OUTPUT
cat <<EOF > EXPECTED
? refs/heads/master
EOF
test_expect_equal_file EXPECTED OUTPUT
test_begin_subtest 'import writes lastmod file'
echo import | run_helper dummy-alias dummy-url > /dev/null
lastmod=$(notmuch count --lastmod '*' | cut -f2-)
test_expect_equal "${lastmod}" "$(cat < ${git_tmp}/notmuch/lastmod)"
# note that this test must not be the first time import is run,
# because it depends on the lastmod file
test_begin_subtest 'import produces expected output'
echo import | run_helper | notmuch_sanitize_git > OUTPUT
test_expect_equal_file $EXPECTED/default.import OUTPUT
test_begin_subtest "clone notmuch://"
test_expect_success "git clone notmuch:// $(mktemp -d cloneXXXXXX)"
test_begin_subtest "clone notmuch://?config=notmuch-config"
test_expect_success "git clone notmuch://?config=notmuch-config $(mktemp -d cloneXXXXXX)"
test_begin_subtest "clone notmuch://?profile=default"
test_expect_success "git clone notmuch://?profile=default $(mktemp -d cloneXXXXXX)"
test_begin_subtest "clone notmuch://?config=notmuch-config&profile=default"
test_expect_success "git clone notmuch://?config=notmuch-config\&profile=default $(mktemp -d cloneXXXXXX)"
test_begin_subtest 'clone notmuch://`pwd`/mail'
test_expect_success "env -u NOTMUCH_CONFIG git clone notmuch://`pwd`/mail $(mktemp -d cloneXXXXXX)"
test_begin_subtest 'clone notmuch://`pwd`/mail/?config=`pwd`/notmuch-config'
test_expect_success "env -u NOTMUCH_CONFIG git clone notmuch://`pwd`/mail?config=`pwd`/notmuch-config $(mktemp -d cloneXXXXXX)"
test_begin_subtest 'clone notmuch://.../mail/?config=.../notmuch-config&profile=default'
test_expect_success "env -u NOTMUCH_CONFIG git clone notmuch://`pwd`/mail/?config=`pwd`/notmuch-config\&profile=default $(mktemp -d clone XXX)"
test_begin_subtest 'clone notmuch://?path=.../mail/&config=.../notmuch-config&profile=default'
test_expect_success "env -u NOTMUCH_CONFIG git clone notmuch://?path=`pwd`/mail\&config=notmuch-config\&profile=default $(mktemp -d cloneXXXXXX)"
test_begin_subtest "clone notmuch::"
test_expect_success "git clone notmuch:: $(mktemp -d cloneXXXXXX)"
test_begin_subtest 'clone notmuch::`pwd`/mail'
test_expect_success "env -u NOTMUCH_CONFIG git clone notmuch::`pwd`/mail $(mktemp -d cloneXXXXXX)"
test_begin_subtest 'clone notmuch::`pwd`/mail?config=`pwd`/notmuch-config'
test_expect_success "env -u NOTMUCH_CONFIG git clone notmuch::`pwd`/mail?config=`pwd`/notmuch-config $(mktemp -d cloneXXXXXX)"
test_begin_subtest "clone has every message"
git clone notmuch:: repo
find repo -name tags -type f | sed -e s,repo/../../,id:, -e s,/tags$,, | sort > OUTPUT
notmuch search --output=messages '*' | sort > EXPECTED
test_expect_equal_file EXPECTED OUTPUT
test_begin_subtest "pull get new tag"
notmuch tag +zznew -- id:4EFC743A.3060609@april.org
git -C repo pull
cat<<EOF >EXPECTED
inbox
unread
zznew
EOF
test_expect_equal_file EXPECTED repo/$TAG_FILE
test_begin_subtest "pull sees deletion"
notmuch tag -unread -- id:4EFC743A.3060609@april.org
git -C repo pull
cat<<EOF >EXPECTED
inbox
zznew
EOF
test_expect_equal_file EXPECTED repo/$TAG_FILE
test_done
|