Re: [PATCH 04/11] t4032: make test "set -e" clean
On Tue, Mar 24, 2026 at 11:21:07PM -0700, Junio C Hamano wrote:
Show 13 quoted lines
> diff --git a/t/t4032-diff-inter-hunk-context.sh b/t/t4032-diff-inter-hunk-context.sh
> index bada0cbd32..efcd863126 100755
> --- a/t/t4032-diff-inter-hunk-context.sh
> +++ b/t/t4032-diff-inter-hunk-context.sh
> @@ -40,7 +40,7 @@ t() {
> test $(git $cmd $file | grep '^@@ ' | wc -l) = $hunks
> "
>
> - test -f $expected &&
> + test ! -f $expected ||
> test_expect_success "$label: check output" "
> git $cmd $file | grep -v '^index ' >actual &&
> test_cmp $expected actualI fixed this by applying this change:
@@ -40,11 +40,13 @@ t() {
test $(git $cmd $file | grep '^@@ ' | wc -l) = $hunks
"
- test -f $expected &&
- test_expect_success "$label: check output" "
- git $cmd $file | grep -v '^index ' >actual &&
- test_cmp $expected actual
- "
+ if test -f $expected
+ then
+ test_expect_success "$label: check output" "
+ git $cmd $file | grep -v '^index ' >actual &&
+ test_cmp $expected actual
+ "
+ fi
}
More churn, but the intent is easier to reason about, if you ask me.
Patrick