git p4 test: use client_view in t9806
authorPete Wyckoff <pw@padd.com>
Sun, 27 Jan 2013 03:11:09 +0000 (22:11 -0500)
committerJunio C Hamano <gitster@pobox.com>
Sun, 27 Jan 2013 06:00:38 +0000 (22:00 -0800)
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>
t/lib-git-p4.sh
t/t9806-git-p4-options.sh

index b1dbded3e801bd6c1869598a7b70f8af3fde4ccb..c5d1f4d27a77bcfc753163a35600c1318a1376ef 100644 (file)
@@ -116,8 +116,8 @@ marshal_dump() {
 client_view() {
        (
                cat <<-EOF &&
-               Client: client
-               Description: client
+               Client: $P4CLIENT
+               Description: $P4CLIENT
                Root: $cli
                View:
                EOF
index 4f077eeca86946aa897f15e9f1729f9d0588cfb9..564fc80d9343701385ead6f1acad52f3a65c1097 100755 (executable)
@@ -214,40 +214,33 @@ test_expect_success 'clone --use-client-spec' '
                exec >/dev/null &&
                test_must_fail git p4 clone --dest="$git" --use-client-spec
        ) &&
+       # build a different client
        cli2=$(test-path-utils real_path "$TRASH_DIRECTORY/cli2") &&
        mkdir -p "$cli2" &&
        test_when_finished "rmdir \"$cli2\"" &&
-       (
-               cd "$cli2" &&
-               p4 client -i <<-EOF
-               Client: client2
-               Description: client2
-               Root: $cli2
-               View: //depot/sub/... //client2/bus/...
-               EOF
-       ) &&
        test_when_finished cleanup_git &&
        (
+               # group P4CLIENT and cli changes in a sub-shell
                P4CLIENT=client2 &&
-               git p4 clone --dest="$git" --use-client-spec //depot/...
-       ) &&
-       (
-               cd "$git" &&
-               test_path_is_file bus/dir/f4 &&
-               test_path_is_missing file1
-       ) &&
-       cleanup_git &&
-
-       # same thing again, this time with variable instead of option
-       (
-               cd "$git" &&
-               git init &&
-               git config git-p4.useClientSpec true &&
-               P4CLIENT=client2 &&
-               git p4 sync //depot/... &&
-               git checkout -b master p4/master &&
-               test_path_is_file bus/dir/f4 &&
-               test_path_is_missing file1
+               cli="$cli2" &&
+               client_view "//depot/sub/... //client2/bus/..." &&
+               git p4 clone --dest="$git" --use-client-spec //depot/... &&
+               (
+                       cd "$git" &&
+                       test_path_is_file bus/dir/f4 &&
+                       test_path_is_missing file1
+               ) &&
+               cleanup_git &&
+               # same thing again, this time with variable instead of option
+               (
+                       cd "$git" &&
+                       git init &&
+                       git config git-p4.useClientSpec true &&
+                       git p4 sync //depot/... &&
+                       git checkout -b master p4/master &&
+                       test_path_is_file bus/dir/f4 &&
+                       test_path_is_missing file1
+               )
        )
 '