X-Git-Url: https://git.notmuchmail.org/git?p=notmuch;a=blobdiff_plain;f=test%2FT560-lib-error.sh;h=34d15698d9b69c80139c1bc54c3eef95b54d3c73;hp=b1e77aa0ee3878506d5136050376ed2d2c6f4a75;hb=3805898e3e337768d13b223a40b0ea76da73657e;hpb=32fd74b7aa9c24ec77f8c59d09f89e0535bf64cd diff --git a/test/T560-lib-error.sh b/test/T560-lib-error.sh index b1e77aa0..34d15698 100755 --- a/test/T560-lib-error.sh +++ b/test/T560-lib-error.sh @@ -1,21 +1,12 @@ #!/usr/bin/env bash test_description="error reporting for library" -. ./test-lib.sh - -backup_database () { - rm -rf notmuch-dir-backup - cp -pR ${MAIL_DIR}/.notmuch notmuch-dir-backup -} -restore_database () { - rm -rf ${MAIL_DIR}/.notmuch - cp -pR notmuch-dir-backup ${MAIL_DIR}/.notmuch -} - +. ./test-lib.sh || exit 1 add_email_corpus -test_expect_success "building database" "NOTMUCH_NEW" +test_begin_subtest "building database" +test_expect_success "NOTMUCH_NEW" test_begin_subtest "Open null pointer" test_C <<'EOF' @@ -193,13 +184,13 @@ int main (int argc, char** argv) EOF cat <<'EOF' >EXPECTED == stdout == -Path already exists: CWD/mail +Path already exists: MAIL_DIR == stderr == EOF test_expect_equal_file EXPECTED OUTPUT -cat <<'EOF' > c_head +cat < c_head #include #include #include @@ -212,16 +203,20 @@ int main (int argc, char** argv) notmuch_database_t *db; notmuch_status_t stat; char *path; + char *msg = NULL; int fd; - stat = notmuch_database_open (argv[1], NOTMUCH_DATABASE_MODE_READ_WRITE, &db); + stat = notmuch_database_open_verbose (argv[1], NOTMUCH_DATABASE_MODE_READ_WRITE, &db, &msg); if (stat != NOTMUCH_STATUS_SUCCESS) { - fprintf (stderr, "error opening database: %d\n", stat); + fprintf (stderr, "error opening database: %d %s\n", stat, msg ? msg : ""); + exit (1); } - path = talloc_asprintf (db, "%s/.notmuch/xapian/postlist.DB", argv[1]); + path = talloc_asprintf (db, "%s/.notmuch/xapian/postlist.${db_ending}", argv[1]); fd = open(path,O_WRONLY|O_TRUNC); - if (fd < 0) - fprintf (stderr, "error opening %s\n"); + if (fd < 0) { + fprintf (stderr, "error opening %s\n", argv[1]); + exit (1); + } EOF cat <<'EOF' > c_tail if (stat) { @@ -291,7 +286,7 @@ cat c_head - c_tail <<'EOF' | test_C ${MAIL_DIR} { notmuch_messages_t *messages = NULL; notmuch_query_t *query=notmuch_query_create (db, "*"); - stat = notmuch_query_search_messages_st (query, &messages); + stat = notmuch_query_search_messages (query, &messages); } EOF sed 's/^\(A Xapian exception [^:]*\):.*$/\1/' < OUTPUT > OUTPUT.clean @@ -308,9 +303,9 @@ backup_database test_begin_subtest "Xapian exception counting messages" cat c_head - c_tail <<'EOF' | test_C ${MAIL_DIR} { + int count; notmuch_query_t *query=notmuch_query_create (db, "id:87ocn0qh6d.fsf@yoom.home.cworth.org"); - int count = notmuch_query_count_messages (query); - stat = (count == 0); + stat = notmuch_query_count_messages (query, &count); } EOF sed 's/^\(A Xapian exception [^:]*\):.*$/\1/' < OUTPUT > OUTPUT.clean