Skip to content

Commit e06ed3e

Browse files
committed
Merge branch 'jk/tests-write-script'
* jk/tests-write-script: t0300: use write_script helper tests: add write_script helper function
2 parents 1e9d3e3 + 3d9f5b6 commit e06ed3e

File tree

2 files changed

+11
-6
lines changed

2 files changed

+11
-6
lines changed

t/t0300-credentials.sh

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -14,22 +14,18 @@ test_expect_success 'setup helper scripts' '
1414
done
1515
EOF
1616
17-
cat >git-credential-useless <<-\EOF &&
18-
#!/bin/sh
17+
write_script git-credential-useless <<-\EOF &&
1918
. ./dump
2019
exit 0
2120
EOF
22-
chmod +x git-credential-useless &&
2321
24-
cat >git-credential-verbatim <<-\EOF &&
25-
#!/bin/sh
22+
write_script git-credential-verbatim <<-\EOF &&
2623
user=$1; shift
2724
pass=$1; shift
2825
. ./dump
2926
test -z "$user" || echo username=$user
3027
test -z "$pass" || echo password=$pass
3128
EOF
32-
chmod +x git-credential-verbatim &&
3329
3430
PATH="$PWD:$PATH"
3531
'

t/test-lib.sh

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -395,11 +395,20 @@ test_config () {
395395
git config "$@"
396396
}
397397

398+
398399
test_config_global () {
399400
test_when_finished "test_unconfig --global '$1'" &&
400401
git config --global "$@"
401402
}
402403

404+
write_script () {
405+
{
406+
echo "#!${2-"$SHELL_PATH"}" &&
407+
cat
408+
} >"$1" &&
409+
chmod +x "$1"
410+
}
411+
403412
# Use test_set_prereq to tell that a particular prerequisite is available.
404413
# The prerequisite can later be checked for in two ways:
405414
#

0 commit comments

Comments
 (0)