@@ -338,7 +338,7 @@ def main(argv):
338
338
if p == _DESKTOP : # e.g. 'Desktop' -> 'OSXUniversal'
339
339
p = get_desktop_platform ()
340
340
if p == _PLAYMODE :
341
- logs = perform_in_editor_tests (dir_helper )
341
+ logs = perform_in_editor_tests (dir_helper , remaining_retries = 2 )
342
342
playmode_tests .append (Test (testapp_path = dir_helper .unity_project_dir , logs = logs ))
343
343
else :
344
344
build_testapp (
@@ -580,7 +580,7 @@ def patch_android_env(unity_version):
580
580
os .environ ["UNITY_ANDROID_JDK" ]= os .environ ["JAVA_HOME" ]
581
581
582
582
583
- def perform_in_editor_tests (dir_helper , retry_on_license_check = True ):
583
+ def perform_in_editor_tests (dir_helper , retry_on_license_check = True , remaining_retries = 0 ):
584
584
"""Executes the testapp within the Unity Editor's play mode.
585
585
586
586
Unity has a feature to run a project within the editor itself,
@@ -596,6 +596,8 @@ def perform_in_editor_tests(dir_helper, retry_on_license_check=True):
596
596
the logs, restart the tests. This is because a license check will cause
597
597
a reload of assemblies, which can mess with the tests. The second run
598
598
will not retry if this happens again (which doesn't normally happen).
599
+ remaining_retries: Number of remaining retries allowed before the test is
600
+ considered to have failed.
599
601
600
602
Raises:
601
603
RuntimeError: This error will be thrown if any of the following conditions
@@ -629,7 +631,9 @@ def perform_in_editor_tests(dir_helper, retry_on_license_check=True):
629
631
if retry_on_license_check and "License updated successfully" in text :
630
632
logging .info ("License check caused assembly reload. Retrying tests." )
631
633
open_process .kill ()
632
- perform_in_editor_tests (dir_helper , retry_on_license_check = False )
634
+ # Don't count this against the remaining_retries amount, since the test didn't fail
635
+ perform_in_editor_tests (dir_helper , retry_on_license_check = False ,
636
+ remaining_retries = remaining_retries )
633
637
return
634
638
open_process .kill ()
635
639
logging .info ("Finished running playmode tests" )
@@ -639,8 +643,18 @@ def perform_in_editor_tests(dir_helper, retry_on_license_check=True):
639
643
if results .passes and not results .fails : # Success
640
644
logging .info (results .summary )
641
645
else : # Failed
646
+ if remaining_retries > 0 :
647
+ logging .info ("Test failed, but will retry %d more times" % remaining_retries )
648
+ perform_in_editor_tests (dir_helper , retry_on_license_check = retry_on_license_check ,
649
+ remaining_retries = remaining_retries - 1 )
650
+ return
642
651
raise RuntimeError (results .summary )
643
652
else : # Generally caused by timeout or crash
653
+ if remaining_retries > 0 :
654
+ logging .info ("Test timed out or crashed, but will retry %d more times" % remaining_retries )
655
+ perform_in_editor_tests (dir_helper , retry_on_license_check = retry_on_license_check ,
656
+ remaining_retries = remaining_retries - 1 )
657
+ return
644
658
raise RuntimeError (
645
659
"Tests did not finish running. Log tail:\n " + results .summary )
646
660
0 commit comments