@matheusbsbs / matheus-bagliano / commits / c76b84a121
Fork 0

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 <martin.agren@gmail.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>

Martin Ågren committed Aug 6, 2020 at 22:08 UTC c76b84a12160476fa795831ef3c2236e68c24f36
17 files changed +38 -38
t/t1400-update-ref.sh
+1 -1
@@ -324,7 +324,7 @@ test_expect_success "create $m (logged by config)" '
324 test_expect_success "update $m (logged by config)" '
325 test_config core.logAllRefUpdates true &&
326 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" &&
328 test $B = $(git show-ref -s --verify $m)
329 '
330 test_expect_success "set $m (logged by config)" '
t/t3501-revert-cherry-pick.sh
+2 -2
@@ -47,7 +47,7 @@ test_expect_success 'cherry-pick --nonsense' '
47 git diff --exit-code HEAD &&
48 test_must_fail git cherry-pick --nonsense 2>msg &&
49 git diff --exit-code HEAD "$pos" &&
50 - test_i18ngrep '[Uu]sage:' msg
50 + test_i18ngrep "[Uu]sage:" msg
51 '
52
53 test_expect_success 'revert --nonsense' '
@@ -56,7 +56,7 @@ test_expect_success 'revert --nonsense' '
56 git diff --exit-code HEAD &&
57 test_must_fail git revert --nonsense 2>msg &&
58 git diff --exit-code HEAD "$pos" &&
59 - test_i18ngrep '[Uu]sage:' msg
59 + test_i18ngrep "[Uu]sage:" msg
60 '
61
62 test_expect_success 'cherry-pick after renaming branch' '
t/t3507-cherry-pick-conflict.sh
+2 -2
@@ -512,7 +512,7 @@ test_expect_success 'commit after failed cherry-pick adds -s at the right place'
512 Signed-off-by: C O Mitter <committer@example.com>
513 # Conflicts:
514 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 &&
516 test_cmp expect actual &&
517
518 cat <<-\EOF >expected &&
@@ -541,7 +541,7 @@ test_expect_success 'commit --amend -s places the sign-off at the right place' '
541 Signed-off-by: C O Mitter <committer@example.com>
542 Conflicts:
543 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 &&
545 test_cmp expect actual
546 '
547
t/t4005-diff-rename-2.sh
+2 -2
@@ -14,8 +14,8 @@ test_expect_success 'setup reference tree' '
14 git update-index --add COPYING rezrov &&
15 tree=$(git write-tree) &&
16 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 &&
19 origoid=$(git hash-object COPYING) &&
20 oid1=$(git hash-object COPYING.1) &&
21 oid2=$(git hash-object COPYING.2)
t/t4034-diff-words.sh
+1 -1
@@ -102,7 +102,7 @@ test_expect_success 'word diff with runs of whitespace' '
102 '
103
104 test_expect_success '--word-diff=porcelain' '
105 - sed 's/#.*$//' >expect <<-EOF &&
105 + sed "s/#.*$//" >expect <<-EOF &&
106 diff --git a/pre b/post
107 index $pre..$post 100644
108 --- a/pre
t/t4150-am.sh
+4 -4
@@ -989,7 +989,7 @@ test_expect_success 'am -s unexpected trailer block' '
989 Signed-off-by: J C H <j@c.h>
990 EOF
991 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 &&
993 git format-patch --stdout -1 >patch &&
994
995 git reset --hard HEAD^ &&
@@ -998,7 +998,7 @@ test_expect_success 'am -s unexpected trailer block' '
998 cat original &&
999 echo "Signed-off-by: $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL>"
1000 ) >expect &&
1001 - git cat-file commit HEAD | sed -e '1,/^$/d' >actual &&
1001 + git cat-file commit HEAD | sed -e "1,/^$/d" >actual &&
1002 test_cmp expect actual &&
1003
1004 cat >msg <<-\EOF &&
@@ -1009,7 +1009,7 @@ test_expect_success 'am -s unexpected trailer block' '
1009 EOF
1010 git reset HEAD^ &&
1011 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 &&
1013 git format-patch --stdout -1 >patch &&
1014
1015 git reset --hard HEAD^ &&
@@ -1020,7 +1020,7 @@ test_expect_success 'am -s unexpected trailer block' '
1020 echo &&
1021 echo "Signed-off-by: $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL>"
1022 ) >expect &&
1023 - git cat-file commit HEAD | sed -e '1,/^$/d' >actual &&
1023 + git cat-file commit HEAD | sed -e "1,/^$/d" >actual &&
1024 test_cmp expect actual
1025 '
1026
t/t4200-rerere.sh
+1 -1
@@ -364,7 +364,7 @@ test_expect_success 'set up an unresolved merge' '
364 git reset --hard &&
365 git checkout version2 &&
366 fifth=$(git rev-parse fifth) &&
367 - echo "$fifth branch 'fifth' of ." |
367 + echo "$fifth branch fifth of ." |
368 git fmt-merge-msg >msg &&
369 ancestor=$(git merge-base version2 fifth) &&
370 test_must_fail git merge-recursive "$ancestor" -- HEAD fifth &&
t/t5302-pack-index.sh
+1 -1
@@ -15,7 +15,7 @@ test_expect_success 'setup' '
15 i=1 &&
16 while test $i -le 100
17 do
18 - iii=$(printf '%03i' $i)
18 + iii=$(printf "%03i" $i)
19 test-tool genrandom "bar" 200 > wide_delta_$iii &&
20 test-tool genrandom "baz $iii" 50 >> wide_delta_$iii &&
21 test-tool genrandom "foo"$i 100 > deep_delta_$iii &&
t/t5510-fetch.sh
+2 -2
@@ -213,7 +213,7 @@ test_expect_success 'fetch tags when there is no tags' '
213 test_expect_success 'fetch following tags' '
214
215 cd "$D" &&
216 - git tag -a -m 'annotated' anno HEAD &&
216 + git tag -a -m "annotated" anno HEAD &&
217 git tag light HEAD &&
218
219 mkdir four &&
@@ -331,7 +331,7 @@ test_expect_success 'bundle does not prerequisite objects' '
331 test_expect_success 'bundle should be able to create a full history' '
332
333 cd "$D" &&
334 - git tag -a -m '1.0' v1.0 master &&
334 + git tag -a -m "1.0" v1.0 master &&
335 git bundle create bundle4 v1.0
336
337 '
t/t5553-set-upstream.sh
+3 -3
@@ -81,7 +81,7 @@ test_expect_success 'fetch --set-upstream http://nosuchdomain.example.com fails
81
82 test_expect_success 'fetch --set-upstream with valid URL sets upstream to URL' '
83 clear_config other other2 &&
84 - url="file://'"$PWD"'" &&
84 + url="file://$PWD" &&
85 git fetch --set-upstream "$url" &&
86 check_config master "$url" HEAD &&
87 check_config_missing other &&
@@ -158,7 +158,7 @@ test_expect_success 'pull --set-upstream upstream with more than one branch does
158 test_expect_success 'pull --set-upstream with valid URL sets upstream to URL' '
159 clear_config master other other2 &&
160 git checkout master &&
161 - url="file://'"$PWD"'" &&
161 + url="file://$PWD" &&
162 git pull --set-upstream "$url" &&
163 check_config master "$url" HEAD &&
164 check_config_missing other &&
@@ -168,7 +168,7 @@ test_expect_success 'pull --set-upstream with valid URL sets upstream to URL' '
168 test_expect_success 'pull --set-upstream with valid URL and branch sets branch' '
169 clear_config master other other2 &&
170 git checkout master &&
171 - url="file://'"$PWD"'" &&
171 + url="file://$PWD" &&
172 git pull --set-upstream "$url" master &&
173 check_config master "$url" refs/heads/master &&
174 check_config_missing other &&
t/t6026-merge-attr.sh
+2 -2
@@ -122,7 +122,7 @@ test_expect_success 'custom merge backend' '
122 o=$(git unpack-file master^:text) &&
123 a=$(git unpack-file side^:text) &&
124 b=$(git unpack-file master:text) &&
125 - sh -c "./custom-merge $o $a $b 0 'text'" &&
125 + sh -c "./custom-merge $o $a $b 0 text" &&
126 sed -e 1,3d $a >check-2 &&
127 cmp check-1 check-2 &&
128 rm -f $o $a $b
@@ -149,7 +149,7 @@ test_expect_success 'custom merge backend' '
149 o=$(git unpack-file master^:text) &&
150 a=$(git unpack-file anchor:text) &&
151 b=$(git unpack-file master:text) &&
152 - sh -c "./custom-merge $o $a $b 0 'text'" &&
152 + sh -c "./custom-merge $o $a $b 0 text" &&
153 sed -e 1,3d $a >check-2 &&
154 cmp check-1 check-2 &&
155 sed -e 1,3d -e 4q $a >check-3 &&
t/t7001-mv.sh
+1 -1
@@ -177,7 +177,7 @@ test_expect_success "Sergey Vlasov's test case" '
177 date >ab.c &&
178 date >ab/d &&
179 git add ab.c ab &&
180 - git commit -m 'initial' &&
180 + git commit -m "initial" &&
181 git mv ab a
182 '
183
t/t7600-merge.sh
+3 -3
@@ -246,7 +246,7 @@ test_expect_success 'merge --squash c3 with c7' '
246 # file
247 EOF
248 git cat-file commit HEAD >raw &&
249 - sed -e '1,/^$/d' raw >actual &&
249 + sed -e "1,/^$/d" raw >actual &&
250 test_cmp expect actual
251 '
252
@@ -268,7 +268,7 @@ test_expect_success 'merge c3 with c7 with commit.cleanup = scissors' '
268 # file
269 EOF
270 git cat-file commit HEAD >raw &&
271 - sed -e '1,/^$/d' raw >actual &&
271 + sed -e "1,/^$/d" raw >actual &&
272 test_i18ncmp expect actual
273 '
274
@@ -292,7 +292,7 @@ test_expect_success 'merge c3 with c7 with --squash commit.cleanup = scissors' '
292 # file
293 EOF
294 git cat-file commit HEAD >raw &&
295 - sed -e '1,/^$/d' raw >actual &&
295 + sed -e "1,/^$/d" raw >actual &&
296 test_i18ncmp expect actual
297 '
298
t/t9001-send-email.sh
+5 -5
@@ -1551,7 +1551,7 @@ test_expect_success $PREREQ '8-bit and sendemail.transferencoding=quoted-printab
1551 --smtp-server="$(pwd)/fake.sendmail" \
1552 email-using-8bit \
1553 2>errors >out &&
1554 - sed '1,/^$/d' msgtxt1 >actual &&
1554 + sed "1,/^$/d" msgtxt1 >actual &&
1555 test_cmp expected actual
1556 '
1557
@@ -1568,7 +1568,7 @@ test_expect_success $PREREQ '8-bit and sendemail.transferencoding=base64' '
1568 --smtp-server="$(pwd)/fake.sendmail" \
1569 email-using-8bit \
1570 2>errors >out &&
1571 - sed '1,/^$/d' msgtxt1 >actual &&
1571 + sed "1,/^$/d" msgtxt1 >actual &&
1572 test_cmp expected actual
1573 '
1574
@@ -1594,7 +1594,7 @@ test_expect_success $PREREQ 'convert from quoted-printable to base64' '
1594 --smtp-server="$(pwd)/fake.sendmail" \
1595 email-using-qp \
1596 2>errors >out &&
1597 - sed '1,/^$/d' msgtxt1 >actual &&
1597 + sed "1,/^$/d" msgtxt1 >actual &&
1598 test_cmp expected actual
1599 '
1600
@@ -1624,7 +1624,7 @@ test_expect_success $PREREQ 'CRLF and sendemail.transferencoding=quoted-printabl
1624 --smtp-server="$(pwd)/fake.sendmail" \
1625 email-using-crlf \
1626 2>errors >out &&
1627 - sed '1,/^$/d' msgtxt1 >actual &&
1627 + sed "1,/^$/d" msgtxt1 >actual &&
1628 test_cmp expected actual
1629 '
1630
@@ -1641,7 +1641,7 @@ test_expect_success $PREREQ 'CRLF and sendemail.transferencoding=base64' '
1641 --smtp-server="$(pwd)/fake.sendmail" \
1642 email-using-crlf \
1643 2>errors >out &&
1644 - sed '1,/^$/d' msgtxt1 >actual &&
1644 + sed "1,/^$/d" msgtxt1 >actual &&
1645 test_cmp expected actual
1646 '
1647
t/t9100-git-svn-basic.sh
+3 -3
@@ -63,16 +63,16 @@ test_expect_success "$name" '
63
64
65 name='detect node change from file to directory #1'
66 -test_expect_success "$name" "
66 +test_expect_success "$name" '
67 mkdir dir/new_file &&
68 mv dir/file dir/new_file/file &&
69 mv dir/new_file dir/file &&
70 git update-index --remove dir/file &&
71 git update-index --add dir/file/file &&
72 - git commit -m '$name' &&
72 + git commit -m "$name" &&
73 test_must_fail git svn set-tree --find-copies-harder --rmdir \
74 remotes/git-svn..mybranch
75 -"
75 +'
76
77
78 name='detect node change from directory to file #1'
t/t9401-git-cvsserver-crlf.sh
+4 -4
@@ -167,10 +167,10 @@ test_expect_success 'adding files' '
167
168 test_expect_success 'updating' '
169 git pull gitcvs.git &&
170 - echo 'hi' > subdir/newfile.bin &&
171 - echo 'junk' > subdir/file.h &&
172 - echo 'hi' > subdir/newfile.c &&
173 - echo 'hello' >> binfile.bin &&
170 + echo "hi" >subdir/newfile.bin &&
171 + echo "junk" >subdir/file.h &&
172 + echo "hi" >subdir/newfile.c &&
173 + echo "hello" >>binfile.bin &&
174 git add subdir/newfile.bin subdir/file.h subdir/newfile.c binfile.bin &&
175 git commit -q -m "Add and change some files" &&
176 git push gitcvs.git >/dev/null &&
t/t9402-git-cvsserver-refs.sh
+1 -1
@@ -178,7 +178,7 @@ test_expect_success 'setup v1.2 on b1' '
178 mkdir cdir &&
179 echo "cdir/cfile" >cdir/cfile &&
180 git add -A cdir adir t3 t2 &&
181 - git commit -q -m 'v1.2' &&
181 + git commit -q -m "v1.2" &&
182 git tag v1.2 &&
183 git push --tags gitcvs.git b1:b1
184 '