28 lines
1.3 KiB
Python
28 lines
1.3 KiB
Python
#!/usr/bin/env python3
|
|
"""Real controllers and Process, fake helper only; no production Bluetooth singleton."""
|
|
import os
|
|
from pathlib import Path
|
|
import shutil
|
|
import subprocess
|
|
import tempfile
|
|
|
|
root = Path(__file__).resolve().parents[1]
|
|
with tempfile.TemporaryDirectory(prefix='adaptive-bluetooth-controller-') as tmp:
|
|
runtime = Path(tmp, 'runtime')
|
|
runtime.mkdir(mode=0o700)
|
|
config = Path(tmp, 'config')
|
|
config.mkdir()
|
|
shutil.copyfile(root / 'tests/fixtures/bluetooth.qml', config / 'shell.qml')
|
|
shutil.copyfile(root / 'tests/bluetooth_fake.py', config / 'bluetooth_fake.py')
|
|
for name in ['BluetoothController.qml', 'BluetoothDiscovery.qml']:
|
|
shutil.copyfile(root / 'services' / name, config / name)
|
|
env = dict(os.environ, QT_QPA_PLATFORM='offscreen', XDG_RUNTIME_DIR=str(runtime),
|
|
XDG_STATE_HOME=tmp, XDG_CACHE_HOME=tmp)
|
|
result = subprocess.run(['quickshell', '-p', str(config), '--no-color'], env=env,
|
|
capture_output=True, text=True, timeout=23)
|
|
logs = result.stdout + result.stderr
|
|
print(logs)
|
|
assert result.returncode == 0 and 'BLUETOOTH_TEST_PASS: 14 scenarios' in logs, logs
|
|
for marker in ['BLUETOOTH_TEST_FAIL', 'Failed to load configuration', 'ReferenceError', 'TypeError', 'Binding loop']:
|
|
assert marker not in logs, marker
|