unofficial mirror of notmuch@notmuchmail.org
 help / color / mirror / code / Atom feed
* [PATCH 1/2] test: add general Emacs hook counter
@ 2011-12-21 18:18 Dmitry Kurochkin
  2011-12-21 18:18 ` [PATCH 2/2] test: add test for `notmuch-hello-refresh-hook' Dmitry Kurochkin
  2011-12-22 11:29 ` [PATCH 1/2] test: add general Emacs hook counter David Bremner
  0 siblings, 2 replies; 7+ messages in thread
From: Dmitry Kurochkin @ 2011-12-21 18:18 UTC (permalink / raw)
  To: notmuch

Replace `notmuch-hello-mode-hook-counter' with general `hook-counter'
and `add-hook-counter' functions to allow counting calls for any hook.
---
 test/test-lib.el |   21 +++++++++++++--------
 1 files changed, 13 insertions(+), 8 deletions(-)

diff --git a/test/test-lib.el b/test/test-lib.el
index 3bca138..83b8a65 100644
--- a/test/test-lib.el
+++ b/test/test-lib.el
@@ -62,11 +62,16 @@ running, quit if it terminated."
       (kill-emacs)
     (run-at-time "1 min" nil 'orphan-watchdog pid)))
 
-(defun notmuch-hello-mode-hook-counter ()
-  "Count how many times `notmuch-hello-mode-hook' is called.
-Increments `notmuch-hello-mode-hook-counter' variable value if it
-is bound, otherwise does nothing."
-  (if (boundp 'notmuch-hello-mode-hook-counter)
-      (setq notmuch-hello-mode-hook-counter
-	    (1+ notmuch-hello-mode-hook-counter))))
-(add-hook 'notmuch-hello-mode-hook 'notmuch-hello-mode-hook-counter)
+(defun hook-counter (hook)
+  "Count how many times a hook is called.  Increments
+`hook'-counter variable value if it is bound, otherwise does
+nothing."
+  (let ((counter (intern (concat (symbol-name hook) "-counter"))))
+    (if (boundp counter)
+	(set counter (1+ (symbol-value counter))))))
+
+(defun add-hook-counter (hook)
+  "Add hook to count how many times `hook' is called."
+  (add-hook hook (apply-partially 'hook-counter hook)))
+
+(add-hook-counter 'notmuch-hello-mode-hook)
-- 
1.7.7.3

^ permalink raw reply related	[flat|nested] 7+ messages in thread

* [PATCH 2/2] test: add test for `notmuch-hello-refresh-hook'
  2011-12-21 18:18 [PATCH 1/2] test: add general Emacs hook counter Dmitry Kurochkin
@ 2011-12-21 18:18 ` Dmitry Kurochkin
  2011-12-21 21:49   ` Thomas Jost
  2011-12-22  8:55   ` Tomi Ollila
  2011-12-22 11:29 ` [PATCH 1/2] test: add general Emacs hook counter David Bremner
  1 sibling, 2 replies; 7+ messages in thread
From: Dmitry Kurochkin @ 2011-12-21 18:18 UTC (permalink / raw)
  To: notmuch

Test that `notmuch-hello-refresh-hook' is called once when
`notmuch-hello' is called and twice when calling
`notmuch-hello-update' after that.

The tests are very similar to tests for `notmuch-hello-mode-hook'.
---
 test/emacs       |   19 +++++++++++++++++++
 test/test-lib.el |    1 +
 2 files changed, 20 insertions(+), 0 deletions(-)

diff --git a/test/emacs b/test/emacs
index dffad0f..ca82445 100755
--- a/test/emacs
+++ b/test/emacs
@@ -495,4 +495,23 @@ counter=$(test_emacs \
 )
 test_expect_equal "$counter" 1
 
+test_begin_subtest "notmuch-hello-refresh hook is called"
+counter=$(test_emacs \
+    '(let ((notmuch-hello-refresh-hook-counter 0))
+       (kill-buffer "*notmuch-hello*")
+       (notmuch-hello)
+       notmuch-hello-refresh-hook-counter)'
+)
+test_expect_equal "$counter" 1
+
+test_begin_subtest "notmuch-hello-refresh hook is called on updates"
+counter=$(test_emacs \
+    '(let ((notmuch-hello-refresh-hook-counter 0))
+       (kill-buffer "*notmuch-hello*")
+       (notmuch-hello)
+       (notmuch-hello-update)
+       notmuch-hello-refresh-hook-counter)'
+)
+test_expect_equal "$counter" 2
+
 test_done
diff --git a/test/test-lib.el b/test/test-lib.el
index 83b8a65..3b817c3 100644
--- a/test/test-lib.el
+++ b/test/test-lib.el
@@ -75,3 +75,4 @@ nothing."
   (add-hook hook (apply-partially 'hook-counter hook)))
 
 (add-hook-counter 'notmuch-hello-mode-hook)
+(add-hook-counter 'notmuch-hello-refresh-hook)
-- 
1.7.7.3

^ permalink raw reply related	[flat|nested] 7+ messages in thread

* Re: [PATCH 2/2] test: add test for `notmuch-hello-refresh-hook'
  2011-12-21 18:18 ` [PATCH 2/2] test: add test for `notmuch-hello-refresh-hook' Dmitry Kurochkin
@ 2011-12-21 21:49   ` Thomas Jost
  2011-12-21 21:54     ` Dmitry Kurochkin
  2011-12-22  8:55   ` Tomi Ollila
  1 sibling, 1 reply; 7+ messages in thread
From: Thomas Jost @ 2011-12-21 21:49 UTC (permalink / raw)
  To: Dmitry Kurochkin, notmuch

[-- Attachment #1: Type: text/plain, Size: 2181 bytes --]

On Wed, 21 Dec 2011 22:18:26 +0400, Dmitry Kurochkin <dmitry.kurochkin@gmail.com> wrote:
> Test that `notmuch-hello-refresh-hook' is called once when
> `notmuch-hello' is called and twice when calling
> `notmuch-hello-update' after that.
> 
> The tests are very similar to tests for `notmuch-hello-mode-hook'.

Quite nice, better than what I sent earlier [1] :)

However I'm not sure that notmuch-hello.el is the right place for this
kind of stuff; notmuch-lib.el may be better (so that it can also be used
in other hooks.

Regards,
Thomas

[1] id:"1324473189-8622-1-git-send-email-schnouki@schnouki.net"


> ---
>  test/emacs       |   19 +++++++++++++++++++
>  test/test-lib.el |    1 +
>  2 files changed, 20 insertions(+), 0 deletions(-)
> 
> diff --git a/test/emacs b/test/emacs
> index dffad0f..ca82445 100755
> --- a/test/emacs
> +++ b/test/emacs
> @@ -495,4 +495,23 @@ counter=$(test_emacs \
>  )
>  test_expect_equal "$counter" 1
>  
> +test_begin_subtest "notmuch-hello-refresh hook is called"
> +counter=$(test_emacs \
> +    '(let ((notmuch-hello-refresh-hook-counter 0))
> +       (kill-buffer "*notmuch-hello*")
> +       (notmuch-hello)
> +       notmuch-hello-refresh-hook-counter)'
> +)
> +test_expect_equal "$counter" 1
> +
> +test_begin_subtest "notmuch-hello-refresh hook is called on updates"
> +counter=$(test_emacs \
> +    '(let ((notmuch-hello-refresh-hook-counter 0))
> +       (kill-buffer "*notmuch-hello*")
> +       (notmuch-hello)
> +       (notmuch-hello-update)
> +       notmuch-hello-refresh-hook-counter)'
> +)
> +test_expect_equal "$counter" 2
> +
>  test_done
> diff --git a/test/test-lib.el b/test/test-lib.el
> index 83b8a65..3b817c3 100644
> --- a/test/test-lib.el
> +++ b/test/test-lib.el
> @@ -75,3 +75,4 @@ nothing."
>    (add-hook hook (apply-partially 'hook-counter hook)))
>  
>  (add-hook-counter 'notmuch-hello-mode-hook)
> +(add-hook-counter 'notmuch-hello-refresh-hook)
> -- 
> 1.7.7.3
> 
> _______________________________________________
> notmuch mailing list
> notmuch@notmuchmail.org
> http://notmuchmail.org/mailman/listinfo/notmuch

-- 
Thomas/Schnouki

[-- Attachment #2: Type: application/pgp-signature, Size: 489 bytes --]

^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: [PATCH 2/2] test: add test for `notmuch-hello-refresh-hook'
  2011-12-21 21:49   ` Thomas Jost
@ 2011-12-21 21:54     ` Dmitry Kurochkin
  2011-12-21 22:09       ` Thomas Jost
  0 siblings, 1 reply; 7+ messages in thread
From: Dmitry Kurochkin @ 2011-12-21 21:54 UTC (permalink / raw)
  To: Thomas Jost, notmuch

On Wed, 21 Dec 2011 22:49:13 +0100, Thomas Jost <schnouki@schnouki.net> wrote:
> On Wed, 21 Dec 2011 22:18:26 +0400, Dmitry Kurochkin <dmitry.kurochkin@gmail.com> wrote:
> > Test that `notmuch-hello-refresh-hook' is called once when
> > `notmuch-hello' is called and twice when calling
> > `notmuch-hello-update' after that.
> > 
> > The tests are very similar to tests for `notmuch-hello-mode-hook'.
> 
> Quite nice, better than what I sent earlier [1] :)
> 
> However I'm not sure that notmuch-hello.el is the right place for this
> kind of stuff; notmuch-lib.el may be better (so that it can also be used
> in other hooks.
> 

These patches do not touch notmuch-hello.el.  The functions are added to
test/test-lib.el.

Regards,
  Dmitry

> Regards,
> Thomas
> 
> [1] id:"1324473189-8622-1-git-send-email-schnouki@schnouki.net"
> 
> 
> > ---
> >  test/emacs       |   19 +++++++++++++++++++
> >  test/test-lib.el |    1 +
> >  2 files changed, 20 insertions(+), 0 deletions(-)
> > 
> > diff --git a/test/emacs b/test/emacs
> > index dffad0f..ca82445 100755
> > --- a/test/emacs
> > +++ b/test/emacs
> > @@ -495,4 +495,23 @@ counter=$(test_emacs \
> >  )
> >  test_expect_equal "$counter" 1
> >  
> > +test_begin_subtest "notmuch-hello-refresh hook is called"
> > +counter=$(test_emacs \
> > +    '(let ((notmuch-hello-refresh-hook-counter 0))
> > +       (kill-buffer "*notmuch-hello*")
> > +       (notmuch-hello)
> > +       notmuch-hello-refresh-hook-counter)'
> > +)
> > +test_expect_equal "$counter" 1
> > +
> > +test_begin_subtest "notmuch-hello-refresh hook is called on updates"
> > +counter=$(test_emacs \
> > +    '(let ((notmuch-hello-refresh-hook-counter 0))
> > +       (kill-buffer "*notmuch-hello*")
> > +       (notmuch-hello)
> > +       (notmuch-hello-update)
> > +       notmuch-hello-refresh-hook-counter)'
> > +)
> > +test_expect_equal "$counter" 2
> > +
> >  test_done
> > diff --git a/test/test-lib.el b/test/test-lib.el
> > index 83b8a65..3b817c3 100644
> > --- a/test/test-lib.el
> > +++ b/test/test-lib.el
> > @@ -75,3 +75,4 @@ nothing."
> >    (add-hook hook (apply-partially 'hook-counter hook)))
> >  
> >  (add-hook-counter 'notmuch-hello-mode-hook)
> > +(add-hook-counter 'notmuch-hello-refresh-hook)
> > -- 
> > 1.7.7.3
> > 
> > _______________________________________________
> > notmuch mailing list
> > notmuch@notmuchmail.org
> > http://notmuchmail.org/mailman/listinfo/notmuch
> 
> -- 
> Thomas/Schnouki

^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: [PATCH 2/2] test: add test for `notmuch-hello-refresh-hook'
  2011-12-21 21:54     ` Dmitry Kurochkin
@ 2011-12-21 22:09       ` Thomas Jost
  0 siblings, 0 replies; 7+ messages in thread
From: Thomas Jost @ 2011-12-21 22:09 UTC (permalink / raw)
  To: Dmitry Kurochkin, notmuch

[-- Attachment #1: Type: text/plain, Size: 2907 bytes --]

On Thu, 22 Dec 2011 01:54:21 +0400, Dmitry Kurochkin <dmitry.kurochkin@gmail.com> wrote:
> On Wed, 21 Dec 2011 22:49:13 +0100, Thomas Jost <schnouki@schnouki.net> wrote:
> > On Wed, 21 Dec 2011 22:18:26 +0400, Dmitry Kurochkin <dmitry.kurochkin@gmail.com> wrote:
> > > Test that `notmuch-hello-refresh-hook' is called once when
> > > `notmuch-hello' is called and twice when calling
> > > `notmuch-hello-update' after that.
> > > 
> > > The tests are very similar to tests for `notmuch-hello-mode-hook'.
> > 
> > Quite nice, better than what I sent earlier [1] :)
> > 
> > However I'm not sure that notmuch-hello.el is the right place for this
> > kind of stuff; notmuch-lib.el may be better (so that it can also be used
> > in other hooks.
> > 
> 
> These patches do not touch notmuch-hello.el.  The functions are added to
> test/test-lib.el.

Wow. So apparently 22:49 is too late for me to read correctly.

Full ACK for me then!

Regards,
Thomas

> 
> Regards,
>   Dmitry
> 
> > Regards,
> > Thomas
> > 
> > [1] id:"1324473189-8622-1-git-send-email-schnouki@schnouki.net"
> > 
> > 
> > > ---
> > >  test/emacs       |   19 +++++++++++++++++++
> > >  test/test-lib.el |    1 +
> > >  2 files changed, 20 insertions(+), 0 deletions(-)
> > > 
> > > diff --git a/test/emacs b/test/emacs
> > > index dffad0f..ca82445 100755
> > > --- a/test/emacs
> > > +++ b/test/emacs
> > > @@ -495,4 +495,23 @@ counter=$(test_emacs \
> > >  )
> > >  test_expect_equal "$counter" 1
> > >  
> > > +test_begin_subtest "notmuch-hello-refresh hook is called"
> > > +counter=$(test_emacs \
> > > +    '(let ((notmuch-hello-refresh-hook-counter 0))
> > > +       (kill-buffer "*notmuch-hello*")
> > > +       (notmuch-hello)
> > > +       notmuch-hello-refresh-hook-counter)'
> > > +)
> > > +test_expect_equal "$counter" 1
> > > +
> > > +test_begin_subtest "notmuch-hello-refresh hook is called on updates"
> > > +counter=$(test_emacs \
> > > +    '(let ((notmuch-hello-refresh-hook-counter 0))
> > > +       (kill-buffer "*notmuch-hello*")
> > > +       (notmuch-hello)
> > > +       (notmuch-hello-update)
> > > +       notmuch-hello-refresh-hook-counter)'
> > > +)
> > > +test_expect_equal "$counter" 2
> > > +
> > >  test_done
> > > diff --git a/test/test-lib.el b/test/test-lib.el
> > > index 83b8a65..3b817c3 100644
> > > --- a/test/test-lib.el
> > > +++ b/test/test-lib.el
> > > @@ -75,3 +75,4 @@ nothing."
> > >    (add-hook hook (apply-partially 'hook-counter hook)))
> > >  
> > >  (add-hook-counter 'notmuch-hello-mode-hook)
> > > +(add-hook-counter 'notmuch-hello-refresh-hook)
> > > -- 
> > > 1.7.7.3
> > > 
> > > _______________________________________________
> > > notmuch mailing list
> > > notmuch@notmuchmail.org
> > > http://notmuchmail.org/mailman/listinfo/notmuch
> > 
> > -- 
> > Thomas/Schnouki

-- 
Thomas/Schnouki

[-- Attachment #2: Type: application/pgp-signature, Size: 489 bytes --]

^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: [PATCH 2/2] test: add test for `notmuch-hello-refresh-hook'
  2011-12-21 18:18 ` [PATCH 2/2] test: add test for `notmuch-hello-refresh-hook' Dmitry Kurochkin
  2011-12-21 21:49   ` Thomas Jost
@ 2011-12-22  8:55   ` Tomi Ollila
  1 sibling, 0 replies; 7+ messages in thread
From: Tomi Ollila @ 2011-12-22  8:55 UTC (permalink / raw)
  To: Dmitry Kurochkin, notmuch

On Wed, 21 Dec 2011 22:18:26 +0400, Dmitry Kurochkin <dmitry.kurochkin@gmail.com> wrote:
> Test that `notmuch-hello-refresh-hook' is called once when
> `notmuch-hello' is called and twice when calling
> `notmuch-hello-update' after that.
> 
> The tests are very similar to tests for `notmuch-hello-mode-hook'.

+1 -- both patches.

Tomi

^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: [PATCH 1/2] test: add general Emacs hook counter
  2011-12-21 18:18 [PATCH 1/2] test: add general Emacs hook counter Dmitry Kurochkin
  2011-12-21 18:18 ` [PATCH 2/2] test: add test for `notmuch-hello-refresh-hook' Dmitry Kurochkin
@ 2011-12-22 11:29 ` David Bremner
  1 sibling, 0 replies; 7+ messages in thread
From: David Bremner @ 2011-12-22 11:29 UTC (permalink / raw)
  To: Dmitry Kurochkin, notmuch

On Wed, 21 Dec 2011 22:18:25 +0400, Dmitry Kurochkin <dmitry.kurochkin@gmail.com> wrote:
> Replace `notmuch-hello-mode-hook-counter' with general `hook-counter'
> and `add-hook-counter' functions to allow counting calls for any hook.

Pushed, 

d

^ permalink raw reply	[flat|nested] 7+ messages in thread

end of thread, other threads:[~2011-12-22 11:30 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2011-12-21 18:18 [PATCH 1/2] test: add general Emacs hook counter Dmitry Kurochkin
2011-12-21 18:18 ` [PATCH 2/2] test: add test for `notmuch-hello-refresh-hook' Dmitry Kurochkin
2011-12-21 21:49   ` Thomas Jost
2011-12-21 21:54     ` Dmitry Kurochkin
2011-12-21 22:09       ` Thomas Jost
2011-12-22  8:55   ` Tomi Ollila
2011-12-22 11:29 ` [PATCH 1/2] test: add general Emacs hook counter David Bremner

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).