Re: [PATCH] notmuch-mutt: replace extra command with notmuch-native thread search feature

2023-04-09 Thread Paul Wise
On Sun, 2023-04-09 at 13:00 -0300, David Bremner wrote:

> You might be interested in the s-expression query parser. Part of the
> goal is to be less dwim/quirky than the native Xapian query parser, and
> to make it easier / safer to construct notmuch queries via programs.

That does seem saner to manually construct queries in, but it would
still be better to have a query construction library, otherwise
programs are going to get it wrong all the time, even within notmuch.

> It doesn't do the message-id munging you mention (yet?),

This is a big part of the query construction headache, re-implementing
the space stripping is easy, the user part removal is harder and I
can't find any docs on what else is required here.

PS: I don't intend to work on switching notmuch-mutt to sexp.

-- 
bye,
pabs

https://bonedaddy.net/pabs3/


signature.asc
Description: This is a digitally signed message part
___
notmuch mailing list -- notmuch@notmuchmail.org
To unsubscribe send an email to notmuch-le...@notmuchmail.org


Re: [PATCH] notmuch-mutt: replace extra command with notmuch-native thread search feature

2023-04-09 Thread David Bremner
Paul Wise  writes:

> So I think that it would be good if there were a library for notmuch
> query construction that would take care of all the different quoting
> levels, Message-Id munging etc. This could then get language bindings
> so that notmuch based tools and MUAs could use them for interactive
> graphical query construction. Also maybe Xapian needs or has a way to
> construct queries without serialising them to a text string and the
> notmuch query construction library I propose could base itself on that.

You might be interested in the s-expression query parser. Part of the
goal is to be less dwim/quirky than the native Xapian query parser, and
to make it easier / safer to construct notmuch queries via programs.

It doesn't do the message-id munging you mention (yet?), but quoting is
IMHO saner.

It does require an extra dependency (sfsexpr).
___
notmuch mailing list -- notmuch@notmuchmail.org
To unsubscribe send an email to notmuch-le...@notmuchmail.org


[PATCH v3 5/5] debian: add autopkgtests

2023-04-09 Thread David Bremner
We generate output to stderr for BROKEN tests, which are not failures,
so tell the test runner not to fail because of output on stderr.
---
 debian/tests/control | 17 +
 1 file changed, 17 insertions(+)
 create mode 100644 debian/tests/control

diff --git a/debian/tests/control b/debian/tests/control
new file mode 100644
index ..87e00dc8
--- /dev/null
+++ b/debian/tests/control
@@ -0,0 +1,17 @@
+Test-command: env NOTMUCH_TEST_INSTALLED=1 TERM=dumb
+NOTMUCH_HAVE_MAN=1 NOTMUCH_HAVE_SFSEXP=1 
NOTMUCH_HAVE_XAPIAN_DB_RETRY_LOCK=1
+NOTMUCH_HAVE_PYTHON3_CFFI=1 NOTMUCH_HAVE_PYTHON3_PYTEST=1
+NOTMUCH_HAVE_ASAN=1 NOTMUCH_HAVE_TSAN=1
+./test/notmuch-test
+Restrictions: allow-stderr
+Depends: @,
+ build-essential,
+ dtach,
+ emacs-nox,
+ gdb,
+ git,
+ gnupg,
+ gpgsm,
+ libtalloc-dev,
+ man,
+ xapian-tools
-- 
2.39.2

___
notmuch mailing list -- notmuch@notmuchmail.org
To unsubscribe send an email to notmuch-le...@notmuchmail.org


[PATCH v3 1/5] test: use bash specific test for feature tests

2023-04-09 Thread David Bremner
It is desirable to have the tests consider these variables being
undefined as equivalent to the feature not being present, and in
particular for the tests not to generate errors.

