diff --git a/AutomatedTesting/Gem/PythonTests/physics/TestSuite_Periodic.py b/AutomatedTesting/Gem/PythonTests/physics/TestSuite_Periodic.py index 2b82c3e596..291bb96627 100755 --- a/AutomatedTesting/Gem/PythonTests/physics/TestSuite_Periodic.py +++ b/AutomatedTesting/Gem/PythonTests/physics/TestSuite_Periodic.py @@ -93,11 +93,13 @@ class TestAutomation(TestAutomationBase): self._run_test(request, workspace, editor, test_module) @revert_physics_config + @fm.file_override('physxsystemconfiguration.setreg','C4044457_Material_RestitutionCombine.setreg_override', 'AutomatedTesting/Registry') def test_C4044457_Material_RestitutionCombine(self, request, workspace, editor, launcher_platform): from . import C4044457_Material_RestitutionCombine as test_module self._run_test(request, workspace, editor, test_module) @revert_physics_config + @fm.file_override('physxsystemconfiguration.setreg','C4044456_Material_FrictionCombine.setreg_override', 'AutomatedTesting/Registry') def test_C4044456_Material_FrictionCombine(self, request, workspace, editor, launcher_platform): from . import C4044456_Material_FrictionCombine as test_module self._run_test(request, workspace, editor, test_module) @@ -194,6 +196,7 @@ class TestAutomation(TestAutomationBase): self._run_test(request, workspace, editor, test_module) @revert_physics_config + @fm.file_override('physxsystemconfiguration.setreg','C18981526_Material_RestitutionCombinePriority.setreg_override', 'AutomatedTesting/Registry') def test_C18981526_Material_RestitutionCombinePriority(self, request, workspace, editor, launcher_platform): from . import C18981526_Material_RestitutionCombinePriority as test_module self._run_test(request, workspace, editor, test_module) @@ -229,6 +232,7 @@ class TestAutomation(TestAutomationBase): self._run_test(request, workspace, editor, test_module) @revert_physics_config + @fm.file_override('physxsystemconfiguration.setreg','C18977601_Material_FrictionCombinePriority.setreg_override', 'AutomatedTesting/Registry') def test_C18977601_Material_FrictionCombinePriority(self, request, workspace, editor, launcher_platform): from . import C18977601_Material_FrictionCombinePriority as test_module self._run_test(request, workspace, editor, test_module) @@ -250,6 +254,7 @@ class TestAutomation(TestAutomationBase): @pytest.mark.xfail( reason="This test needs new physics asset with multiple materials to be more stable.") @revert_physics_config + @fm.file_override('physxsystemconfiguration.setreg','C4044697_Material_PerfaceMaterialValidation.setreg_override', 'AutomatedTesting/Registry') def test_C4044697_Material_PerfaceMaterialValidation(self, request, workspace, editor, launcher_platform): from . import C4044697_Material_PerfaceMaterialValidation as test_module self._run_test(request, workspace, editor, test_module) @@ -282,6 +287,7 @@ class TestAutomation(TestAutomationBase): self._run_test(request, workspace, editor, test_module) @revert_physics_config + @fm.file_override('physxsystemconfiguration.setreg','C15556261_PhysXMaterials_CharacterControllerMaterialAssignment.setreg_override', 'AutomatedTesting/Registry') def test_C15556261_PhysXMaterials_CharacterControllerMaterialAssignment(self, request, workspace, editor, launcher_platform): from . import C15556261_PhysXMaterials_CharacterControllerMaterialAssignment as test_module self._run_test(request, workspace, editor, test_module) @@ -326,6 +332,7 @@ class TestAutomation(TestAutomationBase): self._run_test(request, workspace, editor, test_module) @revert_physics_config + @fm.file_override('physxsystemconfiguration.setreg','C4044461_Material_Restitution.setreg_override', 'AutomatedTesting/Registry') def test_C4044461_Material_Restitution(self, request, workspace, editor, launcher_platform): from . import C4044461_Material_Restitution as test_module self._run_test(request, workspace, editor, test_module) diff --git a/AutomatedTesting/Registry/C15556261_PhysXMaterials_CharacterControllerMaterialAssignment.setreg_override b/AutomatedTesting/Registry/C15556261_PhysXMaterials_CharacterControllerMaterialAssignment.setreg_override new file mode 100644 index 0000000000..a329434623 --- /dev/null +++ b/AutomatedTesting/Registry/C15556261_PhysXMaterials_CharacterControllerMaterialAssignment.setreg_override @@ -0,0 +1,115 @@ +{ + "Amazon": { + "Gems": { + "PhysX": { + "PhysXSystemConfiguration": { + "CollisionConfig": { + "Layers": { + "LayerNames": [ + "Default", + {}, + {}, + {}, + {}, + {}, + {}, + {}, + {}, + {}, + {}, + {}, + {}, + {}, + {}, + {}, + {}, + {}, + {}, + {}, + {}, + {}, + {}, + {}, + {}, + {}, + {}, + {}, + {}, + {}, + {}, + {}, + {}, + {}, + {}, + {}, + {}, + {}, + {}, + {}, + {}, + {}, + {}, + {}, + {}, + {}, + {}, + {}, + {}, + {}, + {}, + {}, + {}, + {}, + {}, + {}, + {}, + {}, + {}, + {}, + {}, + {}, + {}, + "TouchBend" + ] + }, + "Groups": { + "GroupPresets": [ + { + "Name": "All", + "ReadOnly": true + }, + { + "Id": { + "GroupId": "{CDB6B8D8-5CD0-40A8-874D-839B00A92EBB}" + }, + "Name": "None", + "Group": { + "Mask": 0 + }, + "ReadOnly": true + }, + { + "Id": { + "GroupId": "{22769429-5D46-429B-829A-0115239D9AAA}" + }, + "Name": "All_NoTouchBend", + "Group": { + "Mask": 9223372036854775807 + }, + "ReadOnly": true + } + ] + } + }, + "MaterialLibrary": { + "assetId": { + "guid": "{70D4A444-AFD4-57C4-9885-63F25AC3C281}" + }, + "loadBehavior": "QueueLoad", + "assetHint": "levels/physics/c15556261_physxmaterials_charactercontrollermaterialassignment/library.physmaterial" + } + } + } + } + } +} \ No newline at end of file diff --git a/AutomatedTesting/Registry/C18977601_Material_FrictionCombinePriority.setreg_override b/AutomatedTesting/Registry/C18977601_Material_FrictionCombinePriority.setreg_override new file mode 100644 index 0000000000..44a91c67cb --- /dev/null +++ b/AutomatedTesting/Registry/C18977601_Material_FrictionCombinePriority.setreg_override @@ -0,0 +1,115 @@ +{ + "Amazon": { + "Gems": { + "PhysX": { + "PhysXSystemConfiguration": { + "CollisionConfig": { + "Layers": { + "LayerNames": [ + "Default", + {}, + {}, + {}, + {}, + {}, + {}, + {}, + {}, + {}, + {}, + {}, + {}, + {}, + {}, + {}, + {}, + {}, + {}, + {}, + {}, + {}, + {}, + {}, + {}, + {}, + {}, + {}, + {}, + {}, + {}, + {}, + {}, + {}, + {}, + {}, + {}, + {}, + {}, + {}, + {}, + {}, + {}, + {}, + {}, + {}, + {}, + {}, + {}, + {}, + {}, + {}, + {}, + {}, + {}, + {}, + {}, + {}, + {}, + {}, + {}, + {}, + {}, + "TouchBend" + ] + }, + "Groups": { + "GroupPresets": [ + { + "Name": "All", + "ReadOnly": true + }, + { + "Id": { + "GroupId": "{CDB6B8D8-5CD0-40A8-874D-839B00A92EBB}" + }, + "Name": "None", + "Group": { + "Mask": 0 + }, + "ReadOnly": true + }, + { + "Id": { + "GroupId": "{22769429-5D46-429B-829A-0115239D9AAA}" + }, + "Name": "All_NoTouchBend", + "Group": { + "Mask": 9223372036854775807 + }, + "ReadOnly": true + } + ] + } + }, + "MaterialLibrary": { + "assetId": { + "guid": "{B8749DAB-15DA-5A61-B565-C853673604CD}" + }, + "loadBehavior": "QueueLoad", + "assetHint": "levels/physics/c18977601_material_frictioncombinepriority/friction_combine.physmaterial" + } + } + } + } + } +} \ No newline at end of file diff --git a/AutomatedTesting/Registry/C18981526_Material_RestitutionCombinePriority.setreg_override b/AutomatedTesting/Registry/C18981526_Material_RestitutionCombinePriority.setreg_override new file mode 100644 index 0000000000..8de10787f1 --- /dev/null +++ b/AutomatedTesting/Registry/C18981526_Material_RestitutionCombinePriority.setreg_override @@ -0,0 +1,115 @@ +{ + "Amazon": { + "Gems": { + "PhysX": { + "PhysXSystemConfiguration": { + "CollisionConfig": { + "Layers": { + "LayerNames": [ + "Default", + {}, + {}, + {}, + {}, + {}, + {}, + {}, + {}, + {}, + {}, + {}, + {}, + {}, + {}, + {}, + {}, + {}, + {}, + {}, + {}, + {}, + {}, + {}, + {}, + {}, + {}, + {}, + {}, + {}, + {}, + {}, + {}, + {}, + {}, + {}, + {}, + {}, + {}, + {}, + {}, + {}, + {}, + {}, + {}, + {}, + {}, + {}, + {}, + {}, + {}, + {}, + {}, + {}, + {}, + {}, + {}, + {}, + {}, + {}, + {}, + {}, + {}, + "TouchBend" + ] + }, + "Groups": { + "GroupPresets": [ + { + "Name": "All", + "ReadOnly": true + }, + { + "Id": { + "GroupId": "{CDB6B8D8-5CD0-40A8-874D-839B00A92EBB}" + }, + "Name": "None", + "Group": { + "Mask": 0 + }, + "ReadOnly": true + }, + { + "Id": { + "GroupId": "{22769429-5D46-429B-829A-0115239D9AAA}" + }, + "Name": "All_NoTouchBend", + "Group": { + "Mask": 9223372036854775807 + }, + "ReadOnly": true + } + ] + } + }, + "MaterialLibrary": { + "assetId": { + "guid": "{AED48B18-0F3F-5E59-A8FF-30DB134B307B}" + }, + "loadBehavior": "QueueLoad", + "assetHint": "levels/physics/c18981526_material_restitutioncombinepriority/restitution_combine.physmaterial" + } + } + } + } + } +} \ No newline at end of file diff --git a/AutomatedTesting/Registry/C4044456_Material_FrictionCombine.setreg_override b/AutomatedTesting/Registry/C4044456_Material_FrictionCombine.setreg_override new file mode 100644 index 0000000000..83f7079e1f --- /dev/null +++ b/AutomatedTesting/Registry/C4044456_Material_FrictionCombine.setreg_override @@ -0,0 +1,115 @@ +{ + "Amazon": { + "Gems": { + "PhysX": { + "PhysXSystemConfiguration": { + "CollisionConfig": { + "Layers": { + "LayerNames": [ + "Default", + {}, + {}, + {}, + {}, + {}, + {}, + {}, + {}, + {}, + {}, + {}, + {}, + {}, + {}, + {}, + {}, + {}, + {}, + {}, + {}, + {}, + {}, + {}, + {}, + {}, + {}, + {}, + {}, + {}, + {}, + {}, + {}, + {}, + {}, + {}, + {}, + {}, + {}, + {}, + {}, + {}, + {}, + {}, + {}, + {}, + {}, + {}, + {}, + {}, + {}, + {}, + {}, + {}, + {}, + {}, + {}, + {}, + {}, + {}, + {}, + {}, + {}, + "TouchBend" + ] + }, + "Groups": { + "GroupPresets": [ + { + "Name": "All", + "ReadOnly": true + }, + { + "Id": { + "GroupId": "{CDB6B8D8-5CD0-40A8-874D-839B00A92EBB}" + }, + "Name": "None", + "Group": { + "Mask": 0 + }, + "ReadOnly": true + }, + { + "Id": { + "GroupId": "{22769429-5D46-429B-829A-0115239D9AAA}" + }, + "Name": "All_NoTouchBend", + "Group": { + "Mask": 9223372036854775807 + }, + "ReadOnly": true + } + ] + } + }, + "MaterialLibrary": { + "assetId": { + "guid": "{8D2C4A29-E0FC-564F-82C9-24BBA30C5A90}" + }, + "loadBehavior": "QueueLoad", + "assetHint": "levels/physics/c4044456_material_frictioncombine/friction_combine.physmaterial" + } + } + } + } + } +} \ No newline at end of file diff --git a/AutomatedTesting/Registry/C4044457_Material_RestitutionCombine.setreg_override b/AutomatedTesting/Registry/C4044457_Material_RestitutionCombine.setreg_override new file mode 100644 index 0000000000..96836b6ae4 --- /dev/null +++ b/AutomatedTesting/Registry/C4044457_Material_RestitutionCombine.setreg_override @@ -0,0 +1,115 @@ +{ + "Amazon": { + "Gems": { + "PhysX": { + "PhysXSystemConfiguration": { + "CollisionConfig": { + "Layers": { + "LayerNames": [ + "Default", + {}, + {}, + {}, + {}, + {}, + {}, + {}, + {}, + {}, + {}, + {}, + {}, + {}, + {}, + {}, + {}, + {}, + {}, + {}, + {}, + {}, + {}, + {}, + {}, + {}, + {}, + {}, + {}, + {}, + {}, + {}, + {}, + {}, + {}, + {}, + {}, + {}, + {}, + {}, + {}, + {}, + {}, + {}, + {}, + {}, + {}, + {}, + {}, + {}, + {}, + {}, + {}, + {}, + {}, + {}, + {}, + {}, + {}, + {}, + {}, + {}, + {}, + "TouchBend" + ] + }, + "Groups": { + "GroupPresets": [ + { + "Name": "All", + "ReadOnly": true + }, + { + "Id": { + "GroupId": "{CDB6B8D8-5CD0-40A8-874D-839B00A92EBB}" + }, + "Name": "None", + "Group": { + "Mask": 0 + }, + "ReadOnly": true + }, + { + "Id": { + "GroupId": "{22769429-5D46-429B-829A-0115239D9AAA}" + }, + "Name": "All_NoTouchBend", + "Group": { + "Mask": 9223372036854775807 + }, + "ReadOnly": true + } + ] + } + }, + "MaterialLibrary": { + "assetId": { + "guid": "{D5D6A6DE-E636-5638-B30D-6CE2FDC321F8}" + }, + "loadBehavior": "QueueLoad", + "assetHint": "levels/physics/c4044457_material_restitutioncombine/restitution_combine.physmaterial" + } + } + } + } + } +} \ No newline at end of file diff --git a/AutomatedTesting/Registry/C4044461_Material_Restitution.setreg_override b/AutomatedTesting/Registry/C4044461_Material_Restitution.setreg_override new file mode 100644 index 0000000000..21b285506b --- /dev/null +++ b/AutomatedTesting/Registry/C4044461_Material_Restitution.setreg_override @@ -0,0 +1,115 @@ +{ + "Amazon": { + "Gems": { + "PhysX": { + "PhysXSystemConfiguration": { + "CollisionConfig": { + "Layers": { + "LayerNames": [ + "Default", + {}, + {}, + {}, + {}, + {}, + {}, + {}, + {}, + {}, + {}, + {}, + {}, + {}, + {}, + {}, + {}, + {}, + {}, + {}, + {}, + {}, + {}, + {}, + {}, + {}, + {}, + {}, + {}, + {}, + {}, + {}, + {}, + {}, + {}, + {}, + {}, + {}, + {}, + {}, + {}, + {}, + {}, + {}, + {}, + {}, + {}, + {}, + {}, + {}, + {}, + {}, + {}, + {}, + {}, + {}, + {}, + {}, + {}, + {}, + {}, + {}, + {}, + "TouchBend" + ] + }, + "Groups": { + "GroupPresets": [ + { + "Name": "All", + "ReadOnly": true + }, + { + "Id": { + "GroupId": "{CDB6B8D8-5CD0-40A8-874D-839B00A92EBB}" + }, + "Name": "None", + "Group": { + "Mask": 0 + }, + "ReadOnly": true + }, + { + "Id": { + "GroupId": "{22769429-5D46-429B-829A-0115239D9AAA}" + }, + "Name": "All_NoTouchBend", + "Group": { + "Mask": 9223372036854775807 + }, + "ReadOnly": true + } + ] + } + }, + "MaterialLibrary": { + "assetId": { + "guid": "{E4117B5B-8D9A-5C1D-BA1E-C36542A6588D}" + }, + "loadBehavior": "QueueLoad", + "assetHint": "levels/physics/c4044461_material_restitution/restitution.physmaterial" + } + } + } + } + } +} \ No newline at end of file diff --git a/AutomatedTesting/Registry/C4044697_Material_PerfaceMaterialValidation.setreg_override b/AutomatedTesting/Registry/C4044697_Material_PerfaceMaterialValidation.setreg_override new file mode 100644 index 0000000000..d585a4c468 --- /dev/null +++ b/AutomatedTesting/Registry/C4044697_Material_PerfaceMaterialValidation.setreg_override @@ -0,0 +1,115 @@ +{ + "Amazon": { + "Gems": { + "PhysX": { + "PhysXSystemConfiguration": { + "CollisionConfig": { + "Layers": { + "LayerNames": [ + "Default", + {}, + {}, + {}, + {}, + {}, + {}, + {}, + {}, + {}, + {}, + {}, + {}, + {}, + {}, + {}, + {}, + {}, + {}, + {}, + {}, + {}, + {}, + {}, + {}, + {}, + {}, + {}, + {}, + {}, + {}, + {}, + {}, + {}, + {}, + {}, + {}, + {}, + {}, + {}, + {}, + {}, + {}, + {}, + {}, + {}, + {}, + {}, + {}, + {}, + {}, + {}, + {}, + {}, + {}, + {}, + {}, + {}, + {}, + {}, + {}, + {}, + {}, + "TouchBend" + ] + }, + "Groups": { + "GroupPresets": [ + { + "Name": "All", + "ReadOnly": true + }, + { + "Id": { + "GroupId": "{CDB6B8D8-5CD0-40A8-874D-839B00A92EBB}" + }, + "Name": "None", + "Group": { + "Mask": 0 + }, + "ReadOnly": true + }, + { + "Id": { + "GroupId": "{22769429-5D46-429B-829A-0115239D9AAA}" + }, + "Name": "All_NoTouchBend", + "Group": { + "Mask": 9223372036854775807 + }, + "ReadOnly": true + } + ] + } + }, + "MaterialLibrary": { + "assetId": { + "guid": "{2E85B457-ED19-5FE3-90B4-6EFFB4D0E682}" + }, + "loadBehavior": "QueueLoad", + "assetHint": "levels/physics/c4044697_material_perfacematerialvalidation/test_library.physmaterial" + } + } + } + } + } +} \ No newline at end of file diff --git a/Gems/Atom/Feature/Common/Assets/ShaderLib/Atom/Features/Shadow/Shadow.azsli b/Gems/Atom/Feature/Common/Assets/ShaderLib/Atom/Features/Shadow/Shadow.azsli index d267a74b36..138ea38562 100644 --- a/Gems/Atom/Feature/Common/Assets/ShaderLib/Atom/Features/Shadow/Shadow.azsli +++ b/Gems/Atom/Feature/Common/Assets/ShaderLib/Atom/Features/Shadow/Shadow.azsli @@ -79,9 +79,9 @@ float4 Shadow::GetJitterUnitVectorDepthDiffBase( return float4(0., 0., 0., 0.); } const float3 v_M = v_M0 / v_M0_length; - const float cosTheta = dot(normalVector, v_M); + const float cosTheta = saturate(dot(normalVector, v_M)); const float sinTheta = sqrt(1 - cosTheta * cosTheta); - if (sinTheta == 0.) + if (sinTheta < 0.001) { return float4(0., 0., 0., 0.); } diff --git a/Tools/LyTestTools/ly_test_tools/_internal/managers/abstract_resource_locator.py b/Tools/LyTestTools/ly_test_tools/_internal/managers/abstract_resource_locator.py index ec4b43b023..48afeb8219 100755 --- a/Tools/LyTestTools/ly_test_tools/_internal/managers/abstract_resource_locator.py +++ b/Tools/LyTestTools/ly_test_tools/_internal/managers/abstract_resource_locator.py @@ -14,11 +14,15 @@ Utility class to resolve Lumberyard directory paths & file mappings. import os import pathlib import warnings +import json +import logging from abc import ABCMeta, abstractmethod +from weakref import KeyedRef import ly_test_tools._internal.pytest_plugin from ly_test_tools.environment.file_system import find_ancestor_file +logger = logging.getLogger(__name__) def _find_engine_root(initial_path): # type: (str) -> str @@ -50,11 +54,41 @@ def _find_project_json(engine_root, project): Find the project.json file for this project. :return: Full path to the project.json file """ - # First check relative to defined build directory, for external projects which configure through SDK settings - project_json = find_ancestor_file(target_file_name='project.json', - start_path=ly_test_tools._internal.pytest_plugin.build_directory) - if not project_json: # check internally for a project bundled with the engine - project_json = os.path.join(engine_root, project, 'project.json') + project_json = None + + # Check the o3de_manifest.json and for the "projects" key + manifest_json = os.path.join(os.path.expanduser('~'), '.o3de', 'o3de_manifest.json') + if os.path.isfile(manifest_json): + # Read the o3de_manifest.json + with open(manifest_json, "r") as manifest_file: + json_data = json.load(manifest_file) + # Look at the "projects" key for registered project paths + try: + for projects_path in json_data["projects"]: + check_project_json = os.path.join(projects_path, 'project.json') + # Check for the project.json file inside of the project directory + if os.path.isfile(check_project_json): + # Check if the "project_name" key matches our project + with open(check_project_json, "r") as project_json_file: + project_json_data = json.load(project_json_file) + if project == project_json_data["project_name"]: + project_json = check_project_json + break + except KeyError as err: + logger.warning(f"Project key could not be found due to error: {err}") + + # Check relative to defined build directory, for external projects which configure through SDK settings + if not project_json: + project_json = find_ancestor_file(target_file_name='project.json', + start_path=ly_test_tools._internal.pytest_plugin.build_directory) + # Check internally for a project bundled with the engine + if not project_json: + check_project_json = os.path.join(engine_root, project, 'project.json') + if os.path.isfile(check_project_json): + project_json = check_project_json + + if not project_json: + raise OSError(f"Unable to find the project directory for project: ${project}") return project_json diff --git a/Tools/LyTestTools/tests/unit/test_abstract_resource_locator.py b/Tools/LyTestTools/tests/unit/test_abstract_resource_locator.py index 12286b3dd7..d8e4e5a14a 100755 --- a/Tools/LyTestTools/tests/unit/test_abstract_resource_locator.py +++ b/Tools/LyTestTools/tests/unit/test_abstract_resource_locator.py @@ -24,6 +24,9 @@ mock_engine_root = "mock_engine_root" mock_dev_path = "mock_dev_path" mock_build_directory = 'mock_build_directory' mock_project = 'mock_project' +mock_manifest_json_file = {'projects': [mock_project]} +mock_project_json_file = {'project_name': mock_project} +mock_project_json = os.path.join(mock_project, 'project.json') class TestFindEngineRoot(object): @@ -47,11 +50,24 @@ class TestFindEngineRoot(object): with pytest.raises(OSError): abstract_resource_locator._find_engine_root(mock_initial_path) +@mock.patch('builtins.open', mock.MagicMock()) +class TestFindProjectJson(object): + + @mock.patch('os.path.isfile', mock.MagicMock(return_value=True)) + @mock.patch('os.path.basename', mock.MagicMock(return_value=mock_project)) + @mock.patch('json.load', mock.MagicMock(side_effect=[mock_manifest_json_file, mock_project_json_file])) + def test_FindProjectJson_ManifestJson_ReturnsProjectJson(self): + project = abstract_resource_locator._find_project_json(mock_engine_root, mock_project) + + assert project == mock_project_json + @mock.patch('ly_test_tools._internal.managers.abstract_resource_locator.os.path.abspath', mock.MagicMock(return_value=mock_initial_path)) @mock.patch('ly_test_tools._internal.managers.abstract_resource_locator._find_engine_root', mock.MagicMock(return_value=mock_engine_root)) +@mock.patch('ly_test_tools._internal.managers.abstract_resource_locator._find_project_json', + mock.MagicMock(return_value=os.path.join(mock_project, 'project.json'))) class TestAbstractResourceLocator(object): def test_Init_HasEngineRoot_SetsAttrs(self): @@ -93,12 +109,11 @@ class TestAbstractResourceLocator(object): assert mock_abstract_resource_locator.build_directory() == mock_build_directory - def test_Project_IsCalled_ReturnsProjectPath(self): + def test_Project_IsCalled_ReturnsProjectDir(self): mock_abstract_resource_locator = abstract_resource_locator.AbstractResourceLocator( mock_build_directory, mock_project) - expected_path = os.path.join(mock_abstract_resource_locator.engine_root(), mock_project) - assert mock_abstract_resource_locator.project() == expected_path + assert mock_abstract_resource_locator.project() == os.path.dirname(mock_project_json) def test_AssetProcessor_IsCalled_ReturnsAssetProcessorPath(self): mock_abstract_resource_locator = abstract_resource_locator.AbstractResourceLocator( @@ -168,8 +183,7 @@ class TestAbstractResourceLocator(object): def test_AutoexecFile_IsCalled_ReturnsAutoexecFilePath(self): mock_abstract_resource_locator = abstract_resource_locator.AbstractResourceLocator( mock_build_directory, mock_project) - expected_path = os.path.join(mock_abstract_resource_locator.engine_root(), - mock_abstract_resource_locator._project, + expected_path = os.path.join(mock_abstract_resource_locator._project, 'autoexec.cfg') assert mock_abstract_resource_locator.autoexec_file() == expected_path diff --git a/Tools/LyTestTools/tests/unit/test_builtin_helpers.py b/Tools/LyTestTools/tests/unit/test_builtin_helpers.py index a4ebf5acec..23a5a10bf3 100755 --- a/Tools/LyTestTools/tests/unit/test_builtin_helpers.py +++ b/Tools/LyTestTools/tests/unit/test_builtin_helpers.py @@ -68,6 +68,8 @@ class TestBuiltinHelpers(object): assert type(under_test) == expected_workspace + @mock.patch('ly_test_tools._internal.managers.abstract_resource_locator._find_project_json', + mock.MagicMock(return_value='mock_project')) @mock.patch('ly_test_tools._internal.managers.workspace.AbstractWorkspaceManager', mock.MagicMock(return_value=MockedWorkspaceManager)) @mock.patch('ly_test_tools.builtin.helpers.MAC', True) diff --git a/Tools/LyTestTools/tests/unit/test_manager_platforms_mac.py b/Tools/LyTestTools/tests/unit/test_manager_platforms_mac.py index bbd8fbf9ae..0acf6457d9 100755 --- a/Tools/LyTestTools/tests/unit/test_manager_platforms_mac.py +++ b/Tools/LyTestTools/tests/unit/test_manager_platforms_mac.py @@ -14,6 +14,7 @@ Unit tests for ly_test_tools._internal.managers.platforms.mac import unittest.mock as mock import os import pytest +import ly_test_tools from ly_test_tools._internal.managers.platforms.mac import ( _MacResourceLocator, MacWorkspaceManager, @@ -22,11 +23,6 @@ from ly_test_tools import MAC pytestmark = pytest.mark.SUITE_smoke -if not MAC: - pytestmark = pytest.mark.skipif( - not MAC, - reason="test_manager_platforms_mac.py only runs on Mac") - mock_engine_root = 'mock_engine_root' mock_dev_path = 'mock_dev_path' mock_build_directory = 'mock_build_directory' @@ -34,16 +30,16 @@ mock_project = 'mock_project' mock_tmp_path = 'mock_tmp_path' mock_output_path = 'mock_output_path' -mac_resource_locator = _MacResourceLocator( - build_directory=mock_build_directory, - project=mock_project) - @mock.patch('ly_test_tools._internal.managers.abstract_resource_locator._find_engine_root', - mock.MagicMock(return_value=(mock_engine_root, mock_dev_path))) + mock.MagicMock(return_value=mock_engine_root)) +@mock.patch('ly_test_tools._internal.managers.abstract_resource_locator._find_project_json', + mock.MagicMock(return_value=mock_project)) class TestMacResourceLocator(object): def test_PlatformConfigFile_HasPath_ReturnsPath(self): + mac_resource_locator = ly_test_tools._internal.managers.platforms.mac._MacResourceLocator(mock_build_directory, + mock_project) expected = os.path.join( mac_resource_locator.engine_root(), CONFIG_FILE) @@ -51,6 +47,8 @@ class TestMacResourceLocator(object): assert mac_resource_locator.platform_config_file() == expected def test_PlatformCache_HasPath_ReturnsPath(self): + mac_resource_locator = ly_test_tools._internal.managers.platforms.mac._MacResourceLocator(mock_build_directory, + mock_project) expected = os.path.join( mac_resource_locator.project_cache(), CACHE_DIR) @@ -58,6 +56,8 @@ class TestMacResourceLocator(object): assert mac_resource_locator.platform_cache() == expected def test_ProjectLog_HasPath_ReturnsPath(self): + mac_resource_locator = ly_test_tools._internal.managers.platforms.mac._MacResourceLocator(mock_build_directory, + mock_project) expected = os.path.join( mac_resource_locator.project(), 'user', @@ -66,6 +66,8 @@ class TestMacResourceLocator(object): assert mac_resource_locator.project_log() == expected def test_ProjectScreenshots_HasPath_ReturnsPath(self): + mac_resource_locator = ly_test_tools._internal.managers.platforms.mac._MacResourceLocator(mock_build_directory, + mock_project) expected = os.path.join( mac_resource_locator.project(), 'user', @@ -74,6 +76,8 @@ class TestMacResourceLocator(object): assert mac_resource_locator.project_screenshots() == expected def test_EditorLog_HasPath_ReturnsPath(self): + mac_resource_locator = ly_test_tools._internal.managers.platforms.mac._MacResourceLocator(mock_build_directory, + mock_project) expected = os.path.join( mac_resource_locator.project_log(), 'editor.log') @@ -82,7 +86,9 @@ class TestMacResourceLocator(object): @mock.patch('ly_test_tools._internal.managers.abstract_resource_locator._find_engine_root', - mock.MagicMock(return_value=(mock_engine_root, mock_dev_path))) + mock.MagicMock(return_value=mock_engine_root)) +@mock.patch('ly_test_tools._internal.managers.abstract_resource_locator._find_project_json', + mock.MagicMock(return_value=mock_project)) class TestMacWorkspaceManager(object): def test_Init_SetDummyParams_ReturnsMacWorkspaceManager(self): diff --git a/Tools/LyTestTools/tests/unit/test_manager_platforms_windows.py b/Tools/LyTestTools/tests/unit/test_manager_platforms_windows.py index aaf34367e7..93ca9e3c07 100755 --- a/Tools/LyTestTools/tests/unit/test_manager_platforms_windows.py +++ b/Tools/LyTestTools/tests/unit/test_manager_platforms_windows.py @@ -14,6 +14,7 @@ Unit tests for ly_test_tools._internal.managers.platforms.windows import unittest.mock as mock import os import pytest +import ly_test_tools from ly_test_tools._internal.managers.platforms.windows import ( _WindowsResourceLocator, WindowsWorkspaceManager, @@ -34,22 +35,16 @@ mock_project = 'mock_project' mock_tmp_path = 'mock_tmp_path' mock_output_path = 'mock_output_path' -windows_resource_locator = _WindowsResourceLocator( - build_directory=mock_build_directory, - project=mock_project) - -windows_workspace_manager = WindowsWorkspaceManager( - build_directory=mock_build_directory, - project=mock_project, - tmp_path=mock_tmp_path, - output_path=mock_output_path) - @mock.patch('ly_test_tools._internal.managers.abstract_resource_locator._find_engine_root', - mock.MagicMock(return_value=(mock_engine_root, mock_dev_path))) + mock.MagicMock(return_value=mock_engine_root)) +@mock.patch('ly_test_tools._internal.managers.abstract_resource_locator._find_project_json', mock.MagicMock( + return_value=mock_project)) class TestWindowsResourceLocator(object): def test_PlatformConfigFile_HasPath_ReturnsPath(self): + windows_resource_locator = ly_test_tools._internal.managers.platforms.windows._WindowsResourceLocator( + mock_build_directory, mock_project) expected = os.path.join( windows_resource_locator.engine_root(), CONFIG_FILE) @@ -57,12 +52,16 @@ class TestWindowsResourceLocator(object): assert windows_resource_locator.platform_config_file() == expected def test_PlatformCache_HasPath_ReturnsPath(self): + windows_resource_locator = ly_test_tools._internal.managers.platforms.windows._WindowsResourceLocator( + mock_build_directory, mock_project) expected = os.path.join( windows_resource_locator.project_cache(), CACHE_DIR) assert windows_resource_locator.platform_cache() == expected def test_ProjectLog_HasPath_ReturnsPath(self): + windows_resource_locator = ly_test_tools._internal.managers.platforms.windows._WindowsResourceLocator( + mock_build_directory, mock_project) expected = os.path.join( windows_resource_locator.project(), 'user', @@ -71,6 +70,8 @@ class TestWindowsResourceLocator(object): assert windows_resource_locator.project_log() == expected def test_ProjectScreenshots_HasPath_ReturnsPath(self): + windows_resource_locator = ly_test_tools._internal.managers.platforms.windows._WindowsResourceLocator( + mock_build_directory, mock_project) expected = os.path.join( windows_resource_locator.project(), 'user', @@ -79,6 +80,8 @@ class TestWindowsResourceLocator(object): assert windows_resource_locator.project_screenshots() == expected def test_EditorLog_HasPath_ReturnsPath(self): + windows_resource_locator = ly_test_tools._internal.managers.platforms.windows._WindowsResourceLocator( + mock_build_directory, mock_project) expected = os.path.join( windows_resource_locator.project_log(), 'editor.log') @@ -87,17 +90,21 @@ class TestWindowsResourceLocator(object): @mock.patch('ly_test_tools._internal.managers.abstract_resource_locator._find_engine_root', - mock.MagicMock(return_value=(mock_engine_root, mock_dev_path))) + mock.MagicMock(return_value=mock_engine_root)) +@mock.patch('ly_test_tools._internal.managers.abstract_resource_locator._find_project_json', mock.MagicMock( + return_value=mock_project)) class TestWindowsWorkspaceManager(object): @mock.patch('ly_test_tools.environment.reg_cleaner.create_ly_keys') def test_SetRegistryKeys_NewWorkspaceManager_KeyCreateCalled(self, mock_create_keys): + windows_workspace_manager = ly_test_tools._internal.managers.platforms.windows.WindowsWorkspaceManager() windows_workspace_manager.set_registry_keys() mock_create_keys.assert_called_once() @mock.patch('ly_test_tools.environment.reg_cleaner.clean_ly_keys') def test_ClearSettings_NewWorkspaceManager_KeyClearCalled(self, mock_clear_keys): + windows_workspace_manager = ly_test_tools._internal.managers.platforms.windows.WindowsWorkspaceManager() windows_workspace_manager.clear_settings() mock_clear_keys.assert_called_with(exception_list=r"SOFTWARE\Amazon\Lumberyard\Identity") diff --git a/cmake/Platform/Common/Install_common.cmake b/cmake/Platform/Common/Install_common.cmake index 933d64149b..bf7134d470 100644 --- a/cmake/Platform/Common/Install_common.cmake +++ b/cmake/Platform/Common/Install_common.cmake @@ -42,8 +42,20 @@ function(ly_setup_target OUTPUT_CONFIGURED_TARGET ALIAS_TARGET_NAME) string(GENEX_STRIP ${include_directory} include_genex_expr) if(include_genex_expr STREQUAL include_directory) # only for cases where there are no generation expressions unset(current_public_headers) + + cmake_path(NORMAL_PATH include_directory) + string(REGEX REPLACE "/$" "" include_directory "${include_directory}") + cmake_path(IS_PREFIX LY_ROOT_FOLDER ${absolute_target_source_dir} NORMALIZE include_directory_child_of_o3de_root) + if(NOT include_directory_child_of_o3de_root) + message(FATAL_ERROR "Include directory of \"${include_directory}\" is outside of the O3DE root folder of \"${LY_ROOT_FOLDER}\". For the INSTALL step, the O3DE root folder must be a prefix of all include directories") + endif() + + cmake_path(RELATIVE_PATH include_directory BASE_DIRECTORY ${LY_ROOT_FOLDER} OUTPUT_VARIABLE rel_include_dir) + cmake_path(APPEND include_location "${rel_include_dir}" ".." OUTPUT_VARIABLE destination_dir) + cmake_path(NORMAL_PATH destination_dir) + install(DIRECTORY ${include_directory} - DESTINATION ${include_location}/${target_source_dir} + DESTINATION ${destination_dir} COMPONENT ${install_component} FILES_MATCHING PATTERN *.h @@ -116,7 +128,9 @@ function(ly_setup_target OUTPUT_CONFIGURED_TARGET ALIAS_TARGET_NAME) string(GENEX_STRIP ${include} include_genex_expr) if(include_genex_expr STREQUAL include) # only for cases where there are no generation expressions file(RELATIVE_PATH relative_include ${absolute_target_source_dir} ${include}) - string(APPEND INCLUDE_DIRECTORIES_PLACEHOLDER "\${LY_ROOT_FOLDER}/include/${target_source_dir}/${relative_include}\n") + cmake_path(APPEND include_location "${target_source_dir}" "${relative_include}" OUTPUT_VARIABLE target_include) + cmake_path(NORMAL_PATH target_include) + string(APPEND INCLUDE_DIRECTORIES_PLACEHOLDER "\${LY_ROOT_FOLDER}/${target_include}\n") endif() endforeach() endif()