[PATCH 1/2] test: remove "Generate some messages" test from raw

classic Classic list List threaded Threaded
9 messages Options
Dmitry Kurochkin Dmitry Kurochkin
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate
star

[PATCH 1/2] test: remove "Generate some messages" test from raw

Before the change, the first subtest in raw format tests just
generated messages and checked that they are added successfully.  This
is not really a raw format test, it is creating of environment
required for other subtests to run.  The patch removes the first
subtest from raw and replaces it with bare add_message calls, similar
to how it is done in other tests.

TODO: we should check that test environment was created successfully.
Currently, many tests do add_message(), notmuch new and other calls
without checking the results.  We should come up with a general
solution for this, i.e. if any command during test initialization
fails, all tests should be skipped with appropriate error message.
---
 test/raw |    7 ++-----
 1 files changed, 2 insertions(+), 5 deletions(-)

diff --git a/test/raw b/test/raw
index 0171e64..de0b867 100755
--- a/test/raw
+++ b/test/raw
@@ -3,11 +3,8 @@
 test_description='notmuch show --format=raw'
 . ./test-lib.sh
 
-test_begin_subtest "Generate some messages"
-generate_message
-generate_message
-output=$(NOTMUCH_NEW)
-test_expect_equal "$output" "Added 2 new messages to the database."
+add_message
+add_message
 
 test_begin_subtest "Attempt to show multiple raw messages"
 output=$(notmuch show --format=raw "*" 2>&1)
--
1.7.8.3

_______________________________________________
notmuch mailing list
[hidden email]
http://notmuchmail.org/mailman/listinfo/notmuch
Dmitry Kurochkin Dmitry Kurochkin
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate
star

[PATCH 2/2] test: use subtest name for generated message subject by default

Before the change, messages generated by generate_message() used "Test
message #N" for default subject where N is the generated messages
counter.  Since message subject is commonly present in expected
results, there is a chance of breaking other tests when a new
generate_message() call is added.  The patch changes default subject
value for generated messages to subtest name if it is available.  If
subtest name is not available (i.e. message is generated during test
initialization), the old default value is used (in this case it is
fine to have the counter in the subject).

Another benefit of this change is a sane default value for subject in
generated messages, which would allow to simplify code like:

  test_begin_subtest "test for a cool feature"
  add_message [subject]="message for test for a cool feature"
---
 test/encoding                |    2 +-
 test/search-folder-coherence |    2 +-
 test/test-lib.sh             |    6 +++++-
 3 files changed, 7 insertions(+), 3 deletions(-)

