Skip to content

Commit 4626269

Browse files
pks-tgitster
authored andcommitted
t4013: simplify magic parsing and drop "failure"
In t14013, we have various different tests that verify whether certain diffs are generated as expected. As much of the logic is the same across many of the tests we some common code in there that generates the actual test cases for us. As some diffs are more special than others depending on the command line parameters passed to git-diff(1), these tests need to adapt behaviour to the specific test case sometimes. This is done via colon-prefixed magic commands, of which we currently know "failure" and "noellipses". The logic to parse this magic is a bit convoluted though and hard to grasp, also due to the rather unnecessary nesting. Un-nest the cases so that it becomes a bit more straightfoward. The logic is further simplified by removing support for the "failure" magic, which is not actually used anymore. Signed-off-by: Patrick Steinhardt <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent 110feb8 commit 4626269

File tree

1 file changed

+12
-15
lines changed

1 file changed

+12
-15
lines changed

t/t4013-diff-various.sh

Lines changed: 12 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -178,32 +178,29 @@ process_diffs () {
178178
V=$(git version | sed -e 's/^git version //' -e 's/\./\\./g')
179179
while read magic cmd
180180
do
181-
status=success
182181
case "$magic" in
183182
'' | '#'*)
184183
continue ;;
185-
:*)
186-
magic=${magic#:}
184+
:noellipses)
185+
magic=noellipses
187186
label="$magic-$cmd"
188-
case "$magic" in
189-
noellipses) ;;
190-
failure)
191-
status=failure
192-
magic=
193-
label="$cmd" ;;
194-
*)
195-
BUG "unknown magic $magic" ;;
196-
esac ;;
187+
;;
188+
:*)
189+
BUG "unknown magic $magic"
190+
;;
197191
*)
198-
cmd="$magic $cmd" magic=
199-
label="$cmd" ;;
192+
cmd="$magic $cmd"
193+
magic=
194+
label="$cmd"
195+
;;
200196
esac
197+
201198
test=$(echo "$label" | sed -e 's|[/ ][/ ]*|_|g')
202199
pfx=$(printf "%04d" $test_count)
203200
expect="$TEST_DIRECTORY/t4013/diff.$test"
204201
actual="$pfx-diff.$test"
205202

206-
test_expect_$status "git $cmd # magic is ${magic:-(not used)}" '
203+
test_expect_success "git $cmd # magic is ${magic:-(not used)}" '
207204
{
208205
echo "$ git $cmd"
209206
case "$magic" in

0 commit comments

Comments
 (0)