unofficial mirror of notmuch@notmuchmail.org
 help / color / mirror / code / Atom feed
blob 4457269502ffdd7e5fb4a4f623594029b08a54e2 5180 bytes (raw)
name: test/T055-path-config.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
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
 
#!/usr/bin/env bash
test_description='Configuration of mail-root and database path'
. $(dirname "$0")/test-lib.sh || exit 1

backup_config () {
    local test_name=$(basename $0 .sh)
    cp ${NOTMUCH_CONFIG} notmuch-config-backup.${test_name}
}

restore_config () {
    local test_name=$(basename $0 .sh)
    export NOTMUCH_CONFIG="${TMP_DIRECTORY}/notmuch-config"
    unset CONFIG_PATH
    unset DATABASE_PATH
    unset NOTMUCH_PROFILE
    cp notmuch-config-backup.${test_name} ${NOTMUCH_CONFIG}
}

split_config () {
    local dir
    backup_config
    dir="$TMP_DIRECTORY/database.$test_count"
    rm -rf $dir
    mkdir $dir
    notmuch config set database.path $dir
    notmuch config set database.mail_root $MAIL_DIR
    DATABASE_PATH=$dir
}

xdg_config () {
    local dir
    local profile=${1:-default}

    if [[ $profile != default ]]; then
	export NOTMUCH_PROFILE=$profile
    fi

    backup_config
    DATABASE_PATH="${HOME}/.local/share/notmuch/${profile}"
    rm -rf $DATABASE_PATH
    mkdir -p $DATABASE_PATH

    config_dir="${HOME}/.config/notmuch/${profile}"
    mkdir -p ${config_dir}
    CONFIG_PATH=$config_dir/config
    mv ${NOTMUCH_CONFIG} $CONFIG_PATH
    unset NOTMUCH_CONFIG

    notmuch --config=${CONFIG_PATH} config set database.mail_root ${TMP_DIRECTORY}/mail
    notmuch --config=${CONFIG_PATH} config set database.path
}

for config in traditional split+prefix split XDG XDG+profile; do
    #start each set of tests with an known set of messages
    add_email_corpus

    case $config in
	traditional)
	    backup_config
	    ;;
	split+prefix)
	    split_config
	    mv mail/.notmuch $DATABASE_PATH
	    ;;
	split)
	    split_config
	    mv mail/.notmuch/xapian $DATABASE_PATH
	    ;;
	XDG)
	    xdg_config
	    mv mail/.notmuch/xapian $DATABASE_PATH
	    ;;
	XDG+profile)
	    xdg_config ${RANDOM}
	    mv mail/.notmuch/xapian $DATABASE_PATH
	    ;;
    esac

    test_begin_subtest "count ($config)"
    output=$(notmuch count '*')
    test_expect_equal "$output" '52'

    test_begin_subtest "count+tag ($config)"
    tag="tag${RANDOM}"
    notmuch tag +$tag '*'
    output=$(notmuch count tag:$tag)
    notmuch tag -$tag '*'
    test_expect_equal "$output" '52'

    test_begin_subtest "create database ($config)"
    rm -rf $DATABASE_PATH/{.notmuch,}/xapian
    notmuch new
    output=$(notmuch count '*')
    test_expect_equal "$output" '52'

    test_begin_subtest "detect new files ($config)"
    generate_message
    generate_message
    notmuch new
    output=$(notmuch count '*')
    test_expect_equal "$output" '54'

    test_begin_subtest "insert+search ($config)"
    generate_message \
	"[subject]=\"insert-subject\"" \
	"[date]=\"Sat, 01 Jan 2000 12:00:00 -0000\"" \
	"[body]=\"insert-message\""
    mkdir -p "$MAIL_DIR"/{cur,new,tmp}
    notmuch insert < "$gen_msg_filename"
    cur_msg_filename=$(notmuch search --output=files "subject:insert-subject")
    test_expect_equal_file "$cur_msg_filename" "$gen_msg_filename"

    test_begin_subtest "Show a raw message ($config)"
    add_message
    notmuch show --format=raw id:$gen_msg_id > OUTPUT
    test_expect_equal_file $gen_msg_filename OUTPUT
    rm -f $gen_msg_filename

    test_begin_subtest "compact+search ($config)"
    notmuch search --output=messages '*' | sort > EXPECTED
    notmuch compact
    notmuch search --output=messages '*' | sort > OUTPUT
    test_expect_equal_file EXPECTED OUTPUT


    test_begin_subtest "reply ($config)"
    add_message '[from]="Sender <sender@example.com>"' \
		[to]=test_suite@notmuchmail.org \
		[subject]=notmuch-reply-test \
		'[date]="Tue, 05 Jan 2010 15:43:56 -0000"' \
		'[body]="basic reply test"'
    notmuch reply id:${gen_msg_id} 2>&1 > OUTPUT
    cat <<EOF > EXPECTED
