2 # Library code for git p4 tests
5 # p4 tests never use the top-level repo; always build/clone into
6 # a subdirectory called "$git"
7 TEST_NO_CREATE_REPO
=NoThanks
11 if ! test_have_prereq PYTHON
13 skip_all
='skipping git p4 tests; python not available'
16 ( p4
-h && p4d
-h ) >/dev
/null
2>&1 ||
{
17 skip_all
='skipping git p4 tests; no p4 or p4d'
21 # On cygwin, the NT version of Perforce can be used. When giving
22 # it paths, either on the command-line or in client specifications,
23 # be sure to use the native windows form.
25 # Older versions of perforce were available compiled natively for
26 # cygwin. Those do not accept native windows paths, so make sure
27 # not to convert for them.
30 if test_have_prereq CYGWIN
&& ! p4
-V |
grep -q CYGWIN
32 path
=$
(cygpath
--windows "$path")
34 path
=$
(test-path-utils real_path
"$path")
39 # Try to pick a unique port: guess a large number, then hope
40 # no more than one of each test is running.
42 # This does not handle the case where somebody else is running the
43 # same tests and has chosen the same ports.
45 git_p4_test_start
=9800
46 P4DPORT
=$
((10669 + ($testid - $git_p4_test_start)))
48 P4PORT
=localhost
:$P4DPORT
53 export P4PORT P4CLIENT P4USER P4EDITOR P4CHARSET
55 db
="$TRASH_DIRECTORY/db"
56 cli
="$TRASH_DIRECTORY/cli"
57 git
="$TRASH_DIRECTORY/git"
58 pidfile
="$TRASH_DIRECTORY/p4d.pid"
61 mkdir
-p "$db" "$cli" "$git" &&
71 # This gives p4d a long time to start up, as it can be
72 # quite slow depending on the machine. Set this environment
73 # variable to something smaller to fail faster in, say,
74 # an automated test setup. If the p4d process dies, that
75 # will be caught with the "kill -0" check below.
76 i
=${P4D_START_PATIENCE:-300}
81 # succeed when p4 client commands start to work
82 if p4 info
>/dev
/null
2>&1
88 kill -0 $pid 2>/dev
/null ||
break
89 echo waiting
for p4d to start
100 # build a p4 user so author@example.com has an entry
104 client_view
"//depot/... //client/..." &&
113 Email: $name@example.com
119 pid
=$
(cat "$pidfile")
120 # it had better exist for the first kill
122 for i
in 1 2 3 4 5 ; do
123 kill $pid >/dev
/null
2>&1 ||
break
126 # complain if it would not die
127 test_must_fail
kill $pid >/dev
/null
2>&1 &&
128 rm -rf "$db" "$cli" "$pidfile"
139 cat >"$TRASH_DIRECTORY/marshal-dump.py" <<-EOF &&
142 for i in range($line):
143 d = marshal.load(sys.stdin)
146 "$PYTHON_PATH" "$TRASH_DIRECTORY/marshal-dump.py"
150 # Construct a client with this list of View lines
156 Description: $P4CLIENT
158 AltRoots: $(native_path "$cli")
166 is_cli_file_writeable
() {
167 # cygwin version of p4 does not set read-only attr,
168 # will be marked 444 but -w is true
170 if test_have_prereq CYGWIN
&& p4
-V |
grep -q CYGWIN
172 stat
=$
(stat
--format=%a
"$file") &&