git@vger.kernel.org mailing list mirror (one of many)
 help / color / mirror / code / Atom feed
From: Andrei Rybak <rybak.a.v@gmail.com>
To: git@vger.kernel.org
Subject: Re: [PATCH v1 2/2] t1300: check stderr for "ignores pairs" tests
Date: Fri, 14 Apr 2023 15:28:17 +0200	[thread overview]
Message-ID: <CACayv=jL4t3cUVS=xXQ3fLxF26vDXRJ3khs2y4UjzBw947JVkw@mail.gmail.com> (raw)
In-Reply-To: <20230414081352.810296-3-rybak.a.v@gmail.com>

On Fri, 14 Apr 2023 at 10:13, Andrei Rybak <rybak.a.v@gmail.com> wrote:
>
> Tests "git config ignores pairs ..." in t1300-config.sh validate that
> "git config" ignores with various kinds of supplied pairs of environment
> variables GIT_CONFIG_KEY_* GIT_CONFIG_VALUE_* that should be ingored.
> By "ignores" here we mean that "git config" doesn't complain about them
> to standard error.

After thinking about this some more, I've realized that this is an
incorrect interpretation
of the titles of these tests. The correct interpretation is more
obvious from another test:

    test_expect_success 'git config ignores pairs exceeding count' '
           GIT_CONFIG_COUNT=1 \
                  GIT_CONFIG_KEY_0="pair.one" GIT_CONFIG_VALUE_0="value" \
                  GIT_CONFIG_KEY_1="pair.two" GIT_CONFIG_VALUE_1="value" \
                  git config --get-regexp "pair.*" >actual &&
           cat >expect <<-EOF &&
           pair.one value
           EOF
           test_cmp expect actual
    '

Key-value pair "pair.two=value" is ignored because it's outside of the
range of the
supplied value of GIT_CONFIG_COUNT.  That is, these tests validate that reading
of these environment variables reads GIT_CONFIG_COUNT first and only loads
GIT_CONFIG_KEY_<n> and GIT_CONFIG_VALUE_<n> that fit in the range.

> This is validated by redirecting the standard error
> to a file called "error" and asserting that it is empty.  However, two
> of these tests incorrectly redirect to standard output while calling the
> file "error", and test 'git config ignores pairs exceeding count'
> doesn't validate standard error at all.
>
> Fix it by redirecting standard error to file "error" and asserting its
> emptiness.
>
> Signed-off-by: Andrei Rybak <rybak.a.v@gmail.com>
> ---
>  t/t1300-config.sh | 9 +++++----
>  1 file changed, 5 insertions(+), 4 deletions(-)
>
> diff --git a/t/t1300-config.sh b/t/t1300-config.sh
> index 696dca17c6..20a15ede5c 100755
> --- a/t/t1300-config.sh
> +++ b/t/t1300-config.sh
> @@ -1462,24 +1462,25 @@ test_expect_success 'git config ignores pairs exceeding count' '
>         GIT_CONFIG_COUNT=1 \
>                 GIT_CONFIG_KEY_0="pair.one" GIT_CONFIG_VALUE_0="value" \
>                 GIT_CONFIG_KEY_1="pair.two" GIT_CONFIG_VALUE_1="value" \
> -               git config --get-regexp "pair.*" >actual &&
> +               git config --get-regexp "pair.*" >actual 2>error &&
>         cat >expect <<-EOF &&
>         pair.one value
>         EOF
> -       test_cmp expect actual
> +       test_cmp expect actual &&
> +       test_must_be_empty error
>  '
>
>  test_expect_success 'git config ignores pairs with zero count' '
>         test_must_fail env \
>                 GIT_CONFIG_COUNT=0 GIT_CONFIG_KEY_0="pair.one" GIT_CONFIG_VALUE_0="value" \
> -               git config pair.one >error &&
> +               git config pair.one 2>error &&
>         test_must_be_empty error
>  '
>
>  test_expect_success 'git config ignores pairs with empty count' '
>         test_must_fail env \
>                 GIT_CONFIG_COUNT= GIT_CONFIG_KEY_0="pair.one" GIT_CONFIG_VALUE_0="value" \
> -               git config pair.one >error &&
> +               git config pair.one 2>error &&


Same question as in Ævar's
https://lore.kernel.org/git/230406.86pm8htnfk.gmgdl@evledraar.gmail.com/
and my reply https://lore.kernel.org/git/c43e6b71-075a-e39a-7351-8595e145dacf@gmail.com/
applies here, though.  In tests 'git config ignores pairs with zero count' and
 'git config ignores pairs with empty count' test_must_fail already asserts that
"git config" couldn't get the value.  Should we be also inspecting
both stdout and
stderr, as the test  'git config ignores pairs exceeding count' does
(after this patch)?

>         test_must_be_empty error
>  '

>
> --
> 2.40.0
>

  reply	other threads:[~2023-04-14 13:28 UTC|newest]

