merge from development

Signed-off-by: sweeneys <sweeneys@amazon.com>
This commit is contained in:
sweeneys
2021-11-12 14:47:08 -08:00
1676 changed files with 212117 additions and 6819 deletions
@@ -378,7 +378,7 @@ class AbstractResourceLocator(object):
def editor_log(self):
"""
Return path to the project's editor log dir using the builds project and platform
:return: path to editor.log
:return: path to Editor.log
"""
raise NotImplementedError(
"editor_log() is not implemented on the base AbstractResourceLocator() class. "
@@ -49,9 +49,9 @@ class _LinuxResourceManager(AbstractResourceLocator):
def editor_log(self):
"""
:return: path to editor.log
:return: path to Editor.log
"""
return os.path.join(self.project_log(), "editor.log")
return os.path.join(self.project_log(), "Editor.log")
class LinuxWorkspaceManager(AbstractWorkspaceManager):
@@ -58,9 +58,9 @@ class _MacResourceLocator(AbstractResourceLocator):
def editor_log(self):
"""
Return path to the project's editor log dir using the builds project and platform
:return: path to editor.log
:return: path to Editor.log
"""
return os.path.join(self.project_log(), "editor.log")
return os.path.join(self.project_log(), "Editor.log")
class MacWorkspaceManager(AbstractWorkspaceManager):
@@ -64,9 +64,9 @@ class _WindowsResourceLocator(AbstractResourceLocator):
def editor_log(self):
"""
Return path to the project's editor log dir using the builds project and platform
:return: path to editor.log
:return: path to Editor.log
"""
return os.path.join(self.project_log(), "editor.log")
return os.path.join(self.project_log(), "Editor.log")
class WindowsWorkspaceManager(AbstractWorkspaceManager):
@@ -219,7 +219,8 @@ def unlock_file(file_name):
:return: True if unlock succeeded, else False
"""
if not os.access(file_name, os.W_OK):
os.chmod(file_name, stat.S_IWRITE)
file_stat = os.stat(file_name)
os.chmod(file_name, file_stat.st_mode | stat.S_IWRITE)
logger.warning(f'Clearing write lock for file {file_name}.')
return True
else:
@@ -235,7 +236,8 @@ def lock_file(file_name):
:return: True if lock succeeded, else False
"""
if os.access(file_name, os.W_OK):
os.chmod(file_name, stat.S_IREAD)
file_stat = os.stat(file_name)
os.chmod(file_name, file_stat.st_mode & (~stat.S_IWRITE))
logger.warning(f'Write locking file {file_name}')
return True
else:
@@ -416,13 +416,8 @@ class AssetProcessor(object):
self.restore_ap_settings()
def process_exists(self):
try:
my_pid = self.get_pid()
if my_pid == -1:
return False
return psutil.pid_exists(my_pid)
except psutil.NoSuchProcess:
pass
if self._ap_proc:
return self._ap_proc.poll() is None
return False
def batch_process(self, timeout=DEFAULT_TIMEOUT_SECONDS, fastscan=True, capture_output=False, platforms=None,
@@ -126,9 +126,9 @@ def retrieve_editor_log_content(run_id: int, log_name: str, workspace: AbstractW
with open(editor_log) as f:
editor_info = ""
for line in f:
editor_info += f"[editor.log] {line}"
editor_info += f"[{log_name}] {line}"
except Exception as ex:
editor_info = f"-- Error reading editor.log: {str(ex)} --"
editor_info = f"-- Error reading {log_name}: {str(ex)} --"
return editor_info
def retrieve_last_run_test_index_from_output(test_spec_list: list[EditorTestBase], output: str) -> int:
@@ -119,7 +119,7 @@ class TestEditorTestUtils(unittest.TestCase):
mock_log = 'mock log info'
with mock.patch('builtins.open', mock.mock_open(read_data=mock_log)) as mock_file:
assert f'[editor.log] {mock_log}' == editor_test_utils.retrieve_editor_log_content(0, mock_logname, mock_workspace)
assert f'[{mock_logname}] {mock_log}' == editor_test_utils.retrieve_editor_log_content(0, mock_logname, mock_workspace)
@mock.patch('ly_test_tools.o3de.editor_test_utils.retrieve_log_path')
@mock.patch('ly_test_tools.environment.waiter.wait_for', mock.MagicMock())
@@ -127,7 +127,7 @@ class TestEditorTestUtils(unittest.TestCase):
mock_retrieve_log_path.return_value = 'mock_log_path'
mock_logname = 'mock_log.log'
mock_workspace = mock.MagicMock()
expected = f"-- Error reading editor.log"
expected = f"-- Error reading {mock_logname}"
assert expected in editor_test_utils.retrieve_editor_log_content(0, mock_logname, mock_workspace)
@@ -8,6 +8,7 @@ SPDX-License-Identifier: Apache-2.0 OR MIT
import errno
import logging
import os
import stat
import psutil
import subprocess
import sys
@@ -454,24 +455,33 @@ class TestChangePermissions(unittest.TestCase):
self.assertEqual(file_system.change_permissions('.', 0o777), False)
class MockStatResult():
def __init__(self, st_mode):
self.st_mode = st_mode
class TestUnlockFile(unittest.TestCase):
def setUp(self):
self.file_name = 'file'
@mock.patch('os.stat')
@mock.patch('os.chmod')
@mock.patch('os.access')
def test_UnlockFile_WriteLocked_UnlockFile(self, mock_access, mock_chmod):
def test_UnlockFile_WriteLocked_UnlockFile(self, mock_access, mock_chmod, mock_stat):
mock_access.return_value = False
os.stat.return_value = MockStatResult(stat.S_IREAD)
success = file_system.unlock_file(self.file_name)
mock_chmod.assert_called_once_with(self.file_name, stat.S_IREAD | stat.S_IWRITE)
self.assertTrue(success)
@mock.patch('os.stat')
@mock.patch('os.chmod')
@mock.patch('os.access')
def test_UnlockFile_AlreadyUnlocked_LogAlreadyUnlocked(self, mock_access, mock_chmod):
def test_UnlockFile_AlreadyUnlocked_LogAlreadyUnlocked(self, mock_access, mock_chmod, mock_stat):
mock_access.return_value = True
os.stat.return_value = MockStatResult(stat.S_IREAD | stat.S_IWRITE)
success = file_system.unlock_file(self.file_name)
@@ -483,19 +493,24 @@ class TestLockFile(unittest.TestCase):
def setUp(self):
self.file_name = 'file'
@mock.patch('os.stat')
@mock.patch('os.chmod')
@mock.patch('os.access')
def test_UnlockFile_UnlockedFile_FileLockedSuccessReturnsTrue(self, mock_access, mock_chmod):
def test_LockFile_UnlockedFile_FileLockedSuccessReturnsTrue(self, mock_access, mock_chmod, mock_stat):
mock_access.return_value = True
os.stat.return_value = MockStatResult(stat.S_IREAD | stat.S_IWRITE)
success = file_system.lock_file(self.file_name)
mock_chmod.assert_called_once_with(self.file_name, stat.S_IREAD)
self.assertTrue(success)
@mock.patch('os.stat')
@mock.patch('os.chmod')
@mock.patch('os.access')
def test_UnlockFile_AlreadyLocked_FileLockedFailedReturnsFalse(self, mock_access, mock_chmod):
def test_LockFile_AlreadyLocked_FileLockedFailedReturnsFalse(self, mock_access, mock_chmod, mock_stat):
mock_access.return_value = False
os.stat.return_value = MockStatResult(stat.S_IREAD)
success = file_system.lock_file(self.file_name)
@@ -76,7 +76,7 @@ class TestMacResourceLocator(object):
mock_project)
expected = os.path.join(
mac_resource_locator.project_log(),
'editor.log')
'Editor.log')
assert mac_resource_locator.editor_log() == expected
@@ -80,7 +80,7 @@ class TestWindowsResourceLocator(object):
mock_build_directory, mock_project)
expected = os.path.join(
windows_resource_locator.project_log(),
'editor.log')
'Editor.log')
assert windows_resource_locator.editor_log() == expected