From 182d41056254938e75fb36e05584f904a48e147b Mon Sep 17 00:00:00 2001 From: jckand-amzn Date: Fri, 20 Aug 2021 16:29:48 -0500 Subject: [PATCH] Updating base.py to allow for turning off batch and autotest modes Signed-off-by: jckand-amzn --- .../Gem/PythonTests/automatedtesting_shared/base.py | 10 +++++++--- .../BasicEditorWorkflows_LevelEntityComponentCRUD.py | 11 ++++++----- .../PythonTests/editor/test_Editor_Main_Optimized.py | 6 ++++-- 3 files changed, 17 insertions(+), 10 deletions(-) diff --git a/AutomatedTesting/Gem/PythonTests/automatedtesting_shared/base.py b/AutomatedTesting/Gem/PythonTests/automatedtesting_shared/base.py index e6c28be2a5..f5cd66cbbe 100755 --- a/AutomatedTesting/Gem/PythonTests/automatedtesting_shared/base.py +++ b/AutomatedTesting/Gem/PythonTests/automatedtesting_shared/base.py @@ -51,8 +51,8 @@ class TestAutomationBase: cls.asset_processor.teardown() cls._kill_ly_processes() - - def _run_test(self, request, workspace, editor, testcase_module, extra_cmdline_args=[], use_null_renderer=True): + def _run_test(self, request, workspace, editor, testcase_module, extra_cmdline_args=[], batch_mode=True, + autotest_mode=True, use_null_renderer=True): test_starttime = time.time() self.logger = logging.getLogger(__name__) errors = [] @@ -90,9 +90,13 @@ class TestAutomationBase: editor_starttime = time.time() self.logger.debug("Running automated test") testcase_module_filepath = self._get_testcase_module_filepath(testcase_module) - pycmd = ["--runpythontest", testcase_module_filepath, "-BatchMode", "-autotest_mode", f"-pythontestcase={request.node.originalname}"] + pycmd = ["--runpythontest", testcase_module_filepath, f"-pythontestcase={request.node.originalname}"] if use_null_renderer: pycmd += ["-rhi=null"] + if batch_mode: + pycmd += ["-BatchMode"] + if autotest_mode: + pycmd += ["-autotest_mode"] pycmd += extra_cmdline_args editor.args.extend(pycmd) # args are added to the WinLauncher start command editor.start(backupFiles = False, launch_ap = False) diff --git a/AutomatedTesting/Gem/PythonTests/editor/EditorScripts/BasicEditorWorkflows_LevelEntityComponentCRUD.py b/AutomatedTesting/Gem/PythonTests/editor/EditorScripts/BasicEditorWorkflows_LevelEntityComponentCRUD.py index 906e28bf8d..9c5880ab1e 100644 --- a/AutomatedTesting/Gem/PythonTests/editor/EditorScripts/BasicEditorWorkflows_LevelEntityComponentCRUD.py +++ b/AutomatedTesting/Gem/PythonTests/editor/EditorScripts/BasicEditorWorkflows_LevelEntityComponentCRUD.py @@ -37,12 +37,12 @@ class Tests: ) -def RunTest(): +def BasicEditorWorkflows_LevelEntityComponentCRUD(): import editor_python_test_tools.pyside_utils as pyside_utils @pyside_utils.wrap_async - async def BasicEditorWorkflows_LevelEntityComponentCRUD(): + async def run_test(): """ Summary: Open O3DE editor and check if basic Editor workflows are completable. @@ -139,7 +139,8 @@ def RunTest(): # Update the component dimensions_to_set = math.Vector3(16.0, 16.0, 16.0) child_entity.get_set_test(0, "Box Shape|Box Configuration|Dimensions", dimensions_to_set) - box_shape_dimensions = hydra.get_component_property_value(child_entity.components[0], "Box Shape|Box Configuration|Dimensions") + box_shape_dimensions = hydra.get_component_property_value(child_entity.components[0], + "Box Shape|Box Configuration|Dimensions") Report.result(Tests.component_updated, box_shape_dimensions == dimensions_to_set) # Remove the component @@ -161,10 +162,10 @@ def RunTest(): export_success = await pyside_utils.wait_for_condition(lambda: os.path.exists(level_pak_file), 5.0) Report.result(Tests.level_saved_and_exported, export_success) - BasicEditorWorkflows_LevelEntityComponentCRUD() + run_test() if __name__ == "__main__": from editor_python_test_tools.utils import Report - Report.start_test(RunTest) + Report.start_test(BasicEditorWorkflows_LevelEntityComponentCRUD) diff --git a/AutomatedTesting/Gem/PythonTests/editor/test_Editor_Main_Optimized.py b/AutomatedTesting/Gem/PythonTests/editor/test_Editor_Main_Optimized.py index ac9c46e4e7..dffba9b983 100644 --- a/AutomatedTesting/Gem/PythonTests/editor/test_Editor_Main_Optimized.py +++ b/AutomatedTesting/Gem/PythonTests/editor/test_Editor_Main_Optimized.py @@ -20,6 +20,7 @@ class TestAutomation(EditorTestSuite): class test_BasicEditorWorkflows_LevelEntityComponentCRUD(EditorSingleTest): # Disable -BatchMode and -autotest_mode EditorTestSuite.global_extra_cmdline_args = [] + # Custom teardown to remove slice asset created during test def teardown(self, request, workspace, editor, editor_test_results, launcher_platform): file_system.delete([os.path.join(workspace.paths.engine_root(), "AutomatedTesting", "Levels", "tmp_level")], @@ -30,9 +31,10 @@ class TestAutomation(EditorTestSuite): class test_BasicEditorWorkflows_GPU_LevelEntityComponentCRUD(EditorSingleTest): # Disable -BatchMode, -autotest_mode, and null renderer EditorTestSuite.global_extra_cmdline_args = [] - use_null_renderer = False + EditorTestSuite.use_null_renderer = False + # Custom teardown to remove slice asset created during test def teardown(self, request, workspace, editor, editor_test_results, launcher_platform): file_system.delete([os.path.join(workspace.paths.engine_root(), "AutomatedTesting", "Levels", "tmp_level")], True, True) - from .EditorScripts import BasicEditorWorkflows_LevelEntityComponentCRUD as test_module \ No newline at end of file + from .EditorScripts import BasicEditorWorkflows_LevelEntityComponentCRUD as test_module