t5100-mailinfo: replace common path prefix with variable
Many tests need to store data in a file, and repeat the same pattern to refer to that path: "$TEST_DIRECTORY"/t5100/ Create a variable that contains this path, and use that instead. While we're making this change, make sure the quotes are not just around the variable, but around the entire string to not give the impression we want shell splitting to affect the other variables. Signed-off-by: Kevin Daudt <me@ikke.info> Signed-off-by: Junio C Hamano <gitster@pobox.com>
Kevin Daudt committed
Sep 28, 2016 at 21:52 UTC
ee4d679f579b957a997830cbcd65741d9428d732
1 file changed
+35
-33
t/t5100-mailinfo.sh
+35
-33
@@ -7,8 +7,10 @@ test_description='git mailinfo and git mailsplit test'
7
8
. ./test-lib.sh
9
10
+DATA="$TEST_DIRECTORY/t5100"
11
+
12
test_expect_success 'split sample box' \
11
- 'git mailsplit -o. "$TEST_DIRECTORY"/t5100/sample.mbox >last &&
13
+ 'git mailsplit -o. "$DATA/sample.mbox" >last &&
14
last=$(cat last) &&
15
echo total is $last &&
16
test $(cat last) = 17'
@@ -16,28 +18,28 @@ test_expect_success 'split sample box' \
18
check_mailinfo () {
19
mail=$1 opt=$2
20
mo="$mail$opt"
19
- git mailinfo -u $opt msg$mo patch$mo <$mail >info$mo &&
20
- test_cmp "$TEST_DIRECTORY"/t5100/msg$mo msg$mo &&
21
- test_cmp "$TEST_DIRECTORY"/t5100/patch$mo patch$mo &&
22
- test_cmp "$TEST_DIRECTORY"/t5100/info$mo info$mo
21
+ git mailinfo -u $opt "msg$mo" "patch$mo" <"$mail" >"info$mo" &&
22
+ test_cmp "$DATA/msg$mo" "msg$mo" &&
23
+ test_cmp "$DATA/patch$mo" "patch$mo" &&
24
+ test_cmp "$DATA/info$mo" "info$mo"
25
}
26
27
28
for mail in 00*
29
do
30
test_expect_success "mailinfo $mail" '
29
- check_mailinfo $mail "" &&
30
- if test -f "$TEST_DIRECTORY"/t5100/msg$mail--scissors
31
+ check_mailinfo "$mail" "" &&
32
+ if test -f "$DATA/msg$mail--scissors"
33
then
32
- check_mailinfo $mail --scissors
34
+ check_mailinfo "$mail" --scissors
35
fi &&
34
- if test -f "$TEST_DIRECTORY"/t5100/msg$mail--no-inbody-headers
36
+ if test -f "$DATA/msg$mail--no-inbody-headers"
37
then
36
- check_mailinfo $mail --no-inbody-headers
38
+ check_mailinfo "$mail" --no-inbody-headers
39
fi &&
38
- if test -f "$TEST_DIRECTORY"/t5100/msg$mail--message-id
40
+ if test -f "$DATA/msg$mail--message-id"
41
then
40
- check_mailinfo $mail --message-id
42
+ check_mailinfo "$mail" --message-id
43
fi
44
'
45
done
@@ -45,7 +47,7 @@ done
47
48
test_expect_success 'split box with rfc2047 samples' \
49
'mkdir rfc2047 &&
48
- git mailsplit -orfc2047 "$TEST_DIRECTORY"/t5100/rfc2047-samples.mbox \
50
+ git mailsplit -orfc2047 "$DATA/rfc2047-samples.mbox" \
51
>rfc2047/last &&
52
last=$(cat rfc2047/last) &&
53
echo total is $last &&
@@ -54,20 +56,20 @@ test_expect_success 'split box with rfc2047 samples' \
56
for mail in rfc2047/00*
57
do
58
test_expect_success "mailinfo $mail" '
57
- git mailinfo -u $mail-msg $mail-patch <$mail >$mail-info &&
59
+ git mailinfo -u "$mail-msg" "$mail-patch" <"$mail" >"$mail-info" &&
60
echo msg &&
59
- test_cmp "$TEST_DIRECTORY"/t5100/empty $mail-msg &&
61
+ test_cmp "$DATA/empty" "$mail-msg" &&
62
echo patch &&
61
- test_cmp "$TEST_DIRECTORY"/t5100/empty $mail-patch &&
63
+ test_cmp "$DATA/empty" "$mail-patch" &&
64
echo info &&
63
- test_cmp "$TEST_DIRECTORY"/t5100/rfc2047-info-$(basename $mail) $mail-info
65
+ test_cmp "$DATA/rfc2047-info-$(basename $mail)" "$mail-info"
66
'
67
done
68
69
test_expect_success 'respect NULs' '
70
69
- git mailsplit -d3 -o. "$TEST_DIRECTORY"/t5100/nul-plain &&
70
- test_cmp "$TEST_DIRECTORY"/t5100/nul-plain 001 &&
71
+ git mailsplit -d3 -o. "$DATA/nul-plain" &&
72
+ test_cmp "$DATA/nul-plain" 001 &&
73
(cat 001 | git mailinfo msg patch) &&
74
test_line_count = 4 patch
75
@@ -75,52 +77,52 @@ test_expect_success 'respect NULs' '
77
78
test_expect_success 'Preserve NULs out of MIME encoded message' '
79
78
- git mailsplit -d5 -o. "$TEST_DIRECTORY"/t5100/nul-b64.in &&
79
- test_cmp "$TEST_DIRECTORY"/t5100/nul-b64.in 00001 &&
80
+ git mailsplit -d5 -o. "$DATA/nul-b64.in" &&
81
+ test_cmp "$DATA/nul-b64.in" 00001 &&
82
git mailinfo msg patch <00001 &&
81
- test_cmp "$TEST_DIRECTORY"/t5100/nul-b64.expect patch
83
+ test_cmp "$DATA/nul-b64.expect" patch
84
85
'
86
87
test_expect_success 'mailinfo on from header without name works' '
88
89
mkdir info-from &&
88
- git mailsplit -oinfo-from "$TEST_DIRECTORY"/t5100/info-from.in &&
89
- test_cmp "$TEST_DIRECTORY"/t5100/info-from.in info-from/0001 &&
90
+ git mailsplit -oinfo-from "$DATA/info-from.in" &&
91
+ test_cmp "$DATA/info-from.in" info-from/0001 &&
92
git mailinfo info-from/msg info-from/patch \
93
<info-from/0001 >info-from/out &&
92
- test_cmp "$TEST_DIRECTORY"/t5100/info-from.expect info-from/out
94
+ test_cmp "$DATA/info-from.expect" info-from/out
95
96
'
97
98
test_expect_success 'mailinfo finds headers after embedded From line' '
99
mkdir embed-from &&
98
- git mailsplit -oembed-from "$TEST_DIRECTORY"/t5100/embed-from.in &&
99
- test_cmp "$TEST_DIRECTORY"/t5100/embed-from.in embed-from/0001 &&
100
+ git mailsplit -oembed-from "$DATA/embed-from.in" &&
101
+ test_cmp "$DATA/embed-from.in" embed-from/0001 &&
102
git mailinfo embed-from/msg embed-from/patch \
103
<embed-from/0001 >embed-from/out &&
102
- test_cmp "$TEST_DIRECTORY"/t5100/embed-from.expect embed-from/out
104
+ test_cmp "$DATA/embed-from.expect" embed-from/out
105
'
106
107
test_expect_success 'mailinfo on message with quoted >From' '
108
mkdir quoted-from &&
107
- git mailsplit -oquoted-from "$TEST_DIRECTORY"/t5100/quoted-from.in &&
108
- test_cmp "$TEST_DIRECTORY"/t5100/quoted-from.in quoted-from/0001 &&
109
+ git mailsplit -oquoted-from "$DATA/quoted-from.in" &&
110
+ test_cmp "$DATA/quoted-from.in" quoted-from/0001 &&
111
git mailinfo quoted-from/msg quoted-from/patch \
112
<quoted-from/0001 >quoted-from/out &&
111
- test_cmp "$TEST_DIRECTORY"/t5100/quoted-from.expect quoted-from/msg
113
+ test_cmp "$DATA/quoted-from.expect" quoted-from/msg
114
'
115
116
test_expect_success 'mailinfo unescapes with --mboxrd' '
117
mkdir mboxrd &&
118
git mailsplit -omboxrd --mboxrd \
117
- "$TEST_DIRECTORY"/t5100/sample.mboxrd >last &&
119
+ "$DATA/sample.mboxrd" >last &&
120
test x"$(cat last)" = x2 &&
121
for i in 0001 0002
122
do
123
git mailinfo mboxrd/msg mboxrd/patch \
124
<mboxrd/$i >mboxrd/out &&
123
- test_cmp "$TEST_DIRECTORY"/t5100/${i}mboxrd mboxrd/msg
125
+ test_cmp "$DATA/${i}mboxrd" mboxrd/msg
126
done &&
127
sp=" " &&
128
echo "From " >expect &&