Skip to content

Commit 020b813

Browse files
sunshinecogitster
authored andcommitted
tests: simplify construction of large blocks of text
Take advantage of here-docs to create large blocks of text rather than using a series of `echo` statements. Not only are here-docs a natural fit for such a task, but there is less opportunity for a broken &&-chain. Signed-off-by: Eric Sunshine <[email protected]> Reviewed-by: Elijah Newren <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent 2041b0e commit 020b813

File tree

7 files changed

+205
-202
lines changed

7 files changed

+205
-202
lines changed

t/t0021-conversion.sh

Lines changed: 22 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -118,17 +118,17 @@ test_expect_success check '
118118
# If an expanded ident ever gets into the repository, we want to make sure that
119119
# it is collapsed before being expanded again on checkout
120120
test_expect_success expanded_in_repo '
121-
{
122-
echo "File with expanded keywords"
123-
echo "\$Id\$"
124-
echo "\$Id:\$"
125-
echo "\$Id: 0000000000000000000000000000000000000000 \$"
126-
echo "\$Id: NoSpaceAtEnd\$"
127-
echo "\$Id:NoSpaceAtFront \$"
128-
echo "\$Id:NoSpaceAtEitherEnd\$"
129-
echo "\$Id: NoTerminatingSymbol"
130-
echo "\$Id: Foreign Commit With Spaces \$"
131-
} >expanded-keywords.0 &&
121+
cat >expanded-keywords.0 <<-\EOF &&
122+
File with expanded keywords
123+
$Id$
124+
$Id:$
125+
$Id: 0000000000000000000000000000000000000000 $
126+
$Id: NoSpaceAtEnd$
127+
$Id:NoSpaceAtFront $
128+
$Id:NoSpaceAtEitherEnd$
129+
$Id: NoTerminatingSymbol
130+
$Id: Foreign Commit With Spaces $
131+
EOF
132132
133133
{
134134
cat expanded-keywords.0 &&
@@ -139,17 +139,17 @@ test_expect_success expanded_in_repo '
139139
git commit -m "File with keywords expanded" &&
140140
id=$(git rev-parse --verify :expanded-keywords) &&
141141
142-
{
143-
echo "File with expanded keywords"
144-
echo "\$Id: $id \$"
145-
echo "\$Id: $id \$"
146-
echo "\$Id: $id \$"
147-
echo "\$Id: $id \$"
148-
echo "\$Id: $id \$"
149-
echo "\$Id: $id \$"
150-
echo "\$Id: NoTerminatingSymbol"
151-
echo "\$Id: Foreign Commit With Spaces \$"
152-
} >expected-output.0 &&
142+
cat >expected-output.0 <<-EOF &&
143+
File with expanded keywords
144+
\$Id: $id \$
145+
\$Id: $id \$
146+
\$Id: $id \$
147+
\$Id: $id \$
148+
\$Id: $id \$
149+
\$Id: $id \$
150+
\$Id: NoTerminatingSymbol
151+
\$Id: Foreign Commit With Spaces \$
152+
EOF
153153
{
154154
cat expected-output.0 &&
155155
printf "\$Id: NoTerminatingSymbolAtEOF"

t/t4106-apply-stdin.sh

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,10 @@ test_expect_success 'git apply --numstat - < patch' '
1818
'
1919

2020
test_expect_success 'git apply --numstat - < patch patch' '
21-
for i in 1 2; do echo "1 1 text"; done >expect &&
21+
cat >expect <<-\EOF &&
22+
1 1 text
23+
1 1 text
24+
EOF
2225
git apply --numstat - < patch patch >actual &&
2326
test_cmp expect actual
2427
'

t/t5510-fetch.sh

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -40,11 +40,11 @@ test_expect_success "clone and setup child repos" '
4040
git config branch.main.remote two &&
4141
git config branch.main.merge refs/heads/one &&
4242
mkdir -p .git/remotes &&
43-
{
44-
echo "URL: ../two/.git/"
45-
echo "Pull: refs/heads/main:refs/heads/two"
46-
echo "Pull: refs/heads/one:refs/heads/one"
47-
} >.git/remotes/two
43+
cat >.git/remotes/two <<-\EOF
44+
URL: ../two/.git/
45+
Pull: refs/heads/main:refs/heads/two
46+
Pull: refs/heads/one:refs/heads/one
47+
EOF
4848
) &&
4949
git clone . bundle &&
5050
git clone . seven

t/t5515-fetch-merge-logic.sh

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -105,19 +105,19 @@ test_expect_success setup '
105105
remotes="$remotes config-glob" &&
106106
107107
mkdir -p .git/remotes &&
108-
{
109-
echo "URL: ../.git/"
110-
echo "Pull: refs/heads/main:remotes/rem/main"
111-
echo "Pull: refs/heads/one:remotes/rem/one"
112-
echo "Pull: two:remotes/rem/two"
113-
echo "Pull: refs/heads/three:remotes/rem/three"
114-
} >.git/remotes/remote-explicit &&
108+
cat >.git/remotes/remote-explicit <<-\EOF &&
109+
URL: ../.git/
110+
Pull: refs/heads/main:remotes/rem/main
111+
Pull: refs/heads/one:remotes/rem/one
112+
Pull: two:remotes/rem/two
113+
Pull: refs/heads/three:remotes/rem/three
114+
EOF
115115
remotes="$remotes remote-explicit" &&
116116
117-
{
118-
echo "URL: ../.git/"
119-
echo "Pull: refs/heads/*:refs/remotes/rem/*"
120-
} >.git/remotes/remote-glob &&
117+
cat >.git/remotes/remote-glob <<-\EOF &&
118+
URL: ../.git/
119+
Pull: refs/heads/*:refs/remotes/rem/*
120+
EOF
121121
remotes="$remotes remote-glob" &&
122122
123123
mkdir -p .git/branches &&

t/t6406-merge-attr.sh

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -62,10 +62,10 @@ test_expect_success setup '
6262

6363
test_expect_success merge '
6464
65-
{
66-
echo "binary -merge"
67-
echo "union merge=union"
68-
} >.gitattributes &&
65+
cat >.gitattributes <<-\EOF &&
66+
binary -merge
67+
union merge=union
68+
EOF
6969
7070
if git merge main
7171
then

t/t6411-merge-filemode.sh

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -51,10 +51,10 @@ test_expect_success 'set up mode change in both branches' '
5151
: >file2 &&
5252
git add file2 &&
5353
git commit -m b2 &&
54-
{
55-
echo "100755 $H 2 file2"
56-
echo "100644 $H 3 file2"
57-
} >expect
54+
cat >expect <<-EOF
55+
100755 $H 2 file2
56+
100644 $H 3 file2
57+
EOF
5858
'
5959

6060
do_both_modes () {

0 commit comments

Comments
 (0)