sapling/tests/p4setup.sh
Jun Wu a94a1bd72a p4fastimport: extract common logic from tests
Summary:
This diff adds a shared `p4setup.sh` that de-duplicates common logic among
tests. It also uses absolute path to make sure the extension being tested is
the version being developed.

The LFS test is also workarounded temporarily waiting for upstream change.

Test Plan: Run existing tests

Reviewers: #mercurial, davidsp

Reviewed By: davidsp

Subscribers: mjpieters

Differential Revision: https://phabricator.intern.facebook.com/D5049279

Signature: t1:5049279:1494547832:28222fd2034115faca73860d6dd2f19206701aaa
2017-05-11 17:13:31 -07:00

39 lines
940 B
Bash

cat >> $HGRCPATH<<EOF
[extensions]
p4fastimport=$TESTDIR/../p4fastimport
EOF
# create p4 depot
p4wd="$TESTTMP/p4"
hgwd="$TESTTMP/hg"
P4ROOT="$TESTTMP/depot"; export P4ROOT
P4AUDIT="$P4ROOT/audit"; export P4AUDIT
P4JOURNAL="$P4ROOT/journal"; export P4JOURNAL
P4LOG="$P4ROOT/log"; export P4LOG
P4PORT=localhost:$HGPORT; export P4PORT
P4DEBUG=1; export P4DEBUG
mkdir "$hgwd"
mkdir "$p4wd"
cd "$p4wd"
# start the p4 server
[ ! -d $P4ROOT ] && mkdir $P4ROOT
p4d $P4DOPTS -f -J off >$P4ROOT/stdout 2>$P4ROOT/stderr &
echo $! >> $DAEMON_PIDS
trap "echo stopping the p4 server ; p4 admin stop" EXIT
# wait for the server to initialize
while ! p4 ; do
sleep 1
done >/dev/null 2>/dev/null
# create a client spec
cd $p4wd
P4CLIENT=hg-p4-import; export P4CLIENT
DEPOTPATH=${DEPOTPATH:-//depot/...}
p4 client -o | sed '/^View:/,$ d' >p4client
echo View: >>p4client
echo " $DEPOTPATH //$P4CLIENT/..." >>p4client
p4 client -i <p4client >/dev/null