|
91 | 91 |
|
92 | 92 | _GAMELOOP_PACKAGE = "com.google.firebase.gameloop" |
93 | 93 | _RESULT_FILE = "Results1.json" |
| 94 | +_TEST_RETRY = 3 |
94 | 95 |
|
95 | 96 | FLAGS = flags.FLAGS |
96 | 97 |
|
@@ -208,9 +209,8 @@ def main(argv): |
208 | 209 |
|
209 | 210 | for app_path in ios_testapps: |
210 | 211 | bundle_id = _get_bundle_id(app_path, config) |
211 | | - tests.append(Test( |
212 | | - testapp_path=app_path, |
213 | | - logs=_run_apple_gameloop_test(bundle_id, app_path, ios_gameloop_app, device_id))) |
| 212 | + logs=_run_apple_gameloop_test(bundle_id, app_path, ios_gameloop_app, device_id, _TEST_RETRY) |
| 213 | + tests.append(Test(testapp_path=app_path, logs=logs)) |
214 | 214 |
|
215 | 215 | _shutdown_simulator() |
216 | 216 |
|
@@ -249,9 +249,8 @@ def main(argv): |
249 | 249 |
|
250 | 250 | for app_path in tvos_testapps: |
251 | 251 | bundle_id = _get_bundle_id(app_path, config) |
252 | | - tests.append(Test( |
253 | | - testapp_path=app_path, |
254 | | - logs=_run_apple_gameloop_test(bundle_id, app_path, tvos_gameloop_app, device_id))) |
| 252 | + logs=_run_apple_gameloop_test(bundle_id, app_path, tvos_gameloop_app, device_id, _TEST_RETRY) |
| 253 | + tests.append(Test(testapp_path=app_path, logs=logs)) |
255 | 254 |
|
256 | 255 | _shutdown_simulator() |
257 | 256 |
|
@@ -285,9 +284,8 @@ def main(argv): |
285 | 284 |
|
286 | 285 | for app_path in android_testapps: |
287 | 286 | package_name = _get_package_name(app_path) |
288 | | - tests.append(Test( |
289 | | - testapp_path=app_path, |
290 | | - logs=_run_android_gameloop_test(package_name, app_path, android_gameloop_project))) |
| 287 | + logs=_run_android_gameloop_test(package_name, app_path, android_gameloop_project, _TEST_RETRY) |
| 288 | + tests.append(Test(testapp_path=app_path, logs=logs)) |
291 | 289 |
|
292 | 290 | _shutdown_emulator() |
293 | 291 |
|
@@ -420,13 +418,19 @@ def _get_bundle_id(app_path, config): |
420 | 418 | return api["bundle_id"] |
421 | 419 |
|
422 | 420 |
|
423 | | -def _run_apple_gameloop_test(bundle_id, app_path, gameloop_app, device_id): |
| 421 | +def _run_apple_gameloop_test(bundle_id, app_path, gameloop_app, device_id, retry=1): |
424 | 422 | """Run gameloop test and collect test result.""" |
425 | 423 | logging.info("Running apple gameloop test: %s, %s, %s, %s", bundle_id, app_path, gameloop_app, device_id) |
426 | 424 | _install_apple_app(app_path, device_id) |
427 | 425 | _run_xctest(gameloop_app, device_id) |
428 | 426 | logs = _get_apple_test_log(bundle_id, app_path, device_id) |
429 | 427 | _uninstall_apple_app(bundle_id, device_id) |
| 428 | + if retry > 1: |
| 429 | + results = test_validation.validate_results_cpp(logs) |
| 430 | + if not results.complete: |
| 431 | + logging.info("Retry _run_apple_gameloop_test. Remaining retry: %s", retry-1) |
| 432 | + return _run_apple_gameloop_test(bundle_id, app_path, gameloop_app, device_id, retry=retry-1) |
| 433 | + |
430 | 434 | return logs |
431 | 435 |
|
432 | 436 |
|
@@ -462,14 +466,13 @@ def _get_apple_test_log(bundle_id, app_path, device_id): |
462 | 466 |
|
463 | 467 | def _read_file(path): |
464 | 468 | """Extracts the contents of a file.""" |
465 | | - with open(path, "r") as f: |
466 | | - test_result = f.read() |
467 | | - |
468 | | - logging.info("Reading file: %s", path) |
469 | | - logging.info("File contant: %s", test_result) |
470 | | - return test_result |
471 | | - |
| 469 | + if os.path.isfile(path): |
| 470 | + with open(path, "r") as f: |
| 471 | + test_result = f.read() |
472 | 472 |
|
| 473 | + logging.info("Reading file: %s", path) |
| 474 | + logging.info("File content: %s", test_result) |
| 475 | + return test_result |
473 | 476 |
|
474 | 477 |
|
475 | 478 | # -------------------Android Only------------------- |
@@ -556,12 +559,18 @@ def _get_package_name(app_path): |
556 | 559 | return package_name |
557 | 560 |
|
558 | 561 |
|
559 | | -def _run_android_gameloop_test(package_name, app_path, gameloop_project): |
| 562 | +def _run_android_gameloop_test(package_name, app_path, gameloop_project, retry=1): |
560 | 563 | logging.info("Running android gameloop test: %s, %s, %s", package_name, app_path, gameloop_project) |
561 | 564 | _install_android_app(app_path) |
562 | 565 | _run_instrumented_test() |
563 | 566 | logs = _get_android_test_log(package_name) |
564 | 567 | _uninstall_android_app(package_name) |
| 568 | + if retry > 1: |
| 569 | + results = test_validation.validate_results_cpp(logs) |
| 570 | + if not results.complete: |
| 571 | + logging.info("Retry _run_android_gameloop_test. Remaining retry: %s", retry-1) |
| 572 | + return _run_android_gameloop_test(package_name, app_path, gameloop_project, retry=retry-1) |
| 573 | + |
565 | 574 | return logs |
566 | 575 |
|
567 | 576 |
|
|
0 commit comments