Re: [PATCH 6/9] test: Add test cases for new exclude option

2022-08-12 Thread David Bremner
Mohsin Kaleem  writes:

This should mention emacs in the commit message. test/emacs: is the
usual convention.

> ---
>  test/T461-emacs-search-exclude.sh | 99 +++
>  .../notmuch-search-tag-inbox-with-excluded| 25 +
>  .../notmuch-search-tag-inbox-without-excluded | 21 
>  .../notmuch-tree-tag-inbox-with-excluded  | 53 ++
>  .../notmuch-tree-tag-inbox-without-excluded   | 49 +
>  5 files changed, 247 insertions(+)
>  create mode 100755 test/T461-emacs-search-exclude.sh
>  create mode 100644 
> test/emacs-exclude.expected-output/notmuch-search-tag-inbox-with-excluded
>  create mode 100644 
> test/emacs-exclude.expected-output/notmuch-search-tag-inbox-without-excluded
>  create mode 100644 
> test/emacs-exclude.expected-output/notmuch-tree-tag-inbox-with-excluded
>  create mode 100644 
> test/emacs-exclude.expected-output/notmuch-tree-tag-inbox-without-excluded
>
> diff --git a/test/T461-emacs-search-exclude.sh 
> b/test/T461-emacs-search-exclude.sh
> new file mode 100755
> index ..bf558847
> --- /dev/null
> +++ b/test/T461-emacs-search-exclude.sh
> @@ -0,0 +1,99 @@
> +#!/usr/bin/env bash
> +
> +test_description="exclude options persist between Emacs search and tree 
> modes"
> +. $(dirname "$0")/test-lib.sh || exit 1
> +. $NOTMUCH_SRCDIR/test/test-lib-emacs.sh || exit 1
> +
> +EXPECTED=$NOTMUCH_SRCDIR/test/emacs-exclude.expected-output
> +
> +test_require_emacs
> +add_email_corpus
> +notmuch config set search.exclude_tags deleted
> +notmuch tag +deleted -- 'from:"Stewart Smith"' or 'from:"Chris Wilson"'
> +
> +# Basic test cases just asserting exclude option is working and consistent.
> +
> +test_begin_subtest "Search doesn't contain excluded mail by default"
> +test_emacs '(notmuch-hello)
> + (goto-char (point-min))
> + (re-search-forward "inbox")
> + (widget-button-press (1- (point)))
> + (notmuch-test-wait)
> + (test-output)
> + (delete-other-windows)'
> +test_expect_equal_file $EXPECTED/notmuch-search-tag-inbox-without-excluded 
> OUTPUT
> +
> +test_begin_subtest "Toggling exclude in search will show excluded mail"
> +test_emacs '(notmuch-hello)
> + (goto-char (point-min))
> + (re-search-forward "inbox")
> + (widget-button-press (1- (point)))
> + (notmuch-test-wait)
> +  (notmuch-search-toggle-exclude)
> + (notmuch-test-wait)
> + (test-output)
> + (delete-other-windows)'
> +test_expect_equal_file $EXPECTED/notmuch-search-tag-inbox-with-excluded 
> OUTPUT
> +
> +test_begin_subtest "Tree search doesn't contain excluded mail by default"
> +test_emacs '(notmuch-hello)
> + (goto-char (point-min))
> + (re-search-forward "inbox")
> + (widget-button-press (1- (point)))
> + (notmuch-test-wait)
> + (notmuch-tree-from-search-current-query)
> + (notmuch-test-wait)
> + (test-output)
> + (delete-other-windows)'
> +test_expect_equal_file $EXPECTED/notmuch-tree-tag-inbox-without-excluded 
> OUTPUT
> +
> +test_begin_subtest "Toggling exclude in tree search will show excluded mail"
> +test_emacs '(notmuch-hello)
> + (goto-char (point-min))
> + (re-search-forward "inbox")
> + (widget-button-press (1- (point)))
> + (notmuch-test-wait)
> + (notmuch-tree-from-search-current-query)
> + (notmuch-test-wait)
> +  (notmuch-tree-toggle-exclude)
> + (notmuch-test-wait)
> + (test-output)
> + (delete-other-windows)'
> +test_expect_equal_file $EXPECTED/notmuch-tree-tag-inbox-with-excluded OUTPUT
> +
> +# Choice of showing excluded mail persists when switching between tree and 
> search
> +# buffers.
> +
> +test_begin_subtest "Value of exclude from search persists into tree search"
> +test_emacs '(notmuch-hello)
> + (goto-char (point-min))
> + (re-search-forward "inbox")
> + (widget-button-press (1- (point)))
> + (notmuch-test-wait)
> +  (notmuch-search-toggle-exclude)
> + (notmuch-test-wait)
> + (notmuch-tree-from-search-current-query)
> + (notmuch-test-wait)
> + (test-output)
> + (delete-other-windows)'
> +test_expect_equal_file $EXPECTED/notmuch-tree-tag-inbox-with-excluded OUTPUT
> +
> +test_begin_subtest "Value of exclude from tree persists into search search"
> +test_emacs '(notmuch-hello)
> + (goto-char (point-min))
> + (re-search-forward "inbox")
> + (widget-button-press (1- (point)))
> + (notmuch-test-wait)
> + (notmuch-tree-from-search-current-query)
> + (notmuch-test-wait)
> +  (notmuch-tree-toggle-exclude)
> + (notmuch-test-wait)
> + (notmuch-search-from-tree-current-query)
> + (notmuch-test-wait)
> + (test-output)
> + (delete-other-windows)'
> +test_expect_equal_file $EXPECTED/notmuch-search-tag-inbox-with-excluded 
> OUTPUT
> +
> +# TODO: Add test 

