t4012: Use test_must_fail instead of if-else

Make the code less bulky and easier to read. Also do not overlook failures like e.g. git failing because of unexpected signals. Signed-off-by: Alexander Strasser <eclipse7@gmx.net> Signed-off-by: Junio C Hamano <gitster@pobox.com>

Alexander Strasser committed Jul 16, 2012 at 22:47 UTC c7c0a2503fef1c8746dd4ce074de51fd6b215aa5
1 file changed +2 -14
t/t4012-diff-binary.sh
+2 -14
@@ -66,13 +66,7 @@ test_expect_success 'apply --numstat understands diff --binary format' '
66 test_expect_success 'apply detecting corrupt patch correctly' '
67 git diff >output &&
68 sed -e "s/-CIT/xCIT/" <output >broken &&
69 - if git apply --stat --summary broken 2>detected
70 - then
71 - echo unhappy - should have detected an error
72 - (exit 1)
73 - else
74 - echo happy
75 - fi &&
69 + test_must_fail git apply --stat --summary broken 2>detected &&
70 detected=`cat detected` &&
71 detected=`expr "$detected" : "fatal.*at line \\([0-9]*\\)\$"` &&
72 detected=`sed -ne "${detected}p" broken` &&
@@ -81,13 +75,7 @@ test_expect_success 'apply detecting corrupt patch correctly' '
75
76 test_expect_success 'apply detecting corrupt patch correctly' '
77 git diff --binary | sed -e "s/-CIT/xCIT/" >broken &&
84 - if git apply --stat --summary broken 2>detected
85 - then
86 - echo unhappy - should have detected an error
87 - (exit 1)
88 - else
89 - echo happy
90 - fi &&
78 + test_must_fail git apply --stat --summary broken 2>detected &&
79 detected=`cat detected` &&
80 detected=`expr "$detected" : "fatal.*at line \\([0-9]*\\)\$"` &&
81 detected=`sed -ne "${detected}p" broken` &&