unofficial mirror of notmuch@notmuchmail.org
 help / color / mirror / code / Atom feed
* [PATCH] test: sort the output of the "prefix" test in T610-message-property
@ 2020-04-19 16:06 Olivier Taïbi
  2020-04-20 20:34 ` Tomi Ollila
  2020-04-24  0:33 ` David Bremner
  0 siblings, 2 replies; 3+ messages in thread
From: Olivier Taïbi @ 2020-04-19 16:06 UTC (permalink / raw)
  To: notmuch

This test extracts values from a (key,value) map where multiple entries
can have the same key, and the entries are sorted by key, but not by
value.  The test incorrectly assumes that the values will be sorted as
well, so sort the output.
---
 test/T610-message-property.sh | 12 ++++++++++++
 1 file changed, 12 insertions(+)

diff --git a/test/T610-message-property.sh b/test/T610-message-property.sh
index 53a0be3b..b8774230 100755
--- a/test/T610-message-property.sh
+++ b/test/T610-message-property.sh
@@ -186,6 +186,18 @@ EXPECT0(notmuch_message_add_property (message, "testkey3", "testvalue3"));
 EXPECT0(notmuch_message_add_property (message, "testkey3", "alice3"));
 print_properties (message, "testkey", FALSE);
 EOF
+# expected: 4 values for testkey1, 3 values for testkey3
+# they are not guaranteed to be sorted, so sort them, leaving the first
+# line '== stdout ==' and the end ('== stderr ==' and whatever error
+# may have been printed) alone
+mv OUTPUT unsorted_OUTPUT
+awk ' NR == 1 { print; next } \
+      NR < 6  { print | "sort"; next } \
+      NR == 6 { close("sort") } \
+      NR < 9  { print | "sort"; next } \
+      NR == 9 { close("sort") } \
+      { print }' unsorted_OUTPUT > OUTPUT
+rm unsorted_OUTPUT
 cat <<'EOF' >EXPECTED
 == stdout ==
 alice
-- 
2.26.1
---
a better version of the previous patch I sent with head/tail replaced by an awk
script by Tomi Ollila which is clearer, and comments added in the test for
clarity.

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

* Re: [PATCH] test: sort the output of the "prefix" test in T610-message-property
  2020-04-19 16:06 [PATCH] test: sort the output of the "prefix" test in T610-message-property Olivier Taïbi
@ 2020-04-20 20:34 ` Tomi Ollila
  2020-04-24  0:33 ` David Bremner
  1 sibling, 0 replies; 3+ messages in thread
From: Tomi Ollila @ 2020-04-20 20:34 UTC (permalink / raw)
  To: Olivier Taïbi, notmuch

On Sun, Apr 19 2020, Olivier Taïbi wrote:

> This test extracts values from a (key,value) map where multiple entries
> can have the same key, and the entries are sorted by key, but not by
> value.  The test incorrectly assumes that the values will be sorted as
> well, so sort the output.

This sure looks good to me.

Tomi

> ---
>  test/T610-message-property.sh | 12 ++++++++++++
>  1 file changed, 12 insertions(+)
>
> diff --git a/test/T610-message-property.sh b/test/T610-message-property.sh
> index 53a0be3b..b8774230 100755
> --- a/test/T610-message-property.sh
> +++ b/test/T610-message-property.sh
> @@ -186,6 +186,18 @@ EXPECT0(notmuch_message_add_property (message, "testkey3", "testvalue3"));
>  EXPECT0(notmuch_message_add_property (message, "testkey3", "alice3"));
>  print_properties (message, "testkey", FALSE);
>  EOF
> +# expected: 4 values for testkey1, 3 values for testkey3
> +# they are not guaranteed to be sorted, so sort them, leaving the first
> +# line '== stdout ==' and the end ('== stderr ==' and whatever error
> +# may have been printed) alone
> +mv OUTPUT unsorted_OUTPUT
> +awk ' NR == 1 { print; next } \
> +      NR < 6  { print | "sort"; next } \
> +      NR == 6 { close("sort") } \
> +      NR < 9  { print | "sort"; next } \
> +      NR == 9 { close("sort") } \
> +      { print }' unsorted_OUTPUT > OUTPUT
> +rm unsorted_OUTPUT
>  cat <<'EOF' >EXPECTED
>  == stdout ==
>  alice
> -- 
> 2.26.1
> ---
> a better version of the previous patch I sent with head/tail replaced by an awk
> script by Tomi Ollila which is clearer, and comments added in the test for
> clarity.
> _______________________________________________
> notmuch mailing list
> notmuch@notmuchmail.org
> https://notmuchmail.org/mailman/listinfo/notmuch

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

* Re: [PATCH] test: sort the output of the "prefix" test in T610-message-property
  2020-04-19 16:06 [PATCH] test: sort the output of the "prefix" test in T610-message-property Olivier Taïbi
  2020-04-20 20:34 ` Tomi Ollila
@ 2020-04-24  0:33 ` David Bremner
  1 sibling, 0 replies; 3+ messages in thread
From: David Bremner @ 2020-04-24  0:33 UTC (permalink / raw)
  To: Olivier Taïbi, notmuch

Olivier Taïbi <oli@olitb.net> writes:

> This test extracts values from a (key,value) map where multiple entries
> can have the same key, and the entries are sorted by key, but not by
> value.  The test incorrectly assumes that the values will be sorted as
> well, so sort the output.

pushed.

d

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

end of thread, other threads:[~2020-04-24  0:33 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-04-19 16:06 [PATCH] test: sort the output of the "prefix" test in T610-message-property Olivier Taïbi
2020-04-20 20:34 ` Tomi Ollila
2020-04-24  0:33 ` 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).