From: Notmuch Test Suite <test_suite@notmuchmail.org>
Subject: Re: notmuch-reply-test
To: Sender <sender@example.com>
In-Reply-To: <${gen_msg_id}>
References: <${gen_msg_id}>

On Tue, 05 Jan 2010 15:43:56 -0000, Sender <sender@example.com> wrote:
> basic reply test
EOF
    test_expect_equal_file EXPECTED OUTPUT

    test_begin_subtest "address ($config)"
    notmuch address --deduplicate=no --sort=newest-first --output=sender --output=recipients path:foo >OUTPUT
    cat <<EOF >EXPECTED
Carl Worth <cworth@cworth.org>
notmuch@notmuchmail.org
EOF
    test_expect_equal_file EXPECTED OUTPUT

    test_begin_subtest "dump ($config)"
    notmuch dump is:attachment and is:signed > OUTPUT
    cat <<EOF > EXPECTED
#notmuch-dump batch-tag:3 config,properties,tags
+attachment +inbox +signed +unread -- id:20091118005829.GB25380@dottiness.seas.harvard.edu
+attachment +inbox +signed +unread -- id:20091118010116.GC25380@dottiness.seas.harvard.edu
EOF
    test_expect_equal_file EXPECTED OUTPUT

    test_begin_subtest "dump + tag + restore ($config)"
    notmuch dump '*' > EXPECTED
    notmuch tag -inbox '*'
    notmuch restore < EXPECTED
    notmuch dump > OUTPUT
    test_expect_equal_file EXPECTED OUTPUT

    test_begin_subtest 'reindex ($config)'
    notmuch search --output=messages '*' > EXPECTED
    notmuch reindex '*'
    notmuch search --output=messages '*' > OUTPUT
    test_expect_equal_file EXPECTED OUTPUT

    restore_config
done

test_done

debug log:

solving 44572695 ...
found 44572695 in https://yhetil.org/notmuch/20210208004109.1192719-24-david@tethera.net/
found 5251aebf in https://yhetil.org/notmuch/20210208004109.1192719-23-david@tethera.net/
found 13086e50 in https://yhetil.org/notmuch/20210208004109.1192719-22-david@tethera.net/
found d0019cd1 in https://yhetil.org/notmuch/20210208004109.1192719-21-david@tethera.net/
found 7bd9739b in https://yhetil.org/notmuch/20210208004109.1192719-20-david@tethera.net/
found e5036400 in https://yhetil.org/notmuch/20210208004109.1192719-19-david@tethera.net/
found 1bae1b1b in https://yhetil.org/notmuch/20210208004109.1192719-17-david@tethera.net/
found 6882ab16 in https://yhetil.org/notmuch/20210208004109.1192719-16-david@tethera.net/
found c82b6a14 in https://yhetil.org/notmuch/20210208004109.1192719-15-david@tethera.net/
found 59b12337 in https://yhetil.org/notmuch/20210208004109.1192719-14-david@tethera.net/
found 1da0e9fe in https://yhetil.org/notmuch/20210208004109.1192719-9-david@tethera.net/
found 54c337ef in https://yhetil.org/notmuch/20210208004109.1192719-8-david@tethera.net/

