Re: [PATCH v3 14/35] userdiff tests: add alternative hunk header test infrastructure
- From
Johannes Sixt <j6t@kdbg.org>
- Date
- Feb 28, 2021, 11:12 UTC
- Message-ID
- <d3ee44f3-e7d7-e9a9-8fde-1bd48323c150@kdbg.org>
- In-Reply-To
- <20210224195129.4004-15-avarab@gmail.com>
Am 24.02.21 um 20:51 schrieb Ævar Arnfjörð Bjarmason:
Show 29 quoted lines
> diff --git a/t/t4018-diff-funcname.sh b/t/t4018-diff-funcname.sh
> index 8a8a7a99c88..6fd3dce1364 100755
> --- a/t/t4018-diff-funcname.sh
> +++ b/t/t4018-diff-funcname.sh
> @@ -87,7 +87,7 @@ last_diff_context_line () {
> }
>
> # check each individual file
> -for i in $(git -C t4018 ls-files)
> +for i in $(git -C t4018 ls-files -- ':!*.sh')
> do
> test_expect_success "setup hunk header: $i" "
> grep -v '^t4018' \"t4018/$i\" >\"t4018/$i.content\" &&
> @@ -106,4 +106,40 @@ do
> "
> done
>
> +test_diff_funcname () {
> + desc=$1
> + cat <&8 >arg.header &&
> + cat <&9 >arg.test &&
> + what=$(cat arg.what) &&
> +
> + test_expect_success "setup: $desc" '
> + cp arg.test "$what" &&
> + cp arg.header expected &&
> + git add "$what" &&
> + do_change_me "$what"
> + ' &&I think we should not chain test_expect_success with && because when one of the tests early in the chain fails, test case numbers are shifted compared to when all tests succeed. I don't know, though, whether that is an important thing (or a thing at all).
Show 20 quoted lines
> + > + test_expect_success "$desc" ' > + git diff -U1 "$what" >diff && > + last_diff_context_line diff >actual && > + test_cmp expected actual > + ' > +} > + > +for what in $diffpatterns > +do > + test="$TEST_DIRECTORY/t4018/$what.sh" > + if ! test -e "$test" > + then > + continue > + fi && > + > + test_expect_success "setup: hunk header for $what" ' > + echo "$what diff=$what" >.gitattributes && > + echo "$what" >arg.what > + ' &&
Same here. And when this is removed, the && just above is not needed anymore, either.
Show 5 quoted lines
> + > + . "$test" > +done > + > test_done
-- Hannes