git p4 test: use client_view in t9806
Use the standard client_view function from lib-git-p4.sh instead of building one by hand. This requires a bit of rework, using the current value of $P4CLIENT for the client name. It also reorganizes the test to isolate changes to $P4CLIENT and $cli in a subshell. Signed-off-by: Pete Wyckoff <pw@padd.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
Pete Wyckoff committed
Jan 26, 2013 at 22:11 UTC
50038ba92a22743be8c105e16fb559a6d96c3a7a
2 files changed
+23
-30
t/lib-git-p4.sh
+2
-2
@@ -116,8 +116,8 @@ marshal_dump() {
116
client_view() {
117
(
118
cat <<-EOF &&
119
- Client: client
120
- Description: client
119
+ Client: $P4CLIENT
120
+ Description: $P4CLIENT
121
Root: $cli
122
View:
123
EOF
t/t9806-git-p4-options.sh
+21
-28
@@ -214,40 +214,33 @@ test_expect_success 'clone --use-client-spec' '
214
exec >/dev/null &&
215
test_must_fail git p4 clone --dest="$git" --use-client-spec
216
) &&
217
+ # build a different client
218
cli2=$(test-path-utils real_path "$TRASH_DIRECTORY/cli2") &&
219
mkdir -p "$cli2" &&
220
test_when_finished "rmdir \"$cli2\"" &&
220
- (
221
- cd "$cli2" &&
222
- p4 client -i <<-EOF
223
- Client: client2
224
- Description: client2
225
- Root: $cli2
226
- View: //depot/sub/... //client2/bus/...
227
- EOF
228
- ) &&
221
test_when_finished cleanup_git &&
222
(
223
+ # group P4CLIENT and cli changes in a sub-shell
224
P4CLIENT=client2 &&
232
- git p4 clone --dest="$git" --use-client-spec //depot/...
233
- ) &&
234
- (
235
- cd "$git" &&
236
- test_path_is_file bus/dir/f4 &&
237
- test_path_is_missing file1
238
- ) &&
239
- cleanup_git &&
240
-
241
- # same thing again, this time with variable instead of option
242
- (
243
- cd "$git" &&
244
- git init &&
245
- git config git-p4.useClientSpec true &&
246
- P4CLIENT=client2 &&
247
- git p4 sync //depot/... &&
248
- git checkout -b master p4/master &&
249
- test_path_is_file bus/dir/f4 &&
250
- test_path_is_missing file1
225
+ cli="$cli2" &&
226
+ client_view "//depot/sub/... //client2/bus/..." &&
227
+ git p4 clone --dest="$git" --use-client-spec //depot/... &&
228
+ (
229
+ cd "$git" &&
230
+ test_path_is_file bus/dir/f4 &&
231
+ test_path_is_missing file1
232
+ ) &&
233
+ cleanup_git &&
234
+ # same thing again, this time with variable instead of option
235
+ (
236
+ cd "$git" &&
237
+ git init &&
238
+ git config git-p4.useClientSpec true &&
239
+ git p4 sync //depot/... &&
240
+ git checkout -b master p4/master &&
241
+ test_path_is_file bus/dir/f4 &&
242
+ test_path_is_missing file1
243
+ )
244
)
245
'
246