We know the test suite is tied to bash anyway, so this is a simple
fix.
---
 test/T060-count.sh   | 2 +-
 test/T081-sexpr-search.sh| 2 +-
 test/T150-tagging.sh | 2 +-
 test/T160-json.sh| 2 +-
 test/T220-reply.sh   | 2 +-
 test/T240-dump-restore.sh| 2 +-
 test/T391-python-cffi.sh | 3 +--
 test/T392-python-cffi-notmuch.sh | 2 +-
 test/T520-show.sh| 2 +-
 test/T570-revision-tracking.sh   | 2 +-
 test/T700-reindex.sh | 2 +-
 test/T800-asan.sh| 2 +-
 test/T810-tsan.sh| 2 +-
 test/T850-git.sh | 2 +-
 14 files changed, 14 insertions(+), 15 deletions(-)

diff --git a/test/T060-count.sh b/test/T060-count.sh
index 48146706..4499b4cb 100755
--- a/test/T060-count.sh
+++ b/test/T060-count.sh
@@ -157,7 +157,7 @@ print("4: {} messages".format(query.count_messages()))
 EOF
 test_expect_equal_file EXPECTED OUTPUT
 
-if [ $NOTMUCH_HAVE_SFSEXP -eq 1 ]; then
+if [[ $NOTMUCH_HAVE_SFSEXP -eq 1 ]]; then
 
 test_begin_subtest "and of exact terms (query=sexp)"
 output=$(notmuch count --query=sexp '(and "wonderful" "wizard")')
diff --git a/test/T081-sexpr-search.sh b/test/T081-sexpr-search.sh
index 0c7db9c2..17b02e06 100755
--- a/test/T081-sexpr-search.sh
+++ b/test/T081-sexpr-search.sh
@@ -2,7 +2,7 @@
 test_description='"notmuch search" in several variations'
 . $(dirname "$0")/test-lib.sh || exit 1
 
-if [ $NOTMUCH_HAVE_SFSEXP -ne 1 ]; then
+if [[ $NOTMUCH_HAVE_SFSEXP -ne 1 ]]; then
 printf "Skipping due to missing sfsexp library\n"
 test_done
 fi
diff --git a/test/T150-tagging.sh b/test/T150-tagging.sh
index ac3f2539..af0b8448 100755
--- a/test/T150-tagging.sh
+++ b/test/T150-tagging.sh
@@ -328,7 +328,7 @@ test_expect_equal "$output" "A Xapian exception occurred 
opening database"
 
 add_email_corpus
 
-if [ $NOTMUCH_HAVE_SFSEXP -eq 1 ]; then
+if [[ $NOTMUCH_HAVE_SFSEXP -eq 1 ]]; then
 
 test_query_syntax '(and "wonderful" "wizard")' 'wonderful and wizard'
 test_query_syntax '(or "php" "wizard")' 'php or wizard'
diff --git a/test/T160-json.sh b/test/T160-json.sh
index 4a797f6a..6f637a21 100755
--- a/test/T160-json.sh
+++ b/test/T160-json.sh
@@ -66,7 +66,7 @@ test_expect_equal_json "$output" "[{\"thread\": \"XXX\",
  \"unread\"]}]"
 
 test_begin_subtest "Search message: json, 64-bit timestamp"
-if [ $NOTMUCH_HAVE_64BIT_TIME_T -ne 1 ]; then
+if [[ $NOTMUCH_HAVE_64BIT_TIME_T -ne 1 ]]; then
 test_subtest_known_broken
 fi
 add_message "[subject]=\"json-search-64bit-timestamp-subject\"" "[date]=\"Tue, 
01 Jan 2999 12:00:00 -\"" "[body]=\"json-search-64bit-timestamp-message\""
diff --git a/test/T220-reply.sh b/test/T220-reply.sh
index 207f5788..a5a9a1df 100755
--- a/test/T220-reply.sh
+++ b/test/T220-reply.sh
@@ -24,7 +24,7 @@ test_begin_subtest "Basic reply"
 notmuch reply id:${gen_msg_id} >OUTPUT 2>&1 && echo OK >> OUTPUT
 test_expect_equal_file basic.expected OUTPUT
 