applying [1/12] https://yhetil.org/notmuch/20210208004109.1192719-8-david@tethera.net/
diff --git a/test/T055-path-config.sh b/test/T055-path-config.sh
new file mode 100755
index 00000000..54c337ef


applying [2/12] https://yhetil.org/notmuch/20210208004109.1192719-9-david@tethera.net/
diff --git a/test/T055-path-config.sh b/test/T055-path-config.sh
index 54c337ef..1da0e9fe 100755


applying [3/12] https://yhetil.org/notmuch/20210208004109.1192719-14-david@tethera.net/
diff --git a/test/T055-path-config.sh b/test/T055-path-config.sh
index 1da0e9fe..59b12337 100755


applying [4/12] https://yhetil.org/notmuch/20210208004109.1192719-15-david@tethera.net/
diff --git a/test/T055-path-config.sh b/test/T055-path-config.sh
index 59b12337..c82b6a14 100755


applying [5/12] https://yhetil.org/notmuch/20210208004109.1192719-16-david@tethera.net/
diff --git a/test/T055-path-config.sh b/test/T055-path-config.sh
index c82b6a14..6882ab16 100755


applying [6/12] https://yhetil.org/notmuch/20210208004109.1192719-17-david@tethera.net/
diff --git a/test/T055-path-config.sh b/test/T055-path-config.sh
index 6882ab16..1bae1b1b 100755


applying [7/12] https://yhetil.org/notmuch/20210208004109.1192719-19-david@tethera.net/
diff --git a/test/T055-path-config.sh b/test/T055-path-config.sh
index 1bae1b1b..e5036400 100755


applying [8/12] https://yhetil.org/notmuch/20210208004109.1192719-20-david@tethera.net/
diff --git a/test/T055-path-config.sh b/test/T055-path-config.sh
index e5036400..7bd9739b 100755


applying [9/12] https://yhetil.org/notmuch/20210208004109.1192719-21-david@tethera.net/
diff --git a/test/T055-path-config.sh b/test/T055-path-config.sh
index 7bd9739b..d0019cd1 100755


applying [10/12] https://yhetil.org/notmuch/20210208004109.1192719-22-david@tethera.net/
diff --git a/test/T055-path-config.sh b/test/T055-path-config.sh
index d0019cd1..13086e50 100755


applying [11/12] https://yhetil.org/notmuch/20210208004109.1192719-23-david@tethera.net/
diff --git a/test/T055-path-config.sh b/test/T055-path-config.sh
index 13086e50..5251aebf 100755


applying [12/12] https://yhetil.org/notmuch/20210208004109.1192719-24-david@tethera.net/
diff --git a/test/T055-path-config.sh b/test/T055-path-config.sh
index 5251aebf..44572695 100755

Checking patch test/T055-path-config.sh...
Applied patch test/T055-path-config.sh cleanly.
Checking patch test/T055-path-config.sh...
Applied patch test/T055-path-config.sh cleanly.
Checking patch test/T055-path-config.sh...
Applied patch test/T055-path-config.sh cleanly.
Checking patch test/T055-path-config.sh...
Applied patch test/T055-path-config.sh cleanly.
Checking patch test/T055-path-config.sh...
Applied patch test/T055-path-config.sh cleanly.
Checking patch test/T055-path-config.sh...
Applied patch test/T055-path-config.sh cleanly.
Checking patch test/T055-path-config.sh...
Applied patch test/T055-path-config.sh cleanly.
Checking patch test/T055-path-config.sh...
Applied patch test/T055-path-config.sh cleanly.
Checking patch test/T055-path-config.sh...
Applied patch test/T055-path-config.sh cleanly.
Checking patch test/T055-path-config.sh...
Applied patch test/T055-path-config.sh cleanly.
Checking patch test/T055-path-config.sh...
Applied patch test/T055-path-config.sh cleanly.
Checking patch test/T055-path-config.sh...
Applied patch test/T055-path-config.sh cleanly.

index at:
100755 4457269502ffdd7e5fb4a4f623594029b08a54e2	test/T055-path-config.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).