Skip to content

Commit 710eb3e

Browse files
tboegigitster
authored andcommitted
t5601: remove clear_ssh, refactor setup_ssh_wrapper
Commit 8d3d28f added test cases for URLs which should be ssh. Remove the function clear_ssh, use test_when_finished to clean up. Introduce the function setup_ssh_wrapper, which could be factored out together with expect_ssh. Tighten one test and use "foo:bar" instead of "./foo:bar", Helped-by: Jeff King <[email protected]> Signed-off-by: Torsten Bögershausen <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent aa27064 commit 710eb3e

File tree

1 file changed

+20
-20
lines changed

1 file changed

+20
-20
lines changed

t/t5601-clone.sh

Lines changed: 20 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -280,25 +280,26 @@ test_expect_success 'clone checking out a tag' '
280280
test_cmp fetch.expected fetch.actual
281281
'
282282

283-
test_expect_success 'setup ssh wrapper' '
284-
write_script "$TRASH_DIRECTORY/ssh-wrapper" <<-\EOF &&
285-
echo >>"$TRASH_DIRECTORY/ssh-output" "ssh: $*" &&
286-
# throw away all but the last argument, which should be the
287-
# command
288-
while test $# -gt 1; do shift; done
289-
eval "$1"
290-
EOF
291-
292-
GIT_SSH="$TRASH_DIRECTORY/ssh-wrapper" &&
293-
export GIT_SSH &&
294-
export TRASH_DIRECTORY
295-
'
296-
297-
clear_ssh () {
298-
>"$TRASH_DIRECTORY/ssh-output"
283+
setup_ssh_wrapper () {
284+
test_expect_success 'setup ssh wrapper' '
285+
write_script "$TRASH_DIRECTORY/ssh-wrapper" <<-\EOF &&
286+
echo >>"$TRASH_DIRECTORY/ssh-output" "ssh: $*" &&
287+
# throw away all but the last argument, which should be the
288+
# command
289+
while test $# -gt 1; do shift; done
290+
eval "$1"
291+
EOF
292+
GIT_SSH="$TRASH_DIRECTORY/ssh-wrapper" &&
293+
export GIT_SSH &&
294+
export TRASH_DIRECTORY &&
295+
>"$TRASH_DIRECTORY"/ssh-output
296+
'
299297
}
300298

301299
expect_ssh () {
300+
test_when_finished '
301+
(cd "$TRASH_DIRECTORY" && rm -f ssh-expect && >ssh-output)
302+
' &&
302303
{
303304
case "$1" in
304305
none)
@@ -310,21 +311,20 @@ expect_ssh () {
310311
(cd "$TRASH_DIRECTORY" && test_cmp ssh-expect ssh-output)
311312
}
312313

314+
setup_ssh_wrapper
315+
313316
test_expect_success 'cloning myhost:src uses ssh' '
314-
clear_ssh &&
315317
git clone myhost:src ssh-clone &&
316318
expect_ssh myhost src
317319
'
318320

319321
test_expect_success NOT_MINGW,NOT_CYGWIN 'clone local path foo:bar' '
320-
clear_ssh &&
321322
cp -R src "foo:bar" &&
322-
git clone "./foo:bar" foobar &&
323+
git clone "foo:bar" foobar &&
323324
expect_ssh none
324325
'
325326

326327
test_expect_success 'bracketed hostnames are still ssh' '
327-
clear_ssh &&
328328
git clone "[myhost:123]:src" ssh-bracket-clone &&
329329
expect_ssh myhost:123 src
330330
'

0 commit comments

Comments
 (0)