Update.
This commit is contained in:
@@ -43,6 +43,20 @@ async def _drain_forever(proc):
|
||||
pass
|
||||
|
||||
|
||||
def _kill_mplex_server(tmp_home):
|
||||
"""The wrapped shell lives in a detached mplex server that outlives the test's client
|
||||
process; stop it, or it keeps its sockets open inside the directory being deleted."""
|
||||
import subprocess
|
||||
env = dict(os.environ, TAI_HOME=os.path.join(tmp_home, ".tai"))
|
||||
for name in (tai.PLEXER_ACTIVE_ENV, tai.PLEXER_SOCKET_ENV, tai.PLEXER_PANE_ENV, "TMUX"):
|
||||
env.pop(name, None)
|
||||
try:
|
||||
subprocess.run([sys.executable, str(Path(tai.__file__).resolve()), "--mplex", "kill-server"], env=env,
|
||||
stdin=subprocess.DEVNULL, stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL, timeout=15)
|
||||
except (OSError, subprocess.SubprocessError):
|
||||
pass
|
||||
|
||||
|
||||
class _BashrcHookTestBase(TestCase):
|
||||
"""Shared fixture for every test that installs the real plexer hook into
|
||||
a real .bashrc: a throwaway $HOME, the real tai.py binary copied into
|
||||
@@ -94,6 +108,7 @@ class _BashrcHookTestBase(TestCase):
|
||||
if self._drain_task is not None:
|
||||
self._drain_task.cancel()
|
||||
if self.tmp_home is not None:
|
||||
_kill_mplex_server(self.tmp_home)
|
||||
shutil.rmtree(self.tmp_home, ignore_errors=True)
|
||||
|
||||
|
||||
@@ -151,6 +166,7 @@ class _ShellPlexerHookTestBase(TestCase):
|
||||
if self._drain_task is not None:
|
||||
self._drain_task.cancel()
|
||||
if self.tmp_home is not None:
|
||||
_kill_mplex_server(self.tmp_home)
|
||||
shutil.rmtree(self.tmp_home, ignore_errors=True)
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user