Re: [PATCH 6/9] test: Add test cases for new exclude option

2022-08-08 Thread Mohsin Kaleem
Tomi Ollila  writes:

> It looks like tab width was not 8 when these (notmuch-search-toggle-exclude)
> were added, accidentally indented w/ leading space, not tab ;/
>
> (ditto for all other (notmuch-search-toggle-exclude), rest of the content
> removed.)

Ah, good job spotting this. My tab width defaults to 2 in sh-script
files. I've fixed this now, but now sure what to do next. Should I
generate a new patch series and send them all again, generate a new
patch series and just send the modified patch, or is there some other
convention for next steps?

> Otherwise, in this large set of changes, I could not see anything alarming,
> but I did not test (I even don't know how, as I don't have excludes...)

An easy way to test would be to set some excluded tags :-).

notmuch config set search.exclude_tags foo

Then:
1. Go to your inbox in Emacs.
2. Tag some mail with foo.
3. Run `M-x notmuch-refresh-this-buffer` and the mail you tagged should
   no longer be shown.
4. Hit the i key and it will be shown again.
5. Hit i again and it will be hidden.
6. Hit i again to re-show it and go ahead and remove the foo tag
7. Run `M-x notmuch-refresh-this-buffer` or hit i as much as you like,
   the mail should now always be shown since its no longer excluded.

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


Re: [PATCH 6/9] test: Add test cases for new exclude option

2022-08-08 Thread Tomi Ollila
On Sun, Aug 07 2022, Mohsin Kaleem wrote:

> ---
>  test/T461-emacs-search-exclude.sh | 99 +++
>  .../notmuch-search-tag-inbox-with-excluded| 25 +
>  .../notmuch-search-tag-inbox-without-excluded | 21 
>  .../notmuch-tree-tag-inbox-with-excluded  | 53 ++
>  .../notmuch-tree-tag-inbox-without-excluded   | 49 +
>  5 files changed, 247 insertions(+)
>  create mode 100755 test/T461-emacs-search-exclude.sh
>  create mode 100644 
> test/emacs-exclude.expected-output/notmuch-search-tag-inbox-with-excluded
>  create mode 100644 
> test/emacs-exclude.expected-output/notmuch-search-tag-inbox-without-excluded
>  create mode 100644 
> test/emacs-exclude.expected-output/notmuch-tree-tag-inbox-with-excluded
>  create mode 100644 
> test/emacs-exclude.expected-output/notmuch-tree-tag-inbox-without-excluded
>
> diff --git a/test/T461-emacs-search-exclude.sh 
> b/test/T461-emacs-search-exclude.sh
> new file mode 100755
> index ..bf558847
> --- /dev/null
> +++ b/test/T461-emacs-search-exclude.sh
> @@ -0,0 +1,99 @@
> +#!/usr/bin/env bash
> +
> +test_description="exclude options persist between Emacs search and tree 
> modes"
> +. $(dirname "$0")/test-lib.sh || exit 1
> +. $NOTMUCH_SRCDIR/test/test-lib-emacs.sh || exit 1
> +
> +EXPECTED=$NOTMUCH_SRCDIR/test/emacs-exclude.expected-output
> +
> +test_require_emacs
> +add_email_corpus
> +notmuch config set search.exclude_tags deleted
> +notmuch tag +deleted -- 'from:"Stewart Smith"' or 'from:"Chris Wilson"'
> +
> +# Basic test cases just asserting exclude option is working and consistent.
> +
> +test_begin_subtest "Search doesn't contain excluded mail by default"
> +test_emacs '(notmuch-hello)
> + (goto-char (point-min))
> + (re-search-forward "inbox")
> + (widget-button-press (1- (point)))
> + (notmuch-test-wait)
> + (test-output)
> + (delete-other-windows)'
> +test_expect_equal_file $EXPECTED/notmuch-search-tag-inbox-without-excluded 
> OUTPUT
> +
> +test_begin_subtest "Toggling exclude in search will show excluded mail"
> +test_emacs '(notmuch-hello)
> + (goto-char (point-min))
> + (re-search-forward "inbox")
> + (widget-button-press (1- (point)))
> + (notmuch-test-wait)
> +  (notmuch-search-toggle-exclude)

It looks like tab width was not 8 when these (notmuch-search-toggle-exclude)
were added, accidentally indented w/ leading space, not tab ;/

(ditto for all other (notmuch-search-toggle-exclude), rest of the content
removed.)

> + (notmuch-test-wait)

Otherwise, in this large set of changes, I could not see anything alarming,
but I did not test (I even don't know how, as I don't have excludes...)

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