[PATCH] test: add test for notmuch tag --batch option

2012-12-02 Thread Jani Nikula
On Fri, 30 Nov 2012, david at tethera.net wrote:
> From: Jani Nikula 
>
> Basic test of functionality, along with all combinations of options.
>
> Modified extensively by David Bremner 
>
> The choice of @ as a tag is intended to be non-alphanumeric, but still
> not too much trouble in the shell and in the old sup dump/restore format.
> ---
>
> Mark: good catch. 
>
> I decided to save restore the tags rather than have
> multiple input and output files here.

But you have to be careful to not add any fancy tags as we're still
using the sup dump format here.

>
>  test/tagging |   50 ++
>  1 file changed, 50 insertions(+)
>
> diff --git a/test/tagging b/test/tagging
> index 980ff92..75552e8 100755
> --- a/test/tagging
> +++ b/test/tagging
> @@ -46,6 +46,56 @@ test_expect_equal "$output" "\
>  thread:XXX   2001-01-05 [1/1] Notmuch Test Suite; One (:\"  inbox tag1 
> unread)
>  thread:XXX   2001-01-05 [1/1] Notmuch Test Suite; Two (inbox tag1 tag4 
> unread)"
>  
> +test_begin_subtest "--batch"
> +notmuch tag --batch < +# %20 is a space in tag
> +-:"%20 -tag1 +tag5 +tag6 -- One
> ++tag1 -tag1 -tag4 +tag4 -- Two
> +-tag6 One
> ++tag5 Two
> +EOF
> +output=$(notmuch search \* | notmuch_search_sanitize)
> +test_expect_equal "$output" "\
> +thread:XXX   2001-01-05 [1/1] Notmuch Test Suite; One (inbox tag5 unread)
> +thread:XXX   2001-01-05 [1/1] Notmuch Test Suite; Two (inbox tag4 tag5 
> unread)"
> +

Perhaps add a comment here that the generated files are used for more
than one subtest.

> +cat > batch.in  < +# %20 is a space in tag

True, but what's it got to do with this bit? :p

BR,
Jani.

> ++%40 -tag5 +tag6 -- One
> ++tag1 -tag1 -tag4 +tag4 -- Two
> +-tag5 +tag6 Two
> +EOF
> +
> +cat > batch.expected < +thread:XXX   2001-01-05 [1/1] Notmuch Test Suite; One (@ inbox tag6 unread)
> +thread:XXX   2001-01-05 [1/1] Notmuch Test Suite; Two (inbox tag4 tag6 
> unread)
> +EOF
> +
> +test_begin_subtest "--input"
> +notmuch dump > backup.tags.$test_count
> +notmuch tag --input=batch.in
> +notmuch search \* | notmuch_search_sanitize > OUTPUT.$test_count
> +notmuch restore < backup.tags.$test_count
> +test_expect_equal_file batch.expected OUTPUT.$test_count
> +
> +test_begin_subtest "--batch --input"
> +notmuch dump > backup.tags.$test_count
> +notmuch tag --batch --input=batch.in
> +notmuch search \* | notmuch_search_sanitize > OUTPUT.$test_count
> +notmuch restore < backup.tags.$test_count
> +test_expect_equal_file batch.expected OUTPUT.$test_count
> +
> +test_begin_subtest "--batch, blank lines and comments"
> +notmuch dump | sort > EXPECTED.$test_count
> +notmuch tag --batch < +# this line is a comment; the next has only white space
> +  
> +
> +# the previous line is empty
> +EOF
> +notmuch dump | sort > OUTPUT.$test_count
> +test_expect_equal_file EXPECTED.$test_count OUTPUT.$test_count
> +
>  test_expect_code 1 "Empty tag names" 'notmuch tag + One'
>  
>  test_expect_code 1 "Tag name beginning with -" 'notmuch tag +- One'
> -- 
> 1.7.10.4


[PATCH] test: add test for notmuch tag --batch option

2012-11-30 Thread Tomi Ollila
On Fri, Nov 30 2012, david at tethera.net wrote:

