Mercurial > hg
changeset 40822:6a75363f834a
test-commandserver: change way of triggering early crash
Future patches will move the logging facility out of the server class, so
cmdserver.log can't be (ab)used for this purpose. Instead, let's hook the
factory function to raise exception.
author | Yuya Nishihara <yuya@tcha.org> |
---|---|
date | Sat, 10 Nov 2018 18:16:33 +0900 |
parents | 96be0ecad648 |
children | 368ecbf734af |
files | tests/test-commandserver.t |
diffstat | 1 files changed, 13 insertions(+), 4 deletions(-) [+] |
line wrap: on
line diff
--- a/tests/test-commandserver.t Sun Nov 18 18:58:06 2018 +0900 +++ b/tests/test-commandserver.t Sat Nov 10 18:16:33 2018 +0900 @@ -846,9 +846,18 @@ if server crashed before hello, traceback will be sent to 'e' channel as last ditch: + $ cat <<'EOF' > ../earlycrasher.py + > from mercurial import commandserver, extensions + > def _serverequest(orig, ui, repo, conn, createcmdserver): + > def createcmdserver(*args, **kwargs): + > raise Exception('crash') + > return orig(ui, repo, conn, createcmdserver) + > def extsetup(ui): + > extensions.wrapfunction(commandserver, b'_serverequest', _serverequest) + > EOF $ cat <<EOF >> .hg/hgrc - > [cmdserver] - > log = inexistent/path.log + > [extensions] + > earlycrasher = ../earlycrasher.py > EOF >>> from hgclient import bprint, check, readchannel, unixserver >>> server = unixserver(b'.hg/server.sock', b'.hg/server.log') @@ -863,13 +872,13 @@ ... break >>> check(earlycrash, server.connect) e, 'Traceback (most recent call last):\n' - e, "(IOError|FileNotFoundError): .*" (re) + e, 'Exception: crash\n' >>> server.shutdown() $ cat .hg/server.log | grep -v '^ ' listening at .hg/server.sock Traceback (most recent call last): - (IOError|FileNotFoundError): .* (re) + Exception: crash killed! #endif #if no-unix-socket