[PATCH v2] contrib: notmuch-pick: add tests

2012-11-04 Thread Tomi Ollila
On Thu, Nov 01 2012, Mark Walters  wrote:

> The test should be run using the wrapper run-tests.sh.  This links
> the tests into the normal notmuch TEST_DIRECTORY and runs them from
> there. After the test is complete then the links are removed.
> ---

2 things:

The PICK_DIR variable needs export in run-tests.sh, otherwise it is
not (always??!!) available for test scripts (all tests failed
for me until I added that export (fatal).

git am informs  test/pick.expected-output/notmuch-pick-show-window 
has trailing whitespace when applied. Could you arrange your test
to use other message there (wish).


Tomi


>
> This is version 2 of the patches to add some tests for notmuch pick. 
>
> The main change is that I have added Tomi's suggested wrapper script
> (id:m2ip9srpd6.fsf at guru.guru-group.fi) which is much more robust and
> generally better than the one I had.
>
> The other changes are to split out the tests for the default async
> parser from those for the sync parser. My guess is that the sync
> parser should be removed but it can be useful for debugging so is
> probably worth keeping until pick is closer to being ready for proper
> mainline.
>
> Best wishes
>
> Mark
>
>
>
>
>  contrib/notmuch-pick/README|5 ++
>  contrib/notmuch-pick/run-tests.sh  |   46 
>  contrib/notmuch-pick/test/emacs-pick   |   76 
> 
>  contrib/notmuch-pick/test/emacs-pick-sync  |   64 
>  .../pick.expected-output/notmuch-pick-show-window  |   32 
>  .../notmuch-pick-single-thread |6 ++
>  .../pick.expected-output/notmuch-pick-tag-inbox|   53 ++
>  7 files changed, 282 insertions(+), 0 deletions(-)
>  create mode 100755 contrib/notmuch-pick/run-tests.sh
>  create mode 100755 contrib/notmuch-pick/test/emacs-pick
>  create mode 100755 contrib/notmuch-pick/test/emacs-pick-sync
>  create mode 100644 
> contrib/notmuch-pick/test/pick.expected-output/notmuch-pick-show-window
>  create mode 100644 
> contrib/notmuch-pick/test/pick.expected-output/notmuch-pick-single-thread
>  create mode 100644 
> contrib/notmuch-pick/test/pick.expected-output/notmuch-pick-tag-inbox
>
> diff --git a/contrib/notmuch-pick/README b/contrib/notmuch-pick/README
> index 8eed974..4200824 100644
> --- a/contrib/notmuch-pick/README
> +++ b/contrib/notmuch-pick/README
> @@ -15,6 +15,11 @@ Then after the "(require 'notmuch)" line in your .emacs 
> file add
>  the line "(require 'notmuch-pick nil t)". This will load notmuch-pick on
>  your next emacs start.
>  
> +TEST
> +
> +Just execute run-tests.sh and it should all work (it does require that
> +notmuch has already been built).
> +
>  USING PICK
>  
>  The main key entries to notmuch pick are
> diff --git a/contrib/notmuch-pick/run-tests.sh 
> b/contrib/notmuch-pick/run-tests.sh
> new file mode 100755
> index 000..97cc9e8
> --- /dev/null
> +++ b/contrib/notmuch-pick/run-tests.sh
> @@ -0,0 +1,46 @@
> +#!/usr/bin/env bash
> +
> +set -eu
> +
> +fail() {
> +echo ERROR $1
> +exit 1
> +}
> +
> +TESTS="emacs-pick emacs-pick-sync"
> +TESTFILES="$TESTS pick.expected-output"
> +
> +PICK_DIR="`cd \`dirname "$0"\` && pwd`"
> +PICK_TEST_DIR="$PICK_DIR/test"
> +
> +
> +for f in $TESTFILES
> +do
> +test -f "$PICK_TEST_DIR/$f" || test -d "$PICK_TEST_DIR/$f" || fail 
> "$PICK_TEST_DIR/$f does not exist"
> +done
> +
> +cd "$PICK_DIR/../../test"
> +
> +test -x ../notmuch || fail "`cd .. && pwd`/notmuch has not been built"
> +
> +for f in $TESTFILES
> +do
> +if test -f "$f"
> +then
> + fail "$f exists"
> +fi
> +done
> +
> +trap "rm -f $TESTFILES" 0
> +
> +for f in $TESTFILES
> +do
> +ln -s "$PICK_TEST_DIR/$f" .
> +done
> +
> +#don't exec -- traps would not run.
> +for f in $TESTS
> +do
> +echo $f
> +./$f
> +done
> diff --git a/contrib/notmuch-pick/test/emacs-pick 
> b/contrib/notmuch-pick/test/emacs-pick
> new file mode 100755
> index 000..9db4b34
> --- /dev/null
> +++ b/contrib/notmuch-pick/test/emacs-pick
> @@ -0,0 +1,76 @@
> +#!/usr/bin/env bash
> +
> +test_description="emacs pick interface"
> +. test-lib.sh
> +
> +EXPECTED=$TEST_DIRECTORY/pick.expected-output
> +
> +add_email_corpus
> +test_begin_subtest "Do we have emacs"
> +test_emacs '(insert "hello\n")
> + (test-output)'
> +cat  +hello
> +EOF
> +test_expect_equal_file OUTPUT EXPECTED
> +
> +test_begin_subtest "Basic notmuch-pick view in emacs"
> +test_emacs '(add-to-list (quote load-path) "'$PICK_DIR'")
> + (require (quote notmuch-pick))
> + (notmuch-pick "tag:inbox")
> + (notmuch-test-wait)
> + (test-output)
> + (delete-other-windows)'
> +test_expect_equal_file OUTPUT $EXPECTED/notmuch-pick-tag-inbox
> +
> +test_begin_subtest "Navigation of notmuch-hello to search results"
> +test_emacs '(notmuch-hello)
> + (goto-char (point-min))
> + (re-search-forward "inbox")
> + 

Re: [PATCH v2] contrib: notmuch-pick: add tests

2012-11-03 Thread Tomi Ollila
On Thu, Nov 01 2012, Mark Walters markwalters1...@gmail.com wrote:

 The test should be run using the wrapper run-tests.sh.  This links
 the tests into the normal notmuch TEST_DIRECTORY and runs them from
 there. After the test is complete then the links are removed.
 ---

2 things:

The PICK_DIR variable needs export in run-tests.sh, otherwise it is
not (always??!!) available for test scripts (all tests failed
for me until I added that export (fatal).

git am informs  test/pick.expected-output/notmuch-pick-show-window 
has trailing whitespace when applied. Could you arrange your test
to use other message there (wish).


Tomi



 This is version 2 of the patches to add some tests for notmuch pick. 

 The main change is that I have added Tomi's suggested wrapper script
 (id:m2ip9srpd6@guru.guru-group.fi) which is much more robust and
 generally better than the one I had.

 The other changes are to split out the tests for the default async
 parser from those for the sync parser. My guess is that the sync
 parser should be removed but it can be useful for debugging so is
 probably worth keeping until pick is closer to being ready for proper
 mainline.

 Best wishes

 Mark




  contrib/notmuch-pick/README|5 ++
  contrib/notmuch-pick/run-tests.sh  |   46 
  contrib/notmuch-pick/test/emacs-pick   |   76 
 
  contrib/notmuch-pick/test/emacs-pick-sync  |   64 
  .../pick.expected-output/notmuch-pick-show-window  |   32 
  .../notmuch-pick-single-thread |6 ++
  .../pick.expected-output/notmuch-pick-tag-inbox|   53 ++
  7 files changed, 282 insertions(+), 0 deletions(-)
  create mode 100755 contrib/notmuch-pick/run-tests.sh
  create mode 100755 contrib/notmuch-pick/test/emacs-pick
  create mode 100755 contrib/notmuch-pick/test/emacs-pick-sync
  create mode 100644 
 contrib/notmuch-pick/test/pick.expected-output/notmuch-pick-show-window
  create mode 100644 
 contrib/notmuch-pick/test/pick.expected-output/notmuch-pick-single-thread
  create mode 100644 
 contrib/notmuch-pick/test/pick.expected-output/notmuch-pick-tag-inbox

 diff --git a/contrib/notmuch-pick/README b/contrib/notmuch-pick/README
 index 8eed974..4200824 100644
 --- a/contrib/notmuch-pick/README
 +++ b/contrib/notmuch-pick/README
 @@ -15,6 +15,11 @@ Then after the (require 'notmuch) line in your .emacs 
 file add
  the line (require 'notmuch-pick nil t). This will load notmuch-pick on
  your next emacs start.
  
 +TEST
 +
 +Just execute run-tests.sh and it should all work (it does require that
 +notmuch has already been built).
 +
  USING PICK
  
  The main key entries to notmuch pick are
 diff --git a/contrib/notmuch-pick/run-tests.sh 
 b/contrib/notmuch-pick/run-tests.sh
 new file mode 100755
 index 000..97cc9e8
 --- /dev/null
 +++ b/contrib/notmuch-pick/run-tests.sh
 @@ -0,0 +1,46 @@
 +#!/usr/bin/env bash
 +
 +set -eu
 +
 +fail() {
 +echo ERROR $1
 +exit 1
 +}
 +
 +TESTS=emacs-pick emacs-pick-sync
 +TESTFILES=$TESTS pick.expected-output
 +
 +PICK_DIR=`cd \`dirname $0\`  pwd`
 +PICK_TEST_DIR=$PICK_DIR/test
 +
 +
 +for f in $TESTFILES
 +do
 +test -f $PICK_TEST_DIR/$f || test -d $PICK_TEST_DIR/$f || fail 
 $PICK_TEST_DIR/$f does not exist
 +done
 +
 +cd $PICK_DIR/../../test
 +
 +test -x ../notmuch || fail `cd ..  pwd`/notmuch has not been built
 +
 +for f in $TESTFILES
 +do
 +if test -f $f
 +then
 + fail $f exists
 +fi
 +done
 +
 +trap rm -f $TESTFILES 0
 +
 +for f in $TESTFILES
 +do
 +ln -s $PICK_TEST_DIR/$f .
 +done
 +
 +#don't exec -- traps would not run.
 +for f in $TESTS
 +do
 +echo $f
 +./$f
 +done
 diff --git a/contrib/notmuch-pick/test/emacs-pick 
 b/contrib/notmuch-pick/test/emacs-pick
 new file mode 100755
 index 000..9db4b34
 --- /dev/null
 +++ b/contrib/notmuch-pick/test/emacs-pick
 @@ -0,0 +1,76 @@
 +#!/usr/bin/env bash
 +
 +test_description=emacs pick interface
 +. test-lib.sh
 +
 +EXPECTED=$TEST_DIRECTORY/pick.expected-output
 +
 +add_email_corpus
 +test_begin_subtest Do we have emacs
 +test_emacs '(insert hello\n)
 + (test-output)'
 +cat EOF EXPECTED
 +hello
 +EOF
 +test_expect_equal_file OUTPUT EXPECTED
 +
 +test_begin_subtest Basic notmuch-pick view in emacs
 +test_emacs '(add-to-list (quote load-path) '$PICK_DIR')
 + (require (quote notmuch-pick))
 + (notmuch-pick tag:inbox)
 + (notmuch-test-wait)
 + (test-output)
 + (delete-other-windows)'
 +test_expect_equal_file OUTPUT $EXPECTED/notmuch-pick-tag-inbox
 +
 +test_begin_subtest Navigation of notmuch-hello to search results
 +test_emacs '(notmuch-hello)
 + (goto-char (point-min))
 + (re-search-forward inbox)
 + (widget-button-press (1- (point)))
 + (notmuch-test-wait)
 + (notmuch-pick-from-search-current-query)
 + (notmuch-test-wait)
 + (test-output)
 + 

[PATCH v2] contrib: notmuch-pick: add tests

2012-11-01 Thread Mark Walters
The test should be run using the wrapper run-tests.sh.  This links
the tests into the normal notmuch TEST_DIRECTORY and runs them from
there. After the test is complete then the links are removed.
---

This is version 2 of the patches to add some tests for notmuch pick. 

The main change is that I have added Tomi's suggested wrapper script
(id:m2ip9srpd6.fsf at guru.guru-group.fi) which is much more robust and
generally better than the one I had.

The other changes are to split out the tests for the default async
parser from those for the sync parser. My guess is that the sync
parser should be removed but it can be useful for debugging so is
probably worth keeping until pick is closer to being ready for proper
mainline.

Best wishes

Mark




 contrib/notmuch-pick/README|5 ++
 contrib/notmuch-pick/run-tests.sh  |   46 
 contrib/notmuch-pick/test/emacs-pick   |   76 
 contrib/notmuch-pick/test/emacs-pick-sync  |   64 
 .../pick.expected-output/notmuch-pick-show-window  |   32 
 .../notmuch-pick-single-thread |6 ++
 .../pick.expected-output/notmuch-pick-tag-inbox|   53 ++
 7 files changed, 282 insertions(+), 0 deletions(-)
 create mode 100755 contrib/notmuch-pick/run-tests.sh
 create mode 100755 contrib/notmuch-pick/test/emacs-pick
 create mode 100755 contrib/notmuch-pick/test/emacs-pick-sync
 create mode 100644 
contrib/notmuch-pick/test/pick.expected-output/notmuch-pick-show-window
 create mode 100644 
contrib/notmuch-pick/test/pick.expected-output/notmuch-pick-single-thread
 create mode 100644 
contrib/notmuch-pick/test/pick.expected-output/notmuch-pick-tag-inbox

diff --git a/contrib/notmuch-pick/README b/contrib/notmuch-pick/README
index 8eed974..4200824 100644
--- a/contrib/notmuch-pick/README
+++ b/contrib/notmuch-pick/README
@@ -15,6 +15,11 @@ Then after the "(require 'notmuch)" line in your .emacs file 
add
 the line "(require 'notmuch-pick nil t)". This will load notmuch-pick on
 your next emacs start.

+TEST
+
+Just execute run-tests.sh and it should all work (it does require that
+notmuch has already been built).
+
 USING PICK

 The main key entries to notmuch pick are
diff --git a/contrib/notmuch-pick/run-tests.sh 
b/contrib/notmuch-pick/run-tests.sh
new file mode 100755
index 000..97cc9e8
--- /dev/null
+++ b/contrib/notmuch-pick/run-tests.sh
@@ -0,0 +1,46 @@
+#!/usr/bin/env bash
+
+set -eu
+
+fail() {
+echo ERROR $1
+exit 1
+}
+
+TESTS="emacs-pick emacs-pick-sync"
+TESTFILES="$TESTS pick.expected-output"
+
+PICK_DIR="`cd \`dirname "$0"\` && pwd`"
+PICK_TEST_DIR="$PICK_DIR/test"
+
+
+for f in $TESTFILES
+do
+test -f "$PICK_TEST_DIR/$f" || test -d "$PICK_TEST_DIR/$f" || fail 
"$PICK_TEST_DIR/$f does not exist"
+done
+
+cd "$PICK_DIR/../../test"
+
+test -x ../notmuch || fail "`cd .. && pwd`/notmuch has not been built"
+
+for f in $TESTFILES
+do
+if test -f "$f"
+then
+   fail "$f exists"
+fi
+done
+
+trap "rm -f $TESTFILES" 0
+
+for f in $TESTFILES
+do
+ln -s "$PICK_TEST_DIR/$f" .
+done
+
+#don't exec -- traps would not run.
+for f in $TESTS
+do
+echo $f
+./$f
+done
diff --git a/contrib/notmuch-pick/test/emacs-pick 
b/contrib/notmuch-pick/test/emacs-pick
new file mode 100755
index 000..9db4b34
--- /dev/null
+++ b/contrib/notmuch-pick/test/emacs-pick
@@ -0,0 +1,76 @@
+#!/usr/bin/env bash
+
+test_description="emacs pick interface"
+. test-lib.sh
+
+EXPECTED=$TEST_DIRECTORY/pick.expected-output
+
+add_email_corpus
+test_begin_subtest "Do we have emacs"
+test_emacs '(insert "hello\n")
+   (test-output)'
+cat 

[PATCH v2] contrib: notmuch-pick: add tests

2012-11-01 Thread Mark Walters
The test should be run using the wrapper run-tests.sh.  This links
the tests into the normal notmuch TEST_DIRECTORY and runs them from
there. After the test is complete then the links are removed.
---

This is version 2 of the patches to add some tests for notmuch pick. 

The main change is that I have added Tomi's suggested wrapper script
(id:m2ip9srpd6@guru.guru-group.fi) which is much more robust and
generally better than the one I had.

The other changes are to split out the tests for the default async
parser from those for the sync parser. My guess is that the sync
parser should be removed but it can be useful for debugging so is
probably worth keeping until pick is closer to being ready for proper
mainline.

Best wishes

Mark




 contrib/notmuch-pick/README|5 ++
 contrib/notmuch-pick/run-tests.sh  |   46 
 contrib/notmuch-pick/test/emacs-pick   |   76 
 contrib/notmuch-pick/test/emacs-pick-sync  |   64 
 .../pick.expected-output/notmuch-pick-show-window  |   32 
 .../notmuch-pick-single-thread |6 ++
 .../pick.expected-output/notmuch-pick-tag-inbox|   53 ++
 7 files changed, 282 insertions(+), 0 deletions(-)
 create mode 100755 contrib/notmuch-pick/run-tests.sh
 create mode 100755 contrib/notmuch-pick/test/emacs-pick
 create mode 100755 contrib/notmuch-pick/test/emacs-pick-sync
 create mode 100644 
contrib/notmuch-pick/test/pick.expected-output/notmuch-pick-show-window
 create mode 100644 
contrib/notmuch-pick/test/pick.expected-output/notmuch-pick-single-thread
 create mode 100644 
contrib/notmuch-pick/test/pick.expected-output/notmuch-pick-tag-inbox

diff --git a/contrib/notmuch-pick/README b/contrib/notmuch-pick/README
index 8eed974..4200824 100644
--- a/contrib/notmuch-pick/README
+++ b/contrib/notmuch-pick/README
@@ -15,6 +15,11 @@ Then after the (require 'notmuch) line in your .emacs file 
add
 the line (require 'notmuch-pick nil t). This will load notmuch-pick on
 your next emacs start.
 
+TEST
+
+Just execute run-tests.sh and it should all work (it does require that
+notmuch has already been built).
+
 USING PICK
 
 The main key entries to notmuch pick are
diff --git a/contrib/notmuch-pick/run-tests.sh 
b/contrib/notmuch-pick/run-tests.sh
new file mode 100755
index 000..97cc9e8
--- /dev/null
+++ b/contrib/notmuch-pick/run-tests.sh
@@ -0,0 +1,46 @@
+#!/usr/bin/env bash
+
+set -eu
+
+fail() {
+echo ERROR $1
+exit 1
+}
+
+TESTS=emacs-pick emacs-pick-sync
+TESTFILES=$TESTS pick.expected-output
+
+PICK_DIR=`cd \`dirname $0\`  pwd`
+PICK_TEST_DIR=$PICK_DIR/test
+
+
+for f in $TESTFILES
+do
+test -f $PICK_TEST_DIR/$f || test -d $PICK_TEST_DIR/$f || fail 
$PICK_TEST_DIR/$f does not exist
+done
+
+cd $PICK_DIR/../../test
+
+test -x ../notmuch || fail `cd ..  pwd`/notmuch has not been built
+
+for f in $TESTFILES
+do
+if test -f $f
+then
+   fail $f exists
+fi
+done
+
+trap rm -f $TESTFILES 0
+
+for f in $TESTFILES
+do
+ln -s $PICK_TEST_DIR/$f .
+done
+
+#don't exec -- traps would not run.
+for f in $TESTS
+do
+echo $f
+./$f
+done
diff --git a/contrib/notmuch-pick/test/emacs-pick 
b/contrib/notmuch-pick/test/emacs-pick
new file mode 100755
index 000..9db4b34
--- /dev/null
+++ b/contrib/notmuch-pick/test/emacs-pick
@@ -0,0 +1,76 @@
+#!/usr/bin/env bash
+
+test_description=emacs pick interface
+. test-lib.sh
+
+EXPECTED=$TEST_DIRECTORY/pick.expected-output
+
+add_email_corpus
+test_begin_subtest Do we have emacs
+test_emacs '(insert hello\n)
+   (test-output)'
+cat EOF EXPECTED
+hello
+EOF
+test_expect_equal_file OUTPUT EXPECTED
+
+test_begin_subtest Basic notmuch-pick view in emacs
+test_emacs '(add-to-list (quote load-path) '$PICK_DIR')
+   (require (quote notmuch-pick))
+   (notmuch-pick tag:inbox)
+   (notmuch-test-wait)
+   (test-output)
+   (delete-other-windows)'
+test_expect_equal_file OUTPUT $EXPECTED/notmuch-pick-tag-inbox
+
+test_begin_subtest Navigation of notmuch-hello to search results
+test_emacs '(notmuch-hello)
+   (goto-char (point-min))
+   (re-search-forward inbox)
+   (widget-button-press (1- (point)))
+   (notmuch-test-wait)
+   (notmuch-pick-from-search-current-query)
+   (notmuch-test-wait)
+   (test-output)
+   (delete-other-windows)'
+test_expect_equal_file OUTPUT $EXPECTED/notmuch-pick-tag-inbox
+
+test_begin_subtest Pick of a single thread (from search)
+test_emacs '(notmuch-hello)
+   (goto-char (point-min))
+   (re-search-forward inbox)
+   (widget-button-press (1- (point)))
+   (notmuch-test-wait)
+   (notmuch-pick-from-search-thread)
+   (notmuch-test-wait)
+   (test-output)
+   (delete-other-windows)'
+test_expect_equal_file OUTPUT $EXPECTED/notmuch-pick-single-thread
+
+test_begin_subtest