From 55b4a5fa30394d4b98443a97659b921f97eac446 Mon Sep 17 00:00:00 2001 From: Russell Keith-Magee Date: Fri, 14 Feb 2025 14:39:02 +0800 Subject: [PATCH] Add pauses and log repeats to avoid issues with detecting test completion on iOS/macOS. --- tests/testbed.py | 24 +++++++++++++++++++++++- 1 file changed, 23 insertions(+), 1 deletion(-) diff --git a/tests/testbed.py b/tests/testbed.py index 9ed11af..f381dc5 100644 --- a/tests/testbed.py +++ b/tests/testbed.py @@ -1,5 +1,7 @@ import os +import sys import tempfile +import time from pathlib import Path import pytest @@ -23,10 +25,30 @@ def run_tests(): ] ) - print(f">>>>>>>>>> EXIT {returncode} <<<<<<<<<<") + # On iOS and macOS, Briefcase needs to use a log streamer. However, this + # streamer can drop lines of test output due to system load. If the log + # result sentinel isn't seen in streamed output, the test will fail because + # the exit status of the test isn't known. As a safety measure on iOS and + # macOS, output the log sentinel multiple times to decrease the chance of + # this happening. + if sys.platform in {"darwin", "ios"}: + for i in range(0, 6): + time.sleep(0.5) + print(f">>>>>>>>>> EXIT {returncode} <<<<<<<<<<") + else: + print(f">>>>>>>>>> EXIT {returncode} <<<<<<<<<<") if __name__ == "__main__": + # On iOS and macOS, Briefcase needs to use a log streamer. However, this + # streamer takes time to start up. As a safety measure, wait a couple of seconds + # at app start, and output some lines to minimize the impact of the streamer + # startup. + if sys.platform in {"darwin", "ios"}: + print("Waiting for log streamer...") + time.sleep(2.0) + print("Log streamer should be ready.") + # Run the app main to stimulate app creation and logging of test conditions. app_main() # Run the actual test suite.