Re: [PATCH v4 02/10] t5526: stop asserting on stderr literally
- From
Junio C Hamano <gitster@pobox.com>
- Date
- Mar 4, 2022, 02:12 UTC
- Message-ID
- <xmqq8rtq5uue.fsf@gitster.g>
- In-Reply-To
- <20220304005757.70107-3-chooglen@google.com>
Glen Choo <chooglen@google.com> writes:
Show 32 quoted lines
> In the previous commit message, we noted that not all of the "git fetch"
> stderr is relevant to the tests. Most of the test setup lines are
> dedicated to these details of the stderr:
>
> 1. which repos (super/sub/deep) are involved in the fetch
> 2. the head of the remote-tracking branch before the fetch (i.e. $head1)
> 3. the head of the remote-tracking branch after the fetch (i.e. $head2)
>
> 1. and 3. are relevant because they tell us that the expected commit is
> fetched by the expected repo, but 2. is completely irrelevant.
>
> Stop asserting on $head1 by replacing it with a dummy value in the
> actual and expected output. Do this by introducing test
> helpers (check_*()) that make it easier to construct the expected
> output, and use sed to munge the actual output.
>
> Signed-off-by: Glen Choo <chooglen@google.com>
> ---
> t/t5526-fetch-submodules.sh | 119 +++++++++++++++++-------------------
> 1 file changed, 57 insertions(+), 62 deletions(-)
>
> diff --git a/t/t5526-fetch-submodules.sh b/t/t5526-fetch-submodules.sh
> index dff7a4b90b..6b24d37b2b 100755
> --- a/t/t5526-fetch-submodules.sh
> +++ b/t/t5526-fetch-submodules.sh
> @@ -10,6 +10,32 @@ export GIT_TEST_FATAL_REGISTER_SUBMODULE_ODB
>
> pwd=$(pwd)
>
> +check_sub () {
> + NEW_HEAD=$1 &&
> + cat >$pwd/expect.err.sub <<-EOFStyle.
cat >"$pwd/expect.err.sub" <<-EOF
Here, $pwd most likely has an $IFS letter in it (because we deliberately use "trash directory.xxxx" as the place to run our tests in) but a redirection target does not go through $IFS word splitting, so such a quoting is not technically necessary, but some versions of bash are known to throw a warning if we don't, and an extra quoting does not hurt.
> +check_deep () {
> + NEW_HEAD=$1 &&
> + cat >$pwd/expect.err.deep <<-EOFLikewise.
Show 9 quoted lines
> + Fetching submodule submodule/subdir/deepsubmodule
> + From $pwd/deepsubmodule
> + OLD_HEAD..$NEW_HEAD deep -> origin/deep
> + EOF
> +}
> +
> +check_super () {
> + NEW_HEAD=$1 &&
> + cat >$pwd/expect.err.super <<-EOFLikewise.
> + From $pwd/. > + OLD_HEAD..$NEW_HEAD super -> origin/super > + EOF > +}