view tests/test-ssh @ 12156:4c94b6d0fb1c

tests: remove unneeded -d flags Many tests fixed the commit date of their changesets at '1000000 0' or similar. However testing with "Mon Jan 12 13:46:40 1970 +0000" is not better than testing with "Thu Jan 01 00:00:00 1970 +0000", which is the default run-tests.py installs. Removing the unnecessary flag removes some clutter and will hopefully make it clearer what the tests are really trying to test. Some tests did not even change their output when the dates were changed, in which case the -d flag was truly irrelevant. Dates used in sequence (such as '0 0', '1 0', etc...) were left alone since they may make the test easier to understand.
author Martin Geisler <mg@lazybytes.net>
date Thu, 02 Sep 2010 23:22:51 +0200
parents 9f76df0edb7d
children 0eaf7d32a5d8
line wrap: on
line source

#!/bin/sh

cp "$TESTDIR"/printenv.py .

# This test tries to exercise the ssh functionality with a dummy script

cat <<EOF > dummyssh
import sys
import os

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)

os.environ["SSH_CLIENT"] = "127.0.0.1 1 2"

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))
EOF

cat <<EOF > badhook
import sys
sys.stdout.write("KABOOM\n")
EOF

echo "# creating 'remote'"
hg init remote
cd remote
echo this > foo
echo this > fooO
hg ci -A -m "init" foo fooO
echo '[server]' > .hg/hgrc
echo 'uncompressed = True' >> .hg/hgrc
echo '[hooks]' >> .hg/hgrc
echo 'changegroup = python ../printenv.py changegroup-in-remote 0 ../dummylog' >> .hg/hgrc

cd ..

echo "# repo not found error"
hg clone -e "python ./dummyssh" ssh://user@dummy/nonexistent local

echo "# clone remote via stream"
hg clone -e "python ./dummyssh" --uncompressed ssh://user@dummy/remote local-stream 2>&1 | \
  sed -e 's/[0-9][0-9.]*/XXX/g' -e 's/[KM]\(B\/sec\)/X\1/'
cd local-stream
hg verify
cd ..

echo "# clone remote via pull"
hg clone -e "python ./dummyssh" ssh://user@dummy/remote local

echo "# verify"
cd local
hg verify

echo '[hooks]' >> .hg/hgrc
echo 'changegroup = python ../printenv.py changegroup-in-local 0 ../dummylog' >> .hg/hgrc

echo "# empty default pull"
hg paths
hg pull -e "python ../dummyssh"

echo "# local change"
echo bleah > foo
hg ci -m "add"

echo "# updating rc"
echo "default-push = ssh://user@dummy/remote" >> .hg/hgrc
echo "[ui]" >> .hg/hgrc
echo "ssh = python ../dummyssh" >> .hg/hgrc

echo "# find outgoing"
hg out ssh://user@dummy/remote

echo "# find incoming on the remote side"
hg incoming -R ../remote -e "python ../dummyssh" ssh://user@dummy/local

echo "# push"
hg push

cd ../remote

echo "# check remote tip"
hg tip
hg verify
hg cat -r tip foo

echo z > z
hg ci -A -m z z
# a bad, evil hook that prints to stdout
echo 'changegroup.stdout = python ../badhook' >> .hg/hgrc

cd ../local
echo r > r
hg ci -A -m z r

echo "# push should succeed even though it has an unexpected response"
hg push
hg -R ../remote heads

cd ..
cat dummylog