The eighteenth batch
[git.git] / t / t9808-git-p4-chdir.sh
blob342f7f3d4a09d20af8e9f00727f91fb5523e9e96
1 #!/bin/sh
3 test_description='git p4 relative chdir'
5 TEST_PASSES_SANITIZE_LEAK=true
6 . ./lib-git-p4.sh
8 test_expect_success 'start p4d' '
9 start_p4d
12 test_expect_success 'init depot' '
14 cd "$cli" &&
15 echo file1 >file1 &&
16 p4 add file1 &&
17 p4 submit -d "change 1"
21 # P4 reads from P4CONFIG file to find its server params, if the
22 # environment variable is set
23 test_expect_success 'P4CONFIG and absolute dir clone' '
24 printf "P4PORT=$P4PORT\nP4CLIENT=$P4CLIENT\n" >p4config &&
25 test_when_finished "rm p4config" &&
26 test_when_finished cleanup_git &&
28 P4CONFIG=p4config && export P4CONFIG &&
29 sane_unset P4PORT P4CLIENT &&
30 git p4 clone --verbose --dest="$git" //depot
34 # same thing, but with relative directory name, note missing $ on --dest
35 test_expect_success 'P4CONFIG and relative dir clone' '
36 printf "P4PORT=$P4PORT\nP4CLIENT=$P4CLIENT\n" >p4config &&
37 test_when_finished "rm p4config" &&
38 test_when_finished cleanup_git &&
40 P4CONFIG=p4config && export P4CONFIG &&
41 sane_unset P4PORT P4CLIENT &&
42 git p4 clone --verbose --dest="git" //depot
46 # Common setup using .p4config to set P4CLIENT and P4PORT breaks
47 # if clone destination is relative. Make sure that chdir() expands
48 # the relative path in --dest to absolute.
49 test_expect_success 'p4 client root would be relative due to clone --dest' '
50 test_when_finished cleanup_git &&
52 echo P4PORT=$P4PORT >git/.p4config &&
53 P4CONFIG=.p4config &&
54 export P4CONFIG &&
55 unset P4PORT &&
56 git p4 clone --dest="git" //depot
60 # When the p4 client Root is a symlink, make sure chdir() does not use
61 # getcwd() to convert it to a physical path.
62 test_expect_success SYMLINKS 'p4 client root symlink should stay symbolic' '
63 physical="$TRASH_DIRECTORY/physical" &&
64 symbolic="$TRASH_DIRECTORY/symbolic" &&
65 test_when_finished "rm -rf \"$physical\"" &&
66 test_when_finished "rm \"$symbolic\"" &&
67 mkdir -p "$physical" &&
68 ln -s "$physical" "$symbolic" &&
69 test_when_finished cleanup_git &&
71 P4CLIENT=client-sym &&
72 p4 client -i <<-EOF &&
73 Client: $P4CLIENT
74 Description: $P4CLIENT
75 Root: $symbolic
76 LineEnd: unix
77 View: //depot/... //$P4CLIENT/...
78 EOF
79 git p4 clone --dest="$git" //depot &&
80 cd "$git" &&
81 test_commit file2 &&
82 git config git-p4.skipSubmitEdit true &&
83 git p4 submit
87 test_done