Patchwork [2,of,8] test-commandserver: change way of triggering early crash

login
register
mail settings
Submitter Yuya Nishihara
Date Dec. 4, 2018, 1:24 p.m.
Message ID <168b9226865275da15d0.1543929856@mimosa>
Download mbox | patch
Permalink /patch/36949/
State Accepted
Headers show

Comments

Yuya Nishihara - Dec. 4, 2018, 1:24 p.m.
# HG changeset patch
# User Yuya Nishihara <yuya@tcha.org>
# Date 1541841393 -32400
#      Sat Nov 10 18:16:33 2018 +0900
# Node ID 168b9226865275da15d00ac3aee11463381f427e
# Parent  b740d4b4a1af3d2c4325973be876acb87f3fa1ae
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.

Patch

diff --git a/tests/test-commandserver.t b/tests/test-commandserver.t
--- a/tests/test-commandserver.t
+++ b/tests/test-commandserver.t
@@ -846,9 +846,18 @@  unix domain socket:
  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 @@  unix domain socket:
   ...             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