Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 15 additions & 6 deletions btest
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,12 @@ DEFAULT_CONFIG_NAME = "btest.cfg"

ConfigDefault = os.environ.get("BTEST_CFG", DEFAULT_CONFIG_NAME)

# These regexes have fixed patterns and are used in child processes, so they
# must be module-level constants to survive multiprocess spawn on Windows.
RE_INPUT = re.compile(r"%INPUT")
RE_DIR = re.compile(r"%DIR")
RE_ENV = re.compile(r"\$\{(\w+)}")


def normalize_path(path):
"""Ensures that paths on Windows convert backslashes to forward slashes, to
Expand Down Expand Up @@ -440,9 +446,6 @@ class TestManager(mp_managers.SyncManager):
mgr_data["Options"] = Options
mgr_data["TestBase"] = TestBase
mgr_data["TmpDir"] = TmpDir
mgr_data["RE_INPUT"] = RE_INPUT
mgr_data["RE_DIR"] = RE_DIR
mgr_data["RE_ENV"] = RE_ENV

output_handler.prepare(self)
self._output_handler = output_handler
Expand Down Expand Up @@ -567,6 +570,15 @@ class TestManager(mp_managers.SyncManager):
for global_key, global_value in mgr_data.items():
globals()[global_key] = global_value

# multiprocess/dill may reconstruct this method with its own globals
# dict, separate from the module-level globals used by functions like
# replaceEnvs. Also set globals in __mp_main__, which is where
# multiprocess imports the script in spawned child processes.
mp_main = sys.modules.get("__mp_main__")
if mp_main is not None:
for global_key, global_value in mgr_data.items():
setattr(mp_main, global_key, global_value)

while True:
# Pull the next test from the list that was built at startup. This may
# be more than one test if there were alternatives requested in the
Expand Down Expand Up @@ -3275,9 +3287,6 @@ if __name__ == "__main__":

CommandPrefix = getOption("CommandPrefix", "@TEST-")

RE_INPUT = re.compile(r"%INPUT")
RE_DIR = re.compile(r"%DIR")
RE_ENV = re.compile(r"\$\{(\w+)}")
RE_PART = re.compile(r"^(.*)#([0-9]+)$")
RE_IGNORE = re.compile(CommandPrefix + "IGNORE")
RE_START_NEXT_TEST = re.compile(CommandPrefix + "START-NEXT")
Expand Down
Loading