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>

Pete Wyckoff committed Jun 27, 2012 at 08:00 UTC 08c5eb7ac0167e5932f2456df3dcebd0712d63a9
4 files changed +17 -21
t/t9800-git-p4-basic.sh
+5 -6
@@ -126,15 +126,14 @@ test_expect_success 'clone two dirs, @all, conflicting files' '
126 '
127
128 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 &&
132 #!$SHELL_PATH
133 exit 1
134 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=$? &&
137 test $retval -eq 1 &&
138 test_must_fail grep -q Traceback errs
139 '
t/t9805-git-p4-skip-submit-edit.sh
+4 -5
@@ -78,20 +78,19 @@ test_expect_success 'skipSubmitEditCheck' '
78 test_expect_success 'no config, edited' '
79 git p4 clone --dest="$git" //depot &&
80 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 &&
83 #!$SHELL_PATH
84 sleep 1
85 touch "\$1"
86 exit 0
87 EOF
89 - chmod 755 "$ed" &&
88 + chmod 755 ed.sh &&
89 (
90 cd "$git" &&
91 echo line >>file1 &&
92 git commit -a -m "change 5" &&
94 - P4EDITOR="" EDITOR="\"$ed\"" git p4 submit &&
93 + P4EDITOR="" EDITOR="\"$TRASH_DIRECTORY/ed.sh\"" git p4 submit &&
94 p4 changes //depot/... >wc &&
95 test_line_count = 5 wc
96 )
t/t9806-git-p4-options.sh
+6 -8
@@ -39,10 +39,9 @@ test_expect_success 'clone --branch' '
39 '
40
41 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 &&
45 test_when_finished cleanup_git &&
46 (
47 cd "$git" &&
@@ -55,10 +54,9 @@ test_expect_success 'clone --changesfile' '
54 '
55
56 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
60 '
61
62 # imports both master and p4/master in refs/heads
t/t9808-git-p4-chdir.sh
+2 -2
@@ -21,7 +21,7 @@ test_expect_success 'init depot' '
21 # environment variable is set
22 test_expect_success 'P4CONFIG and absolute dir clone' '
23 printf "P4PORT=$P4PORT\nP4CLIENT=$P4CLIENT\n" >p4config &&
24 - test_when_finished "rm \"$TRASH_DIRECTORY/p4config\"" &&
24 + test_when_finished "rm p4config" &&
25 test_when_finished cleanup_git &&
26 (
27 P4CONFIG=p4config && export P4CONFIG &&
@@ -33,7 +33,7 @@ test_expect_success 'P4CONFIG and absolute dir clone' '
33 # same thing, but with relative directory name, note missing $ on --dest
34 test_expect_success 'P4CONFIG and relative dir clone' '
35 printf "P4PORT=$P4PORT\nP4CLIENT=$P4CLIENT\n" >p4config &&
36 - test_when_finished "rm \"$TRASH_DIRECTORY/p4config\"" &&
36 + test_when_finished "rm p4config" &&
37 test_when_finished cleanup_git &&
38 (
39 P4CONFIG=p4config && export P4CONFIG &&