import { describe,it,expect } from 'vitest'; import path from 'node:path'; import { resolvePython,describeSpawnError } from './python-runtime'; const root='/repo',venv=path.join(root,'pierzainer_ground','.venv'); const has=(...files:string[])=>(file:string)=>files.includes(file); describe('resolvePython',()=>{ it('uses the Windows venv on win32',()=>{ const exe=path.join(venv,'Scripts','python.exe'); expect(resolvePython(root,'win32',has(exe),{})).toBe(exe); }); it('uses the POSIX venv on Linux/WSL',()=>{ const bin=path.join(venv,'bin','python'); expect(resolvePython(root,'linux',has(bin),{})).toBe(bin); }); it('falls back to PIERZAINER_PYTHON, then python3 / python',()=>{ expect(resolvePython(root,'linux',has(),{PIERZAINER_PYTHON:'/opt/py'})).toBe('/opt/py'); expect(resolvePython(root,'linux',has(),{})).toBe('python3'); expect(resolvePython(root,'win32',has(),{})).toBe('python'); }); it('explains ENOENT instead of the raw spawn message',()=>{ const error=Object.assign(new Error('spawn python ENOENT'),{code:'ENOENT'}); expect(describeSpawnError(error,'python')).toContain('Python 실행 파일을 찾지 못했습니다'); }); });