tests/hgweberror.py
author Siddharth Agarwal <sid0@fb.com>
Sat, 10 Jun 2017 14:07:30 -0700
changeset 32769 efd6e941e933
parent 27299 74e6de99ce7f
child 36865 3d60a22e27f5
permissions -rw-r--r--
tests: add a wrapper to run fsmonitor tests This script does a bunch of non-trivial configuration work: in particular, it sets up an isolated instance of Watchman which isn't affected by global state and can be torn down on completion. This script also sets the HGFSMONITOR_TESTS environment variable, which hghave will use in the next patch to allow gating on whether fsmonitor is enabled. With fsmonitor enabled, there appear to be a number of failures in the test suite. It's not yet clear to me why they're happening, but if someone would like to jump in and fix some of them I hope this will be helpful for that.

# A dummy extension that installs an hgweb command that throws an Exception.

from __future__ import absolute_import

from mercurial.hgweb import (
    webcommands,
)

def raiseerror(web, req, tmpl):
    '''Dummy web command that raises an uncaught Exception.'''

    # Simulate an error after partial response.
    if 'partialresponse' in req.form:
        req.respond(200, 'text/plain')
        req.write('partial content\n')

    raise AttributeError('I am an uncaught error!')

def extsetup(ui):
    setattr(webcommands, 'raiseerror', raiseerror)
    webcommands.__all__.append('raiseerror')