Re: [PATCH 03/13] test: remove USER_FULL_NAME when not present

2021-05-01 Thread Tomi Ollila
On Sat, May 01 2021, Felipe Contreras wrote:

> If a full name is not configured, the output is empty.

> This is possibly not portable, but it's a start.
>
> Signed-off-by: Felipe Contreras 
> ---
>  test/T590-libconfig.sh | 10 ++
>  1 file changed, 10 insertions(+)
>
> diff --git a/test/T590-libconfig.sh b/test/T590-libconfig.sh
> index 51dd29c8..36d9af1b 100755
> --- a/test/T590-libconfig.sh
> +++ b/test/T590-libconfig.sh
> @@ -5,6 +5,14 @@ test_description="library config API"
>  
>  add_email_corpus
>  
> +get_name () {
> +if hash getent 2>/dev/null; then
> +getent passwd "$USER" | cut -d ':' -f 5
> +else
> +echo "Foo Bar"
> +fi
> +}

I'd do

if test -n "$(getent passwd "$USER" | cut -d ':' -f 5)
then
USER_FULL_NAME=USER_FULL_NAME
else
USER_FULL_NAME=
fi

and then e.g.

cat <<"EOF" >EXPECTED
== stdout ==
MAIL_DIR
...
$USER_FULL_NAME
== stderr ==
EOF

if getent does not exist, then we'd get empty string
and $USER_FULL_NAME empty (as good as "Foo bar")


> +
>  cat < c_head
>  #include 
>  #include 
> @@ -402,6 +410,7 @@ NULL
>  USER_FULL_NAME
>  == stderr ==
>  EOF
> +test "$(get_name)" = "" && sed -e "s/USER_FULL_NAME//" -i EXPECTED
>  unset MAILDIR
>  test_expect_equal_file EXPECTED OUTPUT.clean
>  
> @@ -744,6 +753,7 @@ NULL
>  USER_FULL_NAME
>  == stderr ==
>  EOF
> +test "$(get_name)" = "" && sed -e "s/USER_FULL_NAME//" -i EXPECTED
>  test_expect_equal_file EXPECTED OUTPUT.clean
>  
>  backup_database
> -- 
> 2.31.0
___
notmuch mailing list -- notmuch@notmuchmail.org
To unsubscribe send an email to notmuch-le...@notmuchmail.org


[PATCH 03/13] test: remove USER_FULL_NAME when not present

2021-05-01 Thread Felipe Contreras
If a full name is not configured, the output is empty.

This is possibly not portable, but it's a start.

Signed-off-by: Felipe Contreras 
---
 test/T590-libconfig.sh | 10 ++
 1 file changed, 10 insertions(+)

diff --git a/test/T590-libconfig.sh b/test/T590-libconfig.sh
index 51dd29c8..36d9af1b 100755
--- a/test/T590-libconfig.sh
+++ b/test/T590-libconfig.sh
@@ -5,6 +5,14 @@ test_description="library config API"
 
 add_email_corpus
 
+get_name () {
+if hash getent 2>/dev/null; then
+getent passwd "$USER" | cut -d ':' -f 5
+else
+echo "Foo Bar"
+fi
+}
+
 cat < c_head
 #include 
 #include 
@@ -402,6 +410,7 @@ NULL
 USER_FULL_NAME
 == stderr ==
 EOF
+test "$(get_name)" = "" && sed -e "s/USER_FULL_NAME//" -i EXPECTED
 unset MAILDIR
 test_expect_equal_file EXPECTED OUTPUT.clean
 
@@ -744,6 +753,7 @@ NULL
 USER_FULL_NAME
 == stderr ==
 EOF
+test "$(get_name)" = "" && sed -e "s/USER_FULL_NAME//" -i EXPECTED
 test_expect_equal_file EXPECTED OUTPUT.clean
 
 backup_database
-- 
2.31.0
___
notmuch mailing list -- notmuch@notmuchmail.org
To unsubscribe send an email to notmuch-le...@notmuchmail.org