> From: Jani Nikula 
>
> Basic test of functionality, along with all combinations of options.
>
> Modified extensively by David Bremner 
>
> The choice of @ as a tag is intended to be non-alphanumeric, but still
> not too much trouble in the shell and in the old sup dump/restore format.
> ---
>
> Mark: good catch. 
>
> I decided to save restore the tags rather than have
> multiple input and output files here.
>
>  test/tagging |   50 ++
>  1 file changed, 50 insertions(+)
>
> diff --git a/test/tagging b/test/tagging
> index 980ff92..75552e8 100755
> --- a/test/tagging
> +++ b/test/tagging
> @@ -46,6 +46,56 @@ test_expect_equal "$output" "\
>  thread:XXX   2001-01-05 [1/1] Notmuch Test Suite; One (:\"  inbox tag1 
> unread)
>  thread:XXX   2001-01-05 [1/1] Notmuch Test Suite; Two (inbox tag1 tag4 
> unread)"
>  
> +test_begin_subtest "--batch"
> +notmuch tag --batch < +# %20 is a space in tag
> +-:"%20 -tag1 +tag5 +tag6 -- One
> ++tag1 -tag1 -tag4 +tag4 -- Two
> +-tag6 One
> ++tag5 Two
> +EOF
> +output=$(notmuch search \* | notmuch_search_sanitize)
> +test_expect_equal "$output" "\
> +thread:XXX   2001-01-05 [1/1] Notmuch Test Suite; One (inbox tag5 unread)
> +thread:XXX   2001-01-05 [1/1] Notmuch Test Suite; Two (inbox tag4 tag5 
> unread)"
> +
> +cat > batch.in  < +# %20 is a space in tag
> ++%40 -tag5 +tag6 -- One
> ++tag1 -tag1 -tag4 +tag4 -- Two
> +-tag5 +tag6 Two
> +EOF
> +
> +cat > batch.expected < +thread:XXX   2001-01-05 [1/1] Notmuch Test Suite; One (@ inbox tag6 unread)
> +thread:XXX   2001-01-05 [1/1] Notmuch Test Suite; Two (inbox tag4 tag6 
> unread)
> +EOF
> +
> +test_begin_subtest "--input"
> +notmuch dump > backup.tags.$test_count
> +notmuch tag --input=batch.in
> +notmuch search \* | notmuch_search_sanitize > OUTPUT.$test_count
> +notmuch restore < backup.tags.$test_count
> +test_expect_equal_file batch.expected OUTPUT.$test_count

2 things for all of these test_expect_equal_file ...:s