diff --git a/test/encoding b/test/encoding
index 33259c1..dbaceb0 100755
--- a/test/encoding
+++ b/test/encoding
@@ -9,7 +9,7 @@ output=$(notmuch show id:${gen_msg_id} 2>&1 | notmuch_show_sanitize)
 test_expect_equal "$output" " message{ id:msg-001@notmuch-test-suite depth:0 match:1 filename:/XXX/mail/msg-001
  header{
 Notmuch Test Suite <[hidden email]> (2001-01-05) (inbox unread)
-Subject: Test message #1
+Subject: Message with text of unknown charset
 From: Notmuch Test Suite <[hidden email]>
 To: Notmuch Test Suite <[hidden email]>
 Date: Fri, 05 Jan 2001 15:43:57 +0000
diff --git a/test/search-folder-coherence b/test/search-folder-coherence
index f8119cb..3f6ec76 100755
--- a/test/search-folder-coherence
+++ b/test/search-folder-coherence
@@ -32,7 +32,7 @@ test_expect_equal_file OUTPUT EXPECTED
 
 test_begin_subtest "Test matches folder:spam"
 output=$(notmuch search folder:spam)
-test_expect_equal "$output" "thread:0000000000000001   2001-01-05 [1/1] Notmuch Test Suite; Test message #1 (inbox unread)"
+test_expect_equal "$output" "thread:0000000000000001   2001-01-05 [1/1] Notmuch Test Suite; Single new message (inbox unread)"
 
 test_begin_subtest "Remove folder:spam copy of email"
 rm $dir/spam/$(basename $file_x)
diff --git a/test/test-lib.sh b/test/test-lib.sh
index 8158328..94efdc1 100644
--- a/test/test-lib.sh
+++ b/test/test-lib.sh
@@ -318,7 +318,11 @@ generate_message ()
     fi
 
     if [ -z "${template[subject]}" ]; then
- template[subject]="Test message #${gen_msg_cnt}"
+ if [ -n "$test_subtest_name" ]; then
+    template[subject]="$test_subtest_name"
+ else
+    template[subject]="Test message #${gen_msg_cnt}"
+ fi
     fi
 
     if [ -z "${template[date]}" ]; then
--
1.7.8.3

_______________________________________________
notmuch mailing list
[hidden email]
http://notmuchmail.org/mailman/listinfo/notmuch
Dmitry Kurochkin Dmitry Kurochkin
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate
star

Re: [PATCH 1/2] test: remove "Generate some messages" test from raw

In reply to this post by Dmitry Kurochkin
Hi all.

Are there any objections to these changes?

Otherwise, I would ask David to push it as "minor, boring and trivial"
changes.

Regards,
  Dmitry
_______________________________________________
notmuch mailing list
[hidden email]
http://notmuchmail.org/mailman/listinfo/notmuch
Dmitry Kurochkin Dmitry Kurochkin
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate
star

Re: [PATCH 1/2] test: remove "Generate some messages" test from raw

Hi David.

On Wed, 15 Feb 2012 22:33:51 +0400, Dmitry Kurochkin <[hidden email]> wrote:
> Hi all.
>
> Are there any objections to these changes?
>
> Otherwise, I would ask David to push it as "minor, boring and trivial"
> changes.
>

Since there are no objections, I removed the needs-review tag from these
patches.

David, I believe the patches are good to be pushed.

Regards,
  Dmitry

> Regards,
>   Dmitry
_______________________________________________
notmuch mailing list
[hidden email]
http://notmuchmail.org/mailman/listinfo/notmuch
Jani Nikula Jani Nikula
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate
star

Re: [PATCH 2/2] test: use subtest name for generated message subject by default

In reply to this post by Dmitry Kurochkin

Hi Dmitry, I tagged this notmuch::stale as it no longer cleanly applies
to master.

BR,
Jani.

On Tue, 31 Jan 2012 02:06:35 +0400, Dmitry Kurochkin <[hidden email]> wrote:

> Before the change, messages generated by generate_message() used "Test
> message #N" for default subject where N is the generated messages
> counter.  Since message subject is commonly present in expected
> results, there is a chance of breaking other tests when a new
> generate_message() call is added.  The patch changes default subject
> value for generated messages to subtest name if it is available.  If
> subtest name is not available (i.e. message is generated during test
> initialization), the old default value is used (in this case it is
> fine to have the counter in the subject).
>
> Another benefit of this change is a sane default value for subject in
> generated messages, which would allow to simplify code like:
>
>   test_begin_subtest "test for a cool feature"
>   add_message [subject]="message for test for a cool feature"
> ---
>  test/encoding                |    2 +-
>  test/search-folder-coherence |    2 +-
>  test/test-lib.sh             |    6 +++++-
>  3 files changed, 7 insertions(+), 3 deletions(-)
>
> diff --git a/test/encoding b/test/encoding
> index 33259c1..dbaceb0 100755
> --- a/test/encoding
> +++ b/test/encoding
> @@ -9,7 +9,7 @@ output=$(notmuch show id:${gen_msg_id} 2>&1 | notmuch_show_sanitize)
>  test_expect_equal "$output" " message{ id:msg-001@notmuch-test-suite depth:0 match:1 filename:/XXX/mail/msg-001
>   header{
>  Notmuch Test Suite <[hidden email]> (2001-01-05) (inbox unread)
> -Subject: Test message #1
> +Subject: Message with text of unknown charset
>  From: Notmuch Test Suite <[hidden email]>
>  To: Notmuch Test Suite <[hidden email]>
>  Date: Fri, 05 Jan 2001 15:43:57 +0000
> diff --git a/test/search-folder-coherence b/test/search-folder-coherence
> index f8119cb..3f6ec76 100755
> --- a/test/search-folder-coherence
> +++ b/test/search-folder-coherence
> @@ -32,7 +32,7 @@ test_expect_equal_file OUTPUT EXPECTED
>  
>  test_begin_subtest "Test matches folder:spam"
>  output=$(notmuch search folder:spam)
> -test_expect_equal "$output" "thread:0000000000000001   2001-01-05 [1/1] Notmuch Test Suite; Test message #1 (inbox unread)"
> +test_expect_equal "$output" "thread:0000000000000001   2001-01-05 [1/1] Notmuch Test Suite; Single new message (inbox unread)"
>  
>  test_begin_subtest "Remove folder:spam copy of email"
>  rm $dir/spam/$(basename $file_x)
> diff --git a/test/test-lib.sh b/test/test-lib.sh
> index 8158328..94efdc1 100644
> --- a/test/test-lib.sh
> +++ b/test/test-lib.sh
> @@ -318,7 +318,11 @@ generate_message ()
>      fi
>  
>      if [ -z "${template[subject]}" ]; then
> - template[subject]="Test message #${gen_msg_cnt}"
> + if [ -n "$test_subtest_name" ]; then
> +    template[subject]="$test_subtest_name"
> + else
> +    template[subject]="Test message #${gen_msg_cnt}"
> + fi
>      fi
>  
>      if [ -z "${template[date]}" ]; then
> --
> 1.7.8.3
>
> _______________________________________________
> notmuch mailing list
> [hidden email]
> http://notmuchmail.org/mailman/listinfo/notmuch
_______________________________________________
notmuch mailing list
[hidden email]
http://notmuchmail.org/mailman/listinfo/notmuch
Dmitry Kurochkin Dmitry Kurochkin
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate
star

[PATCH v2 0/2] test: use subtest name for generated message subject

In reply to this post by Dmitry Kurochkin
Changes in v2:

* rebase on master

Regards,
  Dmitry

_______________________________________________
notmuch mailing list
[hidden email]
http://notmuchmail.org/mailman/listinfo/notmuch
Dmitry Kurochkin Dmitry Kurochkin
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate
star

[PATCH v2 1/2] test: remove "Generate some messages" test from raw

Before the change, the first subtest in raw format tests just
generated messages and checked that they are added successfully.  This
is not really a raw format test, it is creating of environment
required for other subtests to run.  The patch removes the first
subtest from raw and replaces it with bare add_message calls, similar
to how it is done in other tests.

TODO: we should check that test environment was created successfully.
Currently, many tests do add_message(), notmuch new and other calls
without checking the results.  We should come up with a general
solution for this, i.e. if any command during test initialization
fails, all tests should be skipped with appropriate error message.
---
 test/raw |    7 ++-----
 1 files changed, 2 insertions(+), 5 deletions(-)

diff --git a/test/raw b/test/raw
index 0171e64..de0b867 100755
--- a/test/raw
+++ b/test/raw
@@ -3,11 +3,8 @@
 test_description='notmuch show --format=raw'
 . ./test-lib.sh
 
-test_begin_subtest "Generate some messages"
-generate_message
-generate_message
-output=$(NOTMUCH_NEW)
-test_expect_equal "$output" "Added 2 new messages to the database."
+add_message
+add_message
 
 test_begin_subtest "Attempt to show multiple raw messages"
 output=$(notmuch show --format=raw "*" 2>&1)
--
1.7.9.1

_______________________________________________
notmuch mailing list
[hidden email]
http://notmuchmail.org/mailman/listinfo/notmuch
Dmitry Kurochkin Dmitry Kurochkin
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate
star

[PATCH v2 2/2] test: use subtest name for generated message subject by default

In reply to this post by Dmitry Kurochkin
Before the change, messages generated by generate_message() used "Test
message #N" for default subject where N is the generated messages
counter.  Since message subject is commonly present in expected
results, there is a chance of breaking other tests when a new
generate_message() call is added.  The patch changes default subject
value for generated messages to subtest name if it is available.  If
subtest name is not available (i.e. message is generated during test
initialization), the old default value is used (in this case it is
fine to have the counter in the subject).

Another benefit of this change is a sane default value for subject in
generated messages, which would allow to simplify code like:

  test_begin_subtest "test for a cool feature"
  add_message [subject]="message for test for a cool feature"
---
 test/encoding                |    2 +-
 test/search-folder-coherence |    2 +-
 test/test-lib.sh             |    6 +++++-
 3 files changed, 7 insertions(+), 3 deletions(-)

diff --git a/test/encoding b/test/encoding
index 98abf77..2e1326e 100755
--- a/test/encoding
+++ b/test/encoding
@@ -9,7 +9,7 @@ output=$(notmuch show id:${gen_msg_id} 2>&1 | notmuch_show_sanitize)
 test_expect_equal "$output" " message{ id:msg-001@notmuch-test-suite depth:0 match:1 excluded:0 filename:/XXX/mail/msg-001
  header{
 Notmuch Test Suite <[hidden email]> (2001-01-05) (inbox unread)
-Subject: Test message #1
+Subject: Message with text of unknown charset
 From: Notmuch Test Suite <[hidden email]>
 To: Notmuch Test Suite <[hidden email]>
 Date: Fri, 05 Jan 2001 15:43:57 +0000
diff --git a/test/search-folder-coherence b/test/search-folder-coherence
index f8119cb..3f6ec76 100755
--- a/test/search-folder-coherence
+++ b/test/search-folder-coherence
@@ -32,7 +32,7 @@ test_expect_equal_file OUTPUT EXPECTED
 
 test_begin_subtest "Test matches folder:spam"
 output=$(notmuch search folder:spam)
-test_expect_equal "$output" "thread:0000000000000001   2001-01-05 [1/1] Notmuch Test Suite; Test message #1 (inbox unread)"
+test_expect_equal "$output" "thread:0000000000000001   2001-01-05 [1/1] Notmuch Test Suite; Single new message (inbox unread)"
 
 test_begin_subtest "Remove folder:spam copy of email"
 rm $dir/spam/$(basename $file_x)
diff --git a/test/test-lib.sh b/test/test-lib.sh
index 2781506..06aaea2 100644
--- a/test/test-lib.sh
+++ b/test/test-lib.sh
@@ -318,7 +318,11 @@ generate_message ()
     fi
 
     if [ -z "${template[subject]}" ]; then
- template[subject]="Test message #${gen_msg_cnt}"
+ if [ -n "$test_subtest_name" ]; then
+    template[subject]="$test_subtest_name"
+ else
+    template[subject]="Test message #${gen_msg_cnt}"
+ fi
     fi
 
     if [ -z "${template[date]}" ]; then
--
1.7.9.1

_______________________________________________
notmuch mailing list
[hidden email]
http://notmuchmail.org/mailman/listinfo/notmuch
David Bremner-2 David Bremner-2
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate
star

Re: [PATCH v2 0/2] test: use subtest name for generated message subject

In reply to this post by Dmitry Kurochkin
On Sat, 10 Mar 2012 05:24:49 +0400, Dmitry Kurochkin <[hidden email]> wrote:
> Changes in v2:
>
> * rebase on master
>

pushed.

d
_______________________________________________
notmuch mailing list
[hidden email]
http://notmuchmail.org/mailman/listinfo/notmuch
Loading...