-if [ $NOTMUCH_HAVE_SFSEXP -eq 1 ]; then
+if [[ $NOTMUCH_HAVE_SFSEXP -eq 1 ]]; then
 
 test_begin_subtest "Basic reply (query=sexp)"
 notmuch reply --query=sexp "(id ${gen_msg_id})" >OUTPUT 2>&1 && echo OK >> 
OUTPUT
diff --git a/test/T240-dump-restore.sh b/test/T240-dump-restore.sh
index a86f0fb7..b99a303e 100755
--- a/test/T240-dump-restore.sh
+++ b/test/T240-dump-restore.sh
@@ -118,7 +118,7 @@ notmuch dump -- from:cworth > dump-dash-cworth.actual
 test_expect_equal_file dump-cworth.expected dump-dash-cworth.actual
 
 
-if [ $NOTMUCH_HAVE_SFSEXP -eq 1 ]; then
+if [[ $NOTMUCH_HAVE_SFSEXP -eq 1 ]]; then
 
 test_begin_subtest "dump --query=sexp -- '(from cworth)'"
 notmuch dump --query=sexp -- '(from cworth)' > dump-dash-cworth.actual2
diff --git a/test/T391-python-cffi.sh b/test/T391-python-cffi.sh
index 30872af0..59ad087f 100755
--- a/test/T391-python-cffi.sh
+++ b/test/T391-python-cffi.sh
@@ -2,11 +2,10 @@
 test_description="python bindings (pytest)"
 . $(dirname "$0")/test-lib.sh || exit 1
 
-if [ $NOTMUCH_HAVE_PYTHON3_CFFI -eq 0 -o $NOTMUCH_HAVE_PYTHON3_PYTEST -eq 0 ]; 
then
+if [[ $NOTMUCH_HAVE_PYTHON3_CFFI -eq 0 || $NOTMUCH_HAVE_PYTHON3_PYTEST -eq 0 
]]; then
 test_done
 fi
 
-
 test_begin_subtest "python cffi tests (NOTMUCH_CONFIG set)"
 pytest_dir=$NOTMUCH_BUILDDIR/bindings/python-cffi/build/stage
 printf "[pytest]\nminversion = 3.0\naddopts = -ra\n" > $pytest_dir/pytest.ini
diff --git a/test/T392-python-cffi-notmuch.sh b/test/T392-python-cffi-notmuch.sh
index 15c8fc6b..c97da9b5 100755
--- a/test/T392-python-cffi-notmuch.sh
+++ b/test/T392-python-cffi-notmuch.sh
@@ -2,7 +2,7 @@
 test_description="python bindings (notmuch test suite)"
 . $(dirname "$0")/test-lib.sh || exit 1
 
