]> git.cworth.org Git - notmuch/blob - test/T850-git.sh
test/git: add known broken test for tag with quotes.
[notmuch] / test / T850-git.sh
1 #!/usr/bin/env bash
2 test_description='"notmuch git" to save and restore tags'
3 . $(dirname "$0")/test-lib.sh || exit 1
4
5 add_email_corpus
6
7 git config --global user.email notmuch@example.org
8 git config --global user.name  "Notmuch Test Suite"
9
10 test_begin_subtest "init"
11 test_expect_success "notmuch git -p '' -C remote.git init"
12
13 test_begin_subtest "clone"
14 test_expect_success "notmuch git -p '' -C tags.git clone remote.git"
15
16 test_begin_subtest "commit"
17 notmuch git -C tags.git -p '' commit
18 git -C tags.git ls-tree -r --name-only HEAD | xargs dirname | sort -u | sed s,tags/,id:, > OUTPUT
19 notmuch search --output=messages '*' | sort > EXPECTED
20 test_expect_equal_file_nonempty EXPECTED OUTPUT
21
22 test_begin_subtest "commit, with quoted tag"
23 test_subtest_known_broken
24 notmuch git -C clone2.git -p '' clone tags.git
25 git -C clone2.git ls-tree -r --name-only HEAD | grep /inbox > BEFORE
26 notmuch tag '+"quoted tag"' '*'
27 notmuch git -C clone2.git -p '' commit
28 notmuch tag '-"quoted tag"' '*'
29 git -C clone2.git ls-tree -r --name-only HEAD | grep /inbox > AFTER
30 test_expect_equal_file_nonempty BEFORE AFTER
31
32 test_begin_subtest "checkout"
33 notmuch dump > BEFORE
34 notmuch tag -inbox '*'
35 notmuch git -C tags.git -p '' checkout
36 notmuch dump > AFTER
37 test_expect_equal_file_nonempty BEFORE AFTER
38
39 test_begin_subtest "archive"
40 notmuch git -C tags.git -p '' archive | tar tf - | \
41     grep 20091117190054.GU3165@dottiness.seas.harvard.edu | sort > OUTPUT
42 cat <<EOF > EXPECTED
43 tags/20091117190054.GU3165@dottiness.seas.harvard.edu/
44 tags/20091117190054.GU3165@dottiness.seas.harvard.edu/inbox
45 tags/20091117190054.GU3165@dottiness.seas.harvard.edu/signed
46 tags/20091117190054.GU3165@dottiness.seas.harvard.edu/unread
47 EOF
48 notmuch git -C tags.git -p '' checkout
49 test_expect_equal_file EXPECTED OUTPUT
50
51 test_begin_subtest "status"
52 notmuch tag +test id:20091117190054.GU3165@dottiness.seas.harvard.edu
53 notmuch git -C tags.git -p '' status > OUTPUT
54 cat <<EOF > EXPECTED
55 A       20091117190054.GU3165@dottiness.seas.harvard.edu        test
56 EOF
57 notmuch git -C tags.git -p '' checkout
58 test_expect_equal_file EXPECTED OUTPUT
59
60 test_begin_subtest "fetch"
61 notmuch tag +test2 id:20091117190054.GU3165@dottiness.seas.harvard.edu
62 notmuch git -C remote.git -p '' commit
63 notmuch tag -test2 id:20091117190054.GU3165@dottiness.seas.harvard.edu
64 notmuch git -C tags.git -p '' fetch
65 notmuch git -C tags.git -p '' status > OUTPUT
66 cat <<EOF > EXPECTED
67  a      20091117190054.GU3165@dottiness.seas.harvard.edu        test2
68 EOF
69 notmuch git -C tags.git -p '' checkout
70 test_expect_equal_file EXPECTED OUTPUT
71
72 test_begin_subtest "merge"
73 notmuch git -C tags.git -p '' merge
74 notmuch dump id:20091117190054.GU3165@dottiness.seas.harvard.edu | grep -v '^#' > OUTPUT
75 cat <<EOF > EXPECTED
76 +inbox +signed +test2 +unread -- id:20091117190054.GU3165@dottiness.seas.harvard.edu
77 EOF
78 test_expect_equal_file EXPECTED OUTPUT
79
80 test_begin_subtest "push"
81 notmuch tag +test3 id:20091117190054.GU3165@dottiness.seas.harvard.edu
82 notmuch git -C tags.git -p '' commit
83 notmuch tag -test3 id:20091117190054.GU3165@dottiness.seas.harvard.edu
84 notmuch git -C tags.git -p '' push
85 notmuch git -C remote.git -p '' checkout
86 notmuch dump id:20091117190054.GU3165@dottiness.seas.harvard.edu | grep -v '^#' > OUTPUT
87 cat <<EOF > EXPECTED
88 +inbox +signed +test2 +test3 +unread -- id:20091117190054.GU3165@dottiness.seas.harvard.edu
89 EOF
90 test_expect_equal_file EXPECTED OUTPUT
91
92 test_begin_subtest "environment passed through when run as 'notmuch git'"
93 env NOTMUCH_GIT_DIR=foo NOTMUCH_GIT_PREFIX=bar NOTMUCH_PROFILE=default notmuch git -C tags.git -p '' -ldebug status |& \
94     grep '^env ' | notmuch_dir_sanitize > OUTPUT
95 cat <<EOF > EXPECTED
96 env NOTMUCH_GIT_DIR = foo
97 env NOTMUCH_GIT_PREFIX = bar
98 env NOTMUCH_PROFILE = default
99 env NOTMUCH_CONFIG = CWD/notmuch-config
100 EOF
101 test_expect_equal_file EXPECTED OUTPUT
102
103 test_done