Changeset 0909c92 in mod_gnutls for test/runtest.py


Ignore:
Timestamp:
Dec 27, 2019, 12:40:51 PM (17 months ago)
Author:
Fiona Klute <fiona.klute@…>
Branches:
asyncio, master, proxy-ticket
Children:
3039495
Parents:
05984a0
Message:

Add hooks system to the test runner

With this all tests can use runtest.py to set up their
environment. Note that at the moment only the run_connection hook is
implemented.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • test/runtest.py

    r05984a0 r0909c92  
    2222import sys
    2323
     24import mgstest.hooks
    2425from mgstest import lockfile, TestExpectationFailed
    2526from mgstest.services import ApacheService, TestService
     
    110111    os.environ['TEST_NAME'] = testname
    111112
     113    # Load test case hooks (if any)
     114    plugin_path = os.path.join(testdir, 'hooks.py')
     115    plugin = mgstest.hooks.load_hooks_plugin(plugin_path)
     116
    112117    # PID file name varies depending on whether we're using
    113118    # namespaces.
     
    187192        # Run the test connections
    188193        with contextlib.ExitStack() as stack:
    189             test_conf = stack.enter_context(
    190                 open(os.path.join(testdir, 'test.yml'), 'r'))
    191194            log_file = None
    192195            output_file = None
     
    196199                output_file = stack.enter_context(open(args.log_responses, 'w'))
    197200
    198             run_test_conf(test_conf,
    199                           float(os.environ.get('TEST_QUERY_TIMEOUT', 5.0)),
    200                           conn_log=log_file, response_log=output_file)
     201            if plugin.run_connection:
     202                plugin.run_connection(testname,
     203                                      conn_log=log_file,
     204                                      response_log=output_file)
     205            else:
     206                test_conf = stack.enter_context(
     207                    open(os.path.join(testdir, 'test.yml'), 'r'))
     208                run_test_conf(test_conf,
     209                              float(os.environ.get('TEST_QUERY_TIMEOUT', 5.0)),
     210                              conn_log=log_file, response_log=output_file)
    201211
    202212        # TODO: add hook to replace the test request, e.g. for curl
Note: See TracChangeset for help on using the changeset viewer.