Mercurial > hg-stable
changeset 7344:58fd3c718ca4
tests: add killdaemons helper script
author | Matt Mackall <mpm@selenic.com> |
---|---|
date | Fri, 07 Nov 2008 16:28:53 -0600 |
parents | e47dab64be8d |
children | c3ba5de1b89d |
files | tests/killdaemons.py tests/test-archive tests/test-fetch |
diffstat | 3 files changed, 31 insertions(+), 1 deletions(-) [+] |
line wrap: on
line diff
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/tests/killdaemons.py Fri Nov 07 16:28:53 2008 -0600 @@ -0,0 +1,25 @@ +#!/usr/bin/env python + +import os, sys, time, errno, signal + +# Kill off any leftover daemon processes +try: + fp = file(os.environ['DAEMON_PIDS']) + for line in fp: + try: + pid = int(line) + except ValueError: + continue + try: + os.kill(pid, 0) + os.kill(pid, signal.SIGTERM) + for i in range(10): + time.sleep(0.05) + os.kill(pid, 0) + os.kill(pid, signal.SIGKILL) + except OSError, err: + if err.errno != errno.ESRCH: + raise + fp.close() +except IOError: + pass
--- a/tests/test-archive Fri Nov 07 16:28:52 2008 -0600 +++ b/tests/test-archive Fri Nov 07 16:28:53 2008 -0600 @@ -24,7 +24,7 @@ echo % $3 and $4 disallowed should both give 403 "$TESTDIR/get-with-headers.py" localhost:$HGPORT "/archive/tip.$3" | head -n 1 "$TESTDIR/get-with-headers.py" localhost:$HGPORT "/archive/tip.$4" | head -n 1 - kill `cat hg.pid` + "$TESTDIR/killdaemons.py" cat errors.log cp .hg/hgrc-base .hg/hgrc } @@ -63,6 +63,8 @@ http_proxy= python getarchive.py "$TIP" zip > archive.zip unzip -t archive.zip | sed "s/$QTIP/TIP/" +"$TESTDIR/killdaemons.py" + hg archive -t tar test.tar tar tf test.tar
--- a/tests/test-fetch Fri Nov 07 16:28:52 2008 -0600 +++ b/tests/test-fetch Fri Nov 07 16:28:53 2008 -0600 @@ -37,6 +37,7 @@ hg --cwd c fetch -d '4 0' -m 'automated merge' ../a ls c +netstat -tnap 2>/dev/null | grep $HGPORT | grep LISTEN hg --cwd a serve -a localhost -p $HGPORT -d --pid-file=hg.pid cat a/hg.pid >> "$DAEMON_PIDS" @@ -169,4 +170,6 @@ hg -R n2 parents --template '{rev}\n' rm -fr n1 n2 +"$TESTDIR/killdaemons.py" + true