feat(gui): instance unique + mutex partagé installeur (P0-7)
Protection multi-instance GUI V6 : mutex kernel nommé sur Windows (partagé avec l'installeur Inno via AppMutex), fcntl exclusif sur POSIX (dev/test). 3 tests unitaires, self-test OK, 0 régression gui_v6 (145 passed). Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
33
tests/unit/test_gui_v6_single_instance.py
Normal file
33
tests/unit/test_gui_v6_single_instance.py
Normal file
@@ -0,0 +1,33 @@
|
||||
import pytest
|
||||
|
||||
from gui_v6.single_instance import (
|
||||
APP_MUTEX_NAME,
|
||||
AlreadyRunningError,
|
||||
SingleInstance,
|
||||
)
|
||||
|
||||
|
||||
def test_mutex_name_is_stable():
|
||||
# Nom partagé avec l'installeur (Inno AppMutex). Ne pas changer sans MAJ .iss.
|
||||
assert APP_MUTEX_NAME == "AivanonymAnonymisationV6"
|
||||
|
||||
|
||||
def test_second_instance_is_rejected(tmp_path, monkeypatch):
|
||||
monkeypatch.setenv("LOCALAPPDATA", str(tmp_path))
|
||||
first = SingleInstance()
|
||||
first.acquire()
|
||||
try:
|
||||
with pytest.raises(AlreadyRunningError):
|
||||
SingleInstance().acquire()
|
||||
finally:
|
||||
first.release()
|
||||
|
||||
|
||||
def test_release_allows_reacquire(tmp_path, monkeypatch):
|
||||
monkeypatch.setenv("LOCALAPPDATA", str(tmp_path))
|
||||
a = SingleInstance()
|
||||
a.acquire()
|
||||
a.release()
|
||||
b = SingleInstance()
|
||||
b.acquire() # ne lève pas
|
||||
b.release()
|
||||
Reference in New Issue
Block a user