Generally, argument order is OUTPUT EXPECTED (the diff is harder to grasp
-- but changing the diff order in test_expect_equal_file is pretty easy...
(& I have some patches in preparation for that...)

In case of failure. test_expect_equal_file does

  if diff -q "$file1" "$file2" >/dev/null ; then
   test_ok_ "$test_subtest_name"
  else
   testname=$this_test.$test_count
   cp "$file1" "$testname.$basename1"
   cp "$file2" "$testname.$basename2"

i.e. the $test_count is already in the files -- in these
cases that is duplicated...

Tomi


> +test_begin_subtest "--batch --input"
> +notmuch dump > backup.tags.$test_count
> +notmuch tag --batch --input=batch.in
> +notmuch search \* | notmuch_search_sanitize > OUTPUT.$test_count
> +notmuch restore < backup.tags.$test_count
> +test_expect_equal_file batch.expected OUTPUT.$test_count
> +
> +test_begin_subtest "--batch, blank lines and comments"
> +notmuch dump | sort > EXPECTED.$test_count
> +notmuch tag --batch < +# this line is a comment; the next has only white space
> +  
> +
> +# the previous line is empty
> +EOF
> +notmuch dump | sort > OUTPUT.$test_count
> +test_expect_equal_file EXPECTED.$test_count OUTPUT.$test_count
> +
>  test_expect_code 1 "Empty tag names" 'notmuch tag + One'
>  
>  test_expect_code 1 "Tag name beginning with -" 'notmuch tag +- One'
> -- 
> 1.7.10.4


[PATCH] test: add test for notmuch tag --batch option

2012-11-30 Thread da...@tethera.net
From: Jani Nikula 

Basic test of functionality, along with all combinations of options.

Modified extensively by David Bremner 

The choice of @ as a tag is intended to be non-alphanumeric, but still
not too much trouble in the shell and in the old sup dump/restore format.
---

Mark: good catch. 

I decided to save restore the tags rather than have
multiple input and output files here.

 test/tagging |   50 ++
 1 file changed, 50 insertions(+)

diff --git a/test/tagging b/test/tagging
index 980ff92..75552e8 100755
--- a/test/tagging
+++ b/test/tagging
@@ -46,6 +46,56 @@ test_expect_equal "$output" "\
 thread:XXX   2001-01-05 [1/1] Notmuch Test Suite; One (:\"  inbox tag1 unread)
 thread:XXX   2001-01-05 [1/1] Notmuch Test Suite; Two (inbox tag1 tag4 unread)"

+test_begin_subtest "--batch"
+notmuch tag --batch < batch.in  < batch.expected < backup.tags.$test_count
+notmuch tag --input=batch.in
+notmuch search \* | notmuch_search_sanitize > OUTPUT.$test_count
+notmuch restore < backup.tags.$test_count
+test_expect_equal_file batch.expected OUTPUT.$test_count
+
+test_begin_subtest "--batch --input"
+notmuch dump > backup.tags.$test_count
+notmuch tag --batch --input=batch.in
+notmuch search \* | notmuch_search_sanitize > OUTPUT.$test_count
+notmuch restore < backup.tags.$test_count
+test_expect_equal_file batch.expected OUTPUT.$test_count
+
+test_begin_subtest "--batch, blank lines and comments"
+notmuch dump | sort > EXPECTED.$test_count
+notmuch tag --batch < OUTPUT.$test_count
+test_expect_equal_file EXPECTED.$test_count OUTPUT.$test_count
+
 test_expect_code 1 "Empty tag names" 'notmuch tag + One'

 test_expect_code 1 "Tag name beginning with -" 'notmuch tag +- One'
-- 
1.7.10.4



[PATCH] test: add test for notmuch tag --batch option

2012-11-29 Thread david
From: Jani Nikula j...@nikula.org

Basic test of functionality, along with all combinations of options.

Modified extensively by David Bremner da...@tethera.net

The choice of @ as a tag is intended to be non-alphanumeric, but still
not too much trouble in the shell and in the old sup dump/restore format.
---

Mark: good catch. 

I decided to save restore the tags rather than have
multiple input and output files here.

 test/tagging |   50 ++
 1 file changed, 50 insertions(+)

diff --git a/test/tagging b/test/tagging
index 980ff92..75552e8 100755
--- a/test/tagging
+++ b/test/tagging
@@ -46,6 +46,56 @@ test_expect_equal $output \
 thread:XXX   2001-01-05 [1/1] Notmuch Test Suite; One (:\  inbox tag1 unread)
 thread:XXX   2001-01-05 [1/1] Notmuch Test Suite; Two (inbox tag1 tag4 unread)
 
+test_begin_subtest --batch
+notmuch tag --batch EOF
+# %20 is a space in tag
+-:%20 -tag1 +tag5 +tag6 -- One
++tag1 -tag1 -tag4 +tag4 -- Two
+-tag6 One
++tag5 Two
+EOF
+output=$(notmuch search \* | notmuch_search_sanitize)
+test_expect_equal $output \
+thread:XXX   2001-01-05 [1/1] Notmuch Test Suite; One (inbox tag5 unread)
+thread:XXX   2001-01-05 [1/1] Notmuch Test Suite; Two (inbox tag4 tag5 unread)
+
+cat  batch.in  EOF
+# %20 is a space in tag
++%40 -tag5 +tag6 -- One
++tag1 -tag1 -tag4 +tag4 -- Two
+-tag5 +tag6 Two
+EOF
+
+cat  batch.expected EOF
+thread:XXX   2001-01-05 [1/1] Notmuch Test Suite; One (@ inbox tag6 unread)
+thread:XXX   2001-01-05 [1/1] Notmuch Test Suite; Two (inbox tag4 tag6 unread)
+EOF
+
+test_begin_subtest --input
+notmuch dump  backup.tags.$test_count
+notmuch tag --input=batch.in
+notmuch search \* | notmuch_search_sanitize  OUTPUT.$test_count
+notmuch restore  backup.tags.$test_count
+test_expect_equal_file batch.expected OUTPUT.$test_count
+
+test_begin_subtest --batch --input
+notmuch dump  backup.tags.$test_count
+notmuch tag --batch --input=batch.in
+notmuch search \* | notmuch_search_sanitize  OUTPUT.$test_count
+notmuch restore  backup.tags.$test_count
+test_expect_equal_file batch.expected OUTPUT.$test_count
+
+test_begin_subtest --batch, blank lines and comments
+notmuch dump | sort  EXPECTED.$test_count
+notmuch tag --batch EOF
+# this line is a comment; the next has only white space
+
+
+# the previous line is empty
+EOF
+notmuch dump | sort  OUTPUT.$test_count
+test_expect_equal_file EXPECTED.$test_count OUTPUT.$test_count
+
 test_expect_code 1 Empty tag names 'notmuch tag + One'
 
 test_expect_code 1 Tag name beginning with - 'notmuch tag +- One'
-- 
1.7.10.4

___
notmuch mailing list
notmuch@notmuchmail.org
http://notmuchmail.org/mailman/listinfo/notmuch


Re: [PATCH] test: add test for notmuch tag --batch option

2012-11-29 Thread Tomi Ollila
On Fri, Nov 30 2012, da...@tethera.net wrote:

 From: Jani Nikula j...@nikula.org

 Basic test of functionality, along with all combinations of options.

 Modified extensively by David Bremner da...@tethera.net

 The choice of @ as a tag is intended to be non-alphanumeric, but still
 not too much trouble in the shell and in the old sup dump/restore format.
 ---

 Mark: good catch. 

 I decided to save restore the tags rather than have
 multiple input and output files here.

  test/tagging |   50 ++
  1 file changed, 50 insertions(+)

 diff --git a/test/tagging b/test/tagging
 index 980ff92..75552e8 100755
 --- a/test/tagging
 +++ b/test/tagging
 @@ -46,6 +46,56 @@ test_expect_equal $output \
  thread:XXX   2001-01-05 [1/1] Notmuch Test Suite; One (:\  inbox tag1 
 unread)
  thread:XXX   2001-01-05 [1/1] Notmuch Test Suite; Two (inbox tag1 tag4 
 unread)
  
 +test_begin_subtest --batch
 +notmuch tag --batch EOF
 +# %20 is a space in tag
 +-:%20 -tag1 +tag5 +tag6 -- One
 ++tag1 -tag1 -tag4 +tag4 -- Two
 +-tag6 One
 ++tag5 Two
 +EOF
 +output=$(notmuch search \* | notmuch_search_sanitize)
 +test_expect_equal $output \
 +thread:XXX   2001-01-05 [1/1] Notmuch Test Suite; One (inbox tag5 unread)
 +thread:XXX   2001-01-05 [1/1] Notmuch Test Suite; Two (inbox tag4 tag5 
 unread)
 +
 +cat  batch.in  EOF
 +# %20 is a space in tag
 ++%40 -tag5 +tag6 -- One
 ++tag1 -tag1 -tag4 +tag4 -- Two
 +-tag5 +tag6 Two
 +EOF
 +
 +cat  batch.expected EOF
 +thread:XXX   2001-01-05 [1/1] Notmuch Test Suite; One (@ inbox tag6 unread)
 +thread:XXX   2001-01-05 [1/1] Notmuch Test Suite; Two (inbox tag4 tag6 
 unread)
 +EOF
 +
 +test_begin_subtest --input
 +notmuch dump  backup.tags.$test_count
 +notmuch tag --input=batch.in
 +notmuch search \* | notmuch_search_sanitize  OUTPUT.$test_count
 +notmuch restore  backup.tags.$test_count
 +test_expect_equal_file batch.expected OUTPUT.$test_count

2 things for all of these test_expect_equal_file ...:s

Generally, argument order is OUTPUT EXPECTED (the diff is harder to grasp
-- but changing the diff order in test_expect_equal_file is pretty easy...
( I have some patches in preparation for that...)

In case of failure. test_expect_equal_file does

  if diff -q $file1 $file2 /dev/null ; then
   test_ok_ $test_subtest_name
  else
   testname=$this_test.$test_count
   cp $file1 $testname.$basename1
   cp $file2 $testname.$basename2

i.e. the $test_count is already in the files -- in these
cases that is duplicated...

Tomi


 +test_begin_subtest --batch --input
 +notmuch dump  backup.tags.$test_count
 +notmuch tag --batch --input=batch.in
 +notmuch search \* | notmuch_search_sanitize  OUTPUT.$test_count
 +notmuch restore  backup.tags.$test_count
 +test_expect_equal_file batch.expected OUTPUT.$test_count
 +
 +test_begin_subtest --batch, blank lines and comments
 +notmuch dump | sort  EXPECTED.$test_count
 +notmuch tag --batch EOF
 +# this line is a comment; the next has only white space
 +  
 +
 +# the previous line is empty
 +EOF
 +notmuch dump | sort  OUTPUT.$test_count
 +test_expect_equal_file EXPECTED.$test_count OUTPUT.$test_count
 +
  test_expect_code 1 Empty tag names 'notmuch tag + One'
  
  test_expect_code 1 Tag name beginning with - 'notmuch tag +- One'
 -- 
 1.7.10.4
___
notmuch mailing list
notmuch@notmuchmail.org
http://notmuchmail.org/mailman/listinfo/notmuch