Skip to content

Commit 08c5eb7

Browse files
Pete Wyckoffgitster
authored andcommitted
git p4 test: simplify quoting involving TRASH_DIRECTORY
For temporary files that are created in the top-level TRASH_DIRECTORY, trust that the tests do not chdir except in subshells, and avoid some quoting. Signed-off-by: Pete Wyckoff <pw@padd.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
1 parent 23bd0c9 commit 08c5eb7

File tree

4 files changed

+17
-21
lines changed

4 files changed

+17
-21
lines changed

t/t9800-git-p4-basic.sh

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -126,15 +126,14 @@ test_expect_success 'clone two dirs, @all, conflicting files' '
126126
'
127127

128128
test_expect_success 'exit when p4 fails to produce marshaled output' '
129-
badp4dir="$TRASH_DIRECTORY/badp4dir" &&
130-
mkdir "$badp4dir" &&
131-
test_when_finished "rm \"$badp4dir/p4\" && rmdir \"$badp4dir\"" &&
132-
cat >"$badp4dir"/p4 <<-EOF &&
129+
mkdir badp4dir &&
130+
test_when_finished "rm badp4dir/p4 && rmdir badp4dir" &&
131+
cat >badp4dir/p4 <<-EOF &&
133132
#!$SHELL_PATH
134133
exit 1
135134
EOF
136-
chmod 755 "$badp4dir"/p4 &&
137-
PATH="$badp4dir:$PATH" git p4 clone --dest="$git" //depot >errs 2>&1 ; retval=$? &&
135+
chmod 755 badp4dir/p4 &&
136+
PATH="$TRASH_DIRECTORY/badp4dir:$PATH" git p4 clone --dest="$git" //depot >errs 2>&1 ; retval=$? &&
138137
test $retval -eq 1 &&
139138
test_must_fail grep -q Traceback errs
140139
'

t/t9805-git-p4-skip-submit-edit.sh

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -78,20 +78,19 @@ test_expect_success 'skipSubmitEditCheck' '
7878
test_expect_success 'no config, edited' '
7979
git p4 clone --dest="$git" //depot &&
8080
test_when_finished cleanup_git &&
81-
ed="$TRASH_DIRECTORY/ed.sh" &&
82-
test_when_finished "rm \"$ed\"" &&
83-
cat >"$ed" <<-EOF &&
81+
test_when_finished "rm ed.sh" &&
82+
cat >ed.sh <<-EOF &&
8483
#!$SHELL_PATH
8584
sleep 1
8685
touch "\$1"
8786
exit 0
8887
EOF
89-
chmod 755 "$ed" &&
88+
chmod 755 ed.sh &&
9089
(
9190
cd "$git" &&
9291
echo line >>file1 &&
9392
git commit -a -m "change 5" &&
94-
P4EDITOR="" EDITOR="\"$ed\"" git p4 submit &&
93+
P4EDITOR="" EDITOR="\"$TRASH_DIRECTORY/ed.sh\"" git p4 submit &&
9594
p4 changes //depot/... >wc &&
9695
test_line_count = 5 wc
9796
)

t/t9806-git-p4-options.sh

Lines changed: 6 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -39,10 +39,9 @@ test_expect_success 'clone --branch' '
3939
'
4040

4141
test_expect_success 'clone --changesfile' '
42-
cf="$TRASH_DIRECTORY/cf" &&
43-
test_when_finished "rm \"$cf\"" &&
44-
printf "1\n3\n" >"$cf" &&
45-
git p4 clone --changesfile="$cf" --dest="$git" //depot &&
42+
test_when_finished "rm cf" &&
43+
printf "1\n3\n" >cf &&
44+
git p4 clone --changesfile="$TRASH_DIRECTORY/cf" --dest="$git" //depot &&
4645
test_when_finished cleanup_git &&
4746
(
4847
cd "$git" &&
@@ -55,10 +54,9 @@ test_expect_success 'clone --changesfile' '
5554
'
5655

5756
test_expect_success 'clone --changesfile, @all' '
58-
cf="$TRASH_DIRECTORY/cf" &&
59-
test_when_finished "rm \"$cf\"" &&
60-
printf "1\n3\n" >"$cf" &&
61-
test_must_fail git p4 clone --changesfile="$cf" --dest="$git" //depot@all
57+
test_when_finished "rm cf" &&
58+
printf "1\n3\n" >cf &&
59+
test_must_fail git p4 clone --changesfile="$TRASH_DIRECTORY/cf" --dest="$git" //depot@all
6260
'
6361

6462
# imports both master and p4/master in refs/heads

t/t9808-git-p4-chdir.sh

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ test_expect_success 'init depot' '
2121
# environment variable is set
2222
test_expect_success 'P4CONFIG and absolute dir clone' '
2323
printf "P4PORT=$P4PORT\nP4CLIENT=$P4CLIENT\n" >p4config &&
24-
test_when_finished "rm \"$TRASH_DIRECTORY/p4config\"" &&
24+
test_when_finished "rm p4config" &&
2525
test_when_finished cleanup_git &&
2626
(
2727
P4CONFIG=p4config && export P4CONFIG &&
@@ -33,7 +33,7 @@ test_expect_success 'P4CONFIG and absolute dir clone' '
3333
# same thing, but with relative directory name, note missing $ on --dest
3434
test_expect_success 'P4CONFIG and relative dir clone' '
3535
printf "P4PORT=$P4PORT\nP4CLIENT=$P4CLIENT\n" >p4config &&
36-
test_when_finished "rm \"$TRASH_DIRECTORY/p4config\"" &&
36+
test_when_finished "rm p4config" &&
3737
test_when_finished cleanup_git &&
3838
(
3939
P4CONFIG=p4config && export P4CONFIG &&

0 commit comments

Comments
 (0)