unofficial mirror of notmuch@notmuchmail.org
 help / color / mirror / code / Atom feed
From: Tomi Ollila <tomi.ollila@iki.fi>
To: David Bremner <david@tethera.net>,
	David Bremner <david@tethera.net>,
	Morgan Veyret <morgan.veyret@gmail.com>,
	notmuch@notmuchmail.org
Subject: Re: [PATCH 1/2] lib: add NOTMUCH_STATUS_PATH_ERROR
Date: Thu, 11 Jun 2015 23:21:30 +0300	[thread overview]
Message-ID: <m2k2vam1x1.fsf@guru.guru-group.fi> (raw)
In-Reply-To: <1433920621-5279-1-git-send-email-david@tethera.net>

On Wed, Jun 10 2015, David Bremner <david@tethera.net> 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 <<EOF > 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 <stdio.h>
>  #include <notmuch.h>
> @@ -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 <stdio.h>
> +#include <notmuch.h>
> +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 <stdio.h>
> +#include <notmuch.h>
> +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

  parent reply	other threads:[~2015-06-11 20:22 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-06-07 15:12 BUG: maildir flags sync with database relative path results in corrupted filename Morgan Veyret
2015-06-08  6:02 ` David Bremner
2015-06-08 18:41   ` Morgan Veyret
2015-06-08 20:37     ` David Bremner
2015-06-10  7:17       ` [PATCH 1/2] lib: add NOTMUCH_STATUS_PATH_ERROR David Bremner
2015-06-10  7:17         ` [PATCH 2/2] lib: reject relative paths in n_d_{create,open}_verbose David Bremner
2015-06-11 20:21         ` Tomi Ollila [this message]
2015-06-12  5:40           ` [PATCH 1/2] lib: add NOTMUCH_STATUS_PATH_ERROR David Bremner

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: https://notmuchmail.org/

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=m2k2vam1x1.fsf@guru.guru-group.fi \
    --to=tomi.ollila@iki.fi \
    --cc=david@tethera.net \
    --cc=morgan.veyret@gmail.com \
    --cc=notmuch@notmuchmail.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).