Merge branch 'main' into LoadPipelineFromGitHub
This commit is contained in:
@@ -150,9 +150,9 @@ class AbstractResourceLocator(object):
|
||||
def cache(self):
|
||||
"""
|
||||
Return path to the cache dir.
|
||||
:return: path to engine_root/dev/Cache/
|
||||
:return: path to project_root/Cache/
|
||||
"""
|
||||
return self._cache_override or os.path.join(self.dev(), "Cache")
|
||||
return self._cache_override or os.path.join(self.project(), "Cache")
|
||||
|
||||
def asset_db(self):
|
||||
"""
|
||||
@@ -171,9 +171,9 @@ class AbstractResourceLocator(object):
|
||||
def asset_cache(self, platform):
|
||||
"""
|
||||
Return path to the cache for the current platform and project inside the game project folder
|
||||
:return: path to cache/<project>/<platform>/<project>
|
||||
:return: path to <project_path>/Cache/<platform>
|
||||
"""
|
||||
return os.path.join(self.platform_cache_path(platform), self._project)
|
||||
return os.path.join(self.platform_cache_path(platform))
|
||||
|
||||
def asset_catalog(self, platform):
|
||||
"""
|
||||
@@ -194,14 +194,14 @@ class AbstractResourceLocator(object):
|
||||
Return path to AssetProcessorBatch's log directory using the project bin dir
|
||||
:return: path where the "logs" folder will be found
|
||||
"""
|
||||
return self._ap_log_root or self.build_directory()
|
||||
return self._ap_log_root or self.project_log()
|
||||
|
||||
def ap_log_dir(self):
|
||||
"""
|
||||
Return path to AssetProcessorBatch's log directory using the project bin dir
|
||||
:return: path to 'logs' dir in <bin dir> folder
|
||||
"""
|
||||
return os.path.join(self.ap_log_root(), 'logs')
|
||||
return self.ap_log_root()
|
||||
|
||||
def ap_job_logs(self):
|
||||
"""
|
||||
@@ -210,6 +210,7 @@ class AbstractResourceLocator(object):
|
||||
"""
|
||||
return os.path.join(self.ap_log_dir(), 'JobLogs')
|
||||
|
||||
|
||||
def ap_batch_log(self):
|
||||
"""
|
||||
Return path to AssetProcessorBatch's log file using the project bin dir
|
||||
@@ -227,9 +228,9 @@ class AbstractResourceLocator(object):
|
||||
def project_cache(self):
|
||||
"""
|
||||
Return path to the current project cache folder
|
||||
:return: path to engine_root/dev/Cache/<project>
|
||||
:return: path to <project_path>/Cache
|
||||
"""
|
||||
return os.path.join(self.cache(), self._project)
|
||||
return self.cache()
|
||||
|
||||
def get_shader_compiler_path(self):
|
||||
"""
|
||||
@@ -243,7 +244,7 @@ class AbstractResourceLocator(object):
|
||||
return os.path.join(self.dev(), 'bootstrap.cfg')
|
||||
|
||||
def asset_processor_config_file(self):
|
||||
return os.path.join(self.dev(), 'AssetProcessorPlatformConfig.ini')
|
||||
return os.path.join(self.dev(), 'AssetProcessorPlatformConfig.setreg')
|
||||
|
||||
def autoexec_file(self):
|
||||
return os.path.join(
|
||||
|
||||
@@ -50,14 +50,14 @@ class _MacResourceLocator(AbstractResourceLocator):
|
||||
Return path to the project's log dir for the Mac operating system.
|
||||
:return: path to 'log' dir in the platform cache dir
|
||||
"""
|
||||
return os.path.join(self.platform_cache(), 'user', 'log')
|
||||
return os.path.join(self.project(), 'user', 'log')
|
||||
|
||||
def project_screenshots(self):
|
||||
"""
|
||||
Return path to the project's screenshot dir for the Mac operating system.
|
||||
:return: path to 'screenshot' dir in the platform cache dir
|
||||
"""
|
||||
return os.path.join(self.platform_cache(), 'user', 'ScreenShots')
|
||||
return os.path.join(self.project(), 'user', 'ScreenShots')
|
||||
|
||||
def editor_log(self):
|
||||
"""
|
||||
|
||||
@@ -56,14 +56,14 @@ class _WindowsResourceLocator(AbstractResourceLocator):
|
||||
Return path to the project's log dir for the Windows operating system.
|
||||
:return: path to 'log' dir in the platform cache dir
|
||||
"""
|
||||
return os.path.join(self.platform_cache(), 'user', 'log')
|
||||
return os.path.join(self.project(), 'user', 'log')
|
||||
|
||||
def project_screenshots(self):
|
||||
"""
|
||||
Return path to the project's screenshot dir for the Windows operating system.
|
||||
:return: path to 'screenshot' dir in the platform cache dir
|
||||
"""
|
||||
return os.path.join(self.platform_cache(), 'user', 'ScreenShots')
|
||||
return os.path.join(self.project(), 'user', 'ScreenShots')
|
||||
|
||||
def editor_log(self):
|
||||
"""
|
||||
|
||||
@@ -78,12 +78,12 @@ def setup_bootstrap_project(workspace, project):
|
||||
|
||||
found_gamefolder = False
|
||||
for i, line in enumerate(lines):
|
||||
if line.lstrip().startswith("sys_game_folder"):
|
||||
lines[i] = f"sys_game_folder={project}\n"
|
||||
if line.lstrip().startswith("project_path"):
|
||||
lines[i] = f"project_path={project}\n"
|
||||
found_gamefolder = True
|
||||
break
|
||||
|
||||
assert found_gamefolder, "'sys_game_folder' not found in bootstrap.cfg"
|
||||
assert found_gamefolder, "'project_path' not found in bootstrap.cfg"
|
||||
|
||||
with open(bootstrap_cfg, "w") as f:
|
||||
f.writelines(lines)
|
||||
|
||||
@@ -20,6 +20,7 @@ Assumptions for running automation:
|
||||
import json
|
||||
import logging
|
||||
import os
|
||||
from pathlib import PurePath, Path
|
||||
from subprocess import CalledProcessError
|
||||
|
||||
import six
|
||||
@@ -120,6 +121,7 @@ class AndroidLauncher(Launcher):
|
||||
self._adb_prefix_command = ['adb']
|
||||
self._device_id = None
|
||||
self.launch_proc = None
|
||||
self.android_vfs_setreg_path = None
|
||||
self.package_name = get_package_name(os.path.join(self.workspace.paths.dev(),
|
||||
self.workspace.project))
|
||||
self._device_id = self.get_device_config(config_file=self.workspace.paths.devices_file(),
|
||||
@@ -181,6 +183,9 @@ class AndroidLauncher(Launcher):
|
||||
def teardown(self):
|
||||
ly_test_tools.mobile.android.undo_tcp_port_changes(self._device_id)
|
||||
self.restore_settings()
|
||||
# Remove temporary vfs file if created
|
||||
if self.android_vfs_setreg_path and os.path.isfile(self.android_vfs_setreg_path):
|
||||
os.remove(self.android_vfs_setreg_path)
|
||||
self.workspace.shader_compiler.stop()
|
||||
super(AndroidLauncher, self).teardown()
|
||||
|
||||
@@ -190,12 +195,22 @@ class AndroidLauncher(Launcher):
|
||||
|
||||
:return: None
|
||||
"""
|
||||
self.workspace.settings.modify_bootstrap_setting('sys_game_folder', self.workspace.project)
|
||||
self.workspace.settings.modify_bootstrap_setting('connect_to_remote', 1)
|
||||
self.workspace.settings.modify_bootstrap_setting('android_connect_to_remote', 1)
|
||||
self.workspace.settings.modify_bootstrap_setting('wait_for_connect', 1)
|
||||
self.workspace.settings.modify_bootstrap_setting('remote_ip', '127.0.0.1')
|
||||
self.workspace.settings.modify_bootstrap_setting('remote_port', '45643')
|
||||
|
||||
# Write the Android vfs settings to a settings registry file within the user's registry folder
|
||||
user_registry_path = Path(self.workspace.project) / 'user' / 'Registry'
|
||||
user_registry_path.mkdir(parents=True, exist_ok=True)
|
||||
|
||||
# Create a python dictionary that can serialize to a json file with JSON pointer of
|
||||
# /Amazon/AzCore/Bootstrap/<settings>
|
||||
vfs_settings = { 'Amazon' : { 'AzCore' : { 'Bootstrap' : {} }}}
|
||||
vfs_settings['Amazon']['AzCore']['Bootstrap']['connect_to_remote'] = 1
|
||||
vfs_settings['Amazon']['AzCore']['Bootstrap']['android_connect_to_remote'] = 1
|
||||
vfs_settings['Amazon']['AzCore']['Bootstrap']['wait_for_connect'] = 1
|
||||
vfs_settings['Amazon']['AzCore']['Bootstrap']['remote_ip'] = '127.0.0.1'
|
||||
vfs_settings['Amazon']['AzCore']['Bootstrap']['remote_port'] = 45643
|
||||
self.android_vfs_setreg_path = user_registry_path / 'test_android_vfs_settings.android.setreg'
|
||||
with self.android_vfs_setreg_path.open('w') as android_vfs_setreg:
|
||||
json.dump(vfs_settings, android_vfs_setreg, indent=4)
|
||||
|
||||
self.workspace.settings.modify_platform_setting('r_AssetProcessorShaderCompiler', 1)
|
||||
self.workspace.settings.modify_platform_setting('r_ShadersAsyncCompiling', 0)
|
||||
|
||||
@@ -140,7 +140,6 @@ class Launcher(object):
|
||||
Perform settings configuration, must be called after a backup of settings has been created with
|
||||
backup_settings(). Preferred ways to modify settings are:
|
||||
|
||||
self.workspace.settings.modify_bootstrap_setting()
|
||||
self.workspace.settings.modify_platform_setting()
|
||||
|
||||
:return: None
|
||||
@@ -156,7 +155,6 @@ class Launcher(object):
|
||||
"""
|
||||
backup_path = self.workspace.settings.get_temp_path()
|
||||
log.debug(f"Restoring backup of bootstrap, platform and user settings in path {backup_path}")
|
||||
self.workspace.settings.restore_bootstrap_settings(backup_path)
|
||||
self.workspace.settings.restore_platform_settings(backup_path)
|
||||
self.workspace.settings.restore_shader_compiler_settings(backup_path)
|
||||
|
||||
|
||||
@@ -163,13 +163,12 @@ class WinLauncher(Launcher):
|
||||
|
||||
:return: None
|
||||
"""
|
||||
# Update settings
|
||||
# Update settings via the settings registry to avoid modifying the bootstrap.cfg
|
||||
host_ip = '127.0.0.1'
|
||||
|
||||
self.workspace.settings.modify_bootstrap_setting("sys_game_folder", self.workspace.project)
|
||||
self.workspace.settings.modify_bootstrap_setting("remote_ip", host_ip)
|
||||
self.workspace.settings.modify_bootstrap_setting("wait_for_connect", 1)
|
||||
self.workspace.settings.modify_bootstrap_setting("white_list", host_ip)
|
||||
self.args.append(f'--regset="/Amazon/AzCore/Bootstrap/project_path={self.workspace.project}"')
|
||||
self.args.append(f'--regset="/Amazon/AzCore/Bootstrap/remote_ip={host_ip}"')
|
||||
self.args.append('--regset="/Amazon/AzCore/Bootstrap/wait_for_connect=1"')
|
||||
self.args.append(f'--regset="/Amazon/AzCore/Bootstrap/allowed_list={host_ip}"')
|
||||
|
||||
self.workspace.settings.modify_platform_setting("r_AssetProcessorShaderCompiler", 1)
|
||||
self.workspace.settings.modify_platform_setting("r_ShaderCompilerServer", host_ip)
|
||||
@@ -194,7 +193,7 @@ class WinEditor(WinLauncher):
|
||||
|
||||
def __init__(self, build, args):
|
||||
super(WinEditor, self).__init__(build, args)
|
||||
self.args.append("--regset=\"/Amazon/Settings/EnableSourceControl=false\"")
|
||||
self.args.append('--regset="/Amazon/Settings/EnableSourceControl=false"')
|
||||
|
||||
def binary_path(self):
|
||||
"""
|
||||
|
||||
@@ -49,6 +49,7 @@ ASSET_PROCESSOR_PLATFORM_MAP = {
|
||||
'windows': 'pc',
|
||||
}
|
||||
|
||||
ASSET_PROCESSOR_SETTINGS_ROOT_KEY='/Amazon/AssetProcessor/Settings'
|
||||
|
||||
class AssetProcessorError(Exception):
|
||||
""" Indicates that the AssetProcessor raised an error """
|
||||
@@ -69,6 +70,7 @@ class AssetProcessor(object):
|
||||
self._ap_proc = None
|
||||
self._temp_asset_directory = None
|
||||
self._temp_asset_root = None
|
||||
self._project_path = self._workspace.project
|
||||
self._override_scan_folders = []
|
||||
self._test_assets_source_folder = None
|
||||
self._cache_folder = None
|
||||
@@ -76,6 +78,8 @@ class AssetProcessor(object):
|
||||
self._control_connection = None
|
||||
self._function_name = None
|
||||
self._failed_log_root = None
|
||||
self._disable_all_platforms = False
|
||||
self._enabled_platform_overrides = dict()
|
||||
|
||||
# Starts AP but does not by default run until idle.
|
||||
def start(self, connection_timeout=30, quitonidle=False, add_gem_scan_folders=None, add_config_scan_folders=None,
|
||||
@@ -445,7 +449,10 @@ class AssetProcessor(object):
|
||||
extra_gui_params.append(ap_platform)
|
||||
|
||||
if extra_params:
|
||||
extra_gui_params.append(extra_params)
|
||||
if isinstance(extra_params, list):
|
||||
extra_gui_params.extend(extra_params)
|
||||
else:
|
||||
extra_gui_params.append(extra_params)
|
||||
|
||||
command = self.build_ap_command(ap_path=ap_path, fastscan=fastscan, platforms=platforms,
|
||||
extra_params=extra_gui_params, add_gem_scan_folders=add_gem_scan_folders,
|
||||
@@ -508,9 +515,8 @@ class AssetProcessor(object):
|
||||
if fastscan:
|
||||
command.append("--zeroAnalysisMode")
|
||||
|
||||
if self._workspace.project:
|
||||
command.append("--gamefolder")
|
||||
command.append(self._workspace.project)
|
||||
if self._project_path:
|
||||
command.append(f'--regset="/Amazon/AzCore/Bootstrap/project_path={self._project_path}"')
|
||||
|
||||
# When using a scratch workspace we will set several options. The asset root controls where our
|
||||
# cache lives, gives us a unique directory to place our logs in, and indicates we wish to randomize our
|
||||
@@ -520,6 +526,7 @@ class AssetProcessor(object):
|
||||
command.append(f"{self._temp_asset_root}")
|
||||
command.append("--logDir")
|
||||
command.append(f"{self._temp_asset_root}")
|
||||
command.append(f'--regset="/Amazon/AzCore/Bootstrap/project_cache_path={self.temp_project_cache_path()}"')
|
||||
command.append("--randomListeningPort")
|
||||
if self._override_scan_folders:
|
||||
command.append("--scanfolders")
|
||||
@@ -537,10 +544,16 @@ class AssetProcessor(object):
|
||||
if not isinstance(scan_folder_pattern, list):
|
||||
scan_folder_pattern = [scan_folder_pattern]
|
||||
command.append(f"{','.join(scan_folder_pattern)}")
|
||||
|
||||
if self._disable_all_platforms:
|
||||
command.append(f'--regremove="f{ASSET_PROCESSOR_SETTINGS_ROOT_KEY}/Platforms"')
|
||||
if platforms:
|
||||
if isinstance(platforms, list):
|
||||
platforms = ','.join(platforms)
|
||||
command.append(f'/platforms={platforms}')
|
||||
command.append(f'--platforms={platforms}')
|
||||
for key, value in self._enabled_platform_overrides:
|
||||
command.append(f'--regset="f{ASSET_PROCESSOR_SETTINGS_ROOT_KEY}/Platforms/{key}={value}"')
|
||||
|
||||
if extra_params:
|
||||
if isinstance(extra_params, list):
|
||||
command.extend(extra_params)
|
||||
@@ -602,84 +615,21 @@ class AssetProcessor(object):
|
||||
|
||||
def disable_all_asset_processor_platforms(self):
|
||||
"""
|
||||
Modify the AssetProcessorPlatformConfig file to enable asset procesing for the target platform.
|
||||
This is done by commenting the line containing the platform name.
|
||||
Disables all platforms via the SettingsRegistry --regremove option
|
||||
|
||||
:return: None
|
||||
"""
|
||||
if not os.path.isfile(self._workspace.paths.asset_processor_config_file()):
|
||||
raise IOError("Unable to find a file at {}".format(self._workspace.paths.asset_processor_config_file()))
|
||||
else:
|
||||
# AssetProcessorPlatformConfig.ini is generally in read only mode on fresh checkouts
|
||||
file_system.unlock_file(self._workspace.paths.asset_processor_config_file())
|
||||
with open(self._workspace.paths.asset_processor_config_file(), 'r+') as config_file:
|
||||
data = config_file.readlines()
|
||||
|
||||
section_end = None
|
||||
section_begin = None
|
||||
|
||||
# configParser is useless here because it strips commented lines.
|
||||
for lineNmber, configRow in enumerate(data):
|
||||
if "[Platforms]" in configRow:
|
||||
section_begin = lineNmber
|
||||
# First instance of an open bracket after the platform's section will be the start of a section
|
||||
elif "[" in configRow and section_begin is not None:
|
||||
section_end = lineNmber
|
||||
if section_begin is not None and section_end is not None:
|
||||
break
|
||||
|
||||
offsetFromPlatformsHeader = 0
|
||||
for line in itertools.islice(data, section_begin + 1, section_end):
|
||||
offsetFromPlatformsHeader += 1
|
||||
data[section_begin + offsetFromPlatformsHeader] = f";{line}"
|
||||
|
||||
config_file.seek(0)
|
||||
config_file.truncate()
|
||||
config_file.writelines(data)
|
||||
self._disable_all_platforms = True
|
||||
|
||||
def enable_asset_processor_platform(self, platform):
|
||||
# type: (str) -> None
|
||||
"""
|
||||
Modify the AssetProcessorPlatformConfig file to enable asset processing for the target platform.
|
||||
This is done by uncommenting the line containing the platform name.
|
||||
Add the platform to the dict of platforms to enable via the SettingsRegistry --regset option
|
||||
|
||||
:param platform: The platform to enable
|
||||
:return: None
|
||||
"""
|
||||
config_file_path = self._workspace.paths.asset_processor_config_file()
|
||||
if self._temp_asset_root:
|
||||
config_file_path = os.path.join(self._temp_asset_root, "AssetProcessorPlatformConfig.ini")
|
||||
if not os.path.isfile(config_file_path):
|
||||
raise IOError(f"Unable to find a file at {config_file_path}")
|
||||
else:
|
||||
# AssetProcessorPlatformConfig.ini is generally in read only mode on fresh checkouts
|
||||
file_system.unlock_file(config_file_path)
|
||||
with open(config_file_path, 'r+') as config_file:
|
||||
data = config_file.readlines()
|
||||
|
||||
section_end = None
|
||||
section_begin = None
|
||||
|
||||
# configParser is useless here because it strips commented lines.
|
||||
for lineNmber, configRow in enumerate(data):
|
||||
if "[Platforms]" in configRow:
|
||||
section_begin = lineNmber
|
||||
# First instance of an open bracket after the platform's section will be the start of a section
|
||||
elif "[" in configRow and section_begin is not None:
|
||||
section_end = lineNmber
|
||||
if section_begin is not None and section_end is not None:
|
||||
break
|
||||
|
||||
offsetFromPlatformsHeader = 0
|
||||
for line in itertools.islice(data, section_begin + 1, section_end):
|
||||
offsetFromPlatformsHeader += 1
|
||||
if platform in line:
|
||||
data[section_begin + offsetFromPlatformsHeader] = line.replace(';', '')
|
||||
break
|
||||
|
||||
config_file.seek(0)
|
||||
config_file.truncate()
|
||||
config_file.writelines(data)
|
||||
self._enabled_platform_overrides[platform] = 'enabled'
|
||||
|
||||
def temp_asset_root(self):
|
||||
"""
|
||||
@@ -697,13 +647,11 @@ class AssetProcessor(object):
|
||||
|
||||
:return: None
|
||||
"""
|
||||
for copy_dir in [os.path.join(self._workspace.project, 'Config'), 'Engine']:
|
||||
for copy_dir in [self._workspace.project, 'Engine']:
|
||||
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', 'AssetProcessorPlatformConfig.ini', 'engine.json',
|
||||
os.path.join(self._workspace.project, 'Config', 'Editor.xml'),
|
||||
os.path.join(self._workspace.project, "gems.json"),
|
||||
for copyfile_name in ['bootstrap.cfg', 'AssetProcessorPlatformConfig.setreg',
|
||||
os.path.join(self._workspace.project, "project.json"),
|
||||
os.path.join('Engine', 'exclude.filetag')]:
|
||||
shutil.copyfile(os.path.join(self._workspace.paths.dev(), copyfile_name),
|
||||
@@ -752,9 +700,9 @@ class AssetProcessor(object):
|
||||
self._temp_asset_root = self._temp_asset_directory.name
|
||||
self._copy_asset_root_files()
|
||||
self._workspace.paths.set_ap_log_root(self._temp_asset_root)
|
||||
self._project_path = os.path.join(self._temp_asset_root, self._workspace.project)
|
||||
if project_scan_folder:
|
||||
project_dir = os.path.join(self._temp_asset_root, self._workspace.project)
|
||||
self.add_scan_folder(project_dir)
|
||||
self.add_scan_folder(self._project_path)
|
||||
|
||||
def add_scan_folder(self, folder_name) -> str:
|
||||
"""
|
||||
@@ -834,9 +782,8 @@ class AssetProcessor(object):
|
||||
self._function_name = function_name
|
||||
self._assets_source_folder = utils.prepare_test_assets(assets_path, function_name, test_folder)
|
||||
self._test_assets_source_folder = test_folder
|
||||
self._cache_folder = os.path.join(self._temp_asset_root, 'Cache', self._workspace.project, cache_platform or
|
||||
self._cache_folder = os.path.join(self._temp_asset_root, 'Cache', cache_platform or
|
||||
ASSET_PROCESSOR_PLATFORM_MAP[self._workspace.asset_processor_platform],
|
||||
self._workspace.project.lower(),
|
||||
function_name.lower() if existing_function_name is None
|
||||
else existing_function_name)
|
||||
|
||||
@@ -938,10 +885,20 @@ class AssetProcessor(object):
|
||||
:param asset_platform: Asset platform to use. Workspace's asset platform if not supplied
|
||||
:return: path to project cache
|
||||
"""
|
||||
project_name = project_name or self._workspace.project
|
||||
asset_platform = asset_platform or ASSET_PROCESSOR_PLATFORM_MAP[self._workspace.asset_processor_platform]
|
||||
return os.path.join(self._temp_asset_root, 'Cache', project_name,
|
||||
asset_platform.lower(), project_name.lower())
|
||||
return os.path.join(self._temp_asset_root, 'Cache',
|
||||
asset_platform.lower())
|
||||
|
||||
def temp_project_cache_path(self, project_name=None):
|
||||
"""
|
||||
Get the project cache root folder from a test run using prepare_test_environment
|
||||
The project cache root folder does not include the asset platform
|
||||
|
||||
:param project_name: Project name to use, defaults to workspace's project name
|
||||
|
||||
:return: path to project cache root folder
|
||||
"""
|
||||
return os.path.join(self._temp_asset_root, 'Cache')
|
||||
|
||||
def clear_readonly(self, relative_dest):
|
||||
"""
|
||||
@@ -991,13 +948,19 @@ class AssetProcessor(object):
|
||||
|
||||
|
||||
def _build_ap_batch_call_params(ap_path, project, platforms, extra_params=None):
|
||||
project_str = f"/gamefolder={project}"
|
||||
project_str = f"--regset=/Amazon/AzCore/Bootstrap/project_path={project}"
|
||||
project_str.rstrip(' ')
|
||||
param_list = [ap_path, project_str]
|
||||
|
||||
if self._disable_all_platforms:
|
||||
command.append(f'--regremove="f{ASSET_PROCESSOR_SETTINGS_ROOT_KEY}/Platforms"')
|
||||
if platforms:
|
||||
if isinstance(platforms, list):
|
||||
platforms = ','.join(platforms)
|
||||
param_list.append(f'/platforms={platforms}')
|
||||
param_list.append(f'--platforms={platforms}')
|
||||
for key, value in self._enabled_platform_overrides:
|
||||
param_list.append(f'--regset="f{ASSET_PROCESSOR_SETTINGS_ROOT_KEY}/Platforms/{key}={value}"')
|
||||
|
||||
if extra_params:
|
||||
if isinstance(extra_params, list):
|
||||
param_list.extend(extra_params)
|
||||
|
||||
@@ -9,22 +9,47 @@ remove or modify any license notices. This file is distributed on an "AS IS" BAS
|
||||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
|
||||
Library of functions to support reading, modifying and writing to
|
||||
AssetProcessorPlatformConfig.ini
|
||||
AssetProcessorPlatformConfig.setreg
|
||||
|
||||
"""
|
||||
|
||||
import json
|
||||
import logging
|
||||
from ly_test_tools.lumberyard import ini_configuration_util as ini
|
||||
import os.path as path
|
||||
|
||||
logger = logging.getLogger(__name__)
|
||||
AssetProcessorConfig = "AssetProcessorPlatformConfig.ini"
|
||||
AssetProcessorConfig = "AssetProcessorPlatformConfig.setreg"
|
||||
|
||||
def platform_exists(config_ini_path, platform):
|
||||
def load_asset_processor_platform_config(file_location):
|
||||
"""
|
||||
Loads the AssetProcessorPlatformConfig.setreg file removing any comments
|
||||
|
||||
:param file_location: The file path of AssetProcessorPlatformConfig.setreg
|
||||
"""
|
||||
json_dict = {}
|
||||
with open(file_location, 'r') as json_file:
|
||||
cleaned_lines = []
|
||||
for line in json_file.readlines():
|
||||
lineIndex = line.lstrip().startswith('//')
|
||||
cleaned_lines.append(line if lineIndex == -1 else line[:lineIndex])
|
||||
json_dict = json.loads(''.join(cleaned_lines))
|
||||
return json_dict
|
||||
|
||||
def save_asset_processor_platform_config(file_location, json_dict):
|
||||
"""
|
||||
Saves the json_dict to the AssetProcessorPlatformConfig.setreg file
|
||||
|
||||
:param file_location: The file path of AssetProcessorPlatformConfig.setreg
|
||||
"""
|
||||
with open(file_location, 'w') as json_file:
|
||||
json.dump(json_dict, json_file, indent=4)
|
||||
return json_dict
|
||||
|
||||
def platform_exists(config_setreg_path, platform):
|
||||
"""
|
||||
Checks to see if a specific Platform Key is in Platforms Section
|
||||
|
||||
:param config_ini_path: The file path to the location of AssetProcessorPlatformConfig.ini
|
||||
:param config_setreg_path: The file path to the location of AssetProcessorPlatformConfig.setreg
|
||||
:param platform: Name of the Platform Key that you're checking exists
|
||||
:return: The boolean value of the existance of the platform
|
||||
"""
|
||||
@@ -32,19 +57,22 @@ def platform_exists(config_ini_path, platform):
|
||||
logger.debug("Checking for Platform '{0}' in Platforms Section of '{1}"
|
||||
.format(platform, AssetProcessorConfig))
|
||||
|
||||
file_location = path.join(config_ini_path, AssetProcessorConfig)
|
||||
file_location = path.join(config_setreg_path, AssetProcessorConfig)
|
||||
json_dict = load_asset_processor_platform_config(file_location)
|
||||
try:
|
||||
platformExist = platform in json_dict['Amazon']['AssetProcessor']['Settings']['Platforms']
|
||||
return platformExist
|
||||
except KeyError as err:
|
||||
logger.error(f'KeyError when attempting to query platform existance of {platform} in file {file_location}: {err}')
|
||||
|
||||
assert ini.check_section_exists(file_location, 'Platforms'), \
|
||||
'Platforms section does not exist in {0}'.format(file_location)
|
||||
|
||||
return ini.check_key_exists(path.join(config_ini_path, AssetProcessorConfig), 'Platforms', platform)
|
||||
return False
|
||||
|
||||
|
||||
def is_platform_enabled(config_ini_path, platform):
|
||||
def is_platform_enabled(config_setreg_path, platform):
|
||||
"""
|
||||
Checks to see if a specific Platform Key is enabled in Platforms Section
|
||||
|
||||
:param config_ini_path: The file path to the location of AssetProcessorPlatformConfig.ini
|
||||
:param config_setreg_path: The file path to the location of AssetProcessorPlatformConfig.setreg
|
||||
:param platform: Name of the Platform that you're checking is enabled.
|
||||
See asset_processor.SUPPORTED_PLATFORMS for listed of supported platforms
|
||||
:return: The boolean value of the enabled state of the platform
|
||||
@@ -53,21 +81,23 @@ def is_platform_enabled(config_ini_path, platform):
|
||||
logger.debug("Checking if Platform '{0}' is enabled in Platform Section of '{1}"
|
||||
.format(platform, AssetProcessorConfig))
|
||||
|
||||
file_location = path.join(config_ini_path, AssetProcessorConfig)
|
||||
file_location = path.join(config_setreg_path, AssetProcessorConfig)
|
||||
# load AssetProcessorPlatformConfig.setreg removing any comments
|
||||
json_dict = load_asset_processor_platform_config(file_location)
|
||||
try:
|
||||
enabled = json_dict['Amazon']['AssetProcessor']['Settings']['Platforms'][platform] == 'enabled'
|
||||
return enabled
|
||||
except KeyError as err:
|
||||
logger.error(f'KeyError when attempting to check if platform {platform} is enabled in file {file_location}: {err}')
|
||||
|
||||
assert ini.check_section_exists(file_location, 'Platforms'), \
|
||||
'Platforms section does not exist in {0}'.format(file_location)
|
||||
|
||||
enabled = str(ini.get_string_value(file_location, 'Platforms', platform)) == 'enabled'
|
||||
|
||||
return enabled
|
||||
return False
|
||||
|
||||
|
||||
def enable_platform(config_ini_path, platform):
|
||||
def enable_platform(config_setreg_path, platform):
|
||||
"""
|
||||
Enables a specific Platform Key is in Platforms Section
|
||||
|
||||
:param config_ini_path: The file path to the location of AssetProcessorPlatformConfig.ini
|
||||
:param config_setreg_path: The file path to the location of AssetProcessorPlatformConfig.setreg
|
||||
:param platform: Name of the Platform Key that you're checking exists
|
||||
See asset_processor.SUPPORTED_PLATFORMS for listed of supported platforms
|
||||
:assert: Assert if the platform is not enabled
|
||||
@@ -76,35 +106,35 @@ def enable_platform(config_ini_path, platform):
|
||||
|
||||
logger.debug("Enabling platform '{0}' in '{1}'".format(platform, AssetProcessorConfig))
|
||||
|
||||
file_location = path.join(config_ini_path, AssetProcessorConfig)
|
||||
|
||||
ini.add_key(file_location, 'Platforms', platform, 'enabled')
|
||||
|
||||
assert is_platform_enabled(config_ini_path, platform), "Platform '{0}' failed to enable in '{1}'"\
|
||||
.format(platform, AssetProcessorConfig)
|
||||
file_location = path.join(config_setreg_path, AssetProcessorConfig)
|
||||
json_dict = load_asset_processor_platform_config(file_location)
|
||||
# Enable platform in settings registry
|
||||
json_dict.setdefault('Amazon', {}).setdefault('AssetProcessor', {}).setdefault('Settings',{}) \
|
||||
.setdefault('Platforms',{})[platform] = 'enabled'
|
||||
save_asset_processor_platform_config(file_location)
|
||||
|
||||
|
||||
def enable_all_platforms(config_ini_path):
|
||||
def enable_all_platforms(config_setreg_path):
|
||||
"""
|
||||
Enable all supported platforms in the Platforms Section
|
||||
|
||||
:param config_ini_path: The file path to the location of AssetProcessorPlatformConfig.ini
|
||||
:param config_setreg_path: The file path to the location of AssetProcessorPlatformConfig.setreg
|
||||
:return: None
|
||||
"""
|
||||
|
||||
logger.debug("Enabling all supported platforms in '{0}'.".format(AssetProcessorConfig))
|
||||
|
||||
for platform in SUPPORTED_PLATFORMS:
|
||||
enable_platform(config_ini_path, platform)
|
||||
enable_platform(config_setreg_path, platform)
|
||||
|
||||
logger.debug("All supported platforms have been enabled in '{0}'.".format(AssetProcessorConfig))
|
||||
|
||||
|
||||
def disable_platform(config_ini_path, platform):
|
||||
def disable_platform(config_setreg_path, platform):
|
||||
"""
|
||||
Disables a specific Platform Key is in Platforms Section
|
||||
|
||||
:param config_ini_path: The file path to the location of AssetProcessorPlatformConfig.ini
|
||||
:param config_setreg_path: The file path to the location of AssetProcessorPlatformConfig.setreg
|
||||
:param platform: Name of the Platform Key that you're checking exists.
|
||||
See asset_processor_config_util.SUPPORTED_PLATFORMS for listed of supported platforms
|
||||
:assert: Assert if the platform is not disabled
|
||||
@@ -113,170 +143,196 @@ def disable_platform(config_ini_path, platform):
|
||||
|
||||
logger.debug("Disabling platform '{0}' in '{1}'".format(platform, AssetProcessorConfig))
|
||||
|
||||
file_location = path.join(config_ini_path, AssetProcessorConfig)
|
||||
|
||||
ini.add_key(file_location, 'Platforms', platform, 'disabled')
|
||||
|
||||
assert not is_platform_enabled(config_ini_path, platform), "Platform '{0}' failed to disable in '{1}'"\
|
||||
.format(platform, AssetProcessorConfig)
|
||||
file_location = path.join(config_setreg_path, AssetProcessorConfig)
|
||||
# Disable platform in settings registry
|
||||
json_dict = load_asset_processor_platform_config(file_location)
|
||||
json_dict.setdefault('Amazon', {}).setdefault('AssetProcessor', {}).setdefault('Settings',{}) \
|
||||
.setdefault('Platforms',{})[platform] = 'disabled'
|
||||
save_asset_processor_platform_config(file_location)
|
||||
|
||||
|
||||
def disable_all_platforms(config_ini_path):
|
||||
def disable_all_platforms(config_setreg_path):
|
||||
"""
|
||||
Disable all supported platforms in the Platforms Section
|
||||
|
||||
:param config_ini_path: The file path to the location of AssetProcessorPlatformConfig.ini
|
||||
:param config_setreg_path: The file path to the location of AssetProcessorPlatformConfig.setreg
|
||||
:return: None
|
||||
"""
|
||||
|
||||
logger.debug("Disabling all platforms in '{0}'".format(AssetProcessorConfig))
|
||||
|
||||
for platform in SUPPORTED_PLATFORMS:
|
||||
disable_platform(config_ini_path, platform)
|
||||
disable_platform(config_setreg_path, platform)
|
||||
|
||||
logger.debug("All supported platforms have been disabled in '{0}'.".format(AssetProcessorConfig))
|
||||
|
||||
|
||||
def enable_scanfolder_engine(config_ini_path):
|
||||
def enable_scanfolder_engine(config_setreg_path):
|
||||
"""
|
||||
Enable Asset Processor scanning on the Engine folder
|
||||
|
||||
:param config_ini_path: The file path to the location of AssetProcessorPlatformConfig.ini
|
||||
:param config_setreg_path: The file path to the location of AssetProcessorPlatformConfig.setreg
|
||||
:return: None
|
||||
"""
|
||||
|
||||
file_location = path.join(config_ini_path, AssetProcessorConfig)
|
||||
file_location = path.join(config_setreg_path, AssetProcessorConfig)
|
||||
section = 'ScanFolder Engine'
|
||||
|
||||
logger.debug("Enabling Asset Processor scanning of the Engine folder")
|
||||
|
||||
if not ini.check_section_exists(file_location, section):
|
||||
ini.add_section(file_location, section)
|
||||
ini.add_key(file_location, section, 'watch', r'@ENGINEROOT@/Engine')
|
||||
ini.add_key(file_location, section, 'recursive', '1')
|
||||
ini.add_key(file_location, section, 'order', '20000')
|
||||
json_dict = load_asset_processor_platform_config(file_location)
|
||||
json_dict.setdefault('Amazon', {}).setdefault('AssetProcessor', {}).setdefault('Settings',{}) \
|
||||
.setdefault(section,{})['watch'] = '@ENGINEROOT@/Engine'
|
||||
json_dict['Amazon']['AssetProcessor']['Settings'][section]['recursive'] = '1'
|
||||
json_dict['Amazon']['AssetProcessor']['Settings'][section]['order'] = '20000'
|
||||
save_asset_processor_platform_config(file_location)
|
||||
|
||||
|
||||
def disable_scanfolder_engine(config_ini_path):
|
||||
def disable_scanfolder_engine(config_setreg_path):
|
||||
"""
|
||||
Disable Asset Processor scanning on the Engine folder
|
||||
|
||||
:param config_ini_path: The file path to the location of AssetProcessorPlatformConfig.ini
|
||||
:param config_setreg_path: The file path to the location of AssetProcessorPlatformConfig.setreg
|
||||
:return: None
|
||||
"""
|
||||
|
||||
file_location = path.join(config_ini_path, AssetProcessorConfig)
|
||||
file_location = path.join(config_setreg_path, AssetProcessorConfig)
|
||||
section = 'ScanFolder Engine'
|
||||
|
||||
logger.debug("Disabling Asset Processor scanning of the Engine folder")
|
||||
|
||||
ini.delete_section(file_location, section)
|
||||
json_dict = load_asset_processor_platform_config(file_location)
|
||||
try:
|
||||
del json_dict['Amazon']['AssetProcessor']['Settings'][section]
|
||||
save_asset_processor_platform_config(file_location)
|
||||
except KeyError as err:
|
||||
logger.debug(f'No-op: f{section} key does not exist in file {file_location}')
|
||||
|
||||
|
||||
def enable_scanfolder_editor(config_ini_path):
|
||||
def enable_scanfolder_editor(config_setreg_path):
|
||||
"""
|
||||
Enable Asset Processor scanning on the editor folder
|
||||
|
||||
:param config_ini_path: The file path to the location of AssetProcessorPlatformConfig.ini
|
||||
:param config_setreg_path: The file path to the location of AssetProcessorPlatformConfig.setreg
|
||||
:return: None
|
||||
"""
|
||||
|
||||
file_location = path.join(config_ini_path, AssetProcessorConfig)
|
||||
file_location = path.join(config_setreg_path, AssetProcessorConfig)
|
||||
section = 'ScanFolder Editor'
|
||||
|
||||
|
||||
logger.debug("Enabling Asset Processor scanning of the Editor folder")
|
||||
|
||||
if not ini.check_section_exists(file_location, section):
|
||||
ini.add_section(file_location, section)
|
||||
ini.add_key(file_location, section, 'watch', r'@ENGINEROOT@/Editor')
|
||||
ini.add_key(file_location, section, 'output', 'editor')
|
||||
ini.add_key(file_location, section, 'recursive', '1')
|
||||
ini.add_key(file_location, section, 'order', '30000')
|
||||
ini.add_key(file_location, section, 'include', 'tools,renderer')
|
||||
json_dict = load_asset_processor_platform_config(file_location)
|
||||
json_dict.setdefault('Amazon', {}).setdefault('AssetProcessor', {}).setdefault('Settings',{}) \
|
||||
.setdefault(section,{})['watch'] = '@ENGINEROOT@/Editor'
|
||||
json_dict['Amazon']['AssetProcessor']['Settings'][section]['output'] = 'editor'
|
||||
json_dict['Amazon']['AssetProcessor']['Settings'][section]['recursive'] = '1'
|
||||
json_dict['Amazon']['AssetProcessor']['Settings'][section]['order'] = '30000'
|
||||
json_dict['Amazon']['AssetProcessor']['Settings'][section]['include'] = 'tools,renderer'
|
||||
save_asset_processor_platform_config(file_location)
|
||||
|
||||
|
||||
def disable_scanfolder_editor(config_ini_path):
|
||||
def disable_scanfolder_editor(config_setreg_path):
|
||||
"""
|
||||
Disable Asset Processor scanning on the Engine folder
|
||||
|
||||
:param config_ini_path: The file path to the location of AssetProcessorPlatformConfig.ini
|
||||
:param config_setreg_path: The file path to the location of AssetProcessorPlatformConfig.setreg
|
||||
:return: None
|
||||
"""
|
||||
|
||||
file_location = path.join(config_ini_path, AssetProcessorConfig)
|
||||
file_location = path.join(config_setreg_path, AssetProcessorConfig)
|
||||
section = 'ScanFolder Editor'
|
||||
|
||||
logger.debug("Disabling Asset Processor scanning of the Editor folder")
|
||||
|
||||
ini.delete_section(file_location, section)
|
||||
try:
|
||||
del json_dict['Amazon']['AssetProcessor']['Settings'][section]
|
||||
save_asset_processor_platform_config(file_location)
|
||||
except KeyError as err:
|
||||
logger.debug(f'No-op: f{section} key does not exist in file {file_location}')
|
||||
|
||||
|
||||
def enable_scanfolder_root(config_ini_path):
|
||||
def enable_scanfolder_root(config_setreg_path):
|
||||
"""
|
||||
Enable Asset Processor scanning on the Root folder
|
||||
|
||||
:param config_ini_path: The file path to the location of AssetProcessorPlatformConfig.ini
|
||||
:param config_setreg_path: The file path to the location of AssetProcessorPlatformConfig.setreg
|
||||
:return: None
|
||||
"""
|
||||
|
||||
file_location = path.join(config_ini_path, AssetProcessorConfig)
|
||||
file_location = path.join(config_setreg_path, AssetProcessorConfig)
|
||||
section = 'ScanFolder Root'
|
||||
|
||||
logger.debug("Enabling Asset Processor scanning of the Root folder")
|
||||
|
||||
if not ini.check_section_exists(file_location, section):
|
||||
ini.add_section(file_location, section)
|
||||
ini.add_key(file_location, section, 'watch', r'@ROOT@')
|
||||
ini.add_key(file_location, section, 'recursive', '0')
|
||||
ini.add_key(file_location, section, 'order', '10000')
|
||||
json_dict = load_asset_processor_platform_config(file_location)
|
||||
json_dict.setdefault('Amazon', {}).setdefault('AssetProcessor', {}).setdefault('Settings',{}) \
|
||||
.setdefault(section,{})['watch'] = '@ROOT@'
|
||||
json_dict['Amazon']['AssetProcessor']['Settings'][section]['recursive'] = '0'
|
||||
json_dict['Amazon']['AssetProcessor']['Settings'][section]['order'] = '10000'
|
||||
save_asset_processor_platform_config(file_location)
|
||||
|
||||
|
||||
def disable_scanfolder_root(config_ini_path):
|
||||
def disable_scanfolder_root(config_setreg_path):
|
||||
"""
|
||||
Disable Asset Processor scanning on the Root folder
|
||||
|
||||
:param config_ini_path: The file path to the location of AssetProcessorPlatformConfig.ini
|
||||
:param config_setreg_path: The file path to the location of AssetProcessorPlatformConfig.setreg
|
||||
:return: None
|
||||
"""
|
||||
|
||||
file_location = path.join(config_ini_path, AssetProcessorConfig)
|
||||
file_location = path.join(config_setreg_path, AssetProcessorConfig)
|
||||
section = 'ScanFolder Root'
|
||||
|
||||
logger.debug("Disabling Asset Processor scanning of the Root folder")
|
||||
|
||||
ini.delete_section(file_location, section)
|
||||
try:
|
||||
del json_dict['Amazon']['AssetProcessor']['Settings'][section]
|
||||
save_asset_processor_platform_config(file_location)
|
||||
except KeyError as err:
|
||||
logger.debug(f'No-op: f{section} key does not exist in file {file_location}')
|
||||
|
||||
|
||||
def update_pattern(config_ini_path, pattern, key, value):
|
||||
def update_pattern(config_setreg_path, pattern, key, value):
|
||||
"""
|
||||
Update a RC pattern's behavior options with the provided key and value.
|
||||
|
||||
:param config_ini_path: The file path to the location of AssetProcessorPlatformConfig.ini
|
||||
:param config_setreg_path: The file path to the location of AssetProcessorPlatformConfig.setreg
|
||||
:param pattern: The RC pattern to update
|
||||
:param key: The key to update
|
||||
:param value: The value to set the key to
|
||||
:return: None
|
||||
"""
|
||||
|
||||
file_location = path.join(config_ini_path, AssetProcessorConfig)
|
||||
file_location = path.join(config_setreg_path, AssetProcessorConfig)
|
||||
rc_pattern = 'RC ' + pattern
|
||||
|
||||
logger.debug("Modifying pattern for '{0}'.".format(rc_pattern))
|
||||
ini.add_key(file_location, rc_pattern, key, value)
|
||||
json_dict = load_asset_processor_platform_config(file_location)
|
||||
json_dict.setdefault('Amazon', {}).setdefault('AssetProcessor', {}).setdefault('Settings',{}) \
|
||||
.setdefault(rc_pattern,{})[key] = value
|
||||
save_asset_processor_platform_config(file_location)
|
||||
|
||||
|
||||
def get_pattern_key(config_ini_path, pattern, key):
|
||||
def get_pattern_key(config_setreg_path, pattern, key):
|
||||
"""
|
||||
Get the value of a RC pattern's behavior options key value
|
||||
|
||||
:param config_ini_path: The file path to the location of AssetProcessorPlatformConfig.ini
|
||||
:param config_setreg_path: The file path to the location of AssetProcessorPlatformConfig.setreg
|
||||
:param pattern: The RC pattern to retrieve a key from
|
||||
:param key: The key to retrieve
|
||||
:return: value of RC pattern key value
|
||||
"""
|
||||
|
||||
file_location = path.join(config_ini_path, AssetProcessorConfig)
|
||||
file_location = path.join(config_setreg_path, AssetProcessorConfig)
|
||||
rc_pattern = 'RC ' + pattern
|
||||
logger.debug("Retrieving the key '{0}' from pattern '{1}'.".format(key, rc_pattern))
|
||||
return ini.get_string_value(file_location, rc_pattern, key)
|
||||
json_dict = load_asset_processor_platform_config(file_location)
|
||||
try:
|
||||
value = json_dict['Amazon']['AssetProcessor']['Settings'][rc_pattern][key]
|
||||
return value
|
||||
except KeyError as err:
|
||||
logger.error(f'KeyError attempting to query value for key "/Amazon/AssetProcessor/Settings/{rc_pattern}/{key}" in file {file_location}: {err}')
|
||||
|
||||
return None
|
||||
|
||||
@@ -41,10 +41,6 @@ class LySettings(object):
|
||||
logger.info(f'Updating setting {setting} to {value}')
|
||||
_edit_text_settings_file(self._resource_locator.platform_config_file(), setting, value)
|
||||
|
||||
def modify_bootstrap_setting(self, setting, value, bootstrap_path=None):
|
||||
logger.info(f'Updating setting {setting} to {value}')
|
||||
_edit_text_settings_file(bootstrap_path or self._resource_locator.bootstrap_config_file(), setting, value)
|
||||
|
||||
def modify_shader_compiler_setting(self, setting, value):
|
||||
logger.info(f'Updating setting {setting} to {value}')
|
||||
_edit_text_settings_file(self._resource_locator.shader_compiler_config_file(), setting, value)
|
||||
|
||||
@@ -19,7 +19,8 @@ ly_add_pytest(
|
||||
COMPONENT TestTools
|
||||
)
|
||||
|
||||
if(PAL_TRAIT_BUILD_HOST_TOOLS AND PAL_TRAIT_BUILD_TESTS_SUPPORTED AND AutomatedTesting IN_LIST LY_PROJECTS_NAME)
|
||||
get_property(LY_PROJECTS_TARGET_NAME GLOBAL PROPERTY LY_PROJECTS_TARGET_NAME)
|
||||
if(PAL_TRAIT_BUILD_HOST_TOOLS AND PAL_TRAIT_BUILD_TESTS_SUPPORTED AND AutomatedTesting IN_LIST LY_PROJECTS_TARGET_NAME)
|
||||
# Integration tests.
|
||||
ly_add_pytest(
|
||||
NAME LyTestTools_IntegTests_Sanity_smoke_no_gpu
|
||||
@@ -43,19 +44,6 @@ if(PAL_TRAIT_BUILD_HOST_TOOLS AND PAL_TRAIT_BUILD_TESTS_SUPPORTED AND AutomatedT
|
||||
COMPONENT TestTools
|
||||
)
|
||||
|
||||
ly_add_pytest(
|
||||
NAME LyTestTools_IntegTests_Settings_smoke_no_gpu
|
||||
PATH ${CMAKE_CURRENT_LIST_DIR}/integ/test_settings.py
|
||||
TEST_SERIAL
|
||||
TEST_SUITE smoke
|
||||
RUNTIME_DEPENDENCIES
|
||||
AssetProcessor
|
||||
AutomatedTesting.GameLauncher
|
||||
AutomatedTesting.Assets
|
||||
Legacy::CryRenderNULL
|
||||
COMPONENT TestTools
|
||||
)
|
||||
|
||||
# Regression tests.
|
||||
ly_add_pytest(
|
||||
NAME LyTestTools_IntegTests_RegressionTests_periodic_no_gpu
|
||||
|
||||
@@ -1,52 +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 filecmp
|
||||
import os
|
||||
import pytest
|
||||
|
||||
|
||||
pytestmark = pytest.mark.SUITE_smoke
|
||||
|
||||
|
||||
class TestLySettings(object):
|
||||
|
||||
@pytest.mark.parametrize("project", ["AutomatedTesting"])
|
||||
@pytest.mark.parametrize("wait_for_connect", [1234, 4567])
|
||||
def test_BootstrapSettings_BackupModifyRestore_SettingsMatch(self, workspace, wait_for_connect):
|
||||
backup_path = workspace.tmp_path
|
||||
|
||||
# create backup
|
||||
workspace.settings.backup_bootstrap_settings(backup_path)
|
||||
|
||||
# verify files match
|
||||
bootstrap_settings = workspace.paths.bootstrap_config_file()
|
||||
bootstrap_settings_backup = os.path.join(backup_path, '{}.bak'.format(os.path.basename(bootstrap_settings)))
|
||||
assert os.path.exists(bootstrap_settings), "Bootstrap settings file does not exist"
|
||||
assert os.path.exists(bootstrap_settings_backup), "Bootstrap settings backup does not exist"
|
||||
assert filecmp.cmp(bootstrap_settings, bootstrap_settings_backup), "Bootstrap settings and backup do not match"
|
||||
|
||||
# modify settings
|
||||
workspace.settings.modify_bootstrap_setting('remote_filesystem', 0)
|
||||
workspace.settings.modify_bootstrap_setting('wait_for_connect', wait_for_connect)
|
||||
workspace.settings.modify_bootstrap_setting('remote_ip', '0.36.27.18')
|
||||
workspace.settings.modify_bootstrap_setting('additional_setting', 'value1')
|
||||
|
||||
# verify files are different
|
||||
assert not filecmp.cmp(bootstrap_settings, bootstrap_settings_backup), "Modified bootstrap settings and backup" \
|
||||
" are equal, they should be different"
|
||||
|
||||
# restore backup
|
||||
workspace.settings.restore_bootstrap_settings(backup_path)
|
||||
|
||||
# verify files match
|
||||
assert filecmp.cmp(bootstrap_settings, bootstrap_settings_backup), "Restored bootstrap settings and backup " \
|
||||
"are different, they should be equal"
|
||||
@@ -134,7 +134,7 @@ class TestAbstractResourceLocator(object):
|
||||
def test_Cache_IsCalled_ReturnsCachePath(self):
|
||||
mock_abstract_resource_locator = abstract_resource_locator.AbstractResourceLocator(
|
||||
mock_build_directory, mock_project)
|
||||
expected_path = os.path.join(mock_abstract_resource_locator.dev(), 'Cache')
|
||||
expected_path = os.path.join(mock_abstract_resource_locator.cache())
|
||||
|
||||
assert mock_abstract_resource_locator.cache() == expected_path
|
||||
|
||||
@@ -178,7 +178,7 @@ class TestAbstractResourceLocator(object):
|
||||
def test_AssetProcessorConfigFile_IsCalled_ReturnsAssetProcessorConfigFilePath(self):
|
||||
mock_abstract_resource_locator = abstract_resource_locator.AbstractResourceLocator(
|
||||
mock_build_directory, mock_project)
|
||||
expected_path = os.path.join(mock_abstract_resource_locator.dev(), 'AssetProcessorPlatformConfig.ini')
|
||||
expected_path = os.path.join(mock_abstract_resource_locator.dev(), 'AssetProcessorPlatformConfig.setreg')
|
||||
|
||||
assert mock_abstract_resource_locator.asset_processor_config_file() == expected_path
|
||||
|
||||
|
||||
@@ -60,7 +60,7 @@ class TestAssetProcessor(object):
|
||||
under_test.start(connect_to_ap=True)
|
||||
|
||||
assert under_test._ap_proc is not None
|
||||
mock_popen.assert_called_once_with([mock_ap_path, '--zeroAnalysisMode', '--gamefolder', 'AutomatedTesting',
|
||||
mock_popen.assert_called_once_with([mock_ap_path, '--zeroAnalysisMode', '--regset="/Amazon/AzCore/Bootstrap/project_path=AutomatedTesting"',
|
||||
'--acceptInput', '--platforms', 'bar'], cwd=os.path.dirname(mock_ap_path))
|
||||
mock_connect.assert_called()
|
||||
|
||||
@@ -105,8 +105,8 @@ class TestAssetProcessor(object):
|
||||
@mock.patch('ly_test_tools._internal.managers.workspace.AbstractWorkspaceManager')
|
||||
@mock.patch('subprocess.run')
|
||||
def test_BatchProcess_NoFastscanBatchCompletes_Success(self, mock_run, mock_workspace):
|
||||
under_test = ly_test_tools.lumberyard.asset_processor.AssetProcessor(mock_workspace)
|
||||
mock_workspace.project = None
|
||||
under_test = ly_test_tools.lumberyard.asset_processor.AssetProcessor(mock_workspace)
|
||||
apb_path = mock_workspace.paths.asset_processor_batch()
|
||||
mock_run.return_value.returncode = 0
|
||||
result, _ = under_test.batch_process(1, False)
|
||||
@@ -118,23 +118,23 @@ class TestAssetProcessor(object):
|
||||
@mock.patch('ly_test_tools._internal.managers.workspace.AbstractWorkspaceManager')
|
||||
@mock.patch('subprocess.run')
|
||||
def test_BatchProcess_FastscanBatchCompletes_Success(self, mock_run, mock_workspace):
|
||||
under_test = ly_test_tools.lumberyard.asset_processor.AssetProcessor(mock_workspace)
|
||||
mock_workspace.project = 'AutomatedTesting'
|
||||
under_test = ly_test_tools.lumberyard.asset_processor.AssetProcessor(mock_workspace)
|
||||
apb_path = mock_workspace.paths.asset_processor_batch()
|
||||
mock_run.return_value.returncode = 0
|
||||
|
||||
result = under_test.batch_process(1, True)
|
||||
|
||||
assert result
|
||||
mock_run.assert_called_once_with([apb_path, '--zeroAnalysisMode', '--gamefolder', 'AutomatedTesting'],
|
||||
mock_run.assert_called_once_with([apb_path, '--zeroAnalysisMode', '--regset="/Amazon/AzCore/Bootstrap/project_path=AutomatedTesting"'],
|
||||
close_fds=True, capture_output=False,
|
||||
timeout=1)
|
||||
|
||||
@mock.patch('ly_test_tools._internal.managers.workspace.AbstractWorkspaceManager')
|
||||
@mock.patch('subprocess.run')
|
||||
def test_BatchProcess_ReturnCodeFail_Failure(self, mock_run, mock_workspace):
|
||||
under_test = ly_test_tools.lumberyard.asset_processor.AssetProcessor(mock_workspace)
|
||||
mock_workspace.project = None
|
||||
under_test = ly_test_tools.lumberyard.asset_processor.AssetProcessor(mock_workspace)
|
||||
apb_path = mock_workspace.paths.asset_processor_batch()
|
||||
mock_run.return_value.returncode = 1
|
||||
|
||||
@@ -145,42 +145,11 @@ class TestAssetProcessor(object):
|
||||
|
||||
|
||||
@mock.patch('ly_test_tools._internal.managers.workspace.AbstractWorkspaceManager')
|
||||
@mock.patch('os.path.isfile')
|
||||
@mock.patch('ly_test_tools.lumberyard.asset_processor.file_system.unlock_file')
|
||||
def test_EnableAssetProcessorPlatform_PlatformInConfig_ConfigUpdated(self, mock_unlock, mock_isfile,
|
||||
mock_workspace):
|
||||
mock_isfile.return_value = True
|
||||
def test_EnableAssetProcessorPlatform_AssetProcessorObject_Updated(self, mock_workspace):
|
||||
under_test = ly_test_tools.lumberyard.asset_processor.AssetProcessor(mock_workspace)
|
||||
apconfig_path = mock_workspace.paths.asset_processor_config_file()
|
||||
|
||||
mock_config_content = '[Platforms]\n;foo\n;bar\n[Other]\nsomething\n'
|
||||
|
||||
mock_open_config = mock.mock_open(read_data=mock_config_content)
|
||||
|
||||
patcher = mock.patch('builtins.open', mock_open_config)
|
||||
patcher.start()
|
||||
|
||||
under_test.enable_asset_processor_platform('foo')
|
||||
|
||||
mock_unlock.assert_called_once_with(apconfig_path)
|
||||
mock_open_config.assert_called_once_with(apconfig_path, 'r+')
|
||||
file_handle = mock_open_config()
|
||||
file_handle.writelines.assert_called_once_with(['[Platforms]\n', 'foo\n', ';bar\n', '[Other]\n', 'something\n'])
|
||||
patcher.stop()
|
||||
|
||||
@mock.patch('ly_test_tools._internal.managers.workspace.AbstractWorkspaceManager')
|
||||
@mock.patch('os.path.isfile')
|
||||
@mock.patch('ly_test_tools.lumberyard.asset_processor.file_system.unlock_file')
|
||||
def test_EnableAssetProcessorPlatform_FileDoesNotExist_ErrorRaised(self, mock_unlock, mock_isfile, mock_workspace):
|
||||
mock_isfile.return_value = False
|
||||
under_test = ly_test_tools.lumberyard.asset_processor.AssetProcessor(mock_workspace)
|
||||
apconfig_path = mock_workspace.paths.asset_processor_config_file()
|
||||
|
||||
with pytest.raises(IOError):
|
||||
under_test.enable_asset_processor_platform('foo')
|
||||
|
||||
mock_isfile.assert_called_once_with(apconfig_path)
|
||||
mock_unlock.assert_not_called()
|
||||
assert "foo" in under_test._enabled_platform_overrides
|
||||
|
||||
@mock.patch('ly_test_tools._internal.managers.workspace.AbstractWorkspaceManager')
|
||||
def test_BackupAPSettings_Called_CallsBackupAPSettings(self, mock_workspace):
|
||||
|
||||
@@ -234,7 +234,6 @@ class TestAndroidLauncher:
|
||||
mock_workspace.shader_compiler.stop.assert_called_once()
|
||||
|
||||
@mock.patch('ly_test_tools.launchers.platforms.base.Launcher._config_ini_to_dict')
|
||||
@mock.patch('ly_test_tools.lumberyard.settings.LySettings.modify_bootstrap_setting', mock.MagicMock)
|
||||
@mock.patch('ly_test_tools.lumberyard.settings.LySettings.modify_platform_setting', mock.MagicMock)
|
||||
def test_ConfigureSettings_DefaultValues_SetsValues(self, mock_config):
|
||||
mock_config.return_value = VALID_ANDROID_CONFIG
|
||||
@@ -243,7 +242,6 @@ class TestAndroidLauncher:
|
||||
launcher = ly_test_tools.launchers.AndroidLauncher(mock_workspace, ["dummy"])
|
||||
launcher.configure_settings()
|
||||
|
||||
assert mock_workspace.settings.modify_bootstrap_setting.call_count == 6
|
||||
assert mock_workspace.settings.modify_platform_setting.call_count == 8
|
||||
|
||||
@mock.patch('ly_test_tools.launchers.platforms.base.Launcher._config_ini_to_dict')
|
||||
|
||||
@@ -59,7 +59,7 @@ class TestMacResourceLocator(object):
|
||||
|
||||
def test_ProjectLog_HasPath_ReturnsPath(self):
|
||||
expected = os.path.join(
|
||||
mac_resource_locator.platform_cache(),
|
||||
mac_resource_locator.project(),
|
||||
'user',
|
||||
'log')
|
||||
|
||||
@@ -67,7 +67,7 @@ class TestMacResourceLocator(object):
|
||||
|
||||
def test_ProjectScreenshots_HasPath_ReturnsPath(self):
|
||||
expected = os.path.join(
|
||||
mac_resource_locator.platform_cache(),
|
||||
mac_resource_locator.project(),
|
||||
'user',
|
||||
'ScreenShots')
|
||||
|
||||
|
||||
@@ -64,7 +64,7 @@ class TestWindowsResourceLocator(object):
|
||||
|
||||
def test_ProjectLog_HasPath_ReturnsPath(self):
|
||||
expected = os.path.join(
|
||||
windows_resource_locator.platform_cache(),
|
||||
windows_resource_locator.project(),
|
||||
'user',
|
||||
'log')
|
||||
|
||||
@@ -72,7 +72,7 @@ class TestWindowsResourceLocator(object):
|
||||
|
||||
def test_ProjectScreenshots_HasPath_ReturnsPath(self):
|
||||
expected = os.path.join(
|
||||
windows_resource_locator.platform_cache(),
|
||||
windows_resource_locator.project(),
|
||||
'user',
|
||||
'ScreenShots')
|
||||
|
||||
|
||||
Reference in New Issue
Block a user