From: Tomi Ollila Date: Thu, 7 Apr 2016 13:57:56 +0000 (+0300) Subject: Re: [PATCH 3/3] test: cope with glass backend file naming variations X-Git-Url: http://git.tremily.us/?a=commitdiff_plain;h=13a1cfb710cb43c79e8b8bf0400e6cefcb1e620f;p=notmuch-archives.git Re: [PATCH 3/3] test: cope with glass backend file naming variations --- diff --git a/5f/2b81eed46891db5d755121073752638294a454 b/5f/2b81eed46891db5d755121073752638294a454 new file mode 100644 index 000000000..5bd765cbf --- /dev/null +++ b/5f/2b81eed46891db5d755121073752638294a454 @@ -0,0 +1,188 @@ +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 D83C46DE02B5 + for ; Thu, 7 Apr 2016 06:57:56 -0700 (PDT) +X-Virus-Scanned: Debian amavisd-new at cworth.org +X-Spam-Flag: NO +X-Spam-Score: 0.624 +X-Spam-Level: +X-Spam-Status: No, score=0.624 tagged_above=-999 required=5 tests=[AWL=-0.028, + 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 Sk1rRZAQ4V2x for ; + Thu, 7 Apr 2016 06:57:48 -0700 (PDT) +Received: from guru.guru-group.fi (guru.guru-group.fi [46.183.73.34]) + by arlo.cworth.org (Postfix) with ESMTP id 9C6DB6DE0134 + for ; Thu, 7 Apr 2016 06:57:47 -0700 (PDT) +Received: from guru.guru-group.fi (localhost [IPv6:::1]) + by guru.guru-group.fi (Postfix) with ESMTP id A05A91000E0; + Thu, 7 Apr 2016 16:57:56 +0300 (EEST) +From: Tomi Ollila +To: David Bremner , David Bremner , + notmuch@notmuchmail.org +Subject: Re: [PATCH 3/3] test: cope with glass backend file naming variations +In-Reply-To: <1459938431-28670-4-git-send-email-david@tethera.net> +References: <1459855082-5715-2-git-send-email-david@tethera.net> + <1459938431-28670-1-git-send-email-david@tethera.net> + <1459938431-28670-4-git-send-email-david@tethera.net> +User-Agent: Notmuch/0.21+99~g7cbc880 (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.20 +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, 07 Apr 2016 13:57:57 -0000 + +On Wed, Apr 06 2016, David Bremner wrote: + +> In several places in the test suite we intentionally corrupt the Xapian +> database in order to test error handling. This corruption is specific to +> the on-disk organization of the database, and that changed with the +> glass backend. Hopefully introducing a new backend will be a relatively +> rare event, so that hardcoding the names of backends in the test suite +> is good enough. +> --- +> test/T050-new.sh | 2 +- +> test/T060-count.sh | 2 ++ +> test/T150-tagging.sh | 4 ++-- +> test/T360-symbol-hiding.sh | 4 ++-- +> test/T560-lib-error.sh | 10 ++++++++-- +> 5 files changed, 15 insertions(+), 7 deletions(-) +> +> diff --git a/test/T050-new.sh b/test/T050-new.sh +> index 93a6fa9..fc93bfd 100755 +> --- a/test/T050-new.sh +> +++ b/test/T050-new.sh +> @@ -284,7 +284,7 @@ notmuch config set new.tags $OLDCONFIG +> +> +> test_begin_subtest "Xapian exception: read only files" +> -chmod u-w ${MAIL_DIR}/.notmuch/xapian/*.DB +> +chmod u-w ${MAIL_DIR}/.notmuch/xapian/{*.DB,*.glass} + +if either of these is missing, bash will by default expand like +.../.notmuch/xapian/*.DB or .../.notmuch/xapian/*.glass + +shopt -s nullglob + +could be added to remove this expansion (and make chmod not yell on error) + +> output=$(NOTMUCH_NEW --debug 2>&1 | sed 's/: .*$//' ) +> chmod u+w ${MAIL_DIR}/.notmuch/xapian/*.DB + +Why here the same expansion as above is not done ? + +> test_expect_equal "$output" "A Xapian exception occurred opening database" +> diff --git a/test/T060-count.sh b/test/T060-count.sh +> index 3fec94e..f1df4a2 100755 +> --- a/test/T060-count.sh +> +++ b/test/T060-count.sh +> @@ -96,6 +96,7 @@ test_expect_equal_file EXPECTED OUTPUT +> backup_database +> test_begin_subtest "error message for database open" +> dd if=/dev/zero of="${MAIL_DIR}/.notmuch/xapian/postlist.DB" count=3 +> +dd if=/dev/zero of="${MAIL_DIR}/.notmuch/xapian/postlist.glass" count=3 +> notmuch count '*' 2>OUTPUT 1>/dev/null +> output=$(sed 's/^\(A Xapian exception [^:]*\):.*$/\1/' OUTPUT) +> test_expect_equal "${output}" "A Xapian exception occurred opening database" +> @@ -106,6 +107,7 @@ set breakpoint pending on +> break count_files +> commands +> shell cp /dev/null ${MAIL_DIR}/.notmuch/xapian/postlist.DB +> +shell cp /dev/null ${MAIL_DIR}/.notmuch/xapian/postlist.glass +> continue +> end +> run +> diff --git a/test/T150-tagging.sh b/test/T150-tagging.sh +> index 8adcabc..601d091 100755 +> --- a/test/T150-tagging.sh +> +++ b/test/T150-tagging.sh +> @@ -287,9 +287,9 @@ test_expect_code 1 "Empty tag names" 'notmuch tag + One' +> test_expect_code 1 "Tag name beginning with -" 'notmuch tag +- One' +> +> test_begin_subtest "Xapian exception: read only files" +> -chmod u-w ${MAIL_DIR}/.notmuch/xapian/*.DB +> +chmod u-w ${MAIL_DIR}/.notmuch/xapian/{*.DB,*.glass} + +nullglob again + +> output=$(notmuch tag +something '*' 2>&1 | sed 's/: .*$//' ) +> -chmod u+w ${MAIL_DIR}/.notmuch/xapian/*.DB +> +chmod u+w ${MAIL_DIR}/.notmuch/xapian/{*.DB,*.glass} + +Here you've done that same expansion :D + +> test_expect_equal "$output" "A Xapian exception occurred opening database" +> +> test_done +> diff --git a/test/T360-symbol-hiding.sh b/test/T360-symbol-hiding.sh +> index 89e7f16..2ccdc63 100755 +> --- a/test/T360-symbol-hiding.sh +> +++ b/test/T360-symbol-hiding.sh +> @@ -15,11 +15,11 @@ test_begin_subtest 'running test' run_test +> mkdir -p ${PWD}/fakedb/.notmuch +> ( LD_LIBRARY_PATH="$TEST_DIRECTORY/../lib${LD_LIBRARY_PATH:+:$LD_LIBRARY_PATH}" \ +> $TEST_DIRECTORY/symbol-test ${PWD}/fakedb ${PWD}/nonexistent \ +> - 2>&1 | notmuch_dir_sanitize | sed "s,\`,\',g") > OUTPUT +> + 2>&1 | notmuch_dir_sanitize | sed -e "s,\`,\',g" -e 's,chert\|glass,foo,g') > OUTPUT +> +> cat < EXPECTED +> A Xapian exception occurred opening database: Couldn't stat 'CWD/fakedb/.notmuch/xapian' +> -caught No chert database found at path 'CWD/nonexistent' +> +caught No foo database found at path 'CWD/nonexistent' +> EOF +> test_expect_equal_file EXPECTED OUTPUT +> +> diff --git a/test/T560-lib-error.sh b/test/T560-lib-error.sh +> index 49d3674..7c5748b 100755 +> --- a/test/T560-lib-error.sh +> +++ b/test/T560-lib-error.sh +> @@ -189,7 +189,13 @@ Path already exists: MAIL_DIR +> EOF +> test_expect_equal_file EXPECTED OUTPUT +> +> -cat <<'EOF' > c_head +> +if [ -f "${MAIL_DIR}"/.notmuch/xapian/iamglass ]; then +> + db_ending=glass +> +else +> + db_ending=DB +> +fi +> + +> +cat < c_head +> #include +> #include +> #include +> @@ -210,7 +216,7 @@ int main (int argc, char** argv) +> 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", argv[1]); +> -- +> 2.8.0.rc3 +> +> _______________________________________________ +> notmuch mailing list +> notmuch@notmuchmail.org +> https://notmuchmail.org/mailman/listinfo/notmuch