1#!/usr/bin/env python32"""Run editing checks in VS Code's own extension host, without npm or Node tools."""3import argparse,hashlib,json,os,subprocess,tempfile4from pathlib import Path5ROOT=Path(__file__).resolve().parents[1]6p=argparse.ArgumentParser(description=__doc__);p.add_argument('--code',default='/usr/share/code/code',help='Actual VS Code executable, not the shell CLI wrapper');p.add_argument('--headless',action='store_true');p.add_argument('--output',type=Path,default=ROOT/'release/comparison/vscode-verification.json');a=p.parse_args();a.output=a.output.resolve();a.output.parent.mkdir(parents=True,exist_ok=True);a.output.unlink(missing_ok=True)7with tempfile.TemporaryDirectory(prefix='laymesh-vscode-host-') as temp:8 root=Path(temp);env={**os.environ,'LAYMESH_VSCODE_EVIDENCE':str(a.output)};env.pop('ELECTRON_RUN_AS_NODE',None)9 # The host starts its own executable and the bundled Rust server by absolute path.10 empty=root/'empty-path';empty.mkdir();env['PATH']=str(empty)11 command=[a.code,'--no-sandbox','--disable-gpu','--disable-updates','--user-data-dir='+str(root/'profile'),'--extensions-dir='+str(root/'extensions'),'--extensionDevelopmentPath='+str(ROOT/'extensions/vscode'),'--extensionTestsPath='+str(ROOT/'scripts/vscode-smoke.cjs'),'--skip-welcome','--skip-release-notes','--new-window']12 if a.headless:command+=['--ozone-platform=headless']13 completed=subprocess.run(command,env=env,stdout=subprocess.PIPE,stderr=subprocess.STDOUT,text=True,timeout=90)14 if completed.returncode or not a.output.is_file():raise RuntimeError('VS Code host verification failed:\n'+completed.stdout[-5000:])15 result=json.loads(a.output.read_text());assert len(result['tests'])==2416 files=[Path(__file__),ROOT/'scripts/vscode-smoke.cjs',ROOT/'extensions/vscode/src/client.cjs',ROOT/'extensions/vscode/bin'/('laymesh.exe' if os.name=='nt' else 'laymesh')]17 result['artifact_sha256']={str(p.resolve().relative_to(ROOT)):hashlib.sha256(p.read_bytes()).hexdigest() for p in files}18 a.output.write_text(json.dumps(result,ensure_ascii=False,indent=2)+'\n');print(json.dumps(result,ensure_ascii=False))