Skip to content

Commit

Permalink
Add protection against infinite startup.
Browse files Browse the repository at this point in the history
  • Loading branch information
freakboy3742 committed Jul 1, 2024
1 parent 94d9137 commit d91eeee
Showing 1 changed file with 18 additions and 5 deletions.
23 changes: 18 additions & 5 deletions testbed/tests/testbed.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,13 +16,26 @@
def run_tests(app, cov, args, report_coverage, run_slow, running_in_ci):
try:
# Wait for the app's main window to be visible. Retrieving the actual main window
# will raise an exception until the app is actually initialized, so we check the
# underlying variable.
# will raise an exception until the app is actually initialized.
print("Waiting for app to be ready for testing... ", end="", flush=True)
while app._main_window is app._UNDEFINED:
time.sleep(0.05)
while not app.main_window.visible:
i = 0
ready = False
while i < 100 and not ready:
try:
main_window = app.main_window
if main_window.visible:
ready = True
except ValueError:
pass

time.sleep(0.05)
i += 1

if not ready:
print("\nApp didn't display a main window.")
app.returncode = 1
return

print("ready.")
# Control the run speed of the test app.
app.run_slow = run_slow
Expand Down

0 comments on commit d91eeee

Please sign in to comment.