Skip to content

Commit ddeaf7e

Browse files
szedergitster
authored andcommitted
t4254: modernize tests
- Don't start tests with 'test $? = 0' to catch preparation done outside the test_expect_success block. - Move writing the bogus patch and the expected output into the appropriate test_expect_success blocks. - Use the test_must_fail helper instead of manually checking for non-zero exit code. - Use the debug-friendly test_path_is_file helper instead of 'test -f'. - No space after '>'. Signed-off-by: SZEDER Gábor <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent 3991e91 commit ddeaf7e

File tree

1 file changed

+15
-21
lines changed

1 file changed

+15
-21
lines changed

t/t4254-am-corrupt.sh

Lines changed: 15 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -3,20 +3,19 @@
33
test_description='git am with corrupt input'
44
. ./test-lib.sh
55

6-
# Note the missing "+++" line:
7-
cat > bad-patch.diff <<'EOF'
8-
From: A U Thor <[email protected]>
9-
diff --git a/f b/f
10-
index 7898192..6178079 100644
11-
--- a/f
12-
@@ -1 +1 @@
13-
-a
14-
+b
15-
EOF
16-
176
test_expect_success setup '
18-
test $? = 0 &&
19-
echo a > f &&
7+
# Note the missing "+++" line:
8+
cat >bad-patch.diff <<-\EOF &&
9+
From: A U Thor <[email protected]>
10+
diff --git a/f b/f
11+
index 7898192..6178079 100644
12+
--- a/f
13+
@@ -1 +1 @@
14+
-a
15+
+b
16+
EOF
17+
18+
echo a >f &&
2019
git add f &&
2120
test_tick &&
2221
git commit -m initial
@@ -26,17 +25,12 @@ test_expect_success setup '
2625
# fatal: unable to write file '(null)' mode 100644: Bad address
2726
# Also, it had the unwanted side-effect of deleting f.
2827
test_expect_success 'try to apply corrupted patch' '
29-
git am bad-patch.diff 2> actual
30-
test $? = 1
28+
test_must_fail git am bad-patch.diff 2>actual
3129
'
3230

33-
cat > expected <<EOF
34-
fatal: git diff header lacks filename information (line 4)
35-
EOF
36-
3731
test_expect_success 'compare diagnostic; ensure file is still here' '
38-
test $? = 0 &&
39-
test -f f &&
32+
echo "fatal: git diff header lacks filename information (line 4)" >expected &&
33+
test_path_is_file f &&
4034
test_cmp expected actual
4135
'
4236

0 commit comments

Comments
 (0)