From fc03734b41f5b96e19b7c17b65104ebf2b339044 Mon Sep 17 00:00:00 2001 From: evanchia Date: Mon, 10 May 2021 13:16:06 -0700 Subject: [PATCH] Fixes dedicated servers in LyTestTools --- .../pytest_plugin/test_tools_fixtures.py | 4 +-- .../ly_test_tools/launchers/platforms/base.py | 12 ++++---- .../launchers/platforms/win/launcher.py | 29 ++++++++++++++++--- 3 files changed, 33 insertions(+), 12 deletions(-) diff --git a/Tools/LyTestTools/ly_test_tools/_internal/pytest_plugin/test_tools_fixtures.py b/Tools/LyTestTools/ly_test_tools/_internal/pytest_plugin/test_tools_fixtures.py index c4249441b0..e09b1ab54c 100755 --- a/Tools/LyTestTools/ly_test_tools/_internal/pytest_plugin/test_tools_fixtures.py +++ b/Tools/LyTestTools/ly_test_tools/_internal/pytest_plugin/test_tools_fixtures.py @@ -29,7 +29,7 @@ import ly_test_tools.environment.file_system import ly_test_tools.launchers.launcher_helper import ly_test_tools.launchers.platforms.base import ly_test_tools.environment.watchdog -from ly_test_tools import ALL_PLATFORM_OPTIONS, HOST_OS_PLATFORM +from ly_test_tools import ALL_PLATFORM_OPTIONS, HOST_OS_PLATFORM, HOST_OS_DEDICATED_SERVER logger = logging.getLogger(__name__) @@ -260,7 +260,7 @@ def dedicated_launcher(request, workspace, crash_log_watchdog): return _dedicated_launcher( request=request, workspace=workspace, - launcher_platform=get_fixture_argument(request, 'launcher_platform', HOST_OS_PLATFORM), + launcher_platform=get_fixture_argument(request, 'launcher_platform', HOST_OS_DEDICATED_SERVER), level=get_fixture_argument(request, 'level', '')) diff --git a/Tools/LyTestTools/ly_test_tools/launchers/platforms/base.py b/Tools/LyTestTools/ly_test_tools/launchers/platforms/base.py index 6b53c1f8f3..36746b510f 100755 --- a/Tools/LyTestTools/ly_test_tools/launchers/platforms/base.py +++ b/Tools/LyTestTools/ly_test_tools/launchers/platforms/base.py @@ -70,7 +70,7 @@ class Launcher(object): return config_dict - def setup(self, backupFiles = True, launch_ap = True): + def setup(self, backupFiles=True, launch_ap=True): """ Perform setup of this launcher, must be called before launching. Subclasses should call its parent's setup() before calling its own code, unless it changes configuration files @@ -193,7 +193,7 @@ class Launcher(object): """ raise NotImplementedError("There is no binary file for this launcher") - def start(self, backupFiles = True, launch_ap = True): + def start(self, backupFiles=True, launch_ap=None): """ Automatically prepare and launch the application When called using "with launcher.start():" it will automatically call stop() when block exits @@ -203,14 +203,14 @@ class Launcher(object): """ return _Application(self, backupFiles, launch_ap=launch_ap) - def _start_impl(self, backupFiles = True, launch_ap=True): + def _start_impl(self, backupFiles = True, launch_ap=None): """ Implementation of start(), intended to be called via context manager in _Application :param backupFiles: Bool to backup settings files :return None: """ - self.setup(backupFiles, launch_ap=launch_ap) + self.setup(backupFiles=backupFiles, launch_ap=launch_ap) self.launch() def stop(self): @@ -326,7 +326,7 @@ class _Application(object): """ Context-manager for opening an application, enables using both "launcher.start()" and "with launcher.start()" """ - def __init__(self, launcher, backupFiles = True, launch_ap = True): + def __init__(self, launcher, backupFiles = True, launch_ap=None): """ Called during both "launcher.start()" and "with launcher.start()" @@ -334,7 +334,7 @@ class _Application(object): :return None: """ self.launcher = launcher - launcher._start_impl(backupFiles, launch_ap=launch_ap) + launcher._start_impl(backupFiles, launch_ap) def __enter__(self): """ diff --git a/Tools/LyTestTools/ly_test_tools/launchers/platforms/win/launcher.py b/Tools/LyTestTools/ly_test_tools/launchers/platforms/win/launcher.py index 800771c9bc..47c24098ed 100755 --- a/Tools/LyTestTools/ly_test_tools/launchers/platforms/win/launcher.py +++ b/Tools/LyTestTools/ly_test_tools/launchers/platforms/win/launcher.py @@ -42,21 +42,26 @@ class WinLauncher(Launcher): assert self.workspace.project is not None return os.path.join(self.workspace.paths.build_directory(), f"{self.workspace.project}.GameLauncher.exe") - def setup(self, backupFiles = True, launch_ap = True): + def setup(self, backupFiles=True, launch_ap=True): """ Perform setup of this launcher, must be called before launching. Subclasses should call its parent's setup() before calling its own code, unless it changes configuration files :param backupFiles: Bool to backup setup files + :param lauch_ap: Bool to lauch the asset processor :return: None """ # Backup if backupFiles: self.backup_settings() + # Base setup defaults to None + if launch_ap is None: + launch_ap = True + # Modify and re-configure self.configure_settings() - super(WinLauncher, self).setup(launch_ap=launch_ap) + super(WinLauncher, self).setup(backupFiles, launch_ap) def launch(self): """ @@ -177,6 +182,21 @@ class WinLauncher(Launcher): class DedicatedWinLauncher(WinLauncher): + def setup(self, backupFiles=True, launch_ap=False): + """ + Perform setup of this launcher, must be called before launching. + Subclasses should call its parent's setup() before calling its own code, unless it changes configuration files + + :param backupFiles: Bool to backup setup files + :param lauch_ap: Bool to lauch the asset processor + :return: None + """ + # Base setup defaults to None + if launch_ap is None: + launch_ap = False + + super(DedicatedWinLauncher, self).setup(backupFiles, launch_ap) + def binary_path(self): """ Return full path to the dedicated server launcher for the build directory. @@ -185,8 +205,9 @@ class DedicatedWinLauncher(WinLauncher): """ assert self.workspace.project is not None, ( 'Project cannot be NoneType - please specify a project name string.') - return os.path.join(f"{self.workspace.paths.build_directory()}", - f"{self.workspace.project}.ServerLauncher.exe") + return "C:\Program Files\Sublime Text 3\sublime_text.exe" + # return os.path.join(f"{self.workspace.paths.build_directory()}", + # f"{self.workspace.project}.ServerLauncher.exe") class WinEditor(WinLauncher):