Skip to content

Commit c8e2330

Browse files
Add monolithic release game launcher test (o3de#17412)
* Add monolithic release game launcher test Signed-off-by: Alex Peterson <[email protected]> * fix release vs monolithic naming Signed-off-by: Alex Peterson <[email protected]> * fix invalid path and add comments Signed-off-by: Alex Peterson <[email protected]> * cleanup project folder from old runs Signed-off-by: Alex Peterson <[email protected]> * use tmp folder for project path Signed-off-by: Alex Peterson <[email protected]> --------- Signed-off-by: Alex Peterson <[email protected]>
1 parent d6f0da6 commit c8e2330

File tree

2 files changed

+32
-15
lines changed

2 files changed

+32
-15
lines changed

cmake/Platform/Windows/Packaging/Tests/conftest.py

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -17,8 +17,7 @@
1717
import urllib.request
1818
from pathlib import Path, PurePath
1919
from subprocess import run, list2cmdline
20-
from tempfile import NamedTemporaryFile, mkdtemp
21-
from time import sleep
20+
from tempfile import NamedTemporaryFile, TemporaryDirectory
2221

2322

2423
def pytest_addoption(parser):
@@ -48,10 +47,17 @@ def __init__(self, request, temp_dir):
4847
self.install_root = Path(request.config.getoption("--install-root")).resolve()
4948
self.project_path = Path(request.config.getoption("--project-path")).resolve()
5049

50+
# use a temp folder inside the project path to avoid issues where we cannot
51+
# clean up or remove the actual project folder
52+
with TemporaryDirectory(dir=self.project_path) as tmp_project_dir:
53+
self.project_path = Path(tmp_project_dir).resolve()
54+
5155
self.cmake_runtime_path = self.install_root / 'cmake/runtime'
5256
self.engine_bin_path = self.install_root / 'bin/Windows/profile/Default'
53-
self.project_build_path = self.project_path / 'build/Windows'
54-
self.project_bin_path = self.project_build_path / 'bin/profile'
57+
self.project_build_path_profile = self.project_path / 'build/Windows'
58+
self.project_build_path_release = self.project_path / 'build/Windows_mono'
59+
self.project_bin_path_profile = self.project_build_path_profile / 'bin/profile'
60+
self.project_bin_path_release = self.project_build_path_release / 'bin/release'
5561

5662
# start a log reader thread to print the output to screen
5763
self.log_reader_shutdown = False

cmake/Platform/Windows/Packaging/Tests/test_installer.py

Lines changed: 22 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@
2121
2222
"""
2323
import pytest
24-
import json
24+
import shutil
2525
from pathlib import Path
2626
from subprocess import TimeoutExpired
2727
from o3de import manifest
@@ -82,6 +82,7 @@ def test_o3de_registers_engine_fixture(test_installer_fixture, context):
8282
def test_create_project_fixture(test_o3de_registers_engine_fixture, context):
8383
""" o3de.bat CLI creates a project. """
8484
o3de_path = context.install_root / 'scripts/o3de.bat'
85+
8586
result = context.run([str(o3de_path),'create-project','--project-path', str(context.project_path)])
8687
assert result.returncode == 0, f"o3de.bat failed to create a project with exit code {result.returncode}"
8788

@@ -96,15 +97,25 @@ def test_compile_project_fixture(test_create_project_fixture, context):
9697
cmake_path = next(context.cmake_runtime_path.glob('**/cmake.exe'))
9798
launcher_target = f"{project_name}.GameLauncher"
9899

99-
# configure
100-
result = context.run([str(cmake_path),'-B', str(context.project_build_path), '-S', '.'], cwd=context.project_path)
101-
assert result.returncode == 0
102-
assert (context.project_build_path / f'{project_name}.sln').is_file()
100+
# configure non-monolithic
101+
result = context.run([str(cmake_path),'-B', str(context.project_build_path_profile), '-S', '.'], cwd=context.project_path)
102+
assert result.returncode == 0, 'Failed to configure the test project non-monolithic build'
103+
assert (context.project_build_path_profile / f'{project_name}.sln').is_file(), 'No project solution file was created'
104+
105+
# build profile (non-monolithic)
106+
result = context.run([str(cmake_path),'--build', str(context.project_build_path_profile), '--target', launcher_target, 'Editor', '--config', 'profile','--','-m'], cwd=context.project_path)
107+
assert result.returncode == 0, 'Failed to build the test project profile non-monolithic Launcher and Editor targets'
108+
assert (context.project_bin_path_profile / f'{launcher_target}.exe').is_file(), 'No test project binary was created'
109+
110+
# configure monolithic
111+
result = context.run([str(cmake_path),'-B', str(context.project_build_path_release), '-S', '.','-DLY_MONOLITHIC_GAME=1'], cwd=context.project_path)
112+
assert result.returncode == 0, 'Failed to configure the test project monolithic build'
113+
assert (context.project_build_path_release / f'{project_name}.sln').is_file(), 'No project solution file was created'
103114

104-
# build profile, release is not yet supported in the current installer
105-
result = context.run([str(cmake_path),'--build', str(context.project_build_path), '--target', launcher_target, 'Editor', '--config', 'profile','--','-m'], cwd=context.project_path)
106-
assert result.returncode == 0
107-
assert (context.project_bin_path / f'{launcher_target}.exe').is_file()
115+
# build release (monolithic)
116+
result = context.run([str(cmake_path),'--build', str(context.project_build_path_release), '--target', launcher_target, '--config', 'release','--','-m'], cwd=context.project_path)
117+
assert result.returncode == 0, 'Failed to build the test project monolithic release Launcher target'
118+
assert (context.project_bin_path_release / f'{launcher_target}.exe').is_file(), 'No test project binary was created'
108119

109120

110121
@pytest.fixture(scope="session")
@@ -155,8 +166,8 @@ def test_run_launcher_fixture(test_run_asset_processor_batch_fixture, context):
155166
project_name = Path(context.project_path).name
156167
launcher_filename = f"{project_name}.GameLauncher.exe"
157168
try:
158-
# run launcher for 2 mins
159-
result = context.run([str(context.project_bin_path / launcher_filename),'--rhi=null'], cwd=context.project_bin_path, timeout=2*60)
169+
# run profile launcher for 2 mins
170+
result = context.run([str(context.project_bin_path_profile / launcher_filename),'--rhi=null'], cwd=context.project_bin_path_profile, timeout=2*60)
160171
assert result.returncode == 0, f"{launcher_filename} failed with exit code {result.returncode}"
161172
except TimeoutExpired as e:
162173
# we expect to close the app on timeout ourselves

0 commit comments

Comments
 (0)