updates to launcer
This commit is contained in:
+41
@@ -0,0 +1,41 @@
|
||||
#!/bin/zsh
|
||||
set -euo pipefail
|
||||
ROOT="$(cd "$(dirname "$0")/.." && pwd)"
|
||||
cd "$ROOT"
|
||||
mkdir -p "$ROOT/.build/build-logs"
|
||||
LOG="$ROOT/.build/build-logs/test-$(date +%Y%m%d-%H%M%S).log"
|
||||
exec > >(tee "$LOG") 2>&1
|
||||
print '=== OrionToolbar tests ==='
|
||||
# A successful compile is the minimum regression check.
|
||||
"$ROOT/scripts/build.sh"
|
||||
APP="$ROOT/.build/Build/Products/Debug/OrionToolbar.app"
|
||||
plutil -lint "$APP/Contents/Info.plist"
|
||||
# Verify that the Parallels executable and JSON discovery work independently of SwiftUI.
|
||||
PRLCTL=''
|
||||
for candidate in /usr/local/bin/prlctl '/Applications/Parallels Desktop.app/Contents/MacOS/prlctl'; do
|
||||
if [[ -x "$candidate" ]]; then PRLCTL="$candidate"; break; fi
|
||||
done
|
||||
if [[ -n "$PRLCTL" ]]; then
|
||||
"$PRLCTL" list -a -j | python3 -c '
|
||||
import json,sys
|
||||
v=json.load(sys.stdin)
|
||||
assert isinstance(v,list), "Expected Parallels JSON array"
|
||||
for item in v:
|
||||
assert isinstance(item,dict), "Invalid VM record"
|
||||
assert item.get("name"), "VM without name"
|
||||
assert item.get("uuid"), "VM without UUID"
|
||||
print("Parallels discovery OK: {} VM(s)".format(len(v)))
|
||||
'
|
||||
else
|
||||
echo 'SKIP: Parallels CLI not installed'
|
||||
fi
|
||||
if [[ -d "$ROOT/tests" ]] && find "$ROOT/tests" -name 'test_*.py' -print -quit | grep -q .; then
|
||||
python3 -m unittest discover -s "$ROOT/tests" -v
|
||||
fi
|
||||
# Run Xcode tests only if a test plan is configured for this scheme.
|
||||
if [[ "${RUN_XCODE_TESTS:-0}" == 1 ]]; then
|
||||
xcodebuild -project "$ROOT/OrionToolbar.xcodeproj" -scheme OrionToolbar -configuration Debug -destination 'platform=macOS' -derivedDataPath "$ROOT/.build" CODE_SIGNING_ALLOWED=NO test
|
||||
else
|
||||
echo 'XCTest not run (set RUN_XCODE_TESTS=1 if the scheme has a test target).'
|
||||
fi
|
||||
print "Tests complete. Log: $LOG"
|
||||
@@ -0,0 +1,90 @@
|
||||
#!/usr/bin/env python3
|
||||
"""Source-contract and macOS runtime smoke tests. No VM state is changed."""
|
||||
import os
|
||||
import re
|
||||
import shutil
|
||||
import subprocess
|
||||
import sys
|
||||
import unittest
|
||||
from pathlib import Path
|
||||
|
||||
ROOT = Path(__file__).resolve().parents[1]
|
||||
CONTROLLER = (ROOT/'OrionToolbar/OrionVMController.swift').read_text()
|
||||
VIEW = (ROOT/'OrionToolbar/OrionMenuView.swift').read_text()
|
||||
APP = (ROOT/'OrionToolbar/OrionToolbarApp.swift').read_text()
|
||||
|
||||
class SourceContracts(unittest.TestCase):
|
||||
def test_menu_bar_app(self):
|
||||
self.assertIn('MenuBarExtra', APP)
|
||||
self.assertIn('.menuBarExtraStyle(.window)', APP)
|
||||
def test_vm_discovery(self):
|
||||
self.assertIn('func discoverVMs()', CONTROLLER)
|
||||
self.assertIn('runPrlctl(["list", "-a", "-j"])', CONTROLLER)
|
||||
def test_refresh_probes_on_startup_and_timer(self):
|
||||
self.assertGreaterEqual(CONTROLLER.count('await refreshServiceAvailability()'), 2)
|
||||
self.assertIn('func refreshServiceAvailability()', CONTROLLER)
|
||||
def test_ssh_only_if_reachable(self):
|
||||
self.assertEqual(VIEW.count('vm.reachableSSH.contains(server.id)'), 2)
|
||||
self.assertIn('server.sshUser.isEmpty', VIEW)
|
||||
def test_mailpit_only_if_reachable(self):
|
||||
self.assertEqual(VIEW.count('vm.reachableMailpit.contains(server.id)'), 2)
|
||||
self.assertIn('server.mailpitPort != nil', VIEW)
|
||||
def test_running_filter_for_probes(self):
|
||||
block = CONTROLLER.split('func refreshServiceAvailability()', 1)[1].split('private nonisolated static func tcpPortOpen',1)[0]
|
||||
self.assertIn('"running"', block)
|
||||
self.assertIn('reachableSSH = Set(', block)
|
||||
self.assertIn('reachableMailpit = Set(', block)
|
||||
def test_probe_timeouts(self):
|
||||
self.assertIn('"-G", "2", "-z"', CONTROLLER)
|
||||
self.assertRegex(CONTROLLER, r'timeoutInterval\s*=\s*3')
|
||||
def test_actions(self):
|
||||
for name in ('openSSH','openMailpit','operate','hideVM','restoreVM','reorderVM','reorderServer','integrate','removeDefinition'):
|
||||
with self.subTest(name=name):
|
||||
self.assertRegex(CONTROLLER, r'func\s+' + name + r'\s*\(')
|
||||
def test_vm_operations(self):
|
||||
for operation in ('"start"','"stop"','"restart"','"force-stop"'):
|
||||
with self.subTest(operation=operation):
|
||||
self.assertIn(operation, VIEW + CONTROLLER)
|
||||
def test_persisted_order_and_visibility(self):
|
||||
self.assertIn('orionVMOrder.v1', CONTROLLER)
|
||||
self.assertIn('orionHiddenVMIDs.v1', CONTROLLER)
|
||||
self.assertIn('UserDefaults.standard', CONTROLLER)
|
||||
def test_drag_and_drop(self):
|
||||
self.assertGreaterEqual(VIEW.count('.onDrag'), 2)
|
||||
self.assertGreaterEqual(VIEW.count('.onDrop'), 2)
|
||||
def test_icons(self):
|
||||
self.assertIn('VM.app', CONTROLLER)
|
||||
self.assertIn('func icon(for machine:', CONTROLLER)
|
||||
self.assertIn('func icon(for server:', CONTROLLER)
|
||||
def test_settings(self):
|
||||
self.assertIn('OrionSettingsWindowPresenter', VIEW)
|
||||
self.assertIn('SettingsView()', VIEW)
|
||||
def test_confirmation_before_force_stop(self):
|
||||
self.assertIn('pendingForceStop', VIEW)
|
||||
self.assertIn('.confirmationDialog("Force stop virtual machine?', VIEW)
|
||||
def test_button_spacing(self):
|
||||
self.assertIn('.padding(.leading, 12)', VIEW)
|
||||
def test_foreground_activation_contract(self):
|
||||
# Source-level contract only; actual window z-order requires manual UI test.
|
||||
self.assertIn('NSWorkspace.shared', CONTROLLER)
|
||||
self.assertIn('func openSSH', CONTROLLER)
|
||||
self.assertIn('func openMailpit', CONTROLLER)
|
||||
|
||||
@unittest.skipUnless(sys.platform == 'darwin' and os.getenv('ORION_LIVE') == '1', 'Set ORION_LIVE=1 on macOS')
|
||||
class LiveReadOnly(unittest.TestCase):
|
||||
def test_parallels_list_json(self):
|
||||
import json
|
||||
executable = shutil.which('prlctl') or '/Applications/Parallels Desktop.app/Contents/MacOS/prlctl'
|
||||
if not Path(executable).exists(): self.skipTest('Parallels CLI not installed')
|
||||
p = subprocess.run([executable,'list','-a','-j'], capture_output=True, text=True, timeout=20)
|
||||
self.assertEqual(p.returncode,0,p.stderr)
|
||||
data = json.loads(p.stdout)
|
||||
self.assertIsInstance(data,list)
|
||||
for vm in data:
|
||||
self.assertIn('uuid',vm)
|
||||
self.assertIn('name',vm)
|
||||
self.assertIn('status',vm)
|
||||
def test_xcode_project(self):
|
||||
self.assertTrue((ROOT/'OrionToolbar.xcodeproj/project.pbxproj').is_file())
|
||||
|
||||
if __name__ == '__main__': unittest.main()
|
||||
Reference in New Issue
Block a user