From 757a26825ac5a4e09892a9af817c45a13eb44552 Mon Sep 17 00:00:00 2001 From: jromnoa Date: Mon, 10 May 2021 16:27:30 -0700 Subject: [PATCH] adds new HOST_OS_GENERIC_EXECUTABLE constant and adds error handling if the executable doesn't exist in the path provided --- Tools/LyTestTools/ly_test_tools/__init__.py | 1 + .../_internal/pytest_plugin/test_tools_fixtures.py | 4 ++-- .../ly_test_tools/launchers/launcher_helper.py | 2 +- .../launchers/platforms/win/launcher.py | 13 +++++++++++-- 4 files changed, 15 insertions(+), 5 deletions(-) diff --git a/Tools/LyTestTools/ly_test_tools/__init__.py b/Tools/LyTestTools/ly_test_tools/__init__.py index febb89b541..d534f5e0d2 100755 --- a/Tools/LyTestTools/ly_test_tools/__init__.py +++ b/Tools/LyTestTools/ly_test_tools/__init__.py @@ -37,6 +37,7 @@ if WINDOWS: HOST_OS_PLATFORM = 'windows' HOST_OS_EDITOR = 'windows_editor' HOST_OS_DEDICATED_SERVER = 'windows_dedicated' + HOST_OS_GENERIC_EXECUTABLE = 'windows_generic' import ly_test_tools.mobile.android from ly_test_tools.launchers import ( AndroidLauncher, WinLauncher, DedicatedWinLauncher, WinEditor, WinGenericLauncher) 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 c3a9ffdc22..dc2e92f518 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_GENERIC_EXECUTABLE logger = logging.getLogger(__name__) @@ -287,7 +287,7 @@ def generic_launcher(workspace, request, crash_log_watchdog): # type: (...) -> ly_test_tools.launchers.platforms.base.Launcher return _generic_launcher( workspace=workspace, - launcher_platform=get_fixture_argument(request, 'launcher_platform', HOST_OS_PLATFORM), + launcher_platform=get_fixture_argument(request, 'launcher_platform', HOST_OS_GENERIC_EXECUTABLE), exe_file_name=get_fixture_argument(request, 'exe_file_name', '')) diff --git a/Tools/LyTestTools/ly_test_tools/launchers/launcher_helper.py b/Tools/LyTestTools/ly_test_tools/launchers/launcher_helper.py index 63b1eac1d3..45f5e6e73f 100755 --- a/Tools/LyTestTools/ly_test_tools/launchers/launcher_helper.py +++ b/Tools/LyTestTools/ly_test_tools/launchers/launcher_helper.py @@ -75,5 +75,5 @@ def create_generic_launcher(workspace, launcher_platform, exe_file_name, args=No :param args: List of arguments to pass to the launcher's 'args' argument during construction :return: Launcher instance. """ - launcher_class = ly_test_tools.LAUNCHERS.get(launcher_platform, ly_test_tools.HOST_OS_PLATFORM) + launcher_class = ly_test_tools.LAUNCHERS.get(launcher_platform, ly_test_tools.HOST_OS_GENERIC_EXECUTABLE) return launcher_class(workspace, exe_file_name, args) 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 492af0e612..ebb3566806 100755 --- a/Tools/LyTestTools/ly_test_tools/launchers/platforms/win/launcher.py +++ b/Tools/LyTestTools/ly_test_tools/launchers/platforms/win/launcher.py @@ -210,12 +210,21 @@ class WinGenericLauncher(WinLauncher): def __init__(self, build, exe_file_name, args=None): super(WinGenericLauncher, self).__init__(build, args) self.exe_file_name = exe_file_name + self.expected_executable_path = os.path.join( + self.workspace.paths.build_directory(), f"{self.exe_file_name}.exe") + + if not os.path.exists(self.expected_executable_path): + raise ProcessNotStartedError( + f"Unable to locate executable '{self.exe_file_name}.exe' " + f"in path: '{self.expected_executable_path}'") def binary_path(self): """ Return full path to the .exe file for this build's configuration and project + Relies on the build_directory() in self.workspace.paths to be accurate :return: full path to the given exe file """ - assert self.workspace.project is not None - return os.path.join(self.workspace.paths.build_directory(), f"{self.exe_file_name}.exe") + assert self.workspace.project is not None, ( + 'Project cannot be NoneType - please specify a project name string.') + return self.expected_executable_path