test-ssh
111 lines
| 2.3 KiB
| text/plain
|
TextLexer
/ tests / test-ssh
mpm@selenic.com
|
r1110 | #!/bin/sh | ||
Alexis S. L. Carvalho
|
r4291 | cp "$TESTDIR"/printenv.py . | ||
mpm@selenic.com
|
r1110 | # This test tries to exercise the ssh functionality with a dummy script | ||
Alexis S. L. Carvalho
|
r4298 | cat <<EOF > dummyssh | ||
import sys | ||||
import os | ||||
mpm@selenic.com
|
r1110 | |||
Alexis S. L. Carvalho
|
r4298 | os.chdir(os.path.dirname(sys.argv[0])) | ||
if sys.argv[1] != "user@dummy": | ||||
sys.exit(-1) | ||||
if not os.path.exists("dummyssh"): | ||||
sys.exit(-1) | ||||
mpm@selenic.com
|
r1110 | |||
Alexis S. L. Carvalho
|
r4298 | os.environ["SSH_CLIENT"] = "127.0.0.1 1 2" | ||
mpm@selenic.com
|
r1110 | |||
Alexis S. L. Carvalho
|
r4298 | log = open("dummylog", "ab") | ||
log.write("Got arguments") | ||||
for i, arg in enumerate(sys.argv[1:]): | ||||
log.write(" %d:%s" % (i+1, arg)) | ||||
log.write("\n") | ||||
log.close() | ||||
r = os.system(sys.argv[2]) | ||||
sys.exit(bool(r)) | ||||
mpm@selenic.com
|
r1110 | EOF | ||
Alexis S. L. Carvalho
|
r5978 | cat <<EOF > badhook | ||
import sys | ||||
Alexis S. L. Carvalho
|
r6266 | sys.stdout.write("KABOOM\n") | ||
Alexis S. L. Carvalho
|
r5978 | EOF | ||
mpm@selenic.com
|
r1110 | echo "# creating 'remote'" | ||
hg init remote | ||||
cd remote | ||||
echo this > foo | ||||
Benoit Boissinot
|
r3853 | echo this > fooO | ||
hg ci -A -m "init" -d "1000000 0" foo fooO | ||||
Vadim Gelfer
|
r2621 | echo '[server]' > .hg/hgrc | ||
Vadim Gelfer
|
r2622 | echo 'uncompressed = True' >> .hg/hgrc | ||
Vadim Gelfer
|
r2673 | echo '[hooks]' >> .hg/hgrc | ||
Alexis S. L. Carvalho
|
r4291 | echo 'changegroup = python ../printenv.py changegroup-in-remote 0 ../dummylog' >> .hg/hgrc | ||
mpm@selenic.com
|
r1110 | |||
cd .. | ||||
Benoit Boissinot
|
r3275 | echo "# repo not found error" | ||
Alexis S. L. Carvalho
|
r4298 | hg clone -e "python ./dummyssh" ssh://user@dummy/nonexistent local | ||
Benoit Boissinot
|
r3275 | |||
Vadim Gelfer
|
r2612 | echo "# clone remote via stream" | ||
Alexis S. L. Carvalho
|
r4298 | hg clone -e "python ./dummyssh" --uncompressed ssh://user@dummy/remote local-stream 2>&1 | \ | ||
Lee Cantey
|
r3015 | sed -e 's/[0-9][0-9.]*/XXX/g' -e 's/[KM]\(B\/sec\)/X\1/' | ||
Vadim Gelfer
|
r2612 | cd local-stream | ||
hg verify | ||||
cd .. | ||||
echo "# clone remote via pull" | ||||
Alexis S. L. Carvalho
|
r4298 | hg clone -e "python ./dummyssh" ssh://user@dummy/remote local | ||
mpm@selenic.com
|
r1110 | |||
echo "# verify" | ||||
cd local | ||||
hg verify | ||||
Vadim Gelfer
|
r2673 | echo '[hooks]' >> .hg/hgrc | ||
Alexis S. L. Carvalho
|
r4291 | echo 'changegroup = python ../printenv.py changegroup-in-local 0 ../dummylog' >> .hg/hgrc | ||
Vadim Gelfer
|
r2673 | |||
mpm@selenic.com
|
r1110 | echo "# empty default pull" | ||
hg paths | ||||
Alexis S. L. Carvalho
|
r4298 | hg pull -e "python ../dummyssh" | ||
mpm@selenic.com
|
r1110 | |||
echo "# local change" | ||||
echo bleah > foo | ||||
Thomas Arendsen Hein
|
r1933 | hg ci -m "add" -d "1000000 0" | ||
mpm@selenic.com
|
r1110 | |||
echo "# updating rc" | ||||
echo "default-push = ssh://user@dummy/remote" >> .hg/hgrc | ||||
echo "[ui]" >> .hg/hgrc | ||||
Alexis S. L. Carvalho
|
r4298 | echo "ssh = python ../dummyssh" >> .hg/hgrc | ||
mpm@selenic.com
|
r1110 | |||
echo "# find outgoing" | ||||
hg out ssh://user@dummy/remote | ||||
Thomas Arendsen Hein
|
r1982 | echo "# find incoming on the remote side" | ||
Alexis S. L. Carvalho
|
r4298 | hg incoming -R ../remote -e "python ../dummyssh" ssh://user@dummy/local | ||
Thomas Arendsen Hein
|
r1982 | |||
mpm@selenic.com
|
r1110 | echo "# push" | ||
hg push | ||||
cd ../remote | ||||
echo "# check remote tip" | ||||
hg tip | ||||
hg verify | ||||
Brendan Cully
|
r3095 | hg cat -r tip foo | ||
mpm@selenic.com
|
r1110 | |||
Vadim Gelfer
|
r2439 | echo z > z | ||
hg ci -A -m z -d '1000001 0' z | ||||
Alexis S. L. Carvalho
|
r5978 | # a bad, evil hook that prints to stdout | ||
echo 'changegroup.stdout = python ../badhook' >> .hg/hgrc | ||||
Vadim Gelfer
|
r2439 | |||
cd ../local | ||||
echo r > r | ||||
hg ci -A -m z -d '1000002 0' r | ||||
Alexis S. L. Carvalho
|
r5978 | echo "# push should succeed even though it has an unexpected response" | ||
Vadim Gelfer
|
r2439 | hg push | ||
Alexis S. L. Carvalho
|
r5978 | hg -R ../remote heads | ||
Vadim Gelfer
|
r2439 | |||
mpm@selenic.com
|
r1110 | cd .. | ||
cat dummylog | ||||