unofficial mirror of notmuch@notmuchmail.org
 help / color / mirror / code / Atom feed
From: Dmitry Kurochkin <dmitry.kurochkin@gmail.com>
To: David Edmondson <dme@dme.org>, notmuch@notmuchmail.org
Subject: Re: [PATCH 2/4] test: Add address cleaning tests.
Date: Tue, 17 Jan 2012 17:11:58 +0400	[thread overview]
Message-ID: <87mx9m323l.fsf@gmail.com> (raw)
In-Reply-To: <1326804748-8989-3-git-send-email-dme@dme.org>

On Tue, 17 Jan 2012 12:52:26 +0000, David Edmondson <dme@dme.org> wrote:
> Including some more test framework in test-lib.el.
> ---
>  test/address-cleaning.el |   29 +++++++++++++++++++++++++++++
>  test/address-cleaning.sh |   11 +++++++++++
>  test/notmuch-test        |    1 +
>  test/test-lib.el         |   29 +++++++++++++++++++++++++++++
>  4 files changed, 70 insertions(+), 0 deletions(-)
>  create mode 100644 test/address-cleaning.el
>  create mode 100755 test/address-cleaning.sh
> 

Since test/ directory is used for all kind of tests not just Emacs
UI-specific, so I think address-cleaning.* files should be
emacs-address-cleaning.

Regards,
  Dmitry