Thread overview: 58+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-04-01 21:28 [PATCH v1 0/6] t: fix unused files, part 2 Andrei Rybak
2023-04-01 21:28 ` [PATCH v1 1/6] t0300: don't create unused file Andrei Rybak
2023-04-02  1:30   ` Eric Sunshine
2023-04-01 21:28 ` [PATCH v1 2/6] t1300: fix config file syntax error descriptions Andrei Rybak
2023-04-01 21:28 ` [PATCH v1 3/6] t1300: don't create unused files Andrei Rybak
2023-04-01 21:28 ` [PATCH v1 4/6] t1450: " Andrei Rybak
2023-04-01 21:28 ` [PATCH v1 5/6] t1502: " Andrei Rybak
2023-04-01 21:28 ` [PATCH v1 6/6] t2019: " Andrei Rybak
2023-04-03 22:33 ` [PATCH v2 0/6] t: fix unused files, part 2 Andrei Rybak
2023-04-03 22:33   ` [PATCH v2 1/6] t0300: don't create unused file Andrei Rybak
2023-04-06  8:34     ` Ævar Arnfjörð Bjarmason
2023-04-06 21:01       ` Andrei Rybak
2023-04-03 22:33   ` [PATCH v2 2/6] t1300: fix config file syntax error descriptions Andrei Rybak
2023-04-03 22:33   ` [PATCH v2 3/6] t1300: don't create unused files Andrei Rybak
2023-04-06  8:38     ` Ævar Arnfjörð Bjarmason
2023-04-06 21:30       ` Andrei Rybak
2023-04-06 21:35         ` git config tests for "'git config ignores pairs ..." (was Re: [PATCH v2 3/6] t1300: don't create unused files) Andrei Rybak
2023-04-14  8:13           ` [PATCH v1 0/2] git config tests for "'git config ignores pairs ..." Andrei Rybak
2023-04-14  8:13             ` [PATCH v1 1/2] t1300: drop duplicate test Andrei Rybak
2023-04-14  8:13             ` [PATCH v1 2/2] t1300: check stderr for "ignores pairs" tests Andrei Rybak
2023-04-14 13:28               ` Andrei Rybak [this message]
2023-04-18 17:50             ` [PATCH v2 0/3] git config tests for "'git config ignores pairs ..." Andrei Rybak
2023-04-18 17:50               ` [PATCH v2 1/3] t1300: drop duplicate test Andrei Rybak
2023-04-18 18:37                 ` Junio C Hamano
2023-04-18 17:50               ` [PATCH v2 2/3] t1300: check stderr for "ignores pairs" tests Andrei Rybak
2023-04-18 18:39                 ` Junio C Hamano
2023-04-18 17:50               ` [RFC PATCH v2 3/3] t1300: add tests for missing keys Andrei Rybak
2023-04-18 19:31                 ` Junio C Hamano
2023-04-18 17:53               ` [PATCH v2 0/3] git config tests for "'git config ignores pairs ..." Andrei Rybak
2023-04-23 13:46               ` [PATCH v3 " Andrei Rybak
2023-04-23 13:46                 ` [PATCH v3 1/3] t1300: drop duplicate test Andrei Rybak
2023-04-23 13:46                 ` [PATCH v3 2/3] t1300: check stderr for "ignores pairs" tests Andrei Rybak
2023-04-23 13:46                 ` [PATCH v3 3/3] t1300: add tests for missing keys Andrei Rybak
2023-05-01 22:02                 ` [PATCH v3 0/3] git config tests for "'git config ignores pairs ..." Junio C Hamano
2023-05-02 19:58                   ` Andrei Rybak
2023-04-03 22:33   ` [PATCH v2 4/6] t1450: don't create unused files Andrei Rybak
2023-04-06  8:41     ` Ævar Arnfjörð Bjarmason
2023-04-06 22:19       ` Andrei Rybak
2023-04-03 22:33   ` [PATCH v2 5/6] t1502: " Andrei Rybak
2023-04-06  8:15     ` Øystein Walle
2023-04-06  8:47     ` Ævar Arnfjörð Bjarmason
2023-04-06 19:51       ` Andrei Rybak
2023-04-03 22:33   ` [PATCH v2 6/6] t2019: " Andrei Rybak
2023-04-06  8:44     ` Ævar Arnfjörð Bjarmason
2023-04-07  2:19       ` Andrei Rybak
2023-04-08 20:54       ` [PATCH] t2024: fix loose/strict local base branch DWIM test Andrei Rybak
2023-04-10 17:37         ` Junio C Hamano
2023-04-17 19:10   ` [PATCH v3 0/6] t: fix unused files, part 2 Andrei Rybak
2023-04-17 19:10     ` [PATCH v3 1/6] t0300: don't create unused file Andrei Rybak
2023-04-17 19:10     ` [PATCH v3 2/6] t1300: fix config file syntax error descriptions Andrei Rybak
2023-04-17 19:10     ` [PATCH v3 3/6] t1300: don't create unused files Andrei Rybak
2023-04-17 19:10     ` [PATCH v3 4/6] t1450: " Andrei Rybak
2023-04-17 19:10     ` [PATCH v3 5/6] t1502: " Andrei Rybak
2023-04-17 19:10     ` [PATCH v3 6/6] t2019: " Andrei Rybak
2023-05-01 21:52     ` [PATCH v3 0/6] t: fix unused files, part 2 Junio C Hamano
2023-05-02 21:03       ` Andrei Rybak
2023-05-03  4:11       ` Elijah Newren
2023-05-03 15:54         ` Junio C Hamano

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: http://vger.kernel.org/majordomo-info.html

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to='CACayv=jL4t3cUVS=xXQ3fLxF26vDXRJ3khs2y4UjzBw947JVkw@mail.gmail.com' \
    --to=rybak.a.v@gmail.com \
    --cc=git@vger.kernel.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://80x24.org/mirrors/git.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).