Skip to content

Commit c76b84a

Browse files
Martin Ågrengitster
authored andcommitted
t: don't spuriously close and reopen quotes
In the test scripts, the recommended style is, e.g.: test_expect_success 'name' ' do-something somehow && do-some-more testing ' When using this style, any single quote in the multi-line test section is actually closing the lone single quotes that surround it. It can be a non-issue in practice: test_expect_success 'sed a little' ' sed -e 's/hi/lo/' in >out # "ok": no whitespace in s/hi/lo/ ' Or it can be a bug in the test, e.g., because variable interpolation happens before the test even begins executing: v=abc test_expect_success 'variable interpolation' ' v=def && echo '"$v"' # abc ' Change several such in-test single quotes to use double quotes instead or, in a few cases, drop them altogether. These were identified using some crude grepping. We're not fixing any test bugs here, but we're hopefully making these tests slightly easier to grok and to maintain. There are legitimate use cases for closing a quote and opening a new one, e.g., both '\'' and '"'"' can be used to produce a literal single quote. I'm not touching any of those here. In t9401, tuck the redirecting ">" to the filename while we're touching those lines. Signed-off-by: Martin Ågren <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent dc04167 commit c76b84a

17 files changed

+38
-38
lines changed

t/t1400-update-ref.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -324,7 +324,7 @@ test_expect_success "create $m (logged by config)" '
324324
test_expect_success "update $m (logged by config)" '
325325
test_config core.logAllRefUpdates true &&
326326
GIT_COMMITTER_DATE="2005-05-26 23:33" \
327-
git update-ref HEAD'" $B $A "'-m "Switch" &&
327+
git update-ref HEAD $B $A -m "Switch" &&
328328
test $B = $(git show-ref -s --verify $m)
329329
'
330330
test_expect_success "set $m (logged by config)" '

t/t3501-revert-cherry-pick.sh

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ test_expect_success 'cherry-pick --nonsense' '
4747
git diff --exit-code HEAD &&
4848
test_must_fail git cherry-pick --nonsense 2>msg &&
4949
git diff --exit-code HEAD "$pos" &&
50-
test_i18ngrep '[Uu]sage:' msg
50+
test_i18ngrep "[Uu]sage:" msg
5151
'
5252

5353
test_expect_success 'revert --nonsense' '
@@ -56,7 +56,7 @@ test_expect_success 'revert --nonsense' '
5656
git diff --exit-code HEAD &&
5757
test_must_fail git revert --nonsense 2>msg &&
5858
git diff --exit-code HEAD "$pos" &&
59-
test_i18ngrep '[Uu]sage:' msg
59+
test_i18ngrep "[Uu]sage:" msg
6060
'
6161

6262
test_expect_success 'cherry-pick after renaming branch' '

t/t3507-cherry-pick-conflict.sh

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -512,7 +512,7 @@ test_expect_success 'commit after failed cherry-pick adds -s at the right place'
512512
Signed-off-by: C O Mitter <[email protected]>
513513
# Conflicts:
514514
EOF
515-
grep -e "^# Conflicts:" -e '^Signed-off-by' .git/COMMIT_EDITMSG >actual &&
515+
grep -e "^# Conflicts:" -e "^Signed-off-by" .git/COMMIT_EDITMSG >actual &&
516516
test_cmp expect actual &&
517517
518518
cat <<-\EOF >expected &&
@@ -541,7 +541,7 @@ test_expect_success 'commit --amend -s places the sign-off at the right place' '
541541
Signed-off-by: C O Mitter <[email protected]>
542542
Conflicts:
543543
EOF
544-
grep -e "^Conflicts:" -e '^Signed-off-by' .git/COMMIT_EDITMSG >actual &&
544+
grep -e "^Conflicts:" -e "^Signed-off-by" .git/COMMIT_EDITMSG >actual &&
545545
test_cmp expect actual
546546
'
547547

t/t4005-diff-rename-2.sh

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,8 +14,8 @@ test_expect_success 'setup reference tree' '
1414
git update-index --add COPYING rezrov &&
1515
tree=$(git write-tree) &&
1616
echo $tree &&
17-
sed -e 's/HOWEVER/However/' <COPYING >COPYING.1 &&
18-
sed -e 's/GPL/G.P.L/g' <COPYING >COPYING.2 &&
17+
sed -e "s/HOWEVER/However/" <COPYING >COPYING.1 &&
18+
sed -e "s/GPL/G.P.L/g" <COPYING >COPYING.2 &&
1919
origoid=$(git hash-object COPYING) &&
2020
oid1=$(git hash-object COPYING.1) &&
2121
oid2=$(git hash-object COPYING.2)

t/t4034-diff-words.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -102,7 +102,7 @@ test_expect_success 'word diff with runs of whitespace' '
102102
'
103103

104104
test_expect_success '--word-diff=porcelain' '
105-
sed 's/#.*$//' >expect <<-EOF &&
105+
sed "s/#.*$//" >expect <<-EOF &&
106106
diff --git a/pre b/post
107107
index $pre..$post 100644
108108
--- a/pre

