Files
glassMxrph/tests/polish_runtime.py
T
mxandClaude Opus 5.5 99e64a7713 Add glassMxrph shell sources
Initial commit of the Quickshell desktop suite: bar, dock, launcher,
settings, Control Center, dashboard, OSD, lock screen, desktop widgets,
plugin host with the vendored Noctalia/Omarchy compatibility layer,
helpers, packaging, tests and phase documentation.

Includes the optimization work so far: usage widgets and dashboard
gauges no longer animate continuously, desktop widgets pause while
covered, system controls stop flickering on background polls, dock app
matching uses an indexed catalog, and workspace ghosts are created only
for occupied slots.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-07 22:36:17 +02:00

66 lines
3.7 KiB
Python

#!/usr/bin/env python3
"""Isolated read-only session: motion, palette recovery, output fallback and collector recovery."""
import json,os,signal,subprocess,tempfile,time
from pathlib import Path
ROOT=Path(__file__).resolve().parents[1]
def ipc(target,method,*args):
p=subprocess.run(['quickshell','ipc','--path',str(ROOT/'quickshell'),'call',target,method,*args],capture_output=True,text=True,timeout=5)
return json.loads(p.stdout) if p.returncode==0 and p.stdout.strip() else None
def wait(check):
end=time.monotonic()+15
while time.monotonic()<end:
try:
if check():return
except (KeyError,TypeError,ValueError):pass
time.sleep(.1)
raise AssertionError('Timed out')
def pref(key,value):assert ipc('shell','setPreference',key,' '+json.dumps(value)) is True
if ipc('shell','status'):raise SystemExit('Stop the project preview before this isolated test.')
with tempfile.TemporaryDirectory(prefix='glassmxrph-polish-') as tmp:
env=dict(os.environ,GLASSMXRPH_POLISH_TESTING='1',XDG_CONFIG_HOME=tmp+'/config',XDG_STATE_HOME=tmp+'/state')
log=ROOT/'.cache/polish-runtime.log'
with log.open('w') as out:
proc=subprocess.Popen([str(ROOT/'scripts/glassmxrph'),'run'],env=env,stdout=out,stderr=subprocess.STDOUT)
try:
wait(lambda:ipc('shell','status')['ready'])
pref('animation.reducedMotion',True)
wait(lambda:ipc('polishTest','snapshot')['intensity']==0)
assert ipc('polishTest','snapshot')['duration']==0
assert all(i['influence']==0 and i['magnification']==1 for i in ipc('polishTest','snapshot')['dock'])
ipc('shell','openSettings','appearance');ipc('polishTest','staleScreens')
wait(lambda:ipc('polishTest','snapshot')['settingsScreen']==ipc('polishTest','snapshot')['active'])
ipc('controlcenter','open');ipc('polishTest','staleScreens')
wait(lambda:ipc('polishTest','snapshot')['controlScreen']==ipc('polishTest','snapshot')['active'])
ipc('shell','close')
for _ in range(5):
ipc('launcher','toggle');ipc('shell','openSettings','appearance');ipc('controlcenter','open');ipc('shell','close')
palette=Path(tmp)/'state/glassMxrph/palette.json'
palette.write_text('{broken')
wait(lambda:bool(ipc('theme','status')['error']))
palette.write_text(json.dumps({'accent':'#889922','accentText':'#889922'}))
wait(lambda:not ipc('theme','status')['error'])
pref('appearance.accentSource','matugen')
wait(lambda:ipc('polishTest','snapshot')['accent']=='#889922')
assert ipc('polishTest','snapshot')['foreground'] in ['#000000','#ffffff']
pref('appearance.accentSource','custom');pref('appearance.customAccent','#ffffff')
wait(lambda:ipc('polishTest','snapshot')['foreground']=='#000000')
pref('appearance.customAccent','#000000')
wait(lambda:ipc('polishTest','snapshot')['foreground']=='#ffffff')
# The collector is demand-driven; the metrics page keeps it running.
ipc('shell','openSettings','metrics')
wait(lambda:ipc('metrics','status')['samples']>=2)
old=ipc('metrics','status');pid=old['processId']
assert str(ROOT/'quickshell/helpers/metrics.py').encode() in Path(f'/proc/{pid}/cmdline').read_bytes().split(b'\0')
os.kill(pid,signal.SIGTERM)
wait(lambda:ipc('metrics','status')['stale'])
wait(lambda:ipc('metrics','status')['processId']!=pid and ipc('metrics','status')['samples']>old['samples'])
assert not ipc('metrics','status')['error']
ipc('shell','close')
pref('animation.reducedMotion',False)
wait(lambda:ipc('polishTest','snapshot')['duration']>0)
ipc('shell','openSettings','appearance');ipc('shell','close')
finally:
proc.terminate();proc.wait(timeout=8)
text=log.read_text();assert 'WARN' not in text and 'ERROR' not in text,text
print('PASS: reduced motion, rapid popup routing, stale-screen fallback, palette error recovery, accent contrast, collector termination/recovery and clean logs.')