-if [ $NOTMUCH_HAVE_PYTHON3_CFFI -eq 0 -o $NOTMUCH_HAVE_PYTHON3_PYTEST -eq 0 ]; 
then
+if [[ 

[PATCH v3 4/5] test: support testing notmuch as installed

2023-04-09 Thread David Bremner
We put some effort into testing the built copy rather than some
installed copy. On the other hand for people like packagers, testing
the installed copy is also of interest.

When NOTMUCH_TEST_INSTALLED is set to a nonempty value, tests do not
require a built notmuch tree or running configure.

Some of the tests marked as broken when running against installed
notmuch are probably fixable.
---
 test/README| 17 +
 test/T000-basic.sh |  1 +
 test/T010-help-test.sh |  5 -
 test/T160-json.sh  |  2 ++
 test/T240-dump-restore.sh  |  2 ++
 test/T310-emacs.sh |  2 ++
 test/T350-crypto.sh|  1 +
 test/T360-symbol-hiding.sh |  4 
 test/T390-python.sh|  4 
 test/T391-python-cffi.sh   |  6 +-
 test/T395-ruby.sh  |  8 ++--
 test/T410-argument-parsing.sh  |  4 
 test/T480-hex-escaping.sh  |  4 
 test/T490-parse-time-string.sh |  4 
 test/T550-db-features.sh   |  4 
 test/T566-lib-message.sh   |  4 
 test/T592-thread-breakage.sh   |  4 
 test/T710-message-id.sh|  4 
 test/T800-asan.sh  |  5 +
 test/T850-git.sh   |  6 ++
 test/export-dirs.sh|  2 +-
 test/notmuch-test  | 12 ++--
 test/test-lib-common.sh| 13 ++---
 test/test-lib-emacs.sh | 14 +++---
 test/test-lib.sh   | 27 +--
 25 files changed, 140 insertions(+), 19 deletions(-)

diff --git a/test/README b/test/README
index 10f127cb..a81808b1 100644
--- a/test/README
+++ b/test/README
@@ -137,6 +137,23 @@ detection of missing prerequisites. In the future we may 
treat tests
 unable to run because of missing prerequisites, but not explicitly
 skipped by the user, as failures.
 
+Testing installed notmuch
+-
+
+Systems integrators (e.g. Linux distros) may wish to test an installed
+version of notmuch.  This can be done be running
+
+ $ NOTMUCH_TEST_INSTALLED=1 ./test/notmuch-test
+
+In this scenario the test suite does not assume a built tree, and in
+particular cannot rely on the output of 'configure'. You may want to
+set certain feature environment variables ('NOTMUCH_HAVE_*') directly
+if you know those apply to your installed notmuch). Consider also
+setting TERM=dumb if the value of TERM cannot be used (e.g. in a
+chroot with missing terminfo). Note that having a built tree may cause
+surprising/broken results for NOTMUCH_TEST_INSTALLED, so consider
+cleaning first.
+
 Writing Tests
 -
 The test script is written as a shell script. It is to be named as
diff --git a/test/T000-basic.sh b/test/T000-basic.sh
index a2f4d93f..642f918d 100755
--- a/test/T000-basic.sh
+++ b/test/T000-basic.sh
@@ -66,6 +66,7 @@ test_begin_subtest 'NOTMUCH_CONFIG is set and points to an 
existing file'
 test_expect_success 'test -f "${NOTMUCH_CONFIG}"'
 
 test_begin_subtest 'PATH is set to build directory'
+test_subtest_broken_for_installed
 test_expect_equal \
 "$(dirname ${TEST_DIRECTORY})" \
 "$(echo $PATH|cut -f1 -d: | sed -e 's,/test/valgrind/bin$,,')"
diff --git a/test/T010-help-test.sh b/test/T010-help-test.sh
index da45d3ae..ae84c22d 100755
--- a/test/T010-help-test.sh
+++ b/test/T010-help-test.sh
@@ -12,13 +12,16 @@ test_expect_success 'notmuch help'
 test_begin_subtest 'notmuch --version'
 test_expect_success 'notmuch --version'
 
-if [ $NOTMUCH_HAVE_MAN -eq 1 ]; then
+if [[ $NOTMUCH_HAVE_MAN -eq 1 ]]; then
 test_begin_subtest 'notmuch --help tag'
 test_expect_success 'notmuch --help tag'
 
 test_begin_subtest 'notmuch help tag'
 test_expect_success 'notmuch help tag'
 else
+if [[ -n $NOTMUCH_TEST_INSTALLED ]]; then
+   test_done
+fi
 test_begin_subtest 'notmuch --help tag (man pages not available)'
 test_expect_success 'test_must_fail notmuch --help tag >/dev/null'
 
diff --git a/test/T160-json.sh b/test/T160-json.sh
index 6f637a21..b19058d7 100755
--- a/test/T160-json.sh
+++ b/test/T160-json.sh
@@ -65,6 +65,7 @@ test_expect_equal_json "$output" "[{\"thread\": \"XXX\",
  \"tags\": [\"inbox\",
  \"unread\"]}]"
 
+if [[ -z NOTMUCH_TEST_INSTALLED ]]; then
 test_begin_subtest "Search message: json, 64-bit timestamp"
 if [[ $NOTMUCH_HAVE_64BIT_TIME_T -ne 1 ]]; then
 test_subtest_known_broken
@@ -81,6 +82,7 @@ test_expect_equal_json "$output" "[{\"thread\": \"XXX\",
  \"query\": [\"id:$gen_msg_id\", null],
  \"tags\": [\"inbox\",
  \"unread\"]}]"
+fi
 
 test_begin_subtest "Format version: too low"
 test_expect_code 20 "notmuch search --format-version=0 \\*"
diff --git a/test/T240-dump-restore.sh b/test/T240-dump-restore.sh
index b99a303e..9072f636 100755
--- a/test/T240-dump-restore.sh
+++ b/test/T240-dump-restore.sh
@@ -139,6 +139,7 @@ notmuch dump --output=dump-outfile-dash-inbox.actual -- 
from:cworth
 test_expect_equal_file dump-cworth.expected dump-outfile-dash-inbox.actual
 
 

[PATCH v3 2/5] test: check for empty/missing files in test_expect_equal_message_body

2023-04-09 Thread David Bremner
Messages can have empty bodies, but empty files are not messages.
---
 test/test-lib.sh | 8 
 1 file changed, 8 insertions(+)

diff --git a/test/test-lib.sh b/test/test-lib.sh
index 1a6525df..b5aa94dd 100644
--- a/test/test-lib.sh
+++ b/test/test-lib.sh
@@ -388,6 +388,14 @@ test_expect_equal_message_body () {
 test "$#" = 2 ||
error "bug in the test script: not 2 parameters to 
test_expect_equal_file"
 
+for file in "$1" "$2"; do
+   if [ ! -s "$file" ]; then
+   test_failure_ "Missing or zero length file: $file"
+   inside_subtest=
+   return $?
+   fi
+done
+
 expected=$(sed '1,/^$/d' "$1")
 output=$(sed '1,/^$/d' "$2")
 test_expect_equal "$expected" "$output"
-- 
2.39.2

___
notmuch mailing list -- notmuch@notmuchmail.org
To unsubscribe send an email to notmuch-le...@notmuchmail.org


[PATCH v3 3/5] test: Guess a value for NOTMUCH_PYTHON

2023-04-09 Thread David Bremner
python3 will work for many people, and reduce the friction to running
the tests without running configure first.
---
 test/test-lib-common.sh | 4 
 1 file changed, 4 insertions(+)

diff --git a/test/test-lib-common.sh b/test/test-lib-common.sh
index 18fa29c0..4d14e0b3 100644
--- a/test/test-lib-common.sh
+++ b/test/test-lib-common.sh
@@ -323,6 +323,10 @@ rm -rf "$TMP_DIRECTORY" || {
exit 1
 }
 
+# Provide a guess at a usable Python, to support running tests without
+# running configure first.
+NOTMUCH_PYTHON=${NOTMUCH_PYTHON-python3}
+
 # A temporary home directory is needed by at least:
 # - emacs/"Sending a message via (fake) SMTP"
 # - emacs/"Reply within emacs"
-- 
2.39.2

___
notmuch mailing list -- notmuch@notmuchmail.org
To unsubscribe send an email to notmuch-le...@notmuchmail.org


v3 test notmuch as installed

2023-04-09 Thread David Bremner
Compared to the previous version [1], the first patch is now applied,
and the setup for running without configure now relies on the various
NOTMUCH_HAVE_* environment variables working OK when unset. This
allows eliminating the "defaults.sh". There is also some added
documentation on how to use the new feature (in patch 4/5).  

[1]: id:20230104124145.2882983-1-da...@tethera.net


___
notmuch mailing list -- notmuch@notmuchmail.org
To unsubscribe send an email to notmuch-le...@notmuchmail.org