From: Tomi Ollila <tomi.ollila@iki.fi>
To: Felipe Contreras <felipe.contreras@gmail.com>, notmuch@notmuchmail.org
Cc: Daniel Kahn Gillmor <dkg@fifthhorseman.net>
Subject: Re: [PATCH 03/13] test: remove USER_FULL_NAME when not present
Date: Sat, 01 May 2021 23:13:55 +0300 [thread overview]
Message-ID: <m2h7jm43gc.fsf@guru.guru-group.fi> (raw)
In-Reply-To: <20210501115422.483314-4-felipe.contreras@gmail.com>
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 <felipe.contreras@gmail.com>
> ---
> 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 <<EOF > c_head
> #include <string.h>
> #include <stdlib.h>
> @@ -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
next prev parent reply other threads:[~2021-05-01 20:14 UTC|newest]
Thread overview: 29+ messages / expand[flat|nested] mbox.gz Atom feed top
2021-05-01 11:54 [PATCH 00/13] test: several fixes and improvements Felipe Contreras
2021-05-01 11:54 ` [PATCH 01/13] test: fix passwd_sanitize() Felipe Contreras
2021-05-01 20:01 ` Tomi Ollila
2021-05-01 11:54 ` [PATCH 02/13] test: unset NAME environment variable Felipe Contreras
2021-05-01 20:01 ` Tomi Ollila
2021-05-01 11:54 ` [PATCH 03/13] test: remove USER_FULL_NAME when not present Felipe Contreras
2021-05-01 20:13 ` Tomi Ollila [this message]
2021-05-01 11:54 ` [PATCH 04/13] test: use correct fqdn in passwd_sanitize() Felipe Contreras
2021-05-01 20:14 ` Tomi Ollila
2021-05-01 11:54 ` [PATCH 05/13] test: fix wrong SKIP messages Felipe Contreras
2021-05-01 20:18 ` Tomi Ollila
2021-05-01 11:54 ` [PATCH 06/13] test: add prereqs check in test_emacs_expect_t Felipe Contreras
2021-05-01 20:18 ` Tomi Ollila
2021-05-01 11:54 ` [PATCH 07/13] test: add external prereqs to many emacs tests Felipe Contreras
2021-05-01 20:19 ` Tomi Ollila
2021-05-01 11:54 ` [PATCH 08/13] test: split emacs functionality to its own file Felipe Contreras
2021-05-01 20:28 ` Tomi Ollila
2021-05-01 11:54 ` [PATCH 09/13] test: emacs: simplify missing dependencies check Felipe Contreras
2021-05-01 20:20 ` Tomi Ollila
2021-05-01 11:54 ` [PATCH 10/13] test: emacs: check for configured emacs Felipe Contreras
2021-05-01 20:20 ` Tomi Ollila
2021-05-01 11:54 ` [PATCH 11/13] test: emacs: fix a couple of shellcheck complaints Felipe Contreras
2021-05-01 20:21 ` Tomi Ollila
2021-05-01 11:54 ` [PATCH 12/13] test: trivial style cleanups Felipe Contreras
2021-05-01 20:28 ` Tomi Ollila
2021-05-01 11:54 ` [PATCH 13/13] test: more style fixes Felipe Contreras
2021-05-01 20:29 ` Tomi Ollila
2021-05-02 0:36 ` [PATCH 00/13] test: several fixes and improvements David Bremner
2021-05-02 5:08 ` Tomi Ollila
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
List information: https://notmuchmail.org/
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=m2h7jm43gc.fsf@guru.guru-group.fi \
--to=tomi.ollila@iki.fi \
--cc=dkg@fifthhorseman.net \
--cc=felipe.contreras@gmail.com \
--cc=notmuch@notmuchmail.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
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).