Skip to content

Commit 50038ba

Browse files
Pete Wyckoffgitster
authored andcommitted
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>
1 parent 6112541 commit 50038ba

File tree

2 files changed

+23
-30
lines changed

2 files changed

+23
-30
lines changed

t/lib-git-p4.sh

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -116,8 +116,8 @@ marshal_dump() {
116116
client_view() {
117117
(
118118
cat <<-EOF &&
119-
Client: client
120-
Description: client
119+
Client: $P4CLIENT
120+
Description: $P4CLIENT
121121
Root: $cli
122122
View:
123123
EOF

t/t9806-git-p4-options.sh

Lines changed: 21 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -214,40 +214,33 @@ test_expect_success 'clone --use-client-spec' '
214214
exec >/dev/null &&
215215
test_must_fail git p4 clone --dest="$git" --use-client-spec
216216
) &&
217+
# build a different client
217218
cli2=$(test-path-utils real_path "$TRASH_DIRECTORY/cli2") &&
218219
mkdir -p "$cli2" &&
219220
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-
) &&
229221
test_when_finished cleanup_git &&
230222
(
223+
# group P4CLIENT and cli changes in a sub-shell
231224
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+
)
251244
)
252245
'
253246

0 commit comments

Comments
 (0)