From: Junio C Hamano <gitster@pobox.com>
To: Tanay Abhra <tanayabh@gmail.com>
Cc: git@vger.kernel.org, Ramkumar Ramachandra <artagnon@gmail.com>,
Matthieu Moy <Matthieu.Moy@grenoble-inp.fr>,
Matthieu Moy <Matthieu.Moy@imag.fr>
Subject: Re: [PATCH v9 2/2] test-config: add tests for the config_set API
Date: Tue, 15 Jul 2014 08:57:52 -0700 [thread overview]
Message-ID: <xmqqk37ewr5r.fsf@gitster.dls.corp.google.com> (raw)
In-Reply-To: <1405434571-25459-3-git-send-email-tanayabh@gmail.com> (Tanay Abhra's message of "Tue, 15 Jul 2014 07:29:31 -0700")
Tanay Abhra <tanayabh@gmail.com> writes:
> Expose the `config_set` C API as a set of simple commands in order to
> facilitate testing. Add tests for the `config_set` API as well as for
> `git_config_get_*()` family for the usual config files.
>
> Signed-off-by: Matthieu Moy <Matthieu.Moy@imag.fr>
> Signed-off-by: Tanay Abhra <tanayabh@gmail.com>
> ---
> .gitignore | 1 +
> Makefile | 1 +
> t/t1308-config-set.sh | 212 ++++++++++++++++++++++++++++++++++++++++++++++++++
> test-config.c | 140 +++++++++++++++++++++++++++++++++
> 4 files changed, 354 insertions(+)
> create mode 100755 t/t1308-config-set.sh
> create mode 100644 test-config.c
>
> diff --git a/.gitignore b/.gitignore
> index 42294e5..7677533 100644
> --- a/.gitignore
> +++ b/.gitignore
> @@ -177,6 +177,7 @@
> /gitweb/static/gitweb.min.*
> /test-chmtime
> /test-ctype
> +/test-config
> /test-date
> /test-delta
> /test-dump-cache-tree
> diff --git a/Makefile b/Makefile
> index b92418d..e070eb8 100644
> --- a/Makefile
> +++ b/Makefile
> @@ -549,6 +549,7 @@ PROGRAMS += $(patsubst %.o,git-%$X,$(PROGRAM_OBJS))
>
> TEST_PROGRAMS_NEED_X += test-chmtime
> TEST_PROGRAMS_NEED_X += test-ctype
> +TEST_PROGRAMS_NEED_X += test-config
> TEST_PROGRAMS_NEED_X += test-date
> TEST_PROGRAMS_NEED_X += test-delta
> TEST_PROGRAMS_NEED_X += test-dump-cache-tree
> diff --git a/t/t1308-config-set.sh b/t/t1308-config-set.sh
> new file mode 100755
> index 0000000..94085eb
> --- /dev/null
> +++ b/t/t1308-config-set.sh
> @@ -0,0 +1,212 @@
> +#!/bin/sh
> +
> +test_description='Test git config-set API in different settings'
> +
> +. ./test-lib.sh
> +
> +# 'check_config get_* section.key value' verifies that the entry for
> +# section.key is 'value'
> +check_config () {
> + case "$1" in
> + expect_code)
> + if [ "$#" -lt 5 ];
> + then
Spell out "test" and drop unnecessary semicolon, i.e.
if test $# -lt 5
then
> + >expect
> + else
> + printf "%s\n" "$5" >expect
The other "expecting success" side of this function allows to expect
more than one line of output, but this one only allows you to expect
at most one line? Why?
> + fi &&
> + test_expect_code "$2" test-config "$3" "$4" >actual
> + ;;
> + *)
> + op=$1 key=$2 &&
> + shift &&
> + shift &&
> + printf "%s\n" "$@" >expect &&
> + test-config "$op" "$key" >actual
> + ;;
> + esac &&
> + test_cmp expect actual
Perhaps you meant to say something like this instead?
if test "$1" = expect_code
then
expect_code="$2" && shift && shift
else
expect_code=0
fi &&
op=$1 key=$2 && shift && shift
if test $# != 0
then
printf "%s\n" "$@"
fi >expect &&
test_expect_code $expet_code test-config "$op" "$key" >actual &&
test_cmp expect actual
I dunno.
> +test_expect_success 'setup default config' '
> + cat >.git/config <<\EOF
So the default .git/config that was prepared by "git init" is
discarded and replaced with this? Shouldn't it be
cat >>.git/config <<\EOF
instead?
> +test_expect_success 'find multiple values' '
> + cat >expect <<-\EOF &&
> + sam
> + bat
> + hask
> + EOF
> + test-config get_value_multi "case.baz">actual &&
> + test_cmp expect actual
> +'
Hmmm, wasn't the whole point of the helper to allow us to make
things like the above into a one-liner, perhaps like this?
check_config get_value_multi case.baz sam bat hask
I suspect the same applies to most if not all uses of test-config
in the remainder of this patch.
next prev parent reply other threads:[~2014-07-15 15:58 UTC|newest]
Thread overview: 26+ messages / expand[flat|nested] mbox.gz Atom feed top
2014-07-15 14:29 [PATCH v9 0/3] git config cache & special querying api utilizing the cache Tanay Abhra
2014-07-15 14:29 ` [PATCH v9 1/2] add `config_set` API for caching config-like files Tanay Abhra
2014-07-15 15:46 ` Junio C Hamano
2014-07-15 16:22 ` Tanay Abhra
2014-07-16 11:41 ` [PATCH v9r1 " Tanay Abhra
2014-07-15 14:29 ` [PATCH v9 2/2] test-config: add tests for the config_set API Tanay Abhra
2014-07-15 15:57 ` Junio C Hamano [this message]
2014-07-15 17:07 ` Tanay Abhra
2014-07-15 18:26 ` Junio C Hamano
2014-07-16 11:44 ` [PATCH v9r1 " Tanay Abhra
2014-07-16 11:49 ` Matthieu Moy
2014-07-16 12:22 ` [PATCH v9r2 1/2] add `config_set` API for caching config-like files Tanay Abhra
2014-07-16 16:06 ` Matthieu Moy
2014-07-16 16:09 ` [PATCH 1/3] fixup for patch 2: minor style fix Matthieu Moy
2014-07-16 16:09 ` [PATCH 2/3] fixup for patch 2: actually check the return value Matthieu Moy
2014-07-16 16:55 ` Tanay Abhra
2014-07-16 17:10 ` Matthieu Moy
2014-07-16 16:09 ` [PATCH 3/3] fixup for patch 1: typo Matthieu Moy
2014-07-16 16:44 ` [PATCH v9r2 1/2] add `config_set` API for caching config-like files Tanay Abhra
2014-07-16 17:06 ` Matthieu Moy
[not found] ` <53C6C2BD.3030703@gmail.com>
2014-07-17 10:01 ` Matthieu Moy
2014-07-17 11:06 ` Tanay Abhra
2014-07-17 11:34 ` Matthieu Moy
2014-07-17 11:13 ` Matthieu Moy
2014-07-17 17:12 ` Junio C Hamano
2014-07-16 12:22 ` [PATCH v9r2 2/2] test-config: add tests for the config_set API Tanay Abhra
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
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=xmqqk37ewr5r.fsf@gitster.dls.corp.google.com \
--to=gitster@pobox.com \
--cc=Matthieu.Moy@grenoble-inp.fr \
--cc=Matthieu.Moy@imag.fr \
--cc=artagnon@gmail.com \
--cc=git@vger.kernel.org \
--cc=tanayabh@gmail.com \
/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.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.