Merge pull request #6795 from aws-lumberyard-dev/scspaldi_lytt_improvements
Changed kill to protected.
This commit is contained in:
@@ -78,7 +78,7 @@ class TestAutomationBase:
|
||||
file_system.restore_backup(workspace.paths.editor_log(), workspace.paths.project_log())
|
||||
except FileNotFoundError as e:
|
||||
self.logger.debug(f"File restoration failed, editor log could not be found.\nError: {e}")
|
||||
editor.kill()
|
||||
editor.stop()
|
||||
|
||||
request.addfinalizer(teardown)
|
||||
|
||||
@@ -113,7 +113,7 @@ class TestAutomationBase:
|
||||
editor.wait(TestAutomationBase.MAX_TIMEOUT)
|
||||
except WaitTimeoutError:
|
||||
errors.append(TestRunError("TIMEOUT", f"Editor did not close after {TestAutomationBase.MAX_TIMEOUT} seconds, verify the test is ending and the application didn't freeze"))
|
||||
editor.kill()
|
||||
editor.stop()
|
||||
|
||||
output = editor.get_output()
|
||||
self.logger.debug("Test output:\n" + output)
|
||||
|
||||
@@ -280,7 +280,7 @@ class AndroidLauncher(Launcher):
|
||||
return True
|
||||
return False
|
||||
|
||||
def kill(self):
|
||||
def _kill(self):
|
||||
"""
|
||||
Attempts to force quit any running processes with the stored package name on the device
|
||||
that is set to self._device_id via the self._adb_prefix_command
|
||||
|
||||
@@ -208,7 +208,7 @@ class Launcher(object):
|
||||
|
||||
:return None:
|
||||
"""
|
||||
self.kill()
|
||||
self._kill()
|
||||
self.ensure_stopped()
|
||||
self.teardown()
|
||||
|
||||
@@ -228,7 +228,7 @@ class Launcher(object):
|
||||
"""
|
||||
raise NotImplementedError("Launch is not implemented")
|
||||
|
||||
def kill(self):
|
||||
def _kill(self):
|
||||
"""
|
||||
Force stop the launcher.
|
||||
|
||||
@@ -274,7 +274,7 @@ class Launcher(object):
|
||||
timeout=timeout
|
||||
)
|
||||
except ly_test_tools.launchers.exceptions.TeardownError:
|
||||
self.kill()
|
||||
self._kill()
|
||||
|
||||
def get_device_config(self, config_file, device_section, device_key):
|
||||
"""
|
||||
|
||||
@@ -89,7 +89,7 @@ class LinuxLauncher(Launcher):
|
||||
self.restore_settings()
|
||||
super(LinuxLauncher, self).teardown()
|
||||
|
||||
def kill(self):
|
||||
def _kill(self):
|
||||
"""
|
||||
This is a hard kill, and then wait to make sure until it actually ended.
|
||||
|
||||
|
||||
@@ -44,7 +44,7 @@ class MacLauncher(Launcher):
|
||||
self._proc = subprocess.Popen(command)
|
||||
log.debug(f"Started Mac Launcher with command: {command}")
|
||||
|
||||
def kill(self):
|
||||
def _kill(self):
|
||||
"""
|
||||
This is a hard kill, and then wait to make sure until it actually ended.
|
||||
|
||||
|
||||
@@ -89,7 +89,7 @@ class WinLauncher(Launcher):
|
||||
self.restore_settings()
|
||||
super(WinLauncher, self).teardown()
|
||||
|
||||
def kill(self):
|
||||
def _kill(self):
|
||||
"""
|
||||
This is a hard kill, and then wait to make sure until it actually ended.
|
||||
|
||||
|
||||
@@ -789,7 +789,7 @@ class EditorTestSuite():
|
||||
test_result = Result.Fail.create(test_spec, output, editor_log_content)
|
||||
except WaitTimeoutError:
|
||||
output = editor.get_output()
|
||||
editor.kill()
|
||||
editor.stop()
|
||||
editor_log_content = editor_utils.retrieve_editor_log_content(run_id, log_name, workspace)
|
||||
test_result = Result.Timeout.create(test_spec, output, test_spec.timeout, editor_log_content)
|
||||
|
||||
@@ -891,7 +891,7 @@ class EditorTestSuite():
|
||||
results[test_spec_name] = Result.Crash.create(crashed_result.test_spec, output, return_code,
|
||||
crash_error, crashed_result.editor_log)
|
||||
except WaitTimeoutError:
|
||||
editor.kill()
|
||||
editor.stop()
|
||||
output = editor.get_output()
|
||||
editor_log_content = editor_utils.retrieve_editor_log_content(run_id, log_name, workspace)
|
||||
|
||||
|
||||
@@ -308,9 +308,11 @@ class TestAndroidLauncher:
|
||||
def test_Kill_HappyPath_KillCommandSuccess(self, mock_config, mock_call):
|
||||
mock_config.return_value = VALID_ANDROID_CONFIG
|
||||
mock_workspace = MockedWorkspace()
|
||||
|
||||
launcher = ly_test_tools.launchers.AndroidLauncher(mock_workspace, ["dummy"])
|
||||
launcher.kill()
|
||||
|
||||
# This is a direct call to a protected method, but the point of the test is to ensure functionality of this
|
||||
# protected method, so we will allow this exception
|
||||
launcher._kill()
|
||||
|
||||
mock_call.assert_called_once_with(
|
||||
['adb', '-s', VALID_ANDROID_CONFIG['android']['id'], 'shell', 'am', 'force-stop', PACKAGE_NAME])
|
||||
|
||||
@@ -52,7 +52,7 @@ class TestBaseLauncher:
|
||||
def test_Kill_Unimplemented_NotImplementedError(self):
|
||||
launcher = self.test_Construct_TestDoubles_BaseLauncherCreated()
|
||||
with pytest.raises(NotImplementedError):
|
||||
launcher.kill()
|
||||
launcher.stop()
|
||||
|
||||
def test_Launch_Unimplemented_NotImplementedError(self):
|
||||
launcher = self.test_Construct_TestDoubles_BaseLauncherCreated()
|
||||
@@ -111,7 +111,7 @@ class TestBaseLauncher:
|
||||
with pytest.raises(NotImplementedError):
|
||||
launcher.stop()
|
||||
|
||||
@mock.patch('ly_test_tools.launchers.platforms.base.Launcher.kill')
|
||||
@mock.patch('ly_test_tools.launchers.platforms.base.Launcher._kill')
|
||||
@mock.patch('ly_test_tools.launchers.platforms.base.Launcher.ensure_stopped')
|
||||
@mock.patch('ly_test_tools.launchers.platforms.base.Launcher.teardown')
|
||||
def test_Stop_MockImplementedLauncher_KillTeardown(self, mock_teardown, mock_ensure, mock_kill):
|
||||
|
||||
@@ -57,7 +57,7 @@ class TestLinuxLauncher(object):
|
||||
launcher = ly_test_tools.launchers.LinuxLauncher(mock.MagicMock(), ["dummy"])
|
||||
launcher._proc = mock_proc
|
||||
|
||||
launcher.kill()
|
||||
launcher.stop()
|
||||
|
||||
mock_proc.kill.assert_called_once()
|
||||
mock_alive.assert_called_once()
|
||||
mock_alive.assert_called()
|
||||
|
||||
@@ -62,7 +62,7 @@ class TestMacLauncher(object):
|
||||
launcher = ly_test_tools.launchers.MacLauncher(mock.MagicMock(), ["dummy"])
|
||||
launcher._proc = mock_proc
|
||||
|
||||
launcher.kill()
|
||||
launcher.stop()
|
||||
|
||||
mock_proc.kill.assert_called_once()
|
||||
mock_alive.assert_called_once()
|
||||
mock_alive.assert_called()
|
||||
|
||||
@@ -56,10 +56,10 @@ class TestWinLauncher(object):
|
||||
launcher = ly_test_tools.launchers.WinLauncher(mock.MagicMock(), ["dummy"])
|
||||
launcher._proc = mock_proc
|
||||
|
||||
launcher.kill()
|
||||
launcher.stop()
|
||||
|
||||
mock_proc.kill.assert_called_once()
|
||||
mock_alive.assert_called_once()
|
||||
mock_alive.assert_called()
|
||||
|
||||
def test_IsAlive_NoProc_False(self):
|
||||
launcher = ly_test_tools.launchers.WinLauncher(mock.MagicMock(), ["dummy"])
|
||||
|
||||
@@ -694,7 +694,7 @@ class TestRunningTests(unittest.TestCase):
|
||||
'mock_log_name', mock_test_spec, [])
|
||||
assert mock_cycle_crash.called
|
||||
assert mock_editor.start.called
|
||||
assert mock_editor.kill.called
|
||||
assert mock_editor.stop.called
|
||||
assert mock_create.called
|
||||
assert results == {mock_test_spec.__name__: mock_timeout}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user