From 268fd8b714a1aa1c2a87ceed2a087e85101f5e30 Mon Sep 17 00:00:00 2001 From: amzn-sj Date: Wed, 19 May 2021 13:57:35 -0700 Subject: [PATCH 01/26] Remove bootstrap.cfg and references to it. --- .../amazon/lumberyard/LumberyardActivity.java | 8 +- .../Framework/AzCore/AzCore/Android/Utils.cpp | 2 +- Code/Framework/AzCore/AzCore/Android/Utils.h | 4 +- .../AzCore/Component/ComponentApplication.cpp | 2 - .../Settings/SettingsRegistryMergeUtils.cpp | 7 - .../Settings/SettingsRegistryMergeUtils.h | 3 - .../ProjectManager/ProjectManager.cpp | 1 - Code/Tools/AssetBundler/tests/tests_main.cpp | 1 - .../SettingsRegistryBuilder.cpp | 1 - .../Code/Tests/AssetValidationTestShared.h | 1 - .../managers/abstract_resource_locator.py | 3 - .../ly_test_tools/o3de/asset_processor.py | 3 +- .../ly_test_tools/o3de/settings.py | 16 -- .../unit/test_abstract_resource_locator.py | 7 - bootstrap.cfg | 12 - cmake/Tools/common.py | 28 +- cmake/Tools/generate_game_paks.py | 244 ------------------ cmake/Tools/layout_tool.py | 37 ++- cmake/Tools/unit_test_common.py | 121 --------- cmake/Tools/unit_test_current_project.py | 102 -------- cmake/Tools/unit_test_layout_tool.py | 16 +- scripts/build/package/package.py | 31 --- 22 files changed, 52 insertions(+), 598 deletions(-) delete mode 100644 bootstrap.cfg delete mode 100755 cmake/Tools/generate_game_paks.py delete mode 100755 cmake/Tools/unit_test_current_project.py diff --git a/Code/Framework/AzAndroid/java/com/amazon/lumberyard/LumberyardActivity.java b/Code/Framework/AzAndroid/java/com/amazon/lumberyard/LumberyardActivity.java index b5d3de8164..5c1a120df6 100644 --- a/Code/Framework/AzAndroid/java/com/amazon/lumberyard/LumberyardActivity.java +++ b/Code/Framework/AzAndroid/java/com/amazon/lumberyard/LumberyardActivity.java @@ -244,7 +244,7 @@ public class LumberyardActivity extends NativeActivity boolean useMainObb = GetBooleanResource("use_main_obb"); boolean usePatchObb = GetBooleanResource("use_patch_obb"); - if (IsBootstrapInAPK() && (useMainObb || usePatchObb)) + if (AreAssetsInAPK() && (useMainObb || usePatchObb)) { Log.d(TAG, "Using OBB expansion files for game assets"); @@ -421,12 +421,12 @@ public class LumberyardActivity extends NativeActivity } //////////////////////////////////////////////////////////////// - private boolean IsBootstrapInAPK() + private boolean AreAssetsInAPK() { try { - InputStream bootstrap = getAssets().open("bootstrap.cfg", AssetManager.ACCESS_UNKNOWN); - bootstrap.close(); + InputStream engine = getAssets().open("engine.json", AssetManager.ACCESS_UNKNOWN); + engine.close(); return true; } catch (IOException exception) diff --git a/Code/Framework/AzCore/AzCore/Android/Utils.cpp b/Code/Framework/AzCore/AzCore/Android/Utils.cpp index efbbf50d1d..d6435c67be 100644 --- a/Code/Framework/AzCore/AzCore/Android/Utils.cpp +++ b/Code/Framework/AzCore/AzCore/Android/Utils.cpp @@ -148,7 +148,7 @@ namespace AZ } } - AZ_Assert(false, "Failed to locate the bootstrap.cfg path"); + AZ_Assert(false, "Failed to locate the engine.json path"); return nullptr; } diff --git a/Code/Framework/AzCore/AzCore/Android/Utils.h b/Code/Framework/AzCore/AzCore/Android/Utils.h index 222fac80ad..0862d53aa4 100644 --- a/Code/Framework/AzCore/AzCore/Android/Utils.h +++ b/Code/Framework/AzCore/AzCore/Android/Utils.h @@ -73,8 +73,8 @@ namespace AZ //! \return The pointer position of the relative asset path AZ::IO::FixedMaxPath StripApkPrefix(const char* filePath); - //! Searches application storage and the APK for bootstrap.cfg. Will return nullptr - //! if bootstrap.cfg is not found. + //! Searches application storage and the APK for engine.json. Will return nullptr + //! if engine.json is not found. const char* FindAssetsDirectory(); //! Calls into Java to show the splash screen on the main UI (Java) thread diff --git a/Code/Framework/AzCore/AzCore/Component/ComponentApplication.cpp b/Code/Framework/AzCore/AzCore/Component/ComponentApplication.cpp index 8a170f5d89..f03b1aac76 100644 --- a/Code/Framework/AzCore/AzCore/Component/ComponentApplication.cpp +++ b/Code/Framework/AzCore/AzCore/Component/ComponentApplication.cpp @@ -462,8 +462,6 @@ namespace AZ // for the application root. CalculateAppRoot(); - // Merge the bootstrap.cfg file into the Settings Registry as soon as the OSAllocator has been created. - SettingsRegistryMergeUtils::MergeSettingsToRegistry_Bootstrap(*m_settingsRegistry); SettingsRegistryMergeUtils::MergeSettingsToRegistry_O3deUserRegistry(*m_settingsRegistry, AZ_TRAIT_OS_PLATFORM_CODENAME, {}); SettingsRegistryMergeUtils::MergeSettingsToRegistry_CommandLine(*m_settingsRegistry, m_commandLine, executeRegDumpCommands); SettingsRegistryMergeUtils::MergeSettingsToRegistry_AddRuntimeFilePaths(*m_settingsRegistry); diff --git a/Code/Framework/AzCore/AzCore/Settings/SettingsRegistryMergeUtils.cpp b/Code/Framework/AzCore/AzCore/Settings/SettingsRegistryMergeUtils.cpp index 82bf1db484..5870c66633 100644 --- a/Code/Framework/AzCore/AzCore/Settings/SettingsRegistryMergeUtils.cpp +++ b/Code/Framework/AzCore/AzCore/Settings/SettingsRegistryMergeUtils.cpp @@ -494,13 +494,6 @@ namespace AZ::SettingsRegistryMergeUtils return configFileParsed; } - void MergeSettingsToRegistry_Bootstrap(SettingsRegistryInterface& registry) - { - ConfigParserSettings parserSettings; - parserSettings.m_registryRootPointerPath = BootstrapSettingsRootKey; - MergeSettingsToRegistry_ConfigFile(registry, "bootstrap.cfg", parserSettings); - } - void MergeSettingsToRegistry_AddRuntimeFilePaths(SettingsRegistryInterface& registry) { using FixedValueString = AZ::SettingsRegistryInterface::FixedValueString; diff --git a/Code/Framework/AzCore/AzCore/Settings/SettingsRegistryMergeUtils.h b/Code/Framework/AzCore/AzCore/Settings/SettingsRegistryMergeUtils.h index 576066c29f..b482530d24 100644 --- a/Code/Framework/AzCore/AzCore/Settings/SettingsRegistryMergeUtils.h +++ b/Code/Framework/AzCore/AzCore/Settings/SettingsRegistryMergeUtils.h @@ -172,9 +172,6 @@ namespace AZ::SettingsRegistryMergeUtils bool MergeSettingsToRegistry_ConfigFile(SettingsRegistryInterface& registry, AZStd::string_view filePath, const ConfigParserSettings& configParserSettings); - //! Loads bootstrap.cfg into the Settings Registry. This file does not support specializations. - void MergeSettingsToRegistry_Bootstrap(SettingsRegistryInterface& registry); - //! Extracts file path information from the environment and bootstrap to calculate the various file paths and adds those //! to the Settings Registry under the FilePathsRootKey. void MergeSettingsToRegistry_AddRuntimeFilePaths(SettingsRegistryInterface& registry); diff --git a/Code/Framework/AzFramework/AzFramework/ProjectManager/ProjectManager.cpp b/Code/Framework/AzFramework/AzFramework/ProjectManager/ProjectManager.cpp index 985bc4665d..07470ae64e 100644 --- a/Code/Framework/AzFramework/AzFramework/ProjectManager/ProjectManager.cpp +++ b/Code/Framework/AzFramework/AzFramework/ProjectManager/ProjectManager.cpp @@ -46,7 +46,6 @@ namespace AzFramework::ProjectManager // Store the Command line to the Setting Registry AZ::SettingsRegistryImpl settingsRegistry; AZ::SettingsRegistryMergeUtils::StoreCommandLineToRegistry(settingsRegistry, commandLine); - AZ::SettingsRegistryMergeUtils::MergeSettingsToRegistry_Bootstrap(settingsRegistry); AZ::SettingsRegistryMergeUtils::MergeSettingsToRegistry_O3deUserRegistry(settingsRegistry, AZ_TRAIT_OS_PLATFORM_CODENAME, {}); // Retrieve Command Line from Settings Registry, it may have been updated by the call to FindEngineRoot() // in MergeSettingstoRegistry_ConfigFile diff --git a/Code/Tools/AssetBundler/tests/tests_main.cpp b/Code/Tools/AssetBundler/tests/tests_main.cpp index 9e12623b0d..29f9970f35 100644 --- a/Code/Tools/AssetBundler/tests/tests_main.cpp +++ b/Code/Tools/AssetBundler/tests/tests_main.cpp @@ -109,7 +109,6 @@ namespace AssetBundler if (!AZ::SettingsRegistry::Get()) { - AZ::SettingsRegistryMergeUtils::MergeSettingsToRegistry_Bootstrap(m_registry); AZ::SettingsRegistry::Register(&m_registry); } diff --git a/Code/Tools/AssetProcessor/native/InternalBuilders/SettingsRegistryBuilder.cpp b/Code/Tools/AssetProcessor/native/InternalBuilders/SettingsRegistryBuilder.cpp index 523e39d622..3d7cc3b8b4 100644 --- a/Code/Tools/AssetProcessor/native/InternalBuilders/SettingsRegistryBuilder.cpp +++ b/Code/Tools/AssetProcessor/native/InternalBuilders/SettingsRegistryBuilder.cpp @@ -291,7 +291,6 @@ namespace AssetProcessor } } - AZ::SettingsRegistryMergeUtils::MergeSettingsToRegistry_Bootstrap(registry); AZ::SettingsRegistryMergeUtils::MergeSettingsToRegistry_EngineRegistry(registry, platform, specialization, &scratchBuffer); AZ::SettingsRegistryMergeUtils::MergeSettingsToRegistry_GemRegistries(registry, platform, specialization, &scratchBuffer); AZ::SettingsRegistryMergeUtils::MergeSettingsToRegistry_ProjectRegistry(registry, platform, specialization, &scratchBuffer); diff --git a/Gems/AssetValidation/Code/Tests/AssetValidationTestShared.h b/Gems/AssetValidation/Code/Tests/AssetValidationTestShared.h index ab9e65b896..f4a24bf629 100644 --- a/Gems/AssetValidation/Code/Tests/AssetValidationTestShared.h +++ b/Gems/AssetValidation/Code/Tests/AssetValidationTestShared.h @@ -152,7 +152,6 @@ struct AssetValidationTest { AZ::SettingsRegistry::Register(&m_registry); - AZ::SettingsRegistryMergeUtils::MergeSettingsToRegistry_Bootstrap(m_registry); AZ::SettingsRegistryMergeUtils::MergeSettingsToRegistry_AddRuntimeFilePaths(m_registry); // Set the engine root to the temporary directory and re-update the runtime file paths auto enginePathKey = AZ::SettingsRegistryInterface::FixedValueString(AZ::SettingsRegistryMergeUtils::BootstrapSettingsRootKey) 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 5f6db7ac05..5a14ef9419 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 @@ -250,9 +250,6 @@ class AbstractResourceLocator(object): """ return os.path.join(self.build_directory(), 'CrySCompileServer') - def bootstrap_config_file(self): - return os.path.join(self.engine_root(), 'bootstrap.cfg') - def asset_processor_config_file(self): return os.path.join(self.engine_root(), 'Registry', 'AssetProcessorPlatformConfig.setreg') diff --git a/Tools/LyTestTools/ly_test_tools/o3de/asset_processor.py b/Tools/LyTestTools/ly_test_tools/o3de/asset_processor.py index 0983d2c45f..60dcf06e4c 100644 --- a/Tools/LyTestTools/ly_test_tools/o3de/asset_processor.py +++ b/Tools/LyTestTools/ly_test_tools/o3de/asset_processor.py @@ -664,8 +664,7 @@ class AssetProcessor(object): make_dir = os.path.join(self._temp_asset_root, copy_dir) if not os.path.isdir(make_dir): os.makedirs(make_dir) - for copyfile_name in ['bootstrap.cfg', - 'Registry/AssetProcessorPlatformConfig.setreg', + for copyfile_name in ['Registry/AssetProcessorPlatformConfig.setreg', os.path.join(self._workspace.project, "project.json"), os.path.join('Assets', 'Engine', 'exclude.filetag')]: shutil.copyfile(os.path.join(self._workspace.paths.engine_root(), copyfile_name), diff --git a/Tools/LyTestTools/ly_test_tools/o3de/settings.py b/Tools/LyTestTools/ly_test_tools/o3de/settings.py index 9677a4d3a3..a1e83abe51 100644 --- a/Tools/LyTestTools/ly_test_tools/o3de/settings.py +++ b/Tools/LyTestTools/ly_test_tools/o3de/settings.py @@ -57,14 +57,6 @@ class LySettings(object): """ self._backup_settings(self._resource_locator.platform_config_file(), backup_path) - def backup_bootstrap_settings(self, backup_path=None): - """ - Creates a backup of the bootstrap settings file (~/dev/bootstrap.cfg) in the backup_path. If no path is - provided, it will store in the workspace temp path (the contents of the workspace temp directory are removed - during workspace teardown) - """ - self._backup_settings(self._resource_locator.bootstrap_config_file(), backup_path) - def backup_shader_compiler_settings(self, backup_path=None): self._backup_settings(self._resource_locator.shader_compiler_config_file(), backup_path) @@ -79,14 +71,6 @@ class LySettings(object): """ self._restore_settings(self._resource_locator.platform_config_file(), backup_path) - def restore_bootstrap_settings(self, backup_path=None): - """ - Restores the bootstrap settings file (~/dev/bootstrap.cfg) from its backup. - The backup is stored in the backup_path. - If no backup_path is provided, it will attempt to retrieve the backup from the workspace temp path. - """ - self._restore_settings(self._resource_locator.bootstrap_config_file(), backup_path) - def restore_shader_compiler_settings(self, backup_path=None): self._restore_settings(self._resource_locator.shader_compiler_config_file(), backup_path) diff --git a/Tools/LyTestTools/tests/unit/test_abstract_resource_locator.py b/Tools/LyTestTools/tests/unit/test_abstract_resource_locator.py index e46fefa461..12286b3dd7 100755 --- a/Tools/LyTestTools/tests/unit/test_abstract_resource_locator.py +++ b/Tools/LyTestTools/tests/unit/test_abstract_resource_locator.py @@ -158,13 +158,6 @@ class TestAbstractResourceLocator(object): assert mock_abstract_resource_locator.shader_cache() == expected_path - def test_BootstrapConfigFile_IsCalled_ReturnBootstrapConfigFilePath(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(), 'bootstrap.cfg') - - assert mock_abstract_resource_locator.bootstrap_config_file() == expected_path - def test_AssetProcessorConfigFile_IsCalled_ReturnsAssetProcessorConfigFilePath(self): mock_abstract_resource_locator = abstract_resource_locator.AbstractResourceLocator( mock_build_directory, mock_project) diff --git a/bootstrap.cfg b/bootstrap.cfg deleted file mode 100644 index 858e9093f5..0000000000 --- a/bootstrap.cfg +++ /dev/null @@ -1,12 +0,0 @@ -; This file is deprecated and is only use currently for setting the path when running O3DE in an engine-centric manner -; By engine-centric, what is meant is using CMake to configure from the directory and passing in the LY_PROJECTS value - -project_path=AutomatedTesting - -; The Asset Processor Specific settings are now the /Engine/Registry/bootstrap.setreg settings -; The Engine specific settings can be overridden in order of least precedence to most -; 1. Override the settings in a "/Registry/*.setreg(patch)" file (Shared per Gem Settings) -; 2. Override the settings in a "/Registry/*.setreg(patch)" file (Shared per Project Settings) -; 3. Override the settings in a "/user/Registry/*.setreg(patch)" file (User per Project Settings) -; 4. Override the settings in a "~/.o3de/Registry/*.setreg(patch)" file (User Global Settings) -; Where "~" is %USERPROFILE% on Windows and $HOME on Unix like platforms diff --git a/cmake/Tools/common.py b/cmake/Tools/common.py index b271c59766..d20fcad6c7 100755 --- a/cmake/Tools/common.py +++ b/cmake/Tools/common.py @@ -137,19 +137,33 @@ def get_config_file_values(config_file_path, keys_to_extract): return result_map -def get_bootstrap_values(engine_root, keys_to_extract): +def get_bootstrap_values(bootstrap_dir, keys_to_extract): """ - Extract requested values from the bootstrap.cfg file in the def root folder - :param engine_root: The engine root folder where bootstrap.cfg exists + Extract requested values from the bootstrap.setreg file in the Registry folder + :param bootstrap_dir: The parent directory of the bootstrap.setreg file :param keys_to_extract: The keys to extract into a dictionary :return: Dictionary of keys and its values (for matched keys) """ - bootstrap_file = os.path.join(engine_root, 'bootstrap.cfg') + bootstrap_file = os.path.join(bootstrap_dir, 'bootstrap.setreg') if not os.path.isfile(bootstrap_file): - raise LmbrCmdError("Missing 'bootstrap.cfg' file from engine root ('{}')".format(engine_root), - ERROR_CODE_FILE_NOT_FOUND) + raise logging.error(f'Bootstrap.setreg file {bootstrap_file} does not exist.') + return None + + result_map = {} + with bootstrap_file.open('r') as f: + try: + json_data = json.load(f) + except Exception as e: + logging.error(f'Bootstrap.setreg failed to load: {str(e)}') + else: + for search_key in keys_to_extract: + try: + search_result = json_data["Amazon"]["AzCore"]["Bootstrap"][f'"{search_key}"'] + except Exception as e: + logging.error(f'Bootstrap.setreg cannot find Amazon:AzCore:Bootstrap:{search_result}: {str(e)}') + else: + result_map[search_key] = search_result - result_map = get_config_file_values(bootstrap_file, keys_to_extract) return result_map diff --git a/cmake/Tools/generate_game_paks.py b/cmake/Tools/generate_game_paks.py deleted file mode 100755 index 6a1ff1e458..0000000000 --- a/cmake/Tools/generate_game_paks.py +++ /dev/null @@ -1,244 +0,0 @@ -# -# All or portions of this file Copyright (c) Amazon.com, Inc. or its affiliates or -# its licensors. -# -# For complete copyright and license terms please see the LICENSE at the root of this -# distribution (the "License"). All use of this software is governed by the License, -# or, if provided, by the license below or the license accompanying this file. Do not -# remove or modify any license notices. This file is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# - -import argparse -import datetime -import logging -import pathlib -import platform -import sys -import os -import subprocess - -ROOT_DEV_PATH = os.path.realpath(os.path.join(os.path.dirname(__file__), '..', '..')) -if ROOT_DEV_PATH not in sys.path: - sys.path.append(ROOT_DEV_PATH) - -from cmake.Tools import common - -# The location of this python script is not portable relative to the engine root, we determine the engine root based -# on its relative location -DEV_ROOT = os.path.realpath(os.path.join(__file__, '../../..')) - -BOOTSTRAP_CFG = os.path.join(DEV_ROOT, 'bootstrap.cfg') - -EXECUTABLE_EXTN = '.exe' if platform.system() == 'Windows' else '' -RC_NAME = f'rc{EXECUTABLE_EXTN}' -APB_NAME = f'AssetProcessorBatch{EXECUTABLE_EXTN}' - -# Depending on the user request for verbosity, the argument list to subprocess may or may not redirect stdout to NULL -VERBOSE_CALL_ARGS = dict( - shell=True, - cwd=DEV_ROOT -) -NON_VERBOSE_CALL_ARGS = dict( - **VERBOSE_CALL_ARGS, - stdout=subprocess.DEVNULL -) - - -def command_arg(arg): - """ - Work-around for an issue when running subprocess on Linux: subprocess.check_call will take in the argument as an array - but only invokes the first item in the array, ignoring the arguments. As quick fix, we will combine the array into the - full command line and execute it that way on non-windows platforms - """ - if platform.system() == 'Windows': - return arg - else: - return ' '.join(arg) - - -def validate(binfolder, game_name, pak_script): - - # - # Validate the binfolder is relative and contains 'rc' and 'AssetProcessorBatch' - # - if os.path.isabs(binfolder): - raise common.LmbrCmdError("Invalid value for '-b/--binfolder'. It must be a path relative to the engine root folder", - common.ERROR_CODE_ERROR_DIRECTORY) - - binfolder_abs_path = pathlib.Path(DEV_ROOT) / binfolder - if not binfolder_abs_path.is_dir(): - raise common.LmbrCmdError("Invalid value for '-b/--binfolder'. Path does not exist or is not a directory", - common.ERROR_CODE_ERROR_DIRECTORY) - - rc_check = binfolder_abs_path / RC_NAME - if not rc_check.is_file(): - raise common.LmbrCmdError(f"Invalid value for '-b/--binfolder'. Path does not contain {RC_NAME}", - common.ERROR_CODE_ERROR_DIRECTORY) - - apb_check = binfolder_abs_path / APB_NAME - if not apb_check.is_file(): - raise common.LmbrCmdError(f"Invalid value for '-b/--binfolder'. Path does not contain {APB_NAME}", - common.ERROR_CODE_ERROR_DIRECTORY) - - # - # Validate the game name represents a game project within the game engine - # - gamefolder_abs_path = pathlib.Path(DEV_ROOT) / game_name - if not gamefolder_abs_path.is_dir(): - raise common.LmbrCmdError(f"Invalid value for '-g/--game-name'. No game '{game_name} exists.", - common.ERROR_CODE_ERROR_DIRECTORY) - - project_json_path = gamefolder_abs_path / 'project.json' - if not project_json_path.is_file(): - raise common.LmbrCmdError( - f"Invalid value for '-g/--game-name'. Folder '{game_name} is not a valid game project.", - common.ERROR_CODE_FILE_NOT_FOUND) - - if not os.path.isfile(pak_script): - raise common.LmbrCmdError(f'Pak script file {pak_script} does not exist.', - common.ERROR_CODE_FILE_NOT_FOUND) - - -def process(binfolder, game_name, asset_platform, autorun_assetprocessor, recompress, fastest_compression, target, - pak_script, warn_on_assetprocessor_error, verbose): - - logging.basicConfig(format='%(levelname)s: %(message)s', level=logging.DEBUG if verbose else logging.INFO) - - target_path_root_abs = pathlib.Path(DEV_ROOT) / target - if target_path_root_abs.is_file(): - raise common.LmbrCmdError(f"Target '{target}' already exists as a file.", - common.ERROR_CODE_GENERAL_ERROR) - os.makedirs(target_path_root_abs.absolute(), exist_ok=True) - - target_pak_folder_name = f'{game_name.lower()}_{asset_platform}_paks' - target_pak = target_path_root_abs / target_pak_folder_name - - # Prepare the asset processor batch arguments and execute if requested - if autorun_assetprocessor: - ap_executable = os.path.join(binfolder, APB_NAME) - ap_cmd_args = [ap_executable, - f'/gamefolder={game_name}', - f'/platforms={asset_platform}'] - logging.debug("Calling {}".format(' '.join(ap_cmd_args))) - try: - logging.info(f"Running {APB_NAME} on {game_name}") - start_time = datetime.datetime.now() - - call_args = VERBOSE_CALL_ARGS if verbose else NON_VERBOSE_CALL_ARGS - - subprocess.check_call(command_arg(ap_cmd_args), - **call_args) - - total_time = datetime.datetime.now() - start_time - logging.info(f"Asset Processing Complete. Elapse: {total_time}") - except subprocess.CalledProcessError: - if warn_on_assetprocessor_error: - logging.warning('AssetProcessorBatch reported errors') - else: - raise common.LmbrCmdError("AssetProcessorBatch has one or more failed assets.", - common.ERROR_CODE_GENERAL_ERROR) - - rc_executable = os.path.join(binfolder, RC_NAME) - rc_cmd_args = [rc_executable, - f'/job={pak_script}', - f'/p={asset_platform}', - f'/game={game_name}', - f'/trg={target_pak}'] - if recompress: - rc_cmd_args.append('/recompress=1') - if fastest_compression: - rc_cmd_args.append('/use_fastest=1') - logging.debug("Calling {}".format(' '.join(rc_cmd_args))) - - try: - logging.info(f"Running {APB_NAME} on {game_name}") - start_time = datetime.datetime.now() - - call_args = VERBOSE_CALL_ARGS if verbose else NON_VERBOSE_CALL_ARGS - - subprocess.check_call(command_arg(rc_cmd_args), - **call_args) - - total_time = datetime.datetime.now() - start_time - logging.info(f"Asset Processing Complete. Elapse: {total_time}") - logging.info(f"Pak files for {game_name} written to {target_pak}") - - except subprocess.CalledProcessError as err: - raise common.LmbrCmdError(f"{RC_NAME} returned an error: {str(err)}.", - err.returncode) - - -def main(args): - - parser = argparse.ArgumentParser() - - parser.add_argument('-b', '--binfolder', - help='The relative location of the binary folder that contains the resource compiler and asset processor') - - bootstrap = common.get_bootstrap_values(DEV_ROOT, ['project_path']) - parser.add_argument('-g', '--game-name', - help='The name of the Game whose asset pak will be generated for', - default=bootstrap.get('project_path')) - - parser.add_argument('-p', '--asset-platform', - help='The asset platform type to process') - - parser.add_argument('-a', '--autorun-assetprocessor', - help='Option to automatically invoke asset processor batch on the game before generating the pak', - action='store_true') - - parser.add_argument('-w', '--warn-on-assetprocessor-error', - help='When -a/--autorun-assetprocessor is specified, warn on asset processor failure rather than aborting the process', - action='store_true') - - parser.add_argument('-r', '--recompress', - action='store_true', - help='If present, the ResourceCompiler (RC.exe) will decompress and compress back each PAK file ' - 'found as they are transferred from the cache folder to the game_pc_pak folder.') - parser.add_argument('-fc', '--fastest-compression', - action='store_true', - help='As each file is being added to its PAK file, they will be compressed across all available ' - 'codecs (ZLIB, ZSTD and LZ4) and the one with the fastest decompression time will be ' - 'chosen. The default is to always use ZLIB') - parser.add_argument('--target', - default='Pak', - help='Specify a target folder for the pak files. (Default : Pak)') - parser.add_argument('--pak-script', - default=f'{DEV_ROOT}/{os.path.normpath("Code/Tools/RC/Config/rc/RCJob_Generic_MakePaks.xml")}', - help="The absolute path of the pak script configuration file to use to create the paks.") - - parser.add_argument('-v', '--verbose', - help='Enable debug messages', - action='store_true') - - parsed = parser.parse_args(args) - - validate(binfolder=parsed.binfolder, - game_name=parsed.game_name, - pak_script=parsed.pak_script) - - process(binfolder=parsed.binfolder, - game_name=parsed.game_name, - asset_platform=parsed.asset_platform, - autorun_assetprocessor=parsed.autorun_assetprocessor, - recompress=parsed.recompress, - fastest_compression=parsed.fastest_compression, - target=parsed.target, - pak_script=parsed.pak_script, - warn_on_assetprocessor_error=parsed.warn_on_assetprocessor_error, - verbose=parsed.verbose) - - -if __name__ == '__main__': - try: - if not os.path.isfile(BOOTSTRAP_CFG): - raise common.LmbrCmdError("Invalid dev root, missing bootstrap.cfg.", - common.ERROR_CODE_FILE_NOT_FOUND) - - main(sys.argv[1:]) - exit(0) - - except common.LmbrCmdError as err: - print(str(err), file=sys.stderr) - exit(err.code) diff --git a/cmake/Tools/layout_tool.py b/cmake/Tools/layout_tool.py index 8f573b61f5..69f5b34ae7 100755 --- a/cmake/Tools/layout_tool.py +++ b/cmake/Tools/layout_tool.py @@ -78,19 +78,19 @@ def verify_layout(layout_dir, platform_name, project_path, asset_mode, asset_typ if remote_on_check is None: # Validate that if '_connect_to_remote is enabled, that the 'input_remote_ip' is not set to local host if input_remote_connect == '1' and input_remote_ip == LOCAL_HOST: - return _warn("'bootstrap.cfg' is configured to connect to Asset Processor remotely, but the 'remote_ip' " + return _warn("'bootstrap.setreg' is configured to connect to Asset Processor remotely, but the 'remote_ip' " " is configured for LOCAL HOST") else: if remote_on_check: # Verify we are set for remote AP connection if input_remote_ip == LOCAL_HOST: - return _warn(f"'bootstrap.cfg' is not configured for a remote Asset Processor connection (remote_ip={input_remote_ip})") + return _warn(f"'bootstrap.setreg' is not configured for a remote Asset Processor connection (remote_ip={input_remote_ip})") if input_remote_connect != '1': - return _warn(f"'bootstrap.cfg' is not configured for a remote Asset Processor connection ({platform_name}_connect_to_remote={input_remote_connect}") + return _warn(f"'bootstrap.setreg' is not configured for a remote Asset Processor connection ({platform_name}_connect_to_remote={input_remote_connect}") else: # Verify we are disabled for remote AP connection if input_remote_connect != '0': - return _warn(f"'bootstrap.cfg' is not configured for a remote Asset Processor connection ({platform_name}_connect_to_remote={input_remote_connect}") + return _warn(f"'bootstrap.setreg' is not configured for a remote Asset Processor connection ({platform_name}_connect_to_remote={input_remote_connect}") return 0 @@ -107,20 +107,15 @@ def verify_layout(layout_dir, platform_name, project_path, asset_mode, asset_typ project_name_lower = project_path.lower() layout_path = pathlib.Path(layout_dir) - # Validate bootstrap.cfg exists - bootstrap_file = layout_path / 'bootstrap.cfg' - if not bootstrap_file.is_file(): - warning_count += _warn(f"'bootstrap.cfg' is missing from {str(layout_path)}") - bootstrap_values = None - else: - bootstrap_values = common.get_config_file_values(str(bootstrap_file), [f'{platform_name_lower}_remote_filesystem', - f'{platform_name_lower}_connect_to_remote', - f'{platform_name_lower}_wait_for_connect', - f'{platform_name_lower}_assets', - f'assets', - f'{platform_name_lower}_remote_ip', - f'remote_ip' - ]) + bootstrap_path = layout_path / 'Registry' + bootstrap_values = common.get_bootstrap_values(str(bootstrap_path), [f'{platform_name_lower}_remote_filesystem', + f'{platform_name_lower}_connect_to_remote', + f'{platform_name_lower}_wait_for_connect', + f'{platform_name_lower}_assets', + f'assets', + f'{platform_name_lower}_remote_ip', + f'remote_ip' + ]) # Validate the system_{platform}_{asset type}.cfg exists platform_system_cfg_file = layout_path / f'system_{platform_name_lower}_{asset_type}.cfg' @@ -141,9 +136,9 @@ def verify_layout(layout_dir, platform_name, project_path, asset_mode, asset_typ # Validate that the asset type for the platform matches the one set for the build bootstrap_asset_type = bootstrap_values.get(f'{platform_name_lower}_assets') or bootstrap_values.get('assets') if not bootstrap_asset_type: - warning_count += _warn("'bootstrap.cfg' is missing specifications for asset type.") + warning_count += _warn("'bootstrap.setreg' is missing specifications for asset type.") elif bootstrap_asset_type != asset_type: - warning_count += _warn(f"The asset type specified in bootstrap.cfg ({bootstrap_asset_type}) does not match the asset type specified for this deployment({asset_type}).") + warning_count += _warn(f"The asset type specified in bootstrap.setreg ({bootstrap_asset_type}) does not match the asset type specified for this deployment({asset_type}).") # Validate that if '_connect_to_remote is enabled, that the 'remote_ip' is not set to local host warning_count += _validate_remote_ap(remote_ip, remote_connect, None) @@ -211,7 +206,7 @@ def verify_layout(layout_dir, platform_name, project_path, asset_mode, asset_typ elif asset_mode == ASSET_MODE_VFS: remote_file_system = bootstrap_values.get(f'{platform_name_lower}_remote_filesystem') or '0' if not remote_file_system != '1': - warning_count += _warn("Remote file system is not configured in bootstrap.cfg for VFS mode.") + warning_count += _warn("Remote file system is not configured in bootstrap.setreg for VFS mode.") else: warning_count += _validate_remote_ap(remote_ip, remote_connect, True) diff --git a/cmake/Tools/unit_test_common.py b/cmake/Tools/unit_test_common.py index 58f89876c3..655c2a32c1 100755 --- a/cmake/Tools/unit_test_common.py +++ b/cmake/Tools/unit_test_common.py @@ -48,60 +48,6 @@ def test_determine_engine_root(tmpdir, engine_json_content, expected_success): assert result is None -TEST_BOOTSTRAP_CONTENT_1 = """ -project_path = Game1 -foo = bar -key1 = value1 -key2 = value2 -assets = pc ---No Assets -""" - -TEST_BOOTSTRAP_CONTENT_2 = """ -project_path = Game2 - foo = bar -#------------------------- - key1 = value1 -key2 = value2 -assets = pc ---No Assets -""" - - -@pytest.mark.parametrize( - "contents, input_keys, expected_result_map", [ - pytest.param(TEST_BOOTSTRAP_CONTENT_1, ['project_path', 'foo', 'assets'], {'project_path': 'Game1', - 'foo': 'bar', - 'assets': 'pc'}, id="TestFullMatch"), - pytest.param(TEST_BOOTSTRAP_CONTENT_2, ['project_path', 'foo', 'barnone'], {'project_path': 'Game2', - 'foo': 'bar'}, id="TestPartialMatch"), - pytest.param(TEST_BOOTSTRAP_CONTENT_2, ['project_pathnone', 'foonone', 'barnone'], {}, id="TestNoMatch") - ] -) -def test_get_bootstrap_values_success(tmpdir, contents, input_keys, expected_result_map): - - test_dev_root = 'dev' - tmpdir.ensure('{}/bootstrap.cfg'.format(test_dev_root)) - bootstrap_file = tmpdir.join('{}/bootstrap.cfg'.format(test_dev_root)) - bootstrap_file.write(contents) - - bootstrap_file_path = str(tmpdir.join(test_dev_root).realpath()) - - result = common.get_bootstrap_values(bootstrap_file_path, input_keys) - - assert expected_result_map == result - - -def test_get_bootstrap_values_fail(): - try: - bad_file = 'x:\\foo\\bar\\file\\' - common.get_bootstrap_values(bad_file, ['input_keys']) - except common.LmbrCmdError as err: - assert 'Missing' in str(err) - else: - assert False, "Excepted LayoutToolError (missing file)" - - TEST_AP_CONFIG_1 = """ [Platforms] ;pc=enabled @@ -245,7 +191,6 @@ def test_verify_game_project_and_dev_root_success(tmpdir): game_name = 'MyFoo' game_folder = 'myfoo' game_project_json = TEST_GAME_PROJECT_JSON_FORMAT.format(project_name=game_name) - tmpdir.ensure(f'{dev_root}/bootstrap.cfg') tmpdir.ensure(f'{dev_root}/{game_folder}/project.json') project_json_path = tmpdir / dev_root / game_folder / 'project.json' project_json_path.write_text(game_project_json, encoding='ascii') @@ -285,72 +230,6 @@ asset_deploy_type={test_asset_deploy_type} assert result.asset_deploy_type == test_asset_deploy_type -def test_transform_bootstrap_project_path(tmpdir): - - tmpdir.ensure('bootstrap.cfg') - - test_bootstrap_content = """ --- Blah Blah --- Blah Blah - -project_path=OldProject - --- remote_filesystem - enable Virtual File System (VFS) --- This feature allows a remote instance of the game to run off assets --- on the asset processor computers cache instead of deploying them the remote device --- By default it is off and can be overridden for any platform -remote_filesystem=0 -""" - test_src_bootstrap = tmpdir / 'bootstrap.cfg' - test_src_bootstrap.write_text(test_bootstrap_content, encoding='ascii') - - test_dst_bootstrap = tmpdir / 'bootstrap.transformed.cfg' - test_game_name = 'FooBar' - - common.transform_bootstrap_for_project(game_name=test_game_name, - src_bootstrap=str(test_src_bootstrap), - dst_bootstrap=str(test_dst_bootstrap)) - - transformed_text = test_dst_bootstrap.read_text('ascii') - - search_gamename = re.search(r"project_path\s*=\s*(.*)", transformed_text) - assert search_gamename - assert search_gamename.group(1) - assert search_gamename.group(1) == test_game_name - - -def test_transform_bootstrap_project_path_missing(tmpdir): - - tmpdir.ensure('bootstrap.cfg') - - test_bootstrap_content = """ --- Blah Blah --- Blah Blah - --- remote_filesystem - enable Virtual File System (VFS) --- This feature allows a remote instance of the game to run off assets --- on the asset processor computers cache instead of deploying them the remote device --- By default it is off and can be overridden for any platform -remote_filesystem=0 -""" - test_src_bootstrap = tmpdir / 'bootstrap.cfg' - test_src_bootstrap.write_text(test_bootstrap_content, encoding='ascii') - - test_dst_bootstrap = tmpdir / 'bootstrap.transformed.cfg' - test_game_name = 'FooBar' - - common.transform_bootstrap_for_project(game_name=test_game_name, - src_bootstrap=str(test_src_bootstrap), - dst_bootstrap=str(test_dst_bootstrap)) - - transformed_text = test_dst_bootstrap.read_text('ascii') - - search_gamename = re.search(r"project_path\s*=\s*(.*)", transformed_text) - assert search_gamename - assert search_gamename.group(1) - assert search_gamename.group(1) == test_game_name - - def test_cmake_dependency_success(tmpdir): test_module = 'FooBar' diff --git a/cmake/Tools/unit_test_current_project.py b/cmake/Tools/unit_test_current_project.py deleted file mode 100755 index 7db48b62aa..0000000000 --- a/cmake/Tools/unit_test_current_project.py +++ /dev/null @@ -1,102 +0,0 @@ -# -# All or portions of this file Copyright (c) Amazon.com, Inc. or its affiliates or -# its licensors. -# -# For complete copyright and license terms please see the LICENSE at the root of this -# distribution (the "License"). All use of this software is governed by the License, -# or, if provided, by the license below or the license accompanying this file. Do not -# remove or modify any license notices. This file is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# - -import os -import pytest - -from . import current_project - -TEST_BOOTSTRAP_CONTENT_1 = """ -project_path = Game1 -foo = bar -key1 = value1 -key2 = value2 -assets = pc -""" -TEST_BOOTSTRAP_CONTENT_2 = """ -project_path=Game1 -foo = bar -key1 = value1 -key2 = value2 -assets = pc -""" -TEST_BOOTSTRAP_CONTENT_3 = """ -project_path= Game1 -foo = bar -key1 = value1 -key2 = value2 -assets = pc -""" -TEST_BOOTSTRAP_CONTENT_4 = """ -project_path =Game1 -foo = bar -key1 = value1 -key2 = value2 -assets = pc -""" -TEST_BOOTSTRAP_CONTENT_5 = """ -project_path = Game1 -foo = bar -key1 = value1 -key2 = value2 -assets = pc -""" - -@pytest.mark.parametrize( - "contents, expected_result", [ - pytest.param(TEST_BOOTSTRAP_CONTENT_1, 'Game1'), - pytest.param(TEST_BOOTSTRAP_CONTENT_2, 'Game1'), - pytest.param(TEST_BOOTSTRAP_CONTENT_3, 'Game1'), - pytest.param(TEST_BOOTSTRAP_CONTENT_4, 'Game1'), - pytest.param(TEST_BOOTSTRAP_CONTENT_5, 'Game1'), - ] -) -def test_get_current_project(tmpdir, contents, expected_result): - dev_root = str(tmpdir.join('dev').realpath()).replace('\\', '/') - os.makedirs(dev_root, exist_ok=True) - - bootstrap_file = f'{dev_root}/bootstrap.cfg' - if os.path.isfile(bootstrap_file): - os.unlink(bootstrap_file) - with open(bootstrap_file, 'a') as s: - s.write(contents) - - result = current_project.get_current_project(dev_root) - assert expected_result == result - - -@pytest.mark.parametrize( - "contents, project_to_set, expected_result", [ - pytest.param(TEST_BOOTSTRAP_CONTENT_1, 'Test1', 0), - pytest.param(TEST_BOOTSTRAP_CONTENT_1, ' Test2', 0), - pytest.param(TEST_BOOTSTRAP_CONTENT_1, 'Test3 ', 0), - pytest.param(TEST_BOOTSTRAP_CONTENT_1, '/Test4', 1), - pytest.param(TEST_BOOTSTRAP_CONTENT_1, '=Test5', 1), - ] -) -def test_set_current_project(tmpdir, contents, project_to_set, expected_result): - dev_root = str(tmpdir.join('dev').realpath()).replace('\\', '/') - os.makedirs(dev_root, exist_ok=True) - - bootstrap_file = f'{dev_root}/bootstrap.cfg' - if os.path.isfile(bootstrap_file): - os.unlink(bootstrap_file) - with open(bootstrap_file, 'a') as s: - s.write(contents) - - result = current_project.set_current_project(dev_root, project_to_set) - assert expected_result == result - - if result == 0: - project_that_is_set = current_project.get_current_project(dev_root) - print(project_that_is_set) - print(project_to_set) - assert project_to_set.strip() == project_that_is_set \ No newline at end of file diff --git a/cmake/Tools/unit_test_layout_tool.py b/cmake/Tools/unit_test_layout_tool.py index 5be2c23f11..37684654b1 100755 --- a/cmake/Tools/unit_test_layout_tool.py +++ b/cmake/Tools/unit_test_layout_tool.py @@ -212,16 +212,15 @@ def test_create_link_error(): @pytest.mark.parametrize( - "project_path, asset_type, ensure_path, warn_on_missing, expected_result", [ - pytest.param('Foo', 'pc', 'Foo/Cache/pc/bootstrap.cfg', False, 'Foo/Cache/pc'), - pytest.param('Foo', 'pc', 'dev/bootstrap.cfg', True, None), - pytest.param('Foo', 'pc', 'Foo/Cache/es3/bootstrap.cfg', True, None), - pytest.param('Foo', 'pc', 'dev/bootstrap.cfg', False, common.LmbrCmdError), - pytest.param('Foo', 'pc', 'Foo/Cache/es3/bootstrap.cfg', False, common.LmbrCmdError), + "project_path, asset_type, warn_on_missing, expected_result", [ + pytest.param('Foo', 'pc', False, 'Foo/Cache/pc'), + pytest.param('Foo', 'pc', True, None), + pytest.param('Foo', 'pc', True, None), + pytest.param('Foo', 'pc', False, common.LmbrCmdError), + pytest.param('Foo', 'pc', False, common.LmbrCmdError), ] ) -def test_construct_and_validate_cache_game_asset_folder_success(tmpdir, project_path, asset_type, ensure_path, warn_on_missing, expected_result): - tmpdir.ensure(ensure_path) +def test_construct_and_validate_cache_game_asset_folder_success(tmpdir, project_path, asset_type, warn_on_missing, expected_result): if isinstance(expected_result, str): expected_path_realpath = str(tmpdir.join(expected_result).realpath()) elif expected_result == common.LmbrCmdError: @@ -385,7 +384,6 @@ def test_sync_layout_non_vfs_success(tmpdir, mode, existing_game_link, existing_ old_remove_link = layout_tool.remove_link try: # Simple Test Parameters - tmpdir.ensure('engine-root/bootstrap.cfg') engine_root_realpath = str(tmpdir.join('engine-root').realpath()) test_project_path = str(tmpdir.join('Foo').realpath()) test_project_name_lower = 'foo' diff --git a/scripts/build/package/package.py b/scripts/build/package/package.py index 96b39f0753..4cb09f3918 100755 --- a/scripts/build/package/package.py +++ b/scripts/build/package/package.py @@ -25,9 +25,6 @@ from glob3 import glob def package(options): package_env = PackageEnv(options.platform, options.type, options.package_env) - # Override values in bootstrap.cfg for PC package - override_bootstrap_cfg(package_env) - if not package_env.get('SKIP_BUILD'): print(package_env.get('SKIP_BUILD')) print('SKIP_BUILD is False, running CMake build...') @@ -51,34 +48,6 @@ def get_python_path(package_env): return os.path.join(package_env.get('ENGINE_ROOT'), 'python', 'python.sh') -def override_bootstrap_cfg(package_env): - print('Override values in bootstrap.cfg') - engine_root = package_env.get('ENGINE_ROOT') - bootstrap_path = os.path.join(engine_root, 'bootstrap.cfg') - replace_values = {'project_path':'{}'.format(package_env.get('BOOTSTRAP_CFG_GAME_FOLDER'))} - try: - with open(bootstrap_path, 'r') as bootstrap_cfg: - content = bootstrap_cfg.read() - except: - error('Cannot read file {}'.format(bootstrap_path)) - content = content.split('\n') - new_content = [] - for line in content: - if not line.startswith('--'): - strs = line.split('=') - if len(strs): - key = strs[0].strip(' ') - if key in replace_values: - line = '{}={}'.format(key, replace_values[key]) - new_content.append(line) - try: - with open(bootstrap_path, 'w') as out: - out.write('\n'.join(new_content)) - except: - error('Cannot write to file {}'.format(bootstrap_path)) - print('{} updated with value {}'.format(bootstrap_path, replace_values)) - - def cmake_build(package_env): build_targets = package_env.get('BUILD_TARGETS') for build_target in build_targets: From b63f2449c98e8a56fa3b8f58bdd700c3d0ea6853 Mon Sep 17 00:00:00 2001 From: amzn-sj Date: Wed, 19 May 2021 16:47:40 -0700 Subject: [PATCH 02/26] Remove reference to deleted function --- Tools/LyTestTools/ly_test_tools/launchers/platforms/base.py | 1 - 1 file changed, 1 deletion(-) diff --git a/Tools/LyTestTools/ly_test_tools/launchers/platforms/base.py b/Tools/LyTestTools/ly_test_tools/launchers/platforms/base.py index 1b0afb3efe..386de62048 100755 --- a/Tools/LyTestTools/ly_test_tools/launchers/platforms/base.py +++ b/Tools/LyTestTools/ly_test_tools/launchers/platforms/base.py @@ -123,7 +123,6 @@ class Launcher(object): """ backup_path = self.workspace.settings.get_temp_path() log.debug(f"Performing automatic backup of bootstrap, platform and user settings in path {backup_path}") - self.workspace.settings.backup_bootstrap_settings(backup_path) self.workspace.settings.backup_platform_settings(backup_path) self.workspace.settings.backup_shader_compiler_settings(backup_path) From 980c01efbfae1d1d3970f402edc554c420274ee7 Mon Sep 17 00:00:00 2001 From: amzn-sj Date: Wed, 19 May 2021 16:48:50 -0700 Subject: [PATCH 03/26] Remove call to set default param --- .../TechnicalArt/DccScriptingInterface/azpy/synthetic_env.py | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/Gems/AtomLyIntegration/TechnicalArt/DccScriptingInterface/azpy/synthetic_env.py b/Gems/AtomLyIntegration/TechnicalArt/DccScriptingInterface/azpy/synthetic_env.py index 86e4b68488..6a3340788b 100644 --- a/Gems/AtomLyIntegration/TechnicalArt/DccScriptingInterface/azpy/synthetic_env.py +++ b/Gems/AtomLyIntegration/TechnicalArt/DccScriptingInterface/azpy/synthetic_env.py @@ -384,8 +384,7 @@ def stash_env(_SYNTH_ENV_DICT = OrderedDict()): # changed to just make the fallback what is set in boostrap # so now it's less of a fallnack and more correct if not # explicitly set - _LY_PROJECT = os.getenv(ENVAR_LY_PROJECT, - get_current_project(_LY_DEV)) + _LY_PROJECT = os.getenv(ENVAR_LY_PROJECT) _SYNTH_ENV_DICT[ENVAR_LY_PROJECT] = _LY_PROJECT _LY_BUILD_DIR_NAME = os.getenv(ENVAR_LY_BUILD_DIR_NAME, From d33fa7dccc0cc037e1dd266cc228c84de5a3f4d6 Mon Sep 17 00:00:00 2001 From: amzn-sj Date: Thu, 20 May 2021 09:27:47 -0700 Subject: [PATCH 04/26] Fix for tests that are failing due to project_path not being set --- Code/Tools/AssetBundler/tests/tests_main.cpp | 4 ++++ Gems/AssetValidation/Code/Tests/AssetValidationTestShared.h | 4 ++++ 2 files changed, 8 insertions(+) diff --git a/Code/Tools/AssetBundler/tests/tests_main.cpp b/Code/Tools/AssetBundler/tests/tests_main.cpp index 29f9970f35..5f68e7870b 100644 --- a/Code/Tools/AssetBundler/tests/tests_main.cpp +++ b/Code/Tools/AssetBundler/tests/tests_main.cpp @@ -110,6 +110,10 @@ namespace AssetBundler if (!AZ::SettingsRegistry::Get()) { AZ::SettingsRegistry::Register(&m_registry); + auto projectPathKey = AZ::SettingsRegistryInterface::FixedValueString(AZ::SettingsRegistryMergeUtils::BootstrapSettingsRootKey) + + "/project_path"; + m_registry.Set(projectPathKey, "AutomatedTesting"); + AZ::SettingsRegistryMergeUtils::MergeSettingsToRegistry_AddRuntimeFilePaths(m_registry); } AZ::IO::FixedMaxPath engineRoot = AZ::Utils::GetEnginePath(); diff --git a/Gems/AssetValidation/Code/Tests/AssetValidationTestShared.h b/Gems/AssetValidation/Code/Tests/AssetValidationTestShared.h index f4a24bf629..eafd2bf47d 100644 --- a/Gems/AssetValidation/Code/Tests/AssetValidationTestShared.h +++ b/Gems/AssetValidation/Code/Tests/AssetValidationTestShared.h @@ -152,6 +152,10 @@ struct AssetValidationTest { AZ::SettingsRegistry::Register(&m_registry); + AZ::SettingsRegistry::Register(&m_registry); + auto projectPathKey = AZ::SettingsRegistryInterface::FixedValueString(AZ::SettingsRegistryMergeUtils::BootstrapSettingsRootKey) + + "/project_path"; + m_registry.Set(projectPathKey, "AutomatedTesting"); AZ::SettingsRegistryMergeUtils::MergeSettingsToRegistry_AddRuntimeFilePaths(m_registry); // Set the engine root to the temporary directory and re-update the runtime file paths auto enginePathKey = AZ::SettingsRegistryInterface::FixedValueString(AZ::SettingsRegistryMergeUtils::BootstrapSettingsRootKey) From 471d9afe82baac9dba29b34456ff886047e15fff Mon Sep 17 00:00:00 2001 From: amzn-sj Date: Thu, 20 May 2021 09:31:55 -0700 Subject: [PATCH 05/26] Minor edits to python script --- cmake/Tools/common.py | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/cmake/Tools/common.py b/cmake/Tools/common.py index d20fcad6c7..8189bb3ca3 100755 --- a/cmake/Tools/common.py +++ b/cmake/Tools/common.py @@ -147,7 +147,6 @@ def get_bootstrap_values(bootstrap_dir, keys_to_extract): bootstrap_file = os.path.join(bootstrap_dir, 'bootstrap.setreg') if not os.path.isfile(bootstrap_file): raise logging.error(f'Bootstrap.setreg file {bootstrap_file} does not exist.') - return None result_map = {} with bootstrap_file.open('r') as f: @@ -159,7 +158,7 @@ def get_bootstrap_values(bootstrap_dir, keys_to_extract): for search_key in keys_to_extract: try: search_result = json_data["Amazon"]["AzCore"]["Bootstrap"][f'"{search_key}"'] - except Exception as e: + except KeyError as e: logging.error(f'Bootstrap.setreg cannot find Amazon:AzCore:Bootstrap:{search_result}: {str(e)}') else: result_map[search_key] = search_result From 1a1874b3bce6cdf7595e02e63c2558e1f756804a Mon Sep 17 00:00:00 2001 From: amzn-sj Date: Thu, 20 May 2021 10:56:54 -0700 Subject: [PATCH 06/26] Remove duplicate calls to some functions --- Gems/AssetValidation/Code/Tests/AssetValidationTestShared.h | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/Gems/AssetValidation/Code/Tests/AssetValidationTestShared.h b/Gems/AssetValidation/Code/Tests/AssetValidationTestShared.h index eafd2bf47d..408eb36022 100644 --- a/Gems/AssetValidation/Code/Tests/AssetValidationTestShared.h +++ b/Gems/AssetValidation/Code/Tests/AssetValidationTestShared.h @@ -152,11 +152,10 @@ struct AssetValidationTest { AZ::SettingsRegistry::Register(&m_registry); - AZ::SettingsRegistry::Register(&m_registry); auto projectPathKey = AZ::SettingsRegistryInterface::FixedValueString(AZ::SettingsRegistryMergeUtils::BootstrapSettingsRootKey) + "/project_path"; m_registry.Set(projectPathKey, "AutomatedTesting"); - AZ::SettingsRegistryMergeUtils::MergeSettingsToRegistry_AddRuntimeFilePaths(m_registry); + // Set the engine root to the temporary directory and re-update the runtime file paths auto enginePathKey = AZ::SettingsRegistryInterface::FixedValueString(AZ::SettingsRegistryMergeUtils::BootstrapSettingsRootKey) + "/engine_path"; From ff35804ce350a4361710a0ce57b0e79efccb4283 Mon Sep 17 00:00:00 2001 From: amzn-sj Date: Thu, 20 May 2021 11:19:27 -0700 Subject: [PATCH 07/26] Change prefab assert to warning --- .../AzToolsFramework/AzToolsFramework/Prefab/PrefabLoader.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Code/Framework/AzToolsFramework/AzToolsFramework/Prefab/PrefabLoader.cpp b/Code/Framework/AzToolsFramework/AzToolsFramework/Prefab/PrefabLoader.cpp index 7b4761c39a..2965148172 100644 --- a/Code/Framework/AzToolsFramework/AzToolsFramework/Prefab/PrefabLoader.cpp +++ b/Code/Framework/AzToolsFramework/AzToolsFramework/Prefab/PrefabLoader.cpp @@ -41,7 +41,7 @@ namespace AzToolsFramework [[maybe_unused]] bool result = settingsRegistry->Get(m_projectPathWithOsSeparator.Native(), AZ::SettingsRegistryMergeUtils::FilePathKey_ProjectPath); - AZ_Assert(result, "Couldn't retrieve project root path"); + AZ_Warning("Prefab", result, "Couldn't retrieve project root path"); m_projectPathWithSlashSeparator = AZ::IO::Path(m_projectPathWithOsSeparator.Native(), '/').MakePreferred(); AZ::Interface::Register(this); From ac4df978c60563c09bf4375cd2acb4f019d2ad5b Mon Sep 17 00:00:00 2001 From: amzn-sj Date: Thu, 20 May 2021 14:39:17 -0700 Subject: [PATCH 08/26] Add call to update runtime file paths in the registry back(Partial undo from previous commit). --- Gems/AssetValidation/Code/Tests/AssetValidationTestShared.h | 1 + 1 file changed, 1 insertion(+) diff --git a/Gems/AssetValidation/Code/Tests/AssetValidationTestShared.h b/Gems/AssetValidation/Code/Tests/AssetValidationTestShared.h index 408eb36022..d67260de3e 100644 --- a/Gems/AssetValidation/Code/Tests/AssetValidationTestShared.h +++ b/Gems/AssetValidation/Code/Tests/AssetValidationTestShared.h @@ -155,6 +155,7 @@ struct AssetValidationTest auto projectPathKey = AZ::SettingsRegistryInterface::FixedValueString(AZ::SettingsRegistryMergeUtils::BootstrapSettingsRootKey) + "/project_path"; m_registry.Set(projectPathKey, "AutomatedTesting"); + AZ::SettingsRegistryMergeUtils::MergeSettingsToRegistry_AddRuntimeFilePaths(m_registry); // Set the engine root to the temporary directory and re-update the runtime file paths auto enginePathKey = AZ::SettingsRegistryInterface::FixedValueString(AZ::SettingsRegistryMergeUtils::BootstrapSettingsRootKey) From e54963f0a9f177ff88becc61ebe13ecaf8677191 Mon Sep 17 00:00:00 2001 From: amzn-sj Date: Fri, 21 May 2021 11:00:50 -0700 Subject: [PATCH 09/26] Set project_path in the SettingsRegistry in the test SetUp() functions for tests that require a project to be set --- .../Tests/PlatformAddressedAssetCatalogTests.cpp | 10 ++++++++++ Code/Framework/Tests/ArchiveCompressionTests.cpp | 8 ++++++++ Code/Framework/Tests/ArchiveTests.cpp | 9 +++++++++ .../tests/AssetCatalog/AssetCatalogUnitTests.cpp | 3 +++ .../AssetProcessor/native/tests/AssetProcessorTest.cpp | 8 +++++++- .../tests/assetmanager/AssetProcessorManagerTest.cpp | 3 +++ 6 files changed, 40 insertions(+), 1 deletion(-) diff --git a/Code/Framework/AzToolsFramework/Tests/PlatformAddressedAssetCatalogTests.cpp b/Code/Framework/AzToolsFramework/Tests/PlatformAddressedAssetCatalogTests.cpp index 328bf5dea5..4cc98106d6 100644 --- a/Code/Framework/AzToolsFramework/Tests/PlatformAddressedAssetCatalogTests.cpp +++ b/Code/Framework/AzToolsFramework/Tests/PlatformAddressedAssetCatalogTests.cpp @@ -10,6 +10,8 @@ * */ +#include +#include #include #include #include @@ -49,6 +51,14 @@ namespace UnitTest using namespace AZ::Data; m_application = new ToolsTestApplication("AddressedAssetCatalogManager"); // Shorter name because Setting Registry // specialization are 32 characters max. + + AZ::SettingsRegistryInterface* registry = AZ::SettingsRegistry::Get(); + + auto projectPathKey = + AZ::SettingsRegistryInterface::FixedValueString(AZ::SettingsRegistryMergeUtils::BootstrapSettingsRootKey) + "/project_path"; + registry->Set(projectPathKey, "AutomatedTesting"); + AZ::SettingsRegistryMergeUtils::MergeSettingsToRegistry_AddRuntimeFilePaths(*registry); + m_application->Start(AzFramework::Application::Descriptor()); // Without this, the user settings component would attempt to save on finalize/shutdown. Since the file is // shared across the whole engine, if multiple tests are run in parallel, the saving could cause a crash diff --git a/Code/Framework/Tests/ArchiveCompressionTests.cpp b/Code/Framework/Tests/ArchiveCompressionTests.cpp index fb6beca0b5..c648262599 100644 --- a/Code/Framework/Tests/ArchiveCompressionTests.cpp +++ b/Code/Framework/Tests/ArchiveCompressionTests.cpp @@ -11,6 +11,7 @@ */ #include +#include #include #include #include @@ -40,6 +41,13 @@ namespace UnitTest void SetUp() override { + AZ::SettingsRegistryInterface* registry = AZ::SettingsRegistry::Get(); + + auto projectPathKey = + AZ::SettingsRegistryInterface::FixedValueString(AZ::SettingsRegistryMergeUtils::BootstrapSettingsRootKey) + "/project_path"; + registry->Set(projectPathKey, "AutomatedTesting"); + AZ::SettingsRegistryMergeUtils::MergeSettingsToRegistry_AddRuntimeFilePaths(*registry); + m_application->Start({}); // Without this, the user settings component would attempt to save on finalize/shutdown. Since the file is // shared across the whole engine, if multiple tests are run in parallel, the saving could cause a crash diff --git a/Code/Framework/Tests/ArchiveTests.cpp b/Code/Framework/Tests/ArchiveTests.cpp index aaca043c4b..6dc081ee72 100644 --- a/Code/Framework/Tests/ArchiveTests.cpp +++ b/Code/Framework/Tests/ArchiveTests.cpp @@ -16,6 +16,7 @@ #include #include // for max path decl +#include #include #include #include // for function<> in the find files callback. @@ -42,6 +43,14 @@ namespace UnitTest { AZ::ComponentApplication::Descriptor descriptor; descriptor.m_stackRecordLevels = 30; + + AZ::SettingsRegistryInterface* registry = AZ::SettingsRegistry::Get(); + + auto projectPathKey = + AZ::SettingsRegistryInterface::FixedValueString(AZ::SettingsRegistryMergeUtils::BootstrapSettingsRootKey) + "/project_path"; + registry->Set(projectPathKey, "AutomatedTesting"); + AZ::SettingsRegistryMergeUtils::MergeSettingsToRegistry_AddRuntimeFilePaths(*registry); + m_application->Start(descriptor); // Without this, the user settings component would attempt to save on finalize/shutdown. Since the file is // shared across the whole engine, if multiple tests are run in parallel, the saving could cause a crash diff --git a/Code/Tools/AssetProcessor/native/tests/AssetCatalog/AssetCatalogUnitTests.cpp b/Code/Tools/AssetProcessor/native/tests/AssetCatalog/AssetCatalogUnitTests.cpp index e92e9afba5..3d9ecd3f5e 100644 --- a/Code/Tools/AssetProcessor/native/tests/AssetCatalog/AssetCatalogUnitTests.cpp +++ b/Code/Tools/AssetProcessor/native/tests/AssetCatalog/AssetCatalogUnitTests.cpp @@ -130,6 +130,9 @@ namespace AssetProcessor auto cacheRootKey = AZ::SettingsRegistryInterface::FixedValueString(AZ::SettingsRegistryMergeUtils::BootstrapSettingsRootKey) + "/project_cache_path"; settingsRegistry->Set(cacheRootKey, m_data->m_temporarySourceDir.absoluteFilePath("Cache").toUtf8().constData()); + auto projectPathKey = + AZ::SettingsRegistryInterface::FixedValueString(AZ::SettingsRegistryMergeUtils::BootstrapSettingsRootKey) + "/project_path"; + settingsRegistry->Set(projectPathKey, "AutomatedTesting"); AZ::SettingsRegistryMergeUtils::MergeSettingsToRegistry_AddRuntimeFilePaths(*settingsRegistry); AssetUtilities::ComputeProjectCacheRoot(m_data->m_cacheRootDir); QString normalizedCacheRoot = AssetUtilities::NormalizeDirectoryPath(m_data->m_cacheRootDir.absolutePath()); diff --git a/Code/Tools/AssetProcessor/native/tests/AssetProcessorTest.cpp b/Code/Tools/AssetProcessor/native/tests/AssetProcessorTest.cpp index d04e13aef2..7b88321ad9 100644 --- a/Code/Tools/AssetProcessor/native/tests/AssetProcessorTest.cpp +++ b/Code/Tools/AssetProcessor/native/tests/AssetProcessorTest.cpp @@ -12,7 +12,7 @@ #include "AssetProcessorTest.h" - +#include #include #include "BaseAssetProcessorTest.h" @@ -67,6 +67,12 @@ namespace AssetProcessor static char processName[] = {"AssetProcessorBatch"}; static char* namePtr = &processName[0]; static char** paramStringArray = &namePtr; + + auto registry = AZ::SettingsRegistry::Get(); + auto projectPathKey = + AZ::SettingsRegistryInterface::FixedValueString(AZ::SettingsRegistryMergeUtils::BootstrapSettingsRootKey) + "/project_path"; + registry->Set(projectPathKey, "AutomatedTesting"); + AZ::SettingsRegistryMergeUtils::MergeSettingsToRegistry_AddRuntimeFilePaths(*registry); m_application.reset(new UnitTestAppManager(&numParams, ¶mStringArray)); ASSERT_EQ(m_application->BeforeRun(), ApplicationManager::Status_Success); diff --git a/Code/Tools/AssetProcessor/native/tests/assetmanager/AssetProcessorManagerTest.cpp b/Code/Tools/AssetProcessor/native/tests/assetmanager/AssetProcessorManagerTest.cpp index 07d1e48229..d592ecb012 100644 --- a/Code/Tools/AssetProcessor/native/tests/assetmanager/AssetProcessorManagerTest.cpp +++ b/Code/Tools/AssetProcessor/native/tests/assetmanager/AssetProcessorManagerTest.cpp @@ -204,6 +204,9 @@ void AssetProcessorManagerTest::SetUp() auto cacheRootKey = AZ::SettingsRegistryInterface::FixedValueString(AZ::SettingsRegistryMergeUtils::BootstrapSettingsRootKey) + "/project_cache_path"; registry->Set(cacheRootKey, tempPath.absoluteFilePath("Cache").toUtf8().constData()); + auto projectPathKey = + AZ::SettingsRegistryInterface::FixedValueString(AZ::SettingsRegistryMergeUtils::BootstrapSettingsRootKey) + "/project_path"; + registry->Set(projectPathKey, "AutomatedTesting"); AZ::SettingsRegistryMergeUtils::MergeSettingsToRegistry_AddRuntimeFilePaths(*registry); m_data->m_databaseLocationListener.BusConnect(); From 7c74336ebb5be88a9a9c7d3a1f1bca97c3885681 Mon Sep 17 00:00:00 2001 From: amzn-sj Date: Fri, 21 May 2021 12:01:21 -0700 Subject: [PATCH 10/26] Add project_path to the registry for one more failing test. --- .../Code/Tests/EditorPythonBindingsTest.cpp | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/Gems/EditorPythonBindings/Code/Tests/EditorPythonBindingsTest.cpp b/Gems/EditorPythonBindings/Code/Tests/EditorPythonBindingsTest.cpp index 86628d08a1..440638c61f 100644 --- a/Gems/EditorPythonBindings/Code/Tests/EditorPythonBindingsTest.cpp +++ b/Gems/EditorPythonBindings/Code/Tests/EditorPythonBindingsTest.cpp @@ -18,6 +18,7 @@ #include #include +#include #include #include @@ -322,6 +323,13 @@ sys.version void SetUp() override { PythonTestingFixture::SetUp(); + + auto registry = AZ::SettingsRegistry::Get(); + auto projectPathKey = AZ::SettingsRegistryInterface::FixedValueString(AZ::SettingsRegistryMergeUtils::BootstrapSettingsRootKey) + + "/project_path"; + registry->Set(projectPathKey, "AutomatedTesting"); + AZ::SettingsRegistryMergeUtils::MergeSettingsToRegistry_AddRuntimeFilePaths(*registry); + m_app.RegisterComponentDescriptor(EditorPythonBindings::PythonSystemComponent::CreateDescriptor()); } From f4e6508347653484a280755ec00f4f1dfc9758e8 Mon Sep 17 00:00:00 2001 From: amzn-sj Date: Mon, 24 May 2021 09:50:19 -0700 Subject: [PATCH 11/26] Test fix for some failing tests on Linux --- Gems/LyShine/Code/Tests/LyShineEditorTest.cpp | 7 +++++++ Gems/Prefab/PrefabBuilder/PrefabBuilderTests.cpp | 7 +++++++ 2 files changed, 14 insertions(+) diff --git a/Gems/LyShine/Code/Tests/LyShineEditorTest.cpp b/Gems/LyShine/Code/Tests/LyShineEditorTest.cpp index 9e57ac26fd..68da6e6009 100644 --- a/Gems/LyShine/Code/Tests/LyShineEditorTest.cpp +++ b/Gems/LyShine/Code/Tests/LyShineEditorTest.cpp @@ -16,6 +16,7 @@ #include #include #include +#include #include #include #include @@ -88,6 +89,12 @@ protected: m_data->m_stubEnv.pSystem = &m_data->m_mockSystem; gEnv = &m_data->m_stubEnv; + AZ::SettingsRegistryInterface* registry = AZ::SettingsRegistry::Get(); + auto projectPathKey = + AZ::SettingsRegistryInterface::FixedValueString(AZ::SettingsRegistryMergeUtils::BootstrapSettingsRootKey) + "/project_path"; + registry->Set(projectPathKey, "AutomatedTesting"); + AZ::SettingsRegistryMergeUtils::MergeSettingsToRegistry_AddRuntimeFilePaths(*registry); + m_app.Start(m_descriptor); // Without this, the user settings component would attempt to save on finalize/shutdown. Since the file is // shared across the whole engine, if multiple tests are run in parallel, the saving could cause a crash diff --git a/Gems/Prefab/PrefabBuilder/PrefabBuilderTests.cpp b/Gems/Prefab/PrefabBuilder/PrefabBuilderTests.cpp index 2bb0d8aaf3..ace089b9bd 100644 --- a/Gems/Prefab/PrefabBuilder/PrefabBuilderTests.cpp +++ b/Gems/Prefab/PrefabBuilder/PrefabBuilderTests.cpp @@ -14,6 +14,7 @@ #include #include #include +#include #include namespace UnitTest @@ -172,6 +173,12 @@ namespace UnitTest void PrefabBuilderTests::SetUp() { + AZ::SettingsRegistryInterface* registry = AZ::SettingsRegistry::Get(); + auto projectPathKey = + AZ::SettingsRegistryInterface::FixedValueString(AZ::SettingsRegistryMergeUtils::BootstrapSettingsRootKey) + "/project_path"; + registry->Set(projectPathKey, "AutomatedTesting"); + AZ::SettingsRegistryMergeUtils::MergeSettingsToRegistry_AddRuntimeFilePaths(*registry); + AZ::ComponentApplication::Descriptor desc; m_app.Start(desc); m_app.CreateReflectionManager(); From 115f18fcdc54753dfae542bcd0d79c5cf0a10a66 Mon Sep 17 00:00:00 2001 From: amzn-sj Date: Mon, 24 May 2021 12:24:46 -0700 Subject: [PATCH 12/26] Fix Linux test failures --- Code/Framework/Tests/AssetCatalog.cpp | 7 ++++++ Code/Framework/Tests/BehaviorEntityTests.cpp | 7 ++++++ Code/Framework/Tests/ComponentAddRemove.cpp | 7 ++++++ Code/Framework/Tests/FileFunc.cpp | 7 ++++++ Code/Framework/Tests/FileTagTests.cpp | 8 ++++++ .../Tests/GenericComponentWrapperTest.cpp | 13 ++++++++++ Code/Framework/Tests/Slices.cpp | 7 ++++++ .../tests/applicationManagerTests.cpp | 6 +++++ Code/Tools/AssetBundler/tests/tests_main.cpp | 25 ++++++++++++------- .../platformconfigurationtests.cpp | 5 ++++ .../Tools/DeltaCataloger/Tests/tests_main.cpp | 7 ++++++ .../Code/Tests/Builders/LevelBuilderTest.cpp | 7 ++++++ .../Code/Tests/Builders/LuaBuilderTests.cpp | 7 ++++++ .../Tests/Builders/MaterialBuilderTests.cpp | 7 ++++++ .../Code/Tests/Builders/SeedBuilderTests.cpp | 7 ++++++ .../SceneBuilder/SceneBuilderPhasesTests.cpp | 7 ++++++ .../Tests/SceneBuilder/SceneBuilderTests.cpp | 7 ++++++ 17 files changed, 132 insertions(+), 9 deletions(-) diff --git a/Code/Framework/Tests/AssetCatalog.cpp b/Code/Framework/Tests/AssetCatalog.cpp index 8a89ba349c..42df712713 100644 --- a/Code/Framework/Tests/AssetCatalog.cpp +++ b/Code/Framework/Tests/AssetCatalog.cpp @@ -23,6 +23,7 @@ #include #include #include +#include #include #include #include @@ -301,6 +302,12 @@ namespace UnitTest { AZ::AllocatorInstance::Create(); + AZ::SettingsRegistryInterface* registry = AZ::SettingsRegistry::Get(); + auto projectPathKey = + AZ::SettingsRegistryInterface::FixedValueString(AZ::SettingsRegistryMergeUtils::BootstrapSettingsRootKey) + "/project_path"; + registry->Set(projectPathKey, "AutomatedTesting"); + AZ::SettingsRegistryMergeUtils::MergeSettingsToRegistry_AddRuntimeFilePaths(*registry); + m_app.reset(aznew AzFramework::Application()); AZ::ComponentApplication::Descriptor desc; desc.m_useExistingAllocator = true; diff --git a/Code/Framework/Tests/BehaviorEntityTests.cpp b/Code/Framework/Tests/BehaviorEntityTests.cpp index 5a4116a23b..398d472d6b 100644 --- a/Code/Framework/Tests/BehaviorEntityTests.cpp +++ b/Code/Framework/Tests/BehaviorEntityTests.cpp @@ -12,6 +12,7 @@ #include "FrameworkApplicationFixture.h" #include +#include #include #include @@ -88,6 +89,12 @@ class BehaviorEntityTest protected: void SetUp() override { + AZ::SettingsRegistryInterface* registry = AZ::SettingsRegistry::Get(); + auto projectPathKey = + AZ::SettingsRegistryInterface::FixedValueString(AZ::SettingsRegistryMergeUtils::BootstrapSettingsRootKey) + "/project_path"; + registry->Set(projectPathKey, "AutomatedTesting"); + AZ::SettingsRegistryMergeUtils::MergeSettingsToRegistry_AddRuntimeFilePaths(*registry); + m_appDescriptor.m_enableScriptReflection = true; FrameworkApplicationFixture::SetUp(); diff --git a/Code/Framework/Tests/ComponentAddRemove.cpp b/Code/Framework/Tests/ComponentAddRemove.cpp index 4fd6db7dde..f635a5ee3b 100644 --- a/Code/Framework/Tests/ComponentAddRemove.cpp +++ b/Code/Framework/Tests/ComponentAddRemove.cpp @@ -12,6 +12,7 @@ #include #include +#include #include #include @@ -572,6 +573,12 @@ namespace UnitTest { AllocatorsTestFixture::SetUp(); + AZ::SettingsRegistryInterface* registry = AZ::SettingsRegistry::Get(); + auto projectPathKey = + AZ::SettingsRegistryInterface::FixedValueString(AZ::SettingsRegistryMergeUtils::BootstrapSettingsRootKey) + "/project_path"; + registry->Set(projectPathKey, "AutomatedTesting"); + AZ::SettingsRegistryMergeUtils::MergeSettingsToRegistry_AddRuntimeFilePaths(*registry); + AzFramework::Application::Descriptor descriptor; descriptor.m_enableDrilling = false; m_app.Start(descriptor); diff --git a/Code/Framework/Tests/FileFunc.cpp b/Code/Framework/Tests/FileFunc.cpp index d703164582..8db77fd79b 100644 --- a/Code/Framework/Tests/FileFunc.cpp +++ b/Code/Framework/Tests/FileFunc.cpp @@ -17,6 +17,7 @@ #include #include #include +#include #include #include #include @@ -278,6 +279,12 @@ namespace UnitTest { FrameworkApplicationFixture::SetUp(); + AZ::SettingsRegistryInterface* registry = AZ::SettingsRegistry::Get(); + auto projectPathKey = + AZ::SettingsRegistryInterface::FixedValueString(AZ::SettingsRegistryMergeUtils::BootstrapSettingsRootKey) + "/project_path"; + registry->Set(projectPathKey, "AutomatedTesting"); + AZ::SettingsRegistryMergeUtils::MergeSettingsToRegistry_AddRuntimeFilePaths(*registry); + m_serializeContext = AZStd::make_unique(); m_jsonRegistrationContext = AZStd::make_unique(); m_jsonSystemComponent = AZStd::make_unique(); diff --git a/Code/Framework/Tests/FileTagTests.cpp b/Code/Framework/Tests/FileTagTests.cpp index 989c811111..d17601ed1c 100644 --- a/Code/Framework/Tests/FileTagTests.cpp +++ b/Code/Framework/Tests/FileTagTests.cpp @@ -14,6 +14,7 @@ #include #include #include +#include #include #include #include @@ -83,6 +84,13 @@ namespace UnitTest void SetUp() override { AllocatorsFixture::SetUp(); + + AZ::SettingsRegistryInterface* registry = AZ::SettingsRegistry::Get(); + auto projectPathKey = + AZ::SettingsRegistryInterface::FixedValueString(AZ::SettingsRegistryMergeUtils::BootstrapSettingsRootKey) + "/project_path"; + registry->Set(projectPathKey, "AutomatedTesting"); + AZ::SettingsRegistryMergeUtils::MergeSettingsToRegistry_AddRuntimeFilePaths(*registry); + m_data = AZStd::make_unique(); using namespace AzFramework::FileTag; AZ::ComponentApplication::Descriptor desc; diff --git a/Code/Framework/Tests/GenericComponentWrapperTest.cpp b/Code/Framework/Tests/GenericComponentWrapperTest.cpp index b3dac90777..25af10b339 100644 --- a/Code/Framework/Tests/GenericComponentWrapperTest.cpp +++ b/Code/Framework/Tests/GenericComponentWrapperTest.cpp @@ -12,6 +12,7 @@ #include #include #include +#include #include #include #include @@ -59,6 +60,12 @@ class WrappedEditorComponentTest protected: void SetUp() override { + AZ::SettingsRegistryInterface* registry = AZ::SettingsRegistry::Get(); + auto projectPathKey = + AZ::SettingsRegistryInterface::FixedValueString(AZ::SettingsRegistryMergeUtils::BootstrapSettingsRootKey) + "/project_path"; + registry->Set(projectPathKey, "AutomatedTesting"); + AZ::SettingsRegistryMergeUtils::MergeSettingsToRegistry_AddRuntimeFilePaths(*registry); + m_app.Start(AZ::ComponentApplication::Descriptor()); // Without this, the user settings component would attempt to save on finalize/shutdown. Since the file is @@ -178,6 +185,12 @@ class FindWrappedComponentsTest public: void SetUp() override { + AZ::SettingsRegistryInterface* registry = AZ::SettingsRegistry::Get(); + auto projectPathKey = + AZ::SettingsRegistryInterface::FixedValueString(AZ::SettingsRegistryMergeUtils::BootstrapSettingsRootKey) + "/project_path"; + registry->Set(projectPathKey, "AutomatedTesting"); + AZ::SettingsRegistryMergeUtils::MergeSettingsToRegistry_AddRuntimeFilePaths(*registry); + m_app.Start(AzFramework::Application::Descriptor()); // Without this, the user settings component would attempt to save on finalize/shutdown. Since the file is diff --git a/Code/Framework/Tests/Slices.cpp b/Code/Framework/Tests/Slices.cpp index 6a9ce858c0..8a20c43fb5 100644 --- a/Code/Framework/Tests/Slices.cpp +++ b/Code/Framework/Tests/Slices.cpp @@ -22,6 +22,7 @@ #include #include #include +#include #include #include #include @@ -1059,6 +1060,12 @@ namespace UnitTest void SetUp() override { + AZ::SettingsRegistryInterface* registry = AZ::SettingsRegistry::Get(); + auto projectPathKey = + AZ::SettingsRegistryInterface::FixedValueString(AZ::SettingsRegistryMergeUtils::BootstrapSettingsRootKey) + "/project_path"; + registry->Set(projectPathKey, "AutomatedTesting"); + AZ::SettingsRegistryMergeUtils::MergeSettingsToRegistry_AddRuntimeFilePaths(*registry); + m_app.Start(AzFramework::Application::Descriptor()); // Without this, the user settings component would attempt to save on finalize/shutdown. Since the file is diff --git a/Code/Tools/AssetBundler/tests/applicationManagerTests.cpp b/Code/Tools/AssetBundler/tests/applicationManagerTests.cpp index 4156a6790d..56d0ef615f 100644 --- a/Code/Tools/AssetBundler/tests/applicationManagerTests.cpp +++ b/Code/Tools/AssetBundler/tests/applicationManagerTests.cpp @@ -57,6 +57,12 @@ namespace AssetBundler UnitTest::ScopedAllocatorSetupFixture::SetUp(); m_data = AZStd::make_unique(); + AZ::SettingsRegistryInterface* registry = AZ::SettingsRegistry::Get(); + auto projectPathKey = + AZ::SettingsRegistryInterface::FixedValueString(AZ::SettingsRegistryMergeUtils::BootstrapSettingsRootKey) + "/project_path"; + registry->Set(projectPathKey, "AutomatedTesting"); + AZ::SettingsRegistryMergeUtils::MergeSettingsToRegistry_AddRuntimeFilePaths(*registry); + m_data->m_applicationManager.reset(aznew MockApplicationManagerTest(0, 0)); m_data->m_applicationManager->Start(AzFramework::Application::Descriptor()); diff --git a/Code/Tools/AssetBundler/tests/tests_main.cpp b/Code/Tools/AssetBundler/tests/tests_main.cpp index 5f68e7870b..c530e681da 100644 --- a/Code/Tools/AssetBundler/tests/tests_main.cpp +++ b/Code/Tools/AssetBundler/tests/tests_main.cpp @@ -98,6 +98,22 @@ namespace AssetBundler public: void SetUp() override { + AZ::SettingsRegistryInterface* registry = nullptr; + if (!AZ::SettingsRegistry::Get()) + { + AZ::SettingsRegistry::Register(&m_registry); + registry = &m_registry; + + } + else + { + registry = AZ::SettingsRegistry::Get(); + } + auto projectPathKey = AZ::SettingsRegistryInterface::FixedValueString(AZ::SettingsRegistryMergeUtils::BootstrapSettingsRootKey) + + "/project_path"; + registry->Set(projectPathKey, "AutomatedTesting"); + AZ::SettingsRegistryMergeUtils::MergeSettingsToRegistry_AddRuntimeFilePaths(*registry); + m_data = AZStd::make_unique(); m_data->m_application.reset(aznew AzToolsFramework::ToolsApplication()); m_data->m_application.get()->Start(AzFramework::Application::Descriptor()); @@ -107,15 +123,6 @@ namespace AssetBundler // in the unit tests. AZ::UserSettingsComponentRequestBus::Broadcast(&AZ::UserSettingsComponentRequests::DisableSaveOnFinalize); - if (!AZ::SettingsRegistry::Get()) - { - AZ::SettingsRegistry::Register(&m_registry); - auto projectPathKey = AZ::SettingsRegistryInterface::FixedValueString(AZ::SettingsRegistryMergeUtils::BootstrapSettingsRootKey) - + "/project_path"; - m_registry.Set(projectPathKey, "AutomatedTesting"); - AZ::SettingsRegistryMergeUtils::MergeSettingsToRegistry_AddRuntimeFilePaths(m_registry); - } - AZ::IO::FixedMaxPath engineRoot = AZ::Utils::GetEnginePath(); if (engineRoot.empty()) { diff --git a/Code/Tools/AssetProcessor/native/tests/platformconfiguration/platformconfigurationtests.cpp b/Code/Tools/AssetProcessor/native/tests/platformconfiguration/platformconfigurationtests.cpp index 31e4996b1e..ceec6a7c36 100644 --- a/Code/Tools/AssetProcessor/native/tests/platformconfiguration/platformconfigurationtests.cpp +++ b/Code/Tools/AssetProcessor/native/tests/platformconfiguration/platformconfigurationtests.cpp @@ -40,6 +40,11 @@ void PlatformConfigurationUnitTests::SetUp() AssetProcessorTest::SetUp(); AssetUtilities::ResetAssetRoot(); + AZ::SettingsRegistryInterface* registry = AZ::SettingsRegistry::Get(); + auto projectPathKey = + AZ::SettingsRegistryInterface::FixedValueString(AZ::SettingsRegistryMergeUtils::BootstrapSettingsRootKey) + "/project_path"; + registry->Set(projectPathKey, "AutomatedTesting"); + AZ::SettingsRegistryMergeUtils::MergeSettingsToRegistry_AddRuntimeFilePaths(*registry); } void PlatformConfigurationUnitTests::TearDown() diff --git a/Code/Tools/DeltaCataloger/Tests/tests_main.cpp b/Code/Tools/DeltaCataloger/Tests/tests_main.cpp index 67d6767a17..887889edcb 100644 --- a/Code/Tools/DeltaCataloger/Tests/tests_main.cpp +++ b/Code/Tools/DeltaCataloger/Tests/tests_main.cpp @@ -13,6 +13,7 @@ #include #include #include +#include #include #include #include @@ -45,6 +46,12 @@ public: protected: void SetUp() override { + AZ::SettingsRegistryInterface* registry = AZ::SettingsRegistry::Get(); + auto projectPathKey = + AZ::SettingsRegistryInterface::FixedValueString(AZ::SettingsRegistryMergeUtils::BootstrapSettingsRootKey) + "/project_path"; + registry->Set(projectPathKey, "AutomatedTesting"); + AZ::SettingsRegistryMergeUtils::MergeSettingsToRegistry_AddRuntimeFilePaths(*registry); + AZ::ComponentApplication::Descriptor desc; desc.m_useExistingAllocator = true; desc.m_enableDrilling = false; // we already created a memory driller for the test (AllocatorsFixture) diff --git a/Gems/LmbrCentral/Code/Tests/Builders/LevelBuilderTest.cpp b/Gems/LmbrCentral/Code/Tests/Builders/LevelBuilderTest.cpp index 58e7e9e093..470a2abff6 100644 --- a/Gems/LmbrCentral/Code/Tests/Builders/LevelBuilderTest.cpp +++ b/Gems/LmbrCentral/Code/Tests/Builders/LevelBuilderTest.cpp @@ -15,6 +15,7 @@ #include #include #include +#include #include #include #include @@ -98,6 +99,12 @@ class LevelBuilderTest protected: void SetUp() override { + AZ::SettingsRegistryInterface* registry = AZ::SettingsRegistry::Get(); + auto projectPathKey = + AZ::SettingsRegistryInterface::FixedValueString(AZ::SettingsRegistryMergeUtils::BootstrapSettingsRootKey) + "/project_path"; + registry->Set(projectPathKey, "AutomatedTesting"); + AZ::SettingsRegistryMergeUtils::MergeSettingsToRegistry_AddRuntimeFilePaths(*registry); + m_app.Start(m_descriptor); // Without this, the user settings component would attempt to save on finalize/shutdown. Since the file is // shared across the whole engine, if multiple tests are run in parallel, the saving could cause a crash diff --git a/Gems/LmbrCentral/Code/Tests/Builders/LuaBuilderTests.cpp b/Gems/LmbrCentral/Code/Tests/Builders/LuaBuilderTests.cpp index b8911738f7..99213484fc 100644 --- a/Gems/LmbrCentral/Code/Tests/Builders/LuaBuilderTests.cpp +++ b/Gems/LmbrCentral/Code/Tests/Builders/LuaBuilderTests.cpp @@ -15,6 +15,7 @@ #include #include #include +#include #include #include #include @@ -32,6 +33,12 @@ namespace UnitTest { void SetUp() override { + AZ::SettingsRegistryInterface* registry = AZ::SettingsRegistry::Get(); + auto projectPathKey = + AZ::SettingsRegistryInterface::FixedValueString(AZ::SettingsRegistryMergeUtils::BootstrapSettingsRootKey) + "/project_path"; + registry->Set(projectPathKey, "AutomatedTesting"); + AZ::SettingsRegistryMergeUtils::MergeSettingsToRegistry_AddRuntimeFilePaths(*registry); + m_app.Start(m_descriptor); // Without this, the user settings component would attempt to save on finalize/shutdown. Since the file is // shared across the whole engine, if multiple tests are run in parallel, the saving could cause a crash diff --git a/Gems/LmbrCentral/Code/Tests/Builders/MaterialBuilderTests.cpp b/Gems/LmbrCentral/Code/Tests/Builders/MaterialBuilderTests.cpp index 8aae0c4790..0868a7f147 100644 --- a/Gems/LmbrCentral/Code/Tests/Builders/MaterialBuilderTests.cpp +++ b/Gems/LmbrCentral/Code/Tests/Builders/MaterialBuilderTests.cpp @@ -16,6 +16,7 @@ #include #include #include +#include #include #include #include @@ -35,6 +36,12 @@ protected: { UnitTest::AllocatorsTestFixture::SetUp(); + AZ::SettingsRegistryInterface* registry = AZ::SettingsRegistry::Get(); + auto projectPathKey = + AZ::SettingsRegistryInterface::FixedValueString(AZ::SettingsRegistryMergeUtils::BootstrapSettingsRootKey) + "/project_path"; + registry->Set(projectPathKey, "AutomatedTesting"); + AZ::SettingsRegistryMergeUtils::MergeSettingsToRegistry_AddRuntimeFilePaths(*registry); + m_app.reset(aznew AzToolsFramework::ToolsApplication); m_app->Start(AZ::ComponentApplication::Descriptor()); // Without this, the user settings component would attempt to save on finalize/shutdown. Since the file is diff --git a/Gems/LmbrCentral/Code/Tests/Builders/SeedBuilderTests.cpp b/Gems/LmbrCentral/Code/Tests/Builders/SeedBuilderTests.cpp index 20dd3db446..49fc06c160 100644 --- a/Gems/LmbrCentral/Code/Tests/Builders/SeedBuilderTests.cpp +++ b/Gems/LmbrCentral/Code/Tests/Builders/SeedBuilderTests.cpp @@ -12,6 +12,7 @@ #include "LmbrCentral_precompiled.h" #include +#include #include #include #include @@ -22,6 +23,12 @@ class SeedBuilderTests { void SetUp() override { + AZ::SettingsRegistryInterface* registry = AZ::SettingsRegistry::Get(); + auto projectPathKey = + AZ::SettingsRegistryInterface::FixedValueString(AZ::SettingsRegistryMergeUtils::BootstrapSettingsRootKey) + "/project_path"; + registry->Set(projectPathKey, "AutomatedTesting"); + AZ::SettingsRegistryMergeUtils::MergeSettingsToRegistry_AddRuntimeFilePaths(*registry); + m_app.Start(AZ::ComponentApplication::Descriptor()); // Without this, the user settings component would attempt to save on finalize/shutdown. Since the file is diff --git a/Gems/SceneProcessing/Code/Tests/SceneBuilder/SceneBuilderPhasesTests.cpp b/Gems/SceneProcessing/Code/Tests/SceneBuilder/SceneBuilderPhasesTests.cpp index 5f96353996..2a89911fda 100644 --- a/Gems/SceneProcessing/Code/Tests/SceneBuilder/SceneBuilderPhasesTests.cpp +++ b/Gems/SceneProcessing/Code/Tests/SceneBuilder/SceneBuilderPhasesTests.cpp @@ -16,6 +16,7 @@ #include #include #include +#include #include #include #include @@ -139,6 +140,12 @@ class SceneBuilderPhasesFixture public: void SetUp() override { + AZ::SettingsRegistryInterface* registry = AZ::SettingsRegistry::Get(); + auto projectPathKey = + AZ::SettingsRegistryInterface::FixedValueString(AZ::SettingsRegistryMergeUtils::BootstrapSettingsRootKey) + "/project_path"; + registry->Set(projectPathKey, "AutomatedTesting"); + AZ::SettingsRegistryMergeUtils::MergeSettingsToRegistry_AddRuntimeFilePaths(*registry); + m_app.Start(AZ::ComponentApplication::Descriptor()); // Without this, the user settings component would attempt to save on finalize/shutdown. Since the file is diff --git a/Gems/SceneProcessing/Code/Tests/SceneBuilder/SceneBuilderTests.cpp b/Gems/SceneProcessing/Code/Tests/SceneBuilder/SceneBuilderTests.cpp index 66fd717508..2287077c89 100644 --- a/Gems/SceneProcessing/Code/Tests/SceneBuilder/SceneBuilderTests.cpp +++ b/Gems/SceneProcessing/Code/Tests/SceneBuilder/SceneBuilderTests.cpp @@ -13,6 +13,7 @@ #include #include #include +#include #include #include #include @@ -30,6 +31,12 @@ class SceneBuilderTests protected: void SetUp() override { + AZ::SettingsRegistryInterface* registry = AZ::SettingsRegistry::Get(); + auto projectPathKey = + AZ::SettingsRegistryInterface::FixedValueString(AZ::SettingsRegistryMergeUtils::BootstrapSettingsRootKey) + "/project_path"; + registry->Set(projectPathKey, "AutomatedTesting"); + AZ::SettingsRegistryMergeUtils::MergeSettingsToRegistry_AddRuntimeFilePaths(*registry); + m_app.Start(AZ::ComponentApplication::Descriptor()); AZ::Debug::TraceMessageBus::Handler::BusConnect(); // Without this, the user settings component would attempt to save on finalize/shutdown. Since the file is From 86932f95d6f526329bfff9e0bcd40167e255c06f Mon Sep 17 00:00:00 2001 From: amzn-sj Date: Mon, 24 May 2021 13:08:25 -0700 Subject: [PATCH 13/26] Fix more Linux test failures. --- .../AzToolsFramework/Tests/AssetSeedManager.cpp | 7 +++++++ .../platformconfigurationtests.cpp | 10 +++++----- 2 files changed, 12 insertions(+), 5 deletions(-) diff --git a/Code/Framework/AzToolsFramework/Tests/AssetSeedManager.cpp b/Code/Framework/AzToolsFramework/Tests/AssetSeedManager.cpp index 5ccbd95f09..3d45c10fca 100644 --- a/Code/Framework/AzToolsFramework/Tests/AssetSeedManager.cpp +++ b/Code/Framework/AzToolsFramework/Tests/AssetSeedManager.cpp @@ -15,6 +15,7 @@ #include #include #include +#include #include #include #include @@ -62,6 +63,12 @@ namespace UnitTest m_assetSeedManager = new AzToolsFramework::AssetSeedManager(); m_assetRegistry = new AzFramework::AssetRegistry(); + AZ::SettingsRegistryInterface* registry = AZ::SettingsRegistry::Get(); + auto projectPathKey = + AZ::SettingsRegistryInterface::FixedValueString(AZ::SettingsRegistryMergeUtils::BootstrapSettingsRootKey) + "/project_path"; + registry->Set(projectPathKey, "AutomatedTesting"); + AZ::SettingsRegistryMergeUtils::MergeSettingsToRegistry_AddRuntimeFilePaths(*registry); + m_application->Start(AzFramework::Application::Descriptor()); for (int idx = 0; idx < s_totalAssets; idx++) diff --git a/Code/Tools/AssetProcessor/native/tests/platformconfiguration/platformconfigurationtests.cpp b/Code/Tools/AssetProcessor/native/tests/platformconfiguration/platformconfigurationtests.cpp index ceec6a7c36..08c5ef7ff4 100644 --- a/Code/Tools/AssetProcessor/native/tests/platformconfiguration/platformconfigurationtests.cpp +++ b/Code/Tools/AssetProcessor/native/tests/platformconfiguration/platformconfigurationtests.cpp @@ -35,16 +35,16 @@ PlatformConfigurationUnitTests::PlatformConfigurationUnitTests() void PlatformConfigurationUnitTests::SetUp() { - using namespace AssetProcessor; - m_qApp = new QCoreApplication(m_argc, m_argv); - AssetProcessorTest::SetUp(); - AssetUtilities::ResetAssetRoot(); - AZ::SettingsRegistryInterface* registry = AZ::SettingsRegistry::Get(); auto projectPathKey = AZ::SettingsRegistryInterface::FixedValueString(AZ::SettingsRegistryMergeUtils::BootstrapSettingsRootKey) + "/project_path"; registry->Set(projectPathKey, "AutomatedTesting"); AZ::SettingsRegistryMergeUtils::MergeSettingsToRegistry_AddRuntimeFilePaths(*registry); + + using namespace AssetProcessor; + m_qApp = new QCoreApplication(m_argc, m_argv); + AssetProcessorTest::SetUp(); + AssetUtilities::ResetAssetRoot(); } void PlatformConfigurationUnitTests::TearDown() From 090b770d7e7dd66648c8b6d789154a7b27b5dbda Mon Sep 17 00:00:00 2001 From: amzn-sj Date: Mon, 24 May 2021 14:01:41 -0700 Subject: [PATCH 14/26] Fix segfault in failing tests on Linux --- Code/Framework/Tests/BehaviorEntityTests.cpp | 6 +++--- .../tests/applicationManagerTests.cpp | 18 +++++++++++++++--- .../platformconfigurationtests.cpp | 17 +++++++++++++---- .../platformconfigurationtests.h | 3 ++- .../Tests/Builders/MaterialBuilderTests.cpp | 17 ++++++++++++++--- 5 files changed, 47 insertions(+), 14 deletions(-) diff --git a/Code/Framework/Tests/BehaviorEntityTests.cpp b/Code/Framework/Tests/BehaviorEntityTests.cpp index 398d472d6b..8cb85db20a 100644 --- a/Code/Framework/Tests/BehaviorEntityTests.cpp +++ b/Code/Framework/Tests/BehaviorEntityTests.cpp @@ -89,15 +89,15 @@ class BehaviorEntityTest protected: void SetUp() override { + m_appDescriptor.m_enableScriptReflection = true; + FrameworkApplicationFixture::SetUp(); + AZ::SettingsRegistryInterface* registry = AZ::SettingsRegistry::Get(); auto projectPathKey = AZ::SettingsRegistryInterface::FixedValueString(AZ::SettingsRegistryMergeUtils::BootstrapSettingsRootKey) + "/project_path"; registry->Set(projectPathKey, "AutomatedTesting"); AZ::SettingsRegistryMergeUtils::MergeSettingsToRegistry_AddRuntimeFilePaths(*registry); - m_appDescriptor.m_enableScriptReflection = true; - FrameworkApplicationFixture::SetUp(); - m_application->RegisterComponentDescriptor(HatComponent::CreateDescriptor()); m_application->RegisterComponentDescriptor(EarComponent::CreateDescriptor()); m_application->RegisterComponentDescriptor(DeactivateDuringActivationComponent::CreateDescriptor()); diff --git a/Code/Tools/AssetBundler/tests/applicationManagerTests.cpp b/Code/Tools/AssetBundler/tests/applicationManagerTests.cpp index 56d0ef615f..497e28d3ec 100644 --- a/Code/Tools/AssetBundler/tests/applicationManagerTests.cpp +++ b/Code/Tools/AssetBundler/tests/applicationManagerTests.cpp @@ -17,6 +17,7 @@ #include #include #include +#include #include #include @@ -57,12 +58,22 @@ namespace AssetBundler UnitTest::ScopedAllocatorSetupFixture::SetUp(); m_data = AZStd::make_unique(); - AZ::SettingsRegistryInterface* registry = AZ::SettingsRegistry::Get(); - auto projectPathKey = - AZ::SettingsRegistryInterface::FixedValueString(AZ::SettingsRegistryMergeUtils::BootstrapSettingsRootKey) + "/project_path"; + AZ::SettingsRegistryInterface* registry = nullptr; + if (!AZ::SettingsRegistry::Get()) + { + AZ::SettingsRegistry::Register(&m_registry); + registry = &m_registry; + } + else + { + registry = AZ::SettingsRegistry::Get(); + } + auto projectPathKey = AZ::SettingsRegistryInterface::FixedValueString(AZ::SettingsRegistryMergeUtils::BootstrapSettingsRootKey) + + "/project_path"; registry->Set(projectPathKey, "AutomatedTesting"); AZ::SettingsRegistryMergeUtils::MergeSettingsToRegistry_AddRuntimeFilePaths(*registry); + m_data->m_applicationManager.reset(aznew MockApplicationManagerTest(0, 0)); m_data->m_applicationManager->Start(AzFramework::Application::Descriptor()); @@ -105,6 +116,7 @@ namespace AssetBundler }; AZStd::unique_ptr m_data; + AZ::SettingsRegistryImpl m_registry; }; TEST_F(ApplicationManagerTest, ValidatePlatformFlags_ReadConfigFiles_OK) diff --git a/Code/Tools/AssetProcessor/native/tests/platformconfiguration/platformconfigurationtests.cpp b/Code/Tools/AssetProcessor/native/tests/platformconfiguration/platformconfigurationtests.cpp index 08c5ef7ff4..d11650cbb1 100644 --- a/Code/Tools/AssetProcessor/native/tests/platformconfiguration/platformconfigurationtests.cpp +++ b/Code/Tools/AssetProcessor/native/tests/platformconfiguration/platformconfigurationtests.cpp @@ -35,12 +35,21 @@ PlatformConfigurationUnitTests::PlatformConfigurationUnitTests() void PlatformConfigurationUnitTests::SetUp() { - AZ::SettingsRegistryInterface* registry = AZ::SettingsRegistry::Get(); - auto projectPathKey = - AZ::SettingsRegistryInterface::FixedValueString(AZ::SettingsRegistryMergeUtils::BootstrapSettingsRootKey) + "/project_path"; + AZ::SettingsRegistryInterface* registry = nullptr; + if (!AZ::SettingsRegistry::Get()) + { + AZ::SettingsRegistry::Register(&m_registry); + registry = &m_registry; + } + else + { + registry = AZ::SettingsRegistry::Get(); + } + auto projectPathKey = AZ::SettingsRegistryInterface::FixedValueString(AZ::SettingsRegistryMergeUtils::BootstrapSettingsRootKey) + + "/project_path"; registry->Set(projectPathKey, "AutomatedTesting"); AZ::SettingsRegistryMergeUtils::MergeSettingsToRegistry_AddRuntimeFilePaths(*registry); - + using namespace AssetProcessor; m_qApp = new QCoreApplication(m_argc, m_argv); AssetProcessorTest::SetUp(); diff --git a/Code/Tools/AssetProcessor/native/tests/platformconfiguration/platformconfigurationtests.h b/Code/Tools/AssetProcessor/native/tests/platformconfiguration/platformconfigurationtests.h index fe669460a8..24b6fad1b0 100644 --- a/Code/Tools/AssetProcessor/native/tests/platformconfiguration/platformconfigurationtests.h +++ b/Code/Tools/AssetProcessor/native/tests/platformconfiguration/platformconfigurationtests.h @@ -13,6 +13,7 @@ #pragma once #include +#include #include #include "native/tests/AssetProcessorTest.h" #include "native/unittests/UnitTestRunner.h" @@ -37,6 +38,6 @@ private: int m_argc; char** m_argv; QCoreApplication* m_qApp; - + AZ::SettingsRegistryImpl m_registry; }; diff --git a/Gems/LmbrCentral/Code/Tests/Builders/MaterialBuilderTests.cpp b/Gems/LmbrCentral/Code/Tests/Builders/MaterialBuilderTests.cpp index 0868a7f147..2a66882e06 100644 --- a/Gems/LmbrCentral/Code/Tests/Builders/MaterialBuilderTests.cpp +++ b/Gems/LmbrCentral/Code/Tests/Builders/MaterialBuilderTests.cpp @@ -16,6 +16,7 @@ #include #include #include +#include #include #include #include @@ -36,9 +37,18 @@ protected: { UnitTest::AllocatorsTestFixture::SetUp(); - AZ::SettingsRegistryInterface* registry = AZ::SettingsRegistry::Get(); - auto projectPathKey = - AZ::SettingsRegistryInterface::FixedValueString(AZ::SettingsRegistryMergeUtils::BootstrapSettingsRootKey) + "/project_path"; + AZ::SettingsRegistryInterface* registry = nullptr; + if (!AZ::SettingsRegistry::Get()) + { + AZ::SettingsRegistry::Register(&m_registry); + registry = &m_registry; + } + else + { + registry = AZ::SettingsRegistry::Get(); + } + auto projectPathKey = AZ::SettingsRegistryInterface::FixedValueString(AZ::SettingsRegistryMergeUtils::BootstrapSettingsRootKey) + + "/project_path"; registry->Set(projectPathKey, "AutomatedTesting"); AZ::SettingsRegistryMergeUtils::MergeSettingsToRegistry_AddRuntimeFilePaths(*registry); @@ -128,6 +138,7 @@ protected: } AZStd::unique_ptr m_app; + AZ::SettingsRegistryImpl m_registry; }; TEST_F(MaterialBuilderTests, MaterialBuilder_EmptyFile_ExpectFailure) From 89cde021b25c042c459f846458f5d7bfe0518d76 Mon Sep 17 00:00:00 2001 From: amzn-sj Date: Mon, 24 May 2021 14:27:19 -0700 Subject: [PATCH 15/26] Test fix for segfault in Linux tests --- Code/Tools/AssetBundler/tests/tests_main.cpp | 33 +++++++++---------- .../Tests/Builders/MaterialBuilderTests.cpp | 16 ++++----- 2 files changed, 24 insertions(+), 25 deletions(-) diff --git a/Code/Tools/AssetBundler/tests/tests_main.cpp b/Code/Tools/AssetBundler/tests/tests_main.cpp index c530e681da..b38d09dacb 100644 --- a/Code/Tools/AssetBundler/tests/tests_main.cpp +++ b/Code/Tools/AssetBundler/tests/tests_main.cpp @@ -97,23 +97,7 @@ namespace AssetBundler { public: void SetUp() override - { - AZ::SettingsRegistryInterface* registry = nullptr; - if (!AZ::SettingsRegistry::Get()) - { - AZ::SettingsRegistry::Register(&m_registry); - registry = &m_registry; - - } - else - { - registry = AZ::SettingsRegistry::Get(); - } - auto projectPathKey = AZ::SettingsRegistryInterface::FixedValueString(AZ::SettingsRegistryMergeUtils::BootstrapSettingsRootKey) - + "/project_path"; - registry->Set(projectPathKey, "AutomatedTesting"); - AZ::SettingsRegistryMergeUtils::MergeSettingsToRegistry_AddRuntimeFilePaths(*registry); - + { m_data = AZStd::make_unique(); m_data->m_application.reset(aznew AzToolsFramework::ToolsApplication()); m_data->m_application.get()->Start(AzFramework::Application::Descriptor()); @@ -129,6 +113,21 @@ namespace AssetBundler GTEST_FATAL_FAILURE_(AZStd::string::format("Unable to locate engine root.\n").c_str()); } + AZ::SettingsRegistryInterface* registry = nullptr; + if (!AZ::SettingsRegistry::Get()) + { + AZ::SettingsRegistry::Register(&m_registry); + registry = &m_registry; + + } + else + { + registry = AZ::SettingsRegistry::Get(); + } + auto projectPathKey = AZ::SettingsRegistryInterface::FixedValueString(AZ::SettingsRegistryMergeUtils::BootstrapSettingsRootKey) + + "/project_path"; + registry->Set(projectPathKey, "AutomatedTesting"); + AZ::SettingsRegistryMergeUtils::MergeSettingsToRegistry_AddRuntimeFilePaths(*registry); m_data->m_testEngineRoot = (engineRoot / RelativeTestFolder).LexicallyNormal().String(); diff --git a/Gems/LmbrCentral/Code/Tests/Builders/MaterialBuilderTests.cpp b/Gems/LmbrCentral/Code/Tests/Builders/MaterialBuilderTests.cpp index 2a66882e06..9782c94f6c 100644 --- a/Gems/LmbrCentral/Code/Tests/Builders/MaterialBuilderTests.cpp +++ b/Gems/LmbrCentral/Code/Tests/Builders/MaterialBuilderTests.cpp @@ -37,6 +37,14 @@ protected: { UnitTest::AllocatorsTestFixture::SetUp(); + m_app.reset(aznew AzToolsFramework::ToolsApplication); + m_app->Start(AZ::ComponentApplication::Descriptor()); + // Without this, the user settings component would attempt to save on finalize/shutdown. Since the file is + // shared across the whole engine, if multiple tests are run in parallel, the saving could cause a crash + // in the unit tests. + AZ::UserSettingsComponentRequestBus::Broadcast(&AZ::UserSettingsComponentRequests::DisableSaveOnFinalize); + AZ::Debug::TraceMessageBus::Handler::BusConnect(); + AZ::SettingsRegistryInterface* registry = nullptr; if (!AZ::SettingsRegistry::Get()) { @@ -52,14 +60,6 @@ protected: registry->Set(projectPathKey, "AutomatedTesting"); AZ::SettingsRegistryMergeUtils::MergeSettingsToRegistry_AddRuntimeFilePaths(*registry); - m_app.reset(aznew AzToolsFramework::ToolsApplication); - m_app->Start(AZ::ComponentApplication::Descriptor()); - // Without this, the user settings component would attempt to save on finalize/shutdown. Since the file is - // shared across the whole engine, if multiple tests are run in parallel, the saving could cause a crash - // in the unit tests. - AZ::UserSettingsComponentRequestBus::Broadcast(&AZ::UserSettingsComponentRequests::DisableSaveOnFinalize); - AZ::Debug::TraceMessageBus::Handler::BusConnect(); - const AZStd::string engineRoot = AZ::Test::GetEngineRootPath(); AZ::IO::FileIOBase::GetInstance()->SetAlias("@engroot@", engineRoot.c_str()); From 1a360094d2117ead40ea11cafbdfcea5192ffd39 Mon Sep 17 00:00:00 2001 From: amzn-sj Date: Mon, 24 May 2021 15:06:04 -0700 Subject: [PATCH 16/26] Unregister custom SettingsRegistries in the test Teardown --- Code/Tools/AssetBundler/tests/applicationManagerTests.cpp | 6 ++++++ Code/Tools/AssetBundler/tests/tests_main.cpp | 7 ++++++- .../platformconfiguration/platformconfigurationtests.cpp | 8 +++++++- .../Code/Tests/Builders/MaterialBuilderTests.cpp | 6 ++++++ 4 files changed, 25 insertions(+), 2 deletions(-) diff --git a/Code/Tools/AssetBundler/tests/applicationManagerTests.cpp b/Code/Tools/AssetBundler/tests/applicationManagerTests.cpp index 497e28d3ec..f2477782d0 100644 --- a/Code/Tools/AssetBundler/tests/applicationManagerTests.cpp +++ b/Code/Tools/AssetBundler/tests/applicationManagerTests.cpp @@ -101,6 +101,12 @@ namespace AssetBundler delete m_data->m_localFileIO; AZ::IO::FileIOBase::SetInstance(m_data->m_priorFileIO); + auto settingsRegistry = AZ::SettingsRegistry::Get(); + if(settingsRegistry == &m_registry) + { + AZ::SettingsRegistry::Unregister(settingsRegistry); + } + m_data->m_applicationManager->Stop(); m_data->m_applicationManager.reset(); m_data.reset(); diff --git a/Code/Tools/AssetBundler/tests/tests_main.cpp b/Code/Tools/AssetBundler/tests/tests_main.cpp index b38d09dacb..09d8e39a33 100644 --- a/Code/Tools/AssetBundler/tests/tests_main.cpp +++ b/Code/Tools/AssetBundler/tests/tests_main.cpp @@ -118,7 +118,6 @@ namespace AssetBundler { AZ::SettingsRegistry::Register(&m_registry); registry = &m_registry; - } else { @@ -157,6 +156,12 @@ namespace AssetBundler delete m_data->m_localFileIO; AZ::IO::FileIOBase::SetInstance(m_data->m_priorFileIO); + auto settingsRegistry = AZ::SettingsRegistry::Get(); + if(settingsRegistry == &m_registry) + { + AZ::SettingsRegistry::Unregister(settingsRegistry); + } + m_data->m_gemInfoList.set_capacity(0); m_data->m_gemSeedFilePairList.set_capacity(0); m_data->m_application.get()->Stop(); diff --git a/Code/Tools/AssetProcessor/native/tests/platformconfiguration/platformconfigurationtests.cpp b/Code/Tools/AssetProcessor/native/tests/platformconfiguration/platformconfigurationtests.cpp index d11650cbb1..5343a434cf 100644 --- a/Code/Tools/AssetProcessor/native/tests/platformconfiguration/platformconfigurationtests.cpp +++ b/Code/Tools/AssetProcessor/native/tests/platformconfiguration/platformconfigurationtests.cpp @@ -49,7 +49,7 @@ void PlatformConfigurationUnitTests::SetUp() + "/project_path"; registry->Set(projectPathKey, "AutomatedTesting"); AZ::SettingsRegistryMergeUtils::MergeSettingsToRegistry_AddRuntimeFilePaths(*registry); - + using namespace AssetProcessor; m_qApp = new QCoreApplication(m_argc, m_argv); AssetProcessorTest::SetUp(); @@ -61,6 +61,12 @@ void PlatformConfigurationUnitTests::TearDown() AssetUtilities::ResetAssetRoot(); delete m_qApp; AssetProcessor::AssetProcessorTest::TearDown(); + + auto settingsRegistry = AZ::SettingsRegistry::Get(); + if(settingsRegistry == &m_registry) + { + AZ::SettingsRegistry::Unregister(settingsRegistry); + } } TEST_F(PlatformConfigurationUnitTests, TestFailReadConfigFile_BadPlatform) diff --git a/Gems/LmbrCentral/Code/Tests/Builders/MaterialBuilderTests.cpp b/Gems/LmbrCentral/Code/Tests/Builders/MaterialBuilderTests.cpp index 9782c94f6c..2f534be88a 100644 --- a/Gems/LmbrCentral/Code/Tests/Builders/MaterialBuilderTests.cpp +++ b/Gems/LmbrCentral/Code/Tests/Builders/MaterialBuilderTests.cpp @@ -71,6 +71,12 @@ protected: void TearDown() override { + auto settingsRegistry = AZ::SettingsRegistry::Get(); + if(settingsRegistry == &m_registry) + { + AZ::SettingsRegistry::Unregister(settingsRegistry); + } + AZ::Debug::TraceMessageBus::Handler::BusDisconnect(); m_app->Stop(); m_app.reset(); From e056fdda6ba1dfbbeed6adfae13e0c444976d67e Mon Sep 17 00:00:00 2001 From: amzn-sj Date: Mon, 24 May 2021 15:42:34 -0700 Subject: [PATCH 17/26] Revert changes to tests where segfault occurs --- Code/Framework/Tests/FileTagTests.cpp | 7 ------ .../platformconfigurationtests.cpp | 21 ---------------- .../platformconfigurationtests.h | 2 -- .../Tests/Builders/MaterialBuilderTests.cpp | 24 ------------------- 4 files changed, 54 deletions(-) diff --git a/Code/Framework/Tests/FileTagTests.cpp b/Code/Framework/Tests/FileTagTests.cpp index d17601ed1c..b94131afee 100644 --- a/Code/Framework/Tests/FileTagTests.cpp +++ b/Code/Framework/Tests/FileTagTests.cpp @@ -14,7 +14,6 @@ #include #include #include -#include #include #include #include @@ -85,12 +84,6 @@ namespace UnitTest { AllocatorsFixture::SetUp(); - AZ::SettingsRegistryInterface* registry = AZ::SettingsRegistry::Get(); - auto projectPathKey = - AZ::SettingsRegistryInterface::FixedValueString(AZ::SettingsRegistryMergeUtils::BootstrapSettingsRootKey) + "/project_path"; - registry->Set(projectPathKey, "AutomatedTesting"); - AZ::SettingsRegistryMergeUtils::MergeSettingsToRegistry_AddRuntimeFilePaths(*registry); - m_data = AZStd::make_unique(); using namespace AzFramework::FileTag; AZ::ComponentApplication::Descriptor desc; diff --git a/Code/Tools/AssetProcessor/native/tests/platformconfiguration/platformconfigurationtests.cpp b/Code/Tools/AssetProcessor/native/tests/platformconfiguration/platformconfigurationtests.cpp index 5343a434cf..829d63472d 100644 --- a/Code/Tools/AssetProcessor/native/tests/platformconfiguration/platformconfigurationtests.cpp +++ b/Code/Tools/AssetProcessor/native/tests/platformconfiguration/platformconfigurationtests.cpp @@ -35,21 +35,6 @@ PlatformConfigurationUnitTests::PlatformConfigurationUnitTests() void PlatformConfigurationUnitTests::SetUp() { - AZ::SettingsRegistryInterface* registry = nullptr; - if (!AZ::SettingsRegistry::Get()) - { - AZ::SettingsRegistry::Register(&m_registry); - registry = &m_registry; - } - else - { - registry = AZ::SettingsRegistry::Get(); - } - auto projectPathKey = AZ::SettingsRegistryInterface::FixedValueString(AZ::SettingsRegistryMergeUtils::BootstrapSettingsRootKey) - + "/project_path"; - registry->Set(projectPathKey, "AutomatedTesting"); - AZ::SettingsRegistryMergeUtils::MergeSettingsToRegistry_AddRuntimeFilePaths(*registry); - using namespace AssetProcessor; m_qApp = new QCoreApplication(m_argc, m_argv); AssetProcessorTest::SetUp(); @@ -61,12 +46,6 @@ void PlatformConfigurationUnitTests::TearDown() AssetUtilities::ResetAssetRoot(); delete m_qApp; AssetProcessor::AssetProcessorTest::TearDown(); - - auto settingsRegistry = AZ::SettingsRegistry::Get(); - if(settingsRegistry == &m_registry) - { - AZ::SettingsRegistry::Unregister(settingsRegistry); - } } TEST_F(PlatformConfigurationUnitTests, TestFailReadConfigFile_BadPlatform) diff --git a/Code/Tools/AssetProcessor/native/tests/platformconfiguration/platformconfigurationtests.h b/Code/Tools/AssetProcessor/native/tests/platformconfiguration/platformconfigurationtests.h index 24b6fad1b0..0fb67ab947 100644 --- a/Code/Tools/AssetProcessor/native/tests/platformconfiguration/platformconfigurationtests.h +++ b/Code/Tools/AssetProcessor/native/tests/platformconfiguration/platformconfigurationtests.h @@ -13,7 +13,6 @@ #pragma once #include -#include #include #include "native/tests/AssetProcessorTest.h" #include "native/unittests/UnitTestRunner.h" @@ -38,6 +37,5 @@ private: int m_argc; char** m_argv; QCoreApplication* m_qApp; - AZ::SettingsRegistryImpl m_registry; }; diff --git a/Gems/LmbrCentral/Code/Tests/Builders/MaterialBuilderTests.cpp b/Gems/LmbrCentral/Code/Tests/Builders/MaterialBuilderTests.cpp index 2f534be88a..8aae0c4790 100644 --- a/Gems/LmbrCentral/Code/Tests/Builders/MaterialBuilderTests.cpp +++ b/Gems/LmbrCentral/Code/Tests/Builders/MaterialBuilderTests.cpp @@ -16,8 +16,6 @@ #include #include #include -#include -#include #include #include #include @@ -45,21 +43,6 @@ protected: AZ::UserSettingsComponentRequestBus::Broadcast(&AZ::UserSettingsComponentRequests::DisableSaveOnFinalize); AZ::Debug::TraceMessageBus::Handler::BusConnect(); - AZ::SettingsRegistryInterface* registry = nullptr; - if (!AZ::SettingsRegistry::Get()) - { - AZ::SettingsRegistry::Register(&m_registry); - registry = &m_registry; - } - else - { - registry = AZ::SettingsRegistry::Get(); - } - auto projectPathKey = AZ::SettingsRegistryInterface::FixedValueString(AZ::SettingsRegistryMergeUtils::BootstrapSettingsRootKey) - + "/project_path"; - registry->Set(projectPathKey, "AutomatedTesting"); - AZ::SettingsRegistryMergeUtils::MergeSettingsToRegistry_AddRuntimeFilePaths(*registry); - const AZStd::string engineRoot = AZ::Test::GetEngineRootPath(); AZ::IO::FileIOBase::GetInstance()->SetAlias("@engroot@", engineRoot.c_str()); @@ -71,12 +54,6 @@ protected: void TearDown() override { - auto settingsRegistry = AZ::SettingsRegistry::Get(); - if(settingsRegistry == &m_registry) - { - AZ::SettingsRegistry::Unregister(settingsRegistry); - } - AZ::Debug::TraceMessageBus::Handler::BusDisconnect(); m_app->Stop(); m_app.reset(); @@ -144,7 +121,6 @@ protected: } AZStd::unique_ptr m_app; - AZ::SettingsRegistryImpl m_registry; }; TEST_F(MaterialBuilderTests, MaterialBuilder_EmptyFile_ExpectFailure) From dde35ce42c479e9c0941fc7c54624b8cedc8fabc Mon Sep 17 00:00:00 2001 From: amzn-sj Date: Mon, 24 May 2021 16:08:09 -0700 Subject: [PATCH 18/26] Fix crash in AssetCatalogDeltaTest --- Code/Framework/Tests/AssetCatalog.cpp | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/Code/Framework/Tests/AssetCatalog.cpp b/Code/Framework/Tests/AssetCatalog.cpp index 42df712713..1575b0a469 100644 --- a/Code/Framework/Tests/AssetCatalog.cpp +++ b/Code/Framework/Tests/AssetCatalog.cpp @@ -302,15 +302,16 @@ namespace UnitTest { AZ::AllocatorInstance::Create(); + m_app.reset(aznew AzFramework::Application()); + AZ::ComponentApplication::Descriptor desc; + desc.m_useExistingAllocator = true; + AZ::SettingsRegistryInterface* registry = AZ::SettingsRegistry::Get(); auto projectPathKey = AZ::SettingsRegistryInterface::FixedValueString(AZ::SettingsRegistryMergeUtils::BootstrapSettingsRootKey) + "/project_path"; registry->Set(projectPathKey, "AutomatedTesting"); AZ::SettingsRegistryMergeUtils::MergeSettingsToRegistry_AddRuntimeFilePaths(*registry); - m_app.reset(aznew AzFramework::Application()); - AZ::ComponentApplication::Descriptor desc; - desc.m_useExistingAllocator = true; m_app->Start(desc); // Without this, the user settings component would attempt to save on finalize/shutdown. Since the file is From 83b7122128da520af1cd137516d55f3e59c50a23 Mon Sep 17 00:00:00 2001 From: amzn-sj Date: Tue, 25 May 2021 09:30:55 -0700 Subject: [PATCH 19/26] project_path must be set before call to Application::Start() in order to set aliases. --- Code/Framework/Tests/BehaviorEntityTests.cpp | 7 ------- .../Tests/FrameworkApplicationFixture.h | 7 +++++++ Code/Tools/AssetBundler/tests/tests_main.cpp | 18 +++++++++--------- 3 files changed, 16 insertions(+), 16 deletions(-) diff --git a/Code/Framework/Tests/BehaviorEntityTests.cpp b/Code/Framework/Tests/BehaviorEntityTests.cpp index 8cb85db20a..5a4116a23b 100644 --- a/Code/Framework/Tests/BehaviorEntityTests.cpp +++ b/Code/Framework/Tests/BehaviorEntityTests.cpp @@ -12,7 +12,6 @@ #include "FrameworkApplicationFixture.h" #include -#include #include #include @@ -92,12 +91,6 @@ protected: m_appDescriptor.m_enableScriptReflection = true; FrameworkApplicationFixture::SetUp(); - AZ::SettingsRegistryInterface* registry = AZ::SettingsRegistry::Get(); - auto projectPathKey = - AZ::SettingsRegistryInterface::FixedValueString(AZ::SettingsRegistryMergeUtils::BootstrapSettingsRootKey) + "/project_path"; - registry->Set(projectPathKey, "AutomatedTesting"); - AZ::SettingsRegistryMergeUtils::MergeSettingsToRegistry_AddRuntimeFilePaths(*registry); - m_application->RegisterComponentDescriptor(HatComponent::CreateDescriptor()); m_application->RegisterComponentDescriptor(EarComponent::CreateDescriptor()); m_application->RegisterComponentDescriptor(DeactivateDuringActivationComponent::CreateDescriptor()); diff --git a/Code/Framework/Tests/FrameworkApplicationFixture.h b/Code/Framework/Tests/FrameworkApplicationFixture.h index f3a90864e7..8524964b5c 100644 --- a/Code/Framework/Tests/FrameworkApplicationFixture.h +++ b/Code/Framework/Tests/FrameworkApplicationFixture.h @@ -14,6 +14,7 @@ #include #include #include +#include #include #include #include @@ -55,6 +56,12 @@ namespace UnitTest void SetUp() override { + AZ::SettingsRegistryInterface* registry = AZ::SettingsRegistry::Get(); + auto projectPathKey = + AZ::SettingsRegistryInterface::FixedValueString(AZ::SettingsRegistryMergeUtils::BootstrapSettingsRootKey) + "/project_path"; + registry->Set(projectPathKey, "AutomatedTesting"); + AZ::SettingsRegistryMergeUtils::MergeSettingsToRegistry_AddRuntimeFilePaths(*registry); + m_appDescriptor.m_allocationRecords = true; m_appDescriptor.m_allocationRecordsSaveNames = true; m_appDescriptor.m_recordingMode = AZ::Debug::AllocationRecords::Mode::RECORD_FULL; diff --git a/Code/Tools/AssetBundler/tests/tests_main.cpp b/Code/Tools/AssetBundler/tests/tests_main.cpp index 09d8e39a33..353d9761c3 100644 --- a/Code/Tools/AssetBundler/tests/tests_main.cpp +++ b/Code/Tools/AssetBundler/tests/tests_main.cpp @@ -98,15 +98,6 @@ namespace AssetBundler public: void SetUp() override { - m_data = AZStd::make_unique(); - m_data->m_application.reset(aznew AzToolsFramework::ToolsApplication()); - m_data->m_application.get()->Start(AzFramework::Application::Descriptor()); - - // Without this, the user settings component would attempt to save on finalize/shutdown. Since the file is - // shared across the whole engine, if multiple tests are run in parallel, the saving could cause a crash - // in the unit tests. - AZ::UserSettingsComponentRequestBus::Broadcast(&AZ::UserSettingsComponentRequests::DisableSaveOnFinalize); - AZ::IO::FixedMaxPath engineRoot = AZ::Utils::GetEnginePath(); if (engineRoot.empty()) { @@ -128,6 +119,15 @@ namespace AssetBundler registry->Set(projectPathKey, "AutomatedTesting"); AZ::SettingsRegistryMergeUtils::MergeSettingsToRegistry_AddRuntimeFilePaths(*registry); + m_data = AZStd::make_unique(); + m_data->m_application.reset(aznew AzToolsFramework::ToolsApplication()); + m_data->m_application.get()->Start(AzFramework::Application::Descriptor()); + + // Without this, the user settings component would attempt to save on finalize/shutdown. Since the file is + // shared across the whole engine, if multiple tests are run in parallel, the saving could cause a crash + // in the unit tests. + AZ::UserSettingsComponentRequestBus::Broadcast(&AZ::UserSettingsComponentRequests::DisableSaveOnFinalize); + m_data->m_testEngineRoot = (engineRoot / RelativeTestFolder).LexicallyNormal().String(); m_data->m_localFileIO = aznew AZ::IO::LocalFileIO(); From e371d41688b072e651f621cec29e1abc8823ff4c Mon Sep 17 00:00:00 2001 From: amzn-sj Date: Tue, 25 May 2021 10:21:53 -0700 Subject: [PATCH 20/26] Revert change that caused a seg-fault --- Code/Framework/Tests/FrameworkApplicationFixture.h | 9 +-------- 1 file changed, 1 insertion(+), 8 deletions(-) diff --git a/Code/Framework/Tests/FrameworkApplicationFixture.h b/Code/Framework/Tests/FrameworkApplicationFixture.h index 8524964b5c..c2fea389e0 100644 --- a/Code/Framework/Tests/FrameworkApplicationFixture.h +++ b/Code/Framework/Tests/FrameworkApplicationFixture.h @@ -14,7 +14,6 @@ #include #include #include -#include #include #include #include @@ -55,13 +54,7 @@ namespace UnitTest }; void SetUp() override - { - AZ::SettingsRegistryInterface* registry = AZ::SettingsRegistry::Get(); - auto projectPathKey = - AZ::SettingsRegistryInterface::FixedValueString(AZ::SettingsRegistryMergeUtils::BootstrapSettingsRootKey) + "/project_path"; - registry->Set(projectPathKey, "AutomatedTesting"); - AZ::SettingsRegistryMergeUtils::MergeSettingsToRegistry_AddRuntimeFilePaths(*registry); - + { m_appDescriptor.m_allocationRecords = true; m_appDescriptor.m_allocationRecordsSaveNames = true; m_appDescriptor.m_recordingMode = AZ::Debug::AllocationRecords::Mode::RECORD_FULL; From 4bfc0009744ca27fd7f7286373d0cc3be1f746c6 Mon Sep 17 00:00:00 2001 From: amzn-sj Date: Tue, 25 May 2021 10:30:02 -0700 Subject: [PATCH 21/26] The @assets@ alias should not be set to an empty string. --- .../AzFramework/AzFramework/Application/Application.cpp | 1 - 1 file changed, 1 deletion(-) diff --git a/Code/Framework/AzFramework/AzFramework/Application/Application.cpp b/Code/Framework/AzFramework/AzFramework/Application/Application.cpp index e02892de4e..b8014bc399 100644 --- a/Code/Framework/AzFramework/AzFramework/Application/Application.cpp +++ b/Code/Framework/AzFramework/AzFramework/Application/Application.cpp @@ -679,7 +679,6 @@ namespace AzFramework { auto fileIoBase = m_archiveFileIO.get(); // Set up the default file aliases based on the settings registry - fileIoBase->SetAlias("@assets@", ""); fileIoBase->SetAlias("@root@", GetEngineRoot()); fileIoBase->SetAlias("@engroot@", GetEngineRoot()); fileIoBase->SetAlias("@projectroot@", GetEngineRoot()); From 4e362a2a04557b2c859df38ee020331820cee47b Mon Sep 17 00:00:00 2001 From: lumberyard-employee-dm <56135373+lumberyard-employee-dm@users.noreply.github.com> Date: Tue, 25 May 2021 20:09:13 -0500 Subject: [PATCH 22/26] Removing the initialization of the "@root@" alias to the EngineRoot since it really represents the Asset Cache Root and any paths within it are lowercased. Moved the ordering to set the @assets@ alias before the @projectplatformcache@ so that the "ArchiveTestFixture.IResourceList_Add_AbsolutePath_RemovesAndReplacesWithAlias" test is able to convert it's absolute path to an alias path that starts with @assets@ --- .../AzFramework/AzFramework/Application/Application.cpp | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/Code/Framework/AzFramework/AzFramework/Application/Application.cpp b/Code/Framework/AzFramework/AzFramework/Application/Application.cpp index b8014bc399..c65ba373f8 100644 --- a/Code/Framework/AzFramework/AzFramework/Application/Application.cpp +++ b/Code/Framework/AzFramework/AzFramework/Application/Application.cpp @@ -679,7 +679,6 @@ namespace AzFramework { auto fileIoBase = m_archiveFileIO.get(); // Set up the default file aliases based on the settings registry - fileIoBase->SetAlias("@root@", GetEngineRoot()); fileIoBase->SetAlias("@engroot@", GetEngineRoot()); fileIoBase->SetAlias("@projectroot@", GetEngineRoot()); fileIoBase->SetAlias("@exefolder@", GetExecutableFolder()); @@ -693,8 +692,8 @@ namespace AzFramework pathAliases.clear(); if (m_settingsRegistry->Get(pathAliases.Native(), AZ::SettingsRegistryMergeUtils::FilePathKey_CacheRootFolder)) { - fileIoBase->SetAlias("@projectplatformcache@", pathAliases.c_str()); fileIoBase->SetAlias("@assets@", pathAliases.c_str()); + fileIoBase->SetAlias("@projectplatformcache@", pathAliases.c_str()); fileIoBase->SetAlias("@root@", pathAliases.c_str()); // Deprecated Use @projectplatformcache@ } pathAliases.clear(); From 4b75b7bb634e41e2636d29f2e2524374272f9727 Mon Sep 17 00:00:00 2001 From: lumberyard-employee-dm <56135373+lumberyard-employee-dm@users.noreply.github.com> Date: Tue, 25 May 2021 20:30:59 -0500 Subject: [PATCH 23/26] Fixed the AssetBundler unit test by moving the retrieval of the Engine Root Path after the Settings Registry has merged the runtime paths --- Code/Tools/AssetBundler/tests/tests_main.cpp | 34 +++++++++++--------- 1 file changed, 19 insertions(+), 15 deletions(-) diff --git a/Code/Tools/AssetBundler/tests/tests_main.cpp b/Code/Tools/AssetBundler/tests/tests_main.cpp index 353d9761c3..53b19c5eb4 100644 --- a/Code/Tools/AssetBundler/tests/tests_main.cpp +++ b/Code/Tools/AssetBundler/tests/tests_main.cpp @@ -98,12 +98,6 @@ namespace AssetBundler public: void SetUp() override { - AZ::IO::FixedMaxPath engineRoot = AZ::Utils::GetEnginePath(); - if (engineRoot.empty()) - { - GTEST_FATAL_FAILURE_(AZStd::string::format("Unable to locate engine root.\n").c_str()); - } - AZ::SettingsRegistryInterface* registry = nullptr; if (!AZ::SettingsRegistry::Get()) { @@ -119,6 +113,12 @@ namespace AssetBundler registry->Set(projectPathKey, "AutomatedTesting"); AZ::SettingsRegistryMergeUtils::MergeSettingsToRegistry_AddRuntimeFilePaths(*registry); + AZ::IO::FixedMaxPath engineRoot = AZ::Utils::GetEnginePath(); + if (engineRoot.empty()) + { + GTEST_FATAL_FAILURE_(AZStd::string::format("Unable to locate engine root.\n").c_str()); + } + m_data = AZStd::make_unique(); m_data->m_application.reset(aznew AzToolsFramework::ToolsApplication()); m_data->m_application.get()->Start(AzFramework::Application::Descriptor()); @@ -152,20 +152,24 @@ namespace AssetBundler } void TearDown() override { - AZ::IO::FileIOBase::SetInstance(nullptr); - delete m_data->m_localFileIO; - AZ::IO::FileIOBase::SetInstance(m_data->m_priorFileIO); + if (m_data) + { + AZ::IO::FileIOBase::SetInstance(nullptr); + delete m_data->m_localFileIO; + AZ::IO::FileIOBase::SetInstance(m_data->m_priorFileIO); - auto settingsRegistry = AZ::SettingsRegistry::Get(); - if(settingsRegistry == &m_registry) + m_data->m_gemInfoList.set_capacity(0); + m_data->m_gemSeedFilePairList.set_capacity(0); + m_data->m_application.get()->Stop(); + m_data->m_application.reset(); + } + + if(auto settingsRegistry = AZ::SettingsRegistry::Get(); + settingsRegistry == &m_registry) { AZ::SettingsRegistry::Unregister(settingsRegistry); } - m_data->m_gemInfoList.set_capacity(0); - m_data->m_gemSeedFilePairList.set_capacity(0); - m_data->m_application.get()->Stop(); - m_data->m_application.reset(); } void AddGemData(const char* engineRoot, const char* gemName, bool seedFileExists = true) From 58bd72c4297f04f2465639416f3055d16af3aae0 Mon Sep 17 00:00:00 2001 From: lumberyard-employee-dm <56135373+lumberyard-employee-dm@users.noreply.github.com> Date: Tue, 25 May 2021 22:53:56 -0500 Subject: [PATCH 24/26] Setting project path to AutomatedTesting to fix the EMotionFX CanUseFileMenu and CanOpenWorkspace test from failing when resolving a relative path --- Gems/EMotionFX/Code/Tests/SystemComponentFixture.h | 11 ++++++++++- Gems/EMotionFX/Code/Tests/UI/CanUseFileMenu.cpp | 1 - 2 files changed, 10 insertions(+), 2 deletions(-) diff --git a/Gems/EMotionFX/Code/Tests/SystemComponentFixture.h b/Gems/EMotionFX/Code/Tests/SystemComponentFixture.h index 04a1ca4f81..f8c70a5fee 100644 --- a/Gems/EMotionFX/Code/Tests/SystemComponentFixture.h +++ b/Gems/EMotionFX/Code/Tests/SystemComponentFixture.h @@ -59,7 +59,16 @@ namespace EMotionFX { public: - ComponentFixtureApp() = default; + ComponentFixtureApp() + { + using FixedValueString = AZ::SettingsRegistryInterface::FixedValueString; + constexpr auto projectPathKey = FixedValueString(AZ::SettingsRegistryMergeUtils::BootstrapSettingsRootKey) + "/project_path"; + if(auto settingsRegistry = AZ::SettingsRegistry::Get(); settingsRegistry != nullptr) + { + settingsRegistry->Set(projectPathKey, "AutomatedTesting"); + AZ::SettingsRegistryMergeUtils::MergeSettingsToRegistry_AddRuntimeFilePaths(*settingsRegistry); + } + } AZ::ComponentTypeList GetRequiredSystemComponents() const override { diff --git a/Gems/EMotionFX/Code/Tests/UI/CanUseFileMenu.cpp b/Gems/EMotionFX/Code/Tests/UI/CanUseFileMenu.cpp index 8045499b4a..8e3a19c1ca 100644 --- a/Gems/EMotionFX/Code/Tests/UI/CanUseFileMenu.cpp +++ b/Gems/EMotionFX/Code/Tests/UI/CanUseFileMenu.cpp @@ -77,7 +77,6 @@ namespace EMotionFX { auto testAssetsPath = AZ::IO::Path(GetEMotionFX().GetAssetCacheFolder()) / "TmpTestAssets"; QString dataDir = QString::fromUtf8(testAssetsPath.c_str(), aznumeric_cast(testAssetsPath.Native().size())); - dataDir += "TmpTestAssets"; if (!QDir(dataDir).exists()) { From 6f8f22f340e5be1e0f6882b7ecc13e387b47fb38 Mon Sep 17 00:00:00 2001 From: lumberyard-employee-dm <56135373+lumberyard-employee-dm@users.noreply.github.com> Date: Tue, 25 May 2021 22:55:21 -0500 Subject: [PATCH 25/26] Suppress resolve path failed error in Atom_RHI UtilsTests now that the @assets@ alias isn't set during these test --- Gems/Atom/RHI/Code/Tests/UtilsTests.cpp | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/Gems/Atom/RHI/Code/Tests/UtilsTests.cpp b/Gems/Atom/RHI/Code/Tests/UtilsTests.cpp index 506edc0d1e..afeca6e617 100644 --- a/Gems/Atom/RHI/Code/Tests/UtilsTests.cpp +++ b/Gems/Atom/RHI/Code/Tests/UtilsTests.cpp @@ -60,7 +60,9 @@ namespace UnitTest TEST_F(UtilsTests, LoadFileString_Error_DoesNotExist) { + AZ_TEST_START_TRACE_SUPPRESSION; auto outcome = AZ::RHI::LoadFileString("FileDoesNotExist"); + AZ_TEST_STOP_TRACE_SUPPRESSION_NO_COUNT; EXPECT_FALSE(outcome.IsSuccess()); EXPECT_TRUE(outcome.GetError().find("Could not open file") != AZStd::string::npos); EXPECT_TRUE(outcome.GetError().find("FileDoesNotExist") != AZStd::string::npos); @@ -68,7 +70,9 @@ namespace UnitTest TEST_F(UtilsTests, LoadFileBytes_Error_DoesNotExist) { + AZ_TEST_START_TRACE_SUPPRESSION; auto outcome = AZ::RHI::LoadFileBytes("FileDoesNotExist"); + AZ_TEST_STOP_TRACE_SUPPRESSION_NO_COUNT; EXPECT_FALSE(outcome.IsSuccess()); EXPECT_TRUE(outcome.GetError().find("Could not open file") != AZStd::string::npos); EXPECT_TRUE(outcome.GetError().find("FileDoesNotExist") != AZStd::string::npos); From 791e044457728428853f2ade1d1bfd304c12b3ac Mon Sep 17 00:00:00 2001 From: lumberyard-employee-dm <56135373+lumberyard-employee-dm@users.noreply.github.com> Date: Tue, 25 May 2021 23:38:03 -0500 Subject: [PATCH 26/26] Fixed PlatformConfigurationUnitTests.TestFailReadConfigFile_RegularScanfolder test by setting a project path in the AssetProcessorTest fixture --- .../AssetProcessor/native/tests/AssetProcessorTest.h | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/Code/Tools/AssetProcessor/native/tests/AssetProcessorTest.h b/Code/Tools/AssetProcessor/native/tests/AssetProcessorTest.h index c866a933dd..4ea0695f1c 100644 --- a/Code/Tools/AssetProcessor/native/tests/AssetProcessorTest.h +++ b/Code/Tools/AssetProcessor/native/tests/AssetProcessorTest.h @@ -14,6 +14,7 @@ #include #include #include +#include #include #include #include // for the assert absorber. @@ -44,7 +45,18 @@ namespace AssetProcessor AZ::AllocatorInstance::Create(); } m_errorAbsorber = new UnitTestUtils::AssertAbsorber(); + m_application = AZStd::make_unique(); + + // Inject the AutomatedTesting project as a project path into test fixture + using FixedValueString = AZ::SettingsRegistryInterface::FixedValueString; + constexpr auto projectPathKey = FixedValueString(AZ::SettingsRegistryMergeUtils::BootstrapSettingsRootKey) + + "/project_path"; + if(auto settingsRegistry = AZ::SettingsRegistry::Get(); settingsRegistry != nullptr) + { + settingsRegistry->Set(projectPathKey, "AutomatedTesting"); + AZ::SettingsRegistryMergeUtils::MergeSettingsToRegistry_AddRuntimeFilePaths(*settingsRegistry); + } } void TearDown() override