mirror of
https://github.com/saphid/frame-control.git
synced 2026-10-06 05:02:50 +02:00
Mac view: checking the headset and publishing a tunnel happen under one short lock with retarget
Astra review: a switch landing between the check and the assignment could still install the old headset's tunnel. Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
This commit is contained in:
1 parent
ffef4d897a
commit
b685a601f7
2 files changed
+43
-16
No files matched your search
@@ -10,6 +10,7 @@ Run: python3 -m unittest discover -s tests
|
||||
import base64
|
||||
import http.client
|
||||
import json
|
||||
import io
|
||||
import os
|
||||
import shutil
|
||||
import socket
|
||||
@@ -59,6 +60,26 @@ class Helpers(unittest.TestCase):
|
||||
self.assertIsNone(mv.tunnel)
|
||||
self.assertEqual(mv.frame, "frame-2")
|
||||
|
||||
def test_a_switch_just_before_publishing_drops_the_old_headsets_tunnel(self):
|
||||
mv = frame_macview.MacView(["ssh"], lambda *a, **k: "", "frame")
|
||||
mv.port = 47000
|
||||
ended = []
|
||||
|
||||
class Proc:
|
||||
def poll(self): return None
|
||||
def terminate(self): ended.append(self)
|
||||
def wait(self): return 0
|
||||
stderr = io.StringIO("")
|
||||
|
||||
def probe(port):
|
||||
mv.retarget("frame-2", ["-o", "HostName=192.0.2.2"]) # the app switches right now
|
||||
return True
|
||||
with mock.patch.object(frame_macview.subprocess, "Popen", return_value=Proc()), \
|
||||
mock.patch.object(frame_macview.time, "sleep"), mock.patch.object(mv, "_probe", probe):
|
||||
self.assertFalse(mv._open_tunnel([], [47001]))
|
||||
self.assertIsNone(mv.tunnel)
|
||||
self.assertEqual(len(ended), 1) # the tunnel to the old headset was closed
|
||||
|
||||
@unittest.skipUnless(shutil.which("bash"), "needs bash")
|
||||
@unittest.skipIf(os.name == "nt", "Windows' bash.exe is WSL's launcher, and runners have no distribution")
|
||||
def test_launch_script_parses(self):
|
||||
|
||||
Reference in new issue
Block a user