summaryrefslogtreecommitdiff
path: root/buildscripts/resmokelib/testing/testcases/gennylib_test.py
blob: 96eb08c6cb584edd92abf6c9826fcb0138ab16fb (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
"""The unittest.TestCase for gennylib integration tests."""

from . import interface
from ... import core
from ... import utils


class GennyLibTestCase(interface.ProcessTestCase):
    """A gennylib integration test to be executed.

    The fixture connection string is passed as an environment variable.
    """

    REGISTERED_NAME = "gennylib_test"

    def __init__(self, logger, test_name, program_executable=None, verbatim_arguments=None):
        """
        Initialize the GennyLibTestCase with the executable to run.

        @param verbatim_arguments: list of arguments that are passed through without
            processing by resmoke. This is necessary because Catch2 requires positional arguments
            and CTest can't use resmoke's version of "=" separated keyword arguments.
        """

        interface.ProcessTestCase.__init__(self, logger, "gennylib test", program_executable)

        self.program_executable = program_executable
        self.program_options = {}
        self.verbatim_arguments = utils.default_if_none(verbatim_arguments, [])[:]

    def configure(self, fixture, *args, **kwargs):
        """Configure the test case."""
        interface.ProcessTestCase.configure(self, fixture, *args, **kwargs)

        env_vars = {"MONGO_CONNECTION_STRING": self.fixture.get_driver_connection_url()}
        process_kwargs = {"env_vars": env_vars}
        self.program_options["process_kwargs"] = process_kwargs

    def _make_process(self):
        return core.programs.generic_program(self.logger,
                                             [self.program_executable] + self.verbatim_arguments,
                                             **self.program_options)