[PATCH 1/2] test: known broken test for n_directory_delete with closed db.

Subject: [PATCH 1/2] test: known broken test for n_directory_delete with closed db.

Date: Sun, 26 Jul 2020 21:55:06 -0300

To: David Bremner, notmuch@notmuchmail.org

Cc:

From: David Bremner


There is a return value bug in notmuch_directory_delete that is hiding
the exception.
---
 Well that was embarrassing. Silly bug in notmuch code, nothing to do with Xapian.
 
 test/T563-lib-directory.sh | 38 +++++++++++++++++++++++++++++++++++++-
 1 file changed, 37 insertions(+), 1 deletion(-)

diff --git a/test/T563-lib-directory.sh b/test/T563-lib-directory.sh
index 739469a6..8777f62b 100755
--- a/test/T563-lib-directory.sh
+++ b/test/T563-lib-directory.sh
@@ -26,7 +26,7 @@ int main (int argc, char** argv)
      exit (1);
    }
 
-   EXPECT0(notmuch_database_get_directory (db, "", &dir));
+   EXPECT0(notmuch_database_get_directory (db, "bar", &dir));
    EXPECT0(notmuch_database_close (db));
 EOF
 
@@ -74,4 +74,40 @@ A Xapian exception occurred at lib/directory.cc:XXX: Database has been closed
 EOF
 test_expect_equal_file EXPECTED OUTPUT
 
+backup_database
+test_begin_subtest "delete directory document for a closed db"
+test_subtest_known_broken
+cat c_head - c_tail <<'EOF' | test_C ${MAIL_DIR}
+    {
+        stat = notmuch_directory_delete (dir);
+        printf ("%d\n", stat == NOTMUCH_STATUS_XAPIAN_EXCEPTION);
+    }
+EOF
+cat <<EOF > EXPECTED
+== stdout ==
+1
+== stderr ==
+A Xapian exception occurred deleting directory entry: Database has been closed.
+EOF
+test_expect_equal_file EXPECTED OUTPUT
+restore_database
+
+backup_database
+test_begin_subtest "get/set mtime of directory for a closed db"
+cat c_head - c_tail <<'EOF' | test_C ${MAIL_DIR}
+    {
+        time_t stamp = notmuch_directory_get_mtime (dir);
+        stat = notmuch_directory_set_mtime (dir, stamp);
+        printf ("%d\n", stat == NOTMUCH_STATUS_XAPIAN_EXCEPTION);
+    }
+EOF
+cat <<EOF > EXPECTED
+== stdout ==
+1
+== stderr ==
+A Xapian exception occurred setting directory mtime: Database has been closed.
+EOF
+test_expect_equal_file EXPECTED OUTPUT
+restore_database
+
 test_done
-- 
2.27.0
_______________________________________________
notmuch mailing list -- notmuch@notmuchmail.org
To unsubscribe send an email to notmuch-leave@notmuchmail.org

Thread: