Skip to content

Commit bd3566f

Browse files
committed
Fixed tests to run on MacOS
1 parent ad754b7 commit bd3566f

3 files changed

Lines changed: 22 additions & 8 deletions

File tree

modules/01-operating-room/tests/test_dds_communication.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,8 @@
2828
wait_for_process_ready,
2929
)
3030

31+
_IS_MACOS = sys.platform == "darwin"
32+
3133
# Ensure generated types are importable
3234
if str(SRC_DIR) not in sys.path:
3335
sys.path.insert(0, str(SRC_DIR))
@@ -262,7 +264,7 @@ class TestAllAppsStatus:
262264
"""All five apps should report DeviceStatus ON when running."""
263265

264266
QT_ENV = {"QT_QPA_PLATFORM": "offscreen"}
265-
GTK_ENV = {"GDK_BACKEND": "x11"}
267+
GTK_ENV = {} if _IS_MACOS else {"GDK_BACKEND": "x11"}
266268

267269
EXPECTED_DEVICES = {
268270
"PATIENT_SENSOR",

modules/01-operating-room/tests/test_demo_flow.py

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -23,11 +23,14 @@
2323

2424
import importlib
2525
import sys
26+
import threading
2627
import time
2728
from pathlib import Path
2829

2930
import pytest
3031

32+
_IS_MACOS = sys.platform == "darwin"
33+
3134
TESTS_DIR = Path(__file__).resolve().parent
3235

3336
if str(TESTS_DIR) not in sys.path:
@@ -46,7 +49,7 @@
4649
sys.path.insert(0, str(SRC_DIR))
4750

4851
QT_ENV = {"QT_QPA_PLATFORM": "offscreen"}
49-
GTK_ENV = {"GDK_BACKEND": "x11"}
52+
GTK_ENV = {} if _IS_MACOS else {"GDK_BACKEND": "x11"}
5053

5154

5255
# ---------------------------------------------------------------------------
@@ -304,9 +307,14 @@ def test_secure_launch(self, proc_manager_secure, dds_env_secure):
304307
"ArmController": proc_manager_secure.start_app("ArmController", extra_env=GTK_ENV),
305308
}
306309

307-
# Wait for security handshake and DDS initialization
308-
for p in apps.values():
309-
wait_for_process_ready(p, timeout_sec=15)
310+
# Wait for security handshake and DDS initialization (parallel).
311+
# Apps that fail the handshake crash within the first 1-2 s; 3 s is
312+
# enough to catch startup failures while keeping the test fast.
313+
threads = [threading.Thread(target=wait_for_process_ready, args=(p, 3)) for p in apps.values()]
314+
for t in threads:
315+
t.start()
316+
for t in threads:
317+
t.join()
310318

311319
crashed = {}
312320
for name, p in apps.items():

modules/01-operating-room/tests/test_launch.py

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -15,13 +15,17 @@
1515
GUI applications are marked so they can be skipped on headless systems.
1616
"""
1717

18+
import sys
19+
1820
import pytest
1921
from module01_test_support import (
2022
create_reader,
2123
wait_for_device_status,
2224
wait_for_process_ready,
2325
)
2426

27+
_IS_MACOS = sys.platform == "darwin"
28+
2529

2630
class TestPatientSensor:
2731
"""PatientSensor is a headless C++ app — no display needed."""
@@ -52,7 +56,7 @@ def test_prints_launch_message(self, proc_manager):
5256
class TestOrchestrator:
5357
"""Orchestrator is a C++ GTK application."""
5458

55-
GTK_ENV = {"GDK_BACKEND": "x11"}
59+
GTK_ENV = {} if _IS_MACOS else {"GDK_BACKEND": "x11"}
5660

5761
def test_starts_and_stays_alive(self, proc_manager):
5862
proc = proc_manager.start_app("Orchestrator", extra_env=self.GTK_ENV)
@@ -64,7 +68,7 @@ def test_starts_and_stays_alive(self, proc_manager):
6468
class TestArmController:
6569
"""ArmController is a C++ GTK application."""
6670

67-
GTK_ENV = {"GDK_BACKEND": "x11"}
71+
GTK_ENV = {} if _IS_MACOS else {"GDK_BACKEND": "x11"}
6872

6973
def test_starts_and_stays_alive(self, proc_manager):
7074
proc = proc_manager.start_app("ArmController", extra_env=self.GTK_ENV)
@@ -101,7 +105,7 @@ class TestAllApps:
101105
"""Launch all five applications simultaneously."""
102106

103107
QT_ENV = {"QT_QPA_PLATFORM": "offscreen"}
104-
GTK_ENV = {"GDK_BACKEND": "x11"}
108+
GTK_ENV = {} if _IS_MACOS else {"GDK_BACKEND": "x11"}
105109

106110
def test_all_apps_launch_together(self, proc_manager, dds_participant):
107111
from Types import Common, Common_DeviceStatus

0 commit comments

Comments
 (0)