t/t4150-am.sh

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -989,7 +989,7 @@ test_expect_success 'am -s unexpected trailer block' '
989989
Signed-off-by: J C H <[email protected]>
990990
EOF
991991
git commit -F msg &&
992-
git cat-file commit HEAD | sed -e '1,/^$/d' >original &&
992+
git cat-file commit HEAD | sed -e "1,/^$/d" >original &&
993993
git format-patch --stdout -1 >patch &&
994994
995995
git reset --hard HEAD^ &&
@@ -998,7 +998,7 @@ test_expect_success 'am -s unexpected trailer block' '
998998
cat original &&
999999
echo "Signed-off-by: $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL>"
10001000
) >expect &&
1001-
git cat-file commit HEAD | sed -e '1,/^$/d' >actual &&
1001+
git cat-file commit HEAD | sed -e "1,/^$/d" >actual &&
10021002
test_cmp expect actual &&
10031003
10041004
cat >msg <<-\EOF &&
@@ -1009,7 +1009,7 @@ test_expect_success 'am -s unexpected trailer block' '
10091009
EOF
10101010
git reset HEAD^ &&
10111011
git commit -F msg file &&
1012-
git cat-file commit HEAD | sed -e '1,/^$/d' >original &&
1012+
git cat-file commit HEAD | sed -e "1,/^$/d" >original &&
10131013
git format-patch --stdout -1 >patch &&
10141014
10151015
git reset --hard HEAD^ &&
@@ -1020,7 +1020,7 @@ test_expect_success 'am -s unexpected trailer block' '
10201020
echo &&
10211021
echo "Signed-off-by: $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL>"
10221022
) >expect &&
1023-
git cat-file commit HEAD | sed -e '1,/^$/d' >actual &&
1023+
git cat-file commit HEAD | sed -e "1,/^$/d" >actual &&
10241024
test_cmp expect actual
10251025
'
10261026

t/t4200-rerere.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -364,7 +364,7 @@ test_expect_success 'set up an unresolved merge' '
364364
git reset --hard &&
365365
git checkout version2 &&
366366
fifth=$(git rev-parse fifth) &&
367-
echo "$fifth branch 'fifth' of ." |
367+
echo "$fifth branch fifth of ." |
368368
git fmt-merge-msg >msg &&
369369
ancestor=$(git merge-base version2 fifth) &&
370370
test_must_fail git merge-recursive "$ancestor" -- HEAD fifth &&

t/t5302-pack-index.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ test_expect_success 'setup' '
1515
i=1 &&
1616
while test $i -le 100
1717
do
18-
iii=$(printf '%03i' $i)
18+
iii=$(printf "%03i" $i)
1919
test-tool genrandom "bar" 200 > wide_delta_$iii &&
2020
test-tool genrandom "baz $iii" 50 >> wide_delta_$iii &&
2121
test-tool genrandom "foo"$i 100 > deep_delta_$iii &&

t/t5510-fetch.sh

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -213,7 +213,7 @@ test_expect_success 'fetch tags when there is no tags' '
213213
test_expect_success 'fetch following tags' '
214214
215215
cd "$D" &&
216-
git tag -a -m 'annotated' anno HEAD &&
216+
git tag -a -m "annotated" anno HEAD &&
217217
git tag light HEAD &&
218218
219219
mkdir four &&
@@ -331,7 +331,7 @@ test_expect_success 'bundle does not prerequisite objects' '
331331
test_expect_success 'bundle should be able to create a full history' '
332332
333333
cd "$D" &&
334-
git tag -a -m '1.0' v1.0 master &&
334+
git tag -a -m "1.0" v1.0 master &&
335335
git bundle create bundle4 v1.0
336336
337337
'

t/t5553-set-upstream.sh

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -81,7 +81,7 @@ test_expect_success 'fetch --set-upstream http://nosuchdomain.example.com fails
8181

8282
test_expect_success 'fetch --set-upstream with valid URL sets upstream to URL' '
8383
clear_config other other2 &&
84-
url="file://'"$PWD"'" &&
84+
url="file://$PWD" &&
8585
git fetch --set-upstream "$url" &&
8686
check_config master "$url" HEAD &&
8787
check_config_missing other &&
@@ -158,7 +158,7 @@ test_expect_success 'pull --set-upstream upstream with more than one branch does
158158
test_expect_success 'pull --set-upstream with valid URL sets upstream to URL' '
159159
clear_config master other other2 &&
160160
git checkout master &&
161-
url="file://'"$PWD"'" &&
161+
url="file://$PWD" &&
162162
git pull --set-upstream "$url" &&
163163
check_config master "$url" HEAD &&
164164
check_config_missing other &&
@@ -168,7 +168,7 @@ test_expect_success 'pull --set-upstream with valid URL sets upstream to URL' '
168168
test_expect_success 'pull --set-upstream with valid URL and branch sets branch' '
169169
clear_config master other other2 &&
170170
git checkout master &&
171-
url="file://'"$PWD"'" &&
171+
url="file://$PWD" &&
172172
git pull --set-upstream "$url" master &&
173173
check_config master "$url" refs/heads/master &&
174174
check_config_missing other &&

0 commit comments

Comments
 (0)