tests/test-serve
author Stephen Deasey <sdeasey@gmail.com>
Mon, 10 Mar 2008 19:25:34 +0000
changeset 6262 de7256c82fad
parent 6000 8e7d64989bb8
child 6300 874ca958025b
permissions -rwxr-xr-x
hgweb: clarify which address and port can/cannot be bound at startup (bug 769) The error message at startup when the address/port could not be bound was confusing: hg serve abort: cannot start server: Address already in use Be more explicit: $ hg serve -a localhost abort: cannot start server at 'localhost:8000': Address already in use Also be more explicit on success, showing hostname and ip address/port: $ hg -v serve -a localhost -p 80 listening at http://localhost/ (127.0.0.1:80) We are careful to handle a missconfigured machine whose hostname does not resolve, falling back to the address given at the command line. Remove a dead-code error message.

#!/bin/sh

hg init test
cd test

echo '[web]' > .hg/hgrc
echo 'accesslog = access.log' >> .hg/hgrc

echo % Without -v
hg serve -a localhost -p $HGPORT -d --pid-file=hg.pid
cat hg.pid >> "$DAEMON_PIDS"
if [ -f access.log ]; then
    echo 'access log created - .hg/hgrc respected'
fi

echo % With -v
hg serve -a localhost -p $HGPORT1 -d --pid-file=hg.pid -v \
    | sed -e 's/:[0-9][0-9]*//g' -e 's/localhost\.localdomain/localhost/'
cat hg.pid >> "$DAEMON_PIDS"
sleep 1
kill `cat hg.pid`
sleep 1

echo % With --prefix foo
hg serve -a localhost -p $HGPORT1 -d --pid-file=hg.pid -v --prefix foo \
    | sed -e 's/:[0-9][0-9]*//g' -e 's/localhost\.localdomain/localhost/'
cat hg.pid >> "$DAEMON_PIDS"
sleep 1
kill `cat hg.pid`
sleep 1

echo % With --prefix /foo
hg serve -a localhost -p $HGPORT1 -d --pid-file=hg.pid -v --prefix /foo \
    | sed -e 's/:[0-9][0-9]*//g' -e 's/localhost\.localdomain/localhost/'
cat hg.pid >> "$DAEMON_PIDS"
sleep 1
kill `cat hg.pid`
sleep 1

echo % With --prefix foo/
hg serve -a localhost -p $HGPORT1 -d --pid-file=hg.pid -v --prefix foo/ \
    | sed -e 's/:[0-9][0-9]*//g' -e 's/localhost\.localdomain/localhost/'
cat hg.pid >> "$DAEMON_PIDS"
sleep 1
kill `cat hg.pid`
sleep 1

echo % With --prefix /foo/
hg serve -a localhost -p $HGPORT1 -d --pid-file=hg.pid -v --prefix /foo/ \
    | sed -e 's/:[0-9][0-9]*//g' -e 's/localhost\.localdomain/localhost/'
cat hg.pid >> "$DAEMON_PIDS"