Skip to content

Commit 4cc0f45

Browse files
committed
build gameloop test app & removing the zip
1 parent 068be04 commit 4cc0f45

File tree

3 files changed

+55
-44
lines changed

3 files changed

+55
-44
lines changed
-2.72 MB
Binary file not shown.

scripts/gha/integration_testing/gameloop/gameloop.xcodeproj/project.pbxproj

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -294,7 +294,7 @@
294294
GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE;
295295
GCC_WARN_UNUSED_FUNCTION = YES;
296296
GCC_WARN_UNUSED_VARIABLE = YES;
297-
IPHONEOS_DEPLOYMENT_TARGET = 14.3;
297+
IPHONEOS_DEPLOYMENT_TARGET = 12.0;
298298
MTL_ENABLE_DEBUG_INFO = INCLUDE_SOURCE;
299299
MTL_FAST_MATH = YES;
300300
ONLY_ACTIVE_ARCH = YES;
@@ -349,7 +349,7 @@
349349
GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE;
350350
GCC_WARN_UNUSED_FUNCTION = YES;
351351
GCC_WARN_UNUSED_VARIABLE = YES;
352-
IPHONEOS_DEPLOYMENT_TARGET = 14.3;
352+
IPHONEOS_DEPLOYMENT_TARGET = 12.0;
353353
MTL_ENABLE_DEBUG_INFO = NO;
354354
MTL_FAST_MATH = YES;
355355
SDKROOT = iphoneos;
@@ -366,6 +366,7 @@
366366
ASSETCATALOG_COMPILER_GLOBAL_ACCENT_COLOR_NAME = AccentColor;
367367
CODE_SIGN_STYLE = Automatic;
368368
INFOPLIST_FILE = gameloop/Info.plist;
369+
IPHONEOS_DEPLOYMENT_TARGET = 12.0;
369370
LD_RUNPATH_SEARCH_PATHS = (
370371
"$(inherited)",
371372
"@executable_path/Frameworks",
@@ -384,6 +385,7 @@
384385
ASSETCATALOG_COMPILER_GLOBAL_ACCENT_COLOR_NAME = AccentColor;
385386
CODE_SIGN_STYLE = Automatic;
386387
INFOPLIST_FILE = gameloop/Info.plist;
388+
IPHONEOS_DEPLOYMENT_TARGET = 12.0;
387389
LD_RUNPATH_SEARCH_PATHS = (
388390
"$(inherited)",
389391
"@executable_path/Frameworks",

scripts/gha/test_simulator.py

Lines changed: 51 additions & 42 deletions
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,7 @@
5959
"testapp_dir", None,
6060
"Testapps in this directory will be tested.")
6161
flags.DEFINE_string(
62-
"gameloop_zip", "integration_testing/gameloop.zip",
62+
"gameloop_project", "integration_testing/gameloop",
6363
"An zipped UI Test app that helps doing game-loop test."
6464
" The source code can be found here: integration_testing/gameloop")
6565
flags.DEFINE_string(
@@ -78,8 +78,11 @@ def main(argv):
7878

7979
current_dir = pathlib.Path(__file__).parent.absolute()
8080
testapp_dir = os.path.abspath(os.path.expanduser(FLAGS.testapp_dir))
81-
gameloop_zip = os.path.join(current_dir, FLAGS.gameloop_zip)
81+
gameloop_project = os.path.join(current_dir, FLAGS.gameloop_project)
8282
ios_device = FLAGS.ios_device
83+
device_info = ios_device.split("-")
84+
device_name = device_info[0]
85+
device_os = device_info[1]
8386

8487
config_path = os.path.join(current_dir, "integration_testing", "build_testapps.json")
8588
with open(config_path, "r") as config:
@@ -105,12 +108,12 @@ def main(argv):
105108

106109
logging.info("Testapps found: %s", "\n".join(path for _, path in testapps))
107110

108-
gameloop_app = _unzip_gameloop(gameloop_zip)
111+
gameloop_app = _build_gameloop(gameloop_project, device_name, device_os)
109112
if not gameloop_app:
110113
logging.info("gameloop app not found")
111114
return 2
112115

113-
device_id = _boot_simulator(ios_device)
116+
device_id = _boot_simulator(device_name, device_os)
114117
if not device_id:
115118
logging.info("simulator created fail")
116119
return 3
@@ -125,28 +128,59 @@ def main(argv):
125128
tests, test_validation.CPP, testapp_dir)
126129

127130

128-
def _unzip_gameloop(gameloop_zip):
129-
"""Unzip gameloop UI Test app.
131+
def _get_bundle_id(app_path, config):
132+
"""Get app bundle id from build_testapps.json file."""
133+
for api in config["apis"]:
134+
if api["name"] != "app" and (api["name"] in app_path or api["full_name"] in app_path):
135+
return api["bundle_id"]
136+
137+
138+
def _build_gameloop(gameloop_project, device_name, device_os):
139+
"""Build gameloop UI Test app.
130140
131141
This gameloop app can run integration_test app automatically.
132142
"""
133-
134-
directory = os.path.dirname(gameloop_zip)
135-
with zipfile.ZipFile(gameloop_zip,"r") as zip_ref:
136-
zip_ref.extractall(directory)
143+
project_path = os.path.join(gameloop_project, "gameloop.xcodeproj")
144+
output_path = os.path.join(gameloop_project, "Build")
145+
146+
"""Build the gameloop app for test."""
147+
args = ["xcodebuild", "-project", project_path,
148+
"-scheme", "gameloop",
149+
"-sdk", "iphonesimulator",
150+
"build-for-testing",
151+
"-destination", "platform=iOS Simulator,name=%s,OS=%s" % (device_name, device_os),
152+
"SYMROOT=%s" % output_path]
153+
logging.info("Running game-loop test: %s", " ".join(args))
154+
subprocess.run(args=args, check=True)
137155

138-
for file_dir, _, file_names in os.walk(directory):
156+
for file_dir, _, file_names in os.walk(output_path):
139157
for file_name in file_names:
140158
if file_name.endswith(".xctestrun"):
141159
return os.path.join(file_dir, file_name)
142160

143161

144-
def _boot_simulator(ios_device):
145-
"""Create a simulator locally. Will wait until this simulator botted."""
146-
device_info = ios_device.split("-")
147-
device_name = device_info[0]
148-
device_os = device_info[1]
162+
def _run_xctest(gameloop_app, device_id):
163+
"""Run the gameloop UI Test app.
164+
This gameloop app can run integration_test app automatically.
165+
"""
166+
args = ["xcodebuild", "test-without-building",
167+
"-xctestrun", gameloop_app,
168+
"-destination", "id=%s" % device_id]
169+
logging.info("Running game-loop test: %s", " ".join(args))
170+
result = subprocess.run(args=args, capture_output=True, text=True, check=False)
149171

172+
if not result.stdout:
173+
logging.info("No xctest result")
174+
return
175+
176+
result = result.stdout.splitlines()
177+
log_path = next((line for line in result if ".xcresult" in line), None)
178+
logging.info("game-loop xctest result: %s", log_path)
179+
return log_path
180+
181+
182+
def _boot_simulator(device_name, device_os):
183+
"""Create a simulator locally. Will wait until this simulator botted."""
150184
args = ["xcrun", "simctl", "shutdown", "all"]
151185
logging.info("Shutdown all simulators: %s", " ".join(args))
152186
subprocess.run(args=args, check=True)
@@ -172,20 +206,13 @@ def _delete_simulator(device_id):
172206
subprocess.run(args=args, check=True)
173207

174208

175-
def _get_bundle_id(app_path, config):
176-
"""Get app bundle id from build_testapps.json file."""
177-
for api in config["apis"]:
178-
if api["name"] != "app" and (api["name"] in app_path or api["full_name"] in app_path):
179-
return api["bundle_id"]
180-
181-
182209
def _run_gameloop_test(bundle_id, app_path, gameloop_app, device_id):
183210
"""Run gameloop test and collect test result."""
184211
logging.info("Running test: %s, %s, %s, %s", bundle_id, app_path, gameloop_app, device_id)
185212
_install_app(app_path, device_id)
186213
_run_xctest(gameloop_app, device_id)
187214
logs = _get_test_log(bundle_id, app_path, device_id)
188-
# _uninstall_app(bundle_id, device_id)
215+
_uninstall_app(bundle_id, device_id)
189216
return logs
190217

191218

@@ -219,24 +246,6 @@ def _get_test_log(bundle_id, app_path, device_id):
219246
return _read_file(log_path)
220247

221248

222-
def _run_xctest(gameloop_app, device_id):
223-
"""Run the gamelop test."""
224-
args = ["xcodebuild", "test-without-building",
225-
"-xctestrun", gameloop_app,
226-
"-destination", "id=%s" % device_id]
227-
logging.info("Running game-loop test: %s", " ".join(args))
228-
result = subprocess.run(args=args, capture_output=True, text=True, check=False)
229-
230-
if not result.stdout:
231-
logging.info("No xctest result")
232-
return
233-
234-
result = result.stdout.splitlines()
235-
log_path = next((line for line in result if ".xcresult" in line), None)
236-
logging.info("game-loop xctest result: %s", log_path)
237-
return log_path
238-
239-
240249
def _read_file(path):
241250
"""Extracts the contents of a file."""
242251
with open(path, "r") as f:

0 commit comments

Comments
 (0)