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
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
|
"""
unittest.TestCase for tests with a static JavaScript runner file.
"""
from __future__ import absolute_import
from buildscripts.resmokelib import config
from buildscripts.resmokelib import core
from buildscripts.resmokelib import utils
from buildscripts.resmokelib.testing.testcases import interface
from buildscripts.resmokelib.utils import registry
class JSRunnerFileTestCase(interface.ProcessTestCase):
"""A test case with a static JavaScript runner file to execute."""
REGISTERED_NAME = registry.LEAVE_UNREGISTERED
def __init__(self,
logger,
test_kind,
test_name,
test_runner_file,
shell_executable=None,
shell_options=None):
"""Initializes the JSRunnerFileTestCase with the 'test_name' file."""
interface.ProcessTestCase.__init__(self, logger, test_kind, test_name)
# Command line options override the YAML configuration.
self.shell_executable = utils.default_if_none(config.MONGO_EXECUTABLE, shell_executable)
self.shell_options = utils.default_if_none(shell_options, {}).copy()
self.test_runner_file = test_runner_file
def configure(self, fixture, *args, **kwargs):
interface.ProcessTestCase.configure(self, fixture, *args, **kwargs)
global_vars = self.shell_options.get("global_vars", {}).copy()
test_data = global_vars.get("TestData", {}).copy()
self._populate_test_data(test_data)
global_vars["TestData"] = test_data
self.shell_options["global_vars"] = global_vars
def _populate_test_data(self, test_data):
"""
This method is intended to be overridden by subclasses in order to define the configuration
necessary for the static JavaScript runner file.
"""
pass
def _make_process(self):
return core.programs.mongo_shell_program(
self.logger,
executable=self.shell_executable,
connection_string=self.fixture.get_driver_connection_url(),
filename=self.test_runner_file,
**self.shell_options)
|