. $(dirname "$0")/test-lib.sh || exit 1
+if [ -n "${NOTMUCH_TEST_INSTALLED}" ]; then
+ test_done
+fi
+
add_email_corpus
test_begin_subtest "building database"
{
notmuch_status_t status;
status = notmuch_message_add_tag (message, "boom");
- printf("%d\n%d\n", message != NULL, status == NOTMUCH_STATUS_XAPIAN_EXCEPTION);
+ printf("%d\n%d\n", message != NULL, status == NOTMUCH_STATUS_CLOSED_DATABASE);
}
EOF
cat <<EOF > EXPECTED
{
notmuch_status_t status;
status = notmuch_message_remove_tag (message, "boom");
- printf("%d\n%d\n", message != NULL, status == NOTMUCH_STATUS_XAPIAN_EXCEPTION);
+ printf("%d\n%d\n", message != NULL, status == NOTMUCH_STATUS_CLOSED_DATABASE);
}
EOF
cat <<EOF > EXPECTED
test_expect_equal_file EXPECTED OUTPUT
test_begin_subtest "Handle converting tags to maildir flags with closed db"
-test_subtest_known_broken
cat c_head - c_tail <<'EOF' | test_C ${MAIL_DIR}
{
notmuch_status_t status;
{
notmuch_status_t status;
status = notmuch_message_remove_all_tags (message);
- printf("%d\n%d\n", message != NULL, status == NOTMUCH_STATUS_XAPIAN_EXCEPTION);
+ printf("%d\n%d\n", message != NULL, status == NOTMUCH_STATUS_CLOSED_DATABASE);
}
EOF
cat <<EOF > EXPECTED
{
notmuch_status_t status;
status = notmuch_message_freeze (message);
- printf("%d\n%d\n", message != NULL, status == NOTMUCH_STATUS_SUCCESS);
+ printf("%d\n%d\n", message != NULL, status == NOTMUCH_STATUS_CLOSED_DATABASE);
}
EOF
cat <<EOF > EXPECTED
{
notmuch_status_t status;
status = notmuch_message_thaw (message);
- printf("%d\n%d\n", message != NULL, status == NOTMUCH_STATUS_UNBALANCED_FREEZE_THAW);
+ printf("%d\n%d\n", message != NULL, status == NOTMUCH_STATUS_CLOSED_DATABASE);
}
EOF
cat <<EOF > EXPECTED
EOF
test_expect_equal_file EXPECTED OUTPUT
+TERMLIST_PATH=(${MAIL_DIR}/.notmuch/xapian/termlist.*)
+test_begin_subtest "remove message with corrupted db"
+backup_database
+cat c_head0 - c_tail <<'EOF' | test_private_C ${MAIL_DIR} ${TERMLIST_PATH}
+ {
+ notmuch_status_t status;
+
+ int fd = open(argv[2],O_WRONLY|O_TRUNC);
+ if (fd < 0) {
+ fprintf (stderr, "error opening %s\n", argv[1]);
+ exit (1);
+ }
+
+ stat = _notmuch_message_delete (message);
+ printf ("%d\n", stat == NOTMUCH_STATUS_XAPIAN_EXCEPTION);
+ }
+EOF
+cat <<EOF > EXPECTED
+== stdout ==
+1
+== stderr ==
+A Xapian exception occurred at message.cc:XXX: EOF reading block YYY
+EOF
+sed 's/EOF reading block [0-9]*/EOF reading block YYY/' < OUTPUT > OUTPUT.clean
+test_expect_equal_file EXPECTED OUTPUT.clean
+restore_database
+
test_done