From 1f230d322e005d04f9dfcce25c92d529a3c6c6f2 Mon Sep 17 00:00:00 2001 From: Tomi Ollila Date: Thu, 11 Jun 2015 23:21:30 +0300 Subject: [PATCH] Re: [PATCH 1/2] lib: add NOTMUCH_STATUS_PATH_ERROR --- 10/bd49c6d0ab9d769ad804c239953b8ce371d3a6 | 181 ++++++++++++++++++++++ 1 file changed, 181 insertions(+) create mode 100644 10/bd49c6d0ab9d769ad804c239953b8ce371d3a6 diff --git a/10/bd49c6d0ab9d769ad804c239953b8ce371d3a6 b/10/bd49c6d0ab9d769ad804c239953b8ce371d3a6 new file mode 100644 index 000000000..db22b2e17 --- /dev/null +++ b/10/bd49c6d0ab9d769ad804c239953b8ce371d3a6 @@ -0,0 +1,181 @@ +Return-Path: +X-Original-To: notmuch@notmuchmail.org +Delivered-To: notmuch@notmuchmail.org +Received: from localhost (localhost [127.0.0.1]) + by arlo.cworth.org (Postfix) with ESMTP id 6F4546DE0B29 + for ; Thu, 11 Jun 2015 13:22:00 -0700 (PDT) +X-Virus-Scanned: Debian amavisd-new at cworth.org +X-Spam-Flag: NO +X-Spam-Score: 1 +X-Spam-Level: * +X-Spam-Status: No, score=1 tagged_above=-999 required=5 tests=[AWL=0.348, + SPF_NEUTRAL=0.652] autolearn=disabled +Received: from arlo.cworth.org ([127.0.0.1]) + by localhost (arlo.cworth.org [127.0.0.1]) (amavisd-new, port 10024) + with ESMTP id MAsKa3X6PHFt for ; + Thu, 11 Jun 2015 13:21:57 -0700 (PDT) +Received: from guru.guru-group.fi (guru.guru-group.fi [46.183.73.34]) + by arlo.cworth.org (Postfix) with ESMTP id 118056DE0948 + for ; Thu, 11 Jun 2015 13:21:56 -0700 (PDT) +Received: from guru.guru-group.fi (localhost [IPv6:::1]) + by guru.guru-group.fi (Postfix) with ESMTP id 47C0510005A; + Thu, 11 Jun 2015 23:21:31 +0300 (EEST) +From: Tomi Ollila +To: David Bremner , David Bremner , + Morgan Veyret , notmuch@notmuchmail.org +Subject: Re: [PATCH 1/2] lib: add NOTMUCH_STATUS_PATH_ERROR +In-Reply-To: <1433920621-5279-1-git-send-email-david@tethera.net> +References: <87oakqj5rm.fsf@maritornes.cs.unb.ca> + <1433920621-5279-1-git-send-email-david@tethera.net> +User-Agent: Notmuch/0.20+12~gf3d9440 (http://notmuchmail.org) Emacs/24.3.1 + (x86_64-unknown-linux-gnu) +X-Face: HhBM'cA~ +MIME-Version: 1.0 +Content-Type: text/plain +X-BeenThere: notmuch@notmuchmail.org +X-Mailman-Version: 2.1.18 +Precedence: list +List-Id: "Use and development of the notmuch mail system." + +List-Unsubscribe: , + +List-Archive: +List-Post: +List-Help: +List-Subscribe: , + +X-List-Received-Date: Thu, 11 Jun 2015 20:22:00 -0000 + +On Wed, Jun 10 2015, David Bremner wrote: + +> The difference with FILE_ERROR is that this is for things that are +> wrong with the path before looking at the disk. +> +> Add some 3 tests; two broken as a reminder to actually use this new +> code. +> --- + +Series looks good, tests pass. + +Tomi + + +> lib/database.cc | 2 ++ +> lib/notmuch.h | 5 +++++ +> test/T070-insert.sh | 2 +- +> test/T560-lib-error.sh | 42 ++++++++++++++++++++++++++++++++++++++++-- +> 4 files changed, 48 insertions(+), 3 deletions(-) +> +> diff --git a/lib/database.cc b/lib/database.cc +> index 78a24f7..e726f62 100644 +> --- a/lib/database.cc +> +++ b/lib/database.cc +> @@ -342,6 +342,8 @@ notmuch_status_to_string (notmuch_status_t status) +> return "Unsupported operation"; +> case NOTMUCH_STATUS_UPGRADE_REQUIRED: +> return "Operation requires a database upgrade"; +> + case NOTMUCH_STATUS_PATH_ERROR: +> + return "Path supplied is illegal for this function"; +> default: +> case NOTMUCH_STATUS_LAST_STATUS: +> return "Unknown error status value"; +> diff --git a/lib/notmuch.h b/lib/notmuch.h +> index 20c4e01..aab0151 100644 +> --- a/lib/notmuch.h +> +++ b/lib/notmuch.h +> @@ -164,6 +164,11 @@ typedef enum _notmuch_status { +> */ +> NOTMUCH_STATUS_UPGRADE_REQUIRED, +> /** +> + * There is a problem with the proposed path, a relative path +> + * passed to a function expecting an absolute path. +> + */ +> + NOTMUCH_STATUS_PATH_ERROR, +> + /** +> * Not an actual status value. Just a way to find out how many +> * valid status values there are. +> */ +> diff --git a/test/T070-insert.sh b/test/T070-insert.sh +> index 74f1955..7e71c3b 100755 +> --- a/test/T070-insert.sh +> +++ b/test/T070-insert.sh +> @@ -188,7 +188,7 @@ notmuch config set new.tags $OLDCONFIG +> # DUPLICATE_MESSAGE_ID is not tested here, because it should actually pass. +> +> for code in OUT_OF_MEMORY XAPIAN_EXCEPTION FILE_NOT_EMAIL \ +> - READ_ONLY_DATABASE UPGRADE_REQUIRED; do +> + READ_ONLY_DATABASE UPGRADE_REQUIRED PATH_ERROR; do +> gen_insert_msg +> cat < index-file-$code.gdb +> set breakpoint pending on +> diff --git a/test/T560-lib-error.sh b/test/T560-lib-error.sh +> index c99b17e..9f5f7ae 100755 +> --- a/test/T560-lib-error.sh +> +++ b/test/T560-lib-error.sh +> @@ -35,7 +35,8 @@ Error: Cannot open a database for a NULL path. +> EOF +> test_expect_equal_file EXPECTED OUTPUT +> +> -test_begin_subtest "Open nonexistent database" +> +test_begin_subtest "Open relative path" +> +test_subtest_known_broken +> test_C <<'EOF' +> #include +> #include +> @@ -49,7 +50,44 @@ EOF +> cat <<'EOF' >EXPECTED +> == stdout == +> == stderr == +> -Error opening database at ./nonexistent/foo/.notmuch: No such file or directory +> +Error: Database path must be absolute. +> +EOF +> +test_expect_equal_file EXPECTED OUTPUT +> + +> +test_begin_subtest "Create database in relative path" +> +test_subtest_known_broken +> +test_C <<'EOF' +> +#include +> +#include +> +int main (int argc, char** argv) +> +{ +> + notmuch_database_t *db; +> + notmuch_status_t stat; +> + stat = notmuch_database_create ("./nonexistent/foo", &db); +> +} +> +EOF +> +cat <<'EOF' >EXPECTED +> +== stdout == +> +== stderr == +> +Error: Database path must be absolute. +> +EOF +> +test_expect_equal_file EXPECTED OUTPUT +> + +> +test_begin_subtest "Open nonexistent database" +> +test_C ${PWD}/nonexistent/foo <<'EOF' +> +#include +> +#include +> +int main (int argc, char** argv) +> +{ +> + notmuch_database_t *db; +> + notmuch_status_t stat; +> + stat = notmuch_database_open (argv[1], 0, 0); +> +} +> +EOF +> +cat <<'EOF' >EXPECTED +> +== stdout == +> +== stderr == +> +Error opening database at CWD/nonexistent/foo/.notmuch: No such file or directory +> EOF +> test_expect_equal_file EXPECTED OUTPUT +> +> -- +> 2.1.4 +> +> _______________________________________________ +> notmuch mailing list +> notmuch@notmuchmail.org +> http://notmuchmail.org/mailman/listinfo/notmuch -- 2.26.2