> diff --git a/test/address-cleaning.el b/test/address-cleaning.el
> new file mode 100644
> index 0000000..59e8d92
> --- /dev/null
> +++ b/test/address-cleaning.el
> @@ -0,0 +1,29 @@
> +(defun notmuch-test-address-cleaning-1 ()
> +  (notmuch-test-compare (notmuch-show-clean-address "dme@dme.org")
> +			"dme@dme.org"))
> +
> +(defun notmuch-test-address-cleaning-2 ()
> +  (let* ((input '("foo@bar.com"
> +		  "<foo@bar.com>"
> +		  "Foo Bar <foo@bar.com>"
> +		  "foo@bar.com <foo@bar.com>"
> +		  "\"Foo Bar\" <foo@bar.com>"))
> +	 (expected '("foo@bar.com"
> +		     "foo@bar.com"
> +		     "Foo Bar <foo@bar.com>"
> +		     "foo@bar.com"
> +		     "Foo Bar <foo@bar.com>"))
> +	 (output (mapcar #'notmuch-show-clean-address input)))
> +    (notmuch-test-compare output expected)))
> +
> +(defun notmuch-test-address-cleaning-3 ()
> +  (let* ((input '("ДБ <db-uknot@stop.me.uk>"
> +		  "foo (at home) <foo@bar.com>"
> +		  "foo [at home] <foo@bar.com>"
> +		  "Foo Bar"))
> +	 (expected '("ДБ <db-uknot@stop.me.uk>"
> +		     "foo (at home) <foo@bar.com>"
> +		     "foo [at home] <foo@bar.com>"
> +		     "Foo Bar"))
> +	 (output (mapcar #'notmuch-show-clean-address input)))
> +    (notmuch-test-compare output expected)))
> diff --git a/test/address-cleaning.sh b/test/address-cleaning.sh
> new file mode 100755
> index 0000000..7ec011a
> --- /dev/null
> +++ b/test/address-cleaning.sh
> @@ -0,0 +1,11 @@
> +#!/usr/bin/env bash
> +
> +test_description="emacs address cleaning"
> +. test-lib.sh
> +
> +for i in 1 2 3; do
> +    test_emacs_expect_t "notmuch-test-address-clean-$i" \
> +    '(load "address-cleaning.el") (notmuch-test-address-cleaning-'$i')'
> +done
> +
> +test_done
> diff --git a/test/notmuch-test b/test/notmuch-test
> index d034f99..7768c32 100755
> --- a/test/notmuch-test
> +++ b/test/notmuch-test
> @@ -53,6 +53,7 @@ TESTS="
>    hooks
>    argument-parsing
>    emacs-test-functions.sh
> +  address-cleaning.sh
>  "
>  TESTS=${NOTMUCH_TESTS:=$TESTS}
>  
> diff --git a/test/test-lib.el b/test/test-lib.el
> index 3b817c3..cf8a46d 100644
> --- a/test/test-lib.el
> +++ b/test/test-lib.el
> @@ -20,6 +20,8 @@
>  ;;
>  ;; Authors: Dmitry Kurochkin <dmitry.kurochkin@gmail.com>
>  
> +(require 'cl)	;; This code is generally used uncompiled.
> +
>  ;; `read-file-name' by default uses `completing-read' function to read
>  ;; user input.  It does not respect `standard-input' variable which we
>  ;; use in tests to provide user input.  So replace it with a plain
> @@ -76,3 +78,30 @@ nothing."
>  
>  (add-hook-counter 'notmuch-hello-mode-hook)
>  (add-hook-counter 'notmuch-hello-refresh-hook)
> +
> +;; Functions to help when writing tests:
> +
> +(defun notmuch-test-reporter (output expected)
> +  "Report that the `output' does not match the `expected' result."
> +  (concat "Expect:\t" (prin1-to-string expected) "\n"
> +	  "Output:\t" (prin1-to-string output) "\n"))
> +
> +(defun notmuch-test-unsimilar (output expected)
> +  "`output' and `expected' are dissimilar. Show a summary of
> +the differences, ignoring similarities."
> +  (cond ((and (listp output)
> +	      (listp expected))
> +	 (apply #'concat (loop for o in output
> +			       for e in expected
> +			       if (not (equal o e))
> +			       collect (notmuch-test-reporter o e))))
> +
> +	(t
> +	 ;; Catch all case.
> +	 (notmuch-test-reporter output expected))))
> +
> +(defun notmuch-test-compare (output expected)
> +  "Compare `output' with `expected'. Report any discrepencies."
> +  (if (equal output expected)
> +      t
> +    (notmuch-test-unsimilar output expected)))
> -- 
> 1.7.7.3
> 
> _______________________________________________
> notmuch mailing list
> notmuch@notmuchmail.org
> http://notmuchmail.org/mailman/listinfo/notmuch

  reply	other threads:[~2012-01-17 13:12 UTC|newest]

Thread overview: 49+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2012-01-17 12:52 emacs based tests, version 3 David Edmondson
2012-01-17 12:52 ` [PATCH 1/4] test: Add `test_emacs_expect_t' David Edmondson
2012-01-17 13:09   ` Dmitry Kurochkin
2012-01-17 13:24     ` David Edmondson
2012-01-17 14:07     ` [PATCH 1/3] test: Don't return the result of checking for running emacs to the tester David Edmondson
2012-01-17 14:07       ` [PATCH 2/3] test: Add `test_emacs_expect_t' David Edmondson
2012-01-17 14:26         ` Dmitry Kurochkin
2012-01-17 14:35           ` David Edmondson
2012-01-17 14:43             ` Dmitry Kurochkin
     [not found]         ` <87zkdmwfi7.fsf@gmail.com>
2012-01-17 15:09           ` David Edmondson
2012-01-18  9:09             ` Tomi Ollila
2012-01-18 14:55         ` Tomi Ollila
2012-01-19  9:59           ` David Edmondson
2012-01-19 10:32             ` Tomi Ollila
2012-01-19 10:42               ` David Edmondson
2012-01-19 11:01                 ` Tomi Ollila
2012-01-19 12:54                   ` [PATCH 1/3] test: Don't return the result of checking for running emacs to the tester David Edmondson
2012-01-19 12:54                     ` [PATCH 2/3] test: Add `test_emacs_expect_t' David Edmondson
2012-01-23 11:47                       ` David Edmondson
2012-01-23 16:45                       ` Dmitry Kurochkin
2012-01-19 12:54                     ` [PATCH 3/3] test: Add address cleaning tests David Edmondson
2012-01-23 17:26                       ` Dmitry Kurochkin
2012-01-23 16:32                     ` [PATCH 1/3] test: Don't return the result of checking for running emacs to the tester Dmitry Kurochkin
2012-01-17 14:07       ` [PATCH 3/3] test: Add address cleaning tests David Edmondson
2012-01-17 14:20       ` [PATCH 1/3] test: Don't return the result of checking for running emacs to the tester Dmitry Kurochkin
2012-01-17 14:37         ` David Edmondson
2012-01-17 14:51           ` Dmitry Kurochkin
2012-01-23 18:05   ` [PATCH 1/4 v42] " David Edmondson
2012-01-23 18:05     ` [PATCH 2/4 v42] test: Add `test_emacs_expect_t' David Edmondson
2012-01-24 15:24       ` Dmitry Kurochkin
2012-01-23 18:05     ` [PATCH 3/4 v42] test: Add more helpers for emacs tests David Edmondson
2012-01-24 15:45       ` Dmitry Kurochkin
2012-01-24 15:54         ` David Edmondson
2012-01-23 18:05     ` [PATCH 4/4 v42] test: Add address cleaning tests David Edmondson
2012-01-24 15:35       ` Dmitry Kurochkin
2012-01-24 15:20     ` [PATCH 1/4 v42] test: Don't return the result of checking for running emacs to the tester Dmitry Kurochkin
2012-01-24 16:14   ` [PATCH 0/4 v43] emacs test helpers David Edmondson
2012-01-24 16:14     ` [PATCH 1/4 v43] test: Don't return the result of checking for running emacs to the tester David Edmondson
2012-01-24 16:14     ` [PATCH 2/4 v43] test: Add `test_emacs_expect_t' David Edmondson
2012-01-24 16:14     ` [PATCH 3/4 v43] test: Add more helpers for emacs tests David Edmondson
2012-01-24 16:14     ` [PATCH 4/4 v43] test: Add address cleaning tests David Edmondson
2012-01-24 16:19     ` [PATCH 0/4 v43] emacs test helpers Dmitry Kurochkin
2012-01-24 20:13     ` Tomi Ollila
2012-01-25 11:33     ` David Bremner
2012-01-17 12:52 ` [PATCH 2/4] test: Add address cleaning tests David Edmondson
2012-01-17 13:11   ` Dmitry Kurochkin [this message]
2012-01-17 13:23     ` David Edmondson
2012-01-17 12:52 ` [PATCH 3/4] emacs: Avoid `mail-header-parse-address' in `notmuch-show-clean-address' David Edmondson
2012-01-17 12:52 ` [PATCH 4/4] emacs: Another special case for `notmuch-show-clean-address' David Edmondson

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=87mx9m323l.fsf@gmail.com \
    --to=dmitry.kurochkin@gmail.com \
    --cc=dme@dme.org \
    --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).