Files
Claude-Code-Workflow/ccw/tests/uv-manager-codexlens-python.test.js
catlog22 9aa07e8d01 Add comprehensive tests for CLI functionality and CodexLens compatibility
- Introduced tests for stale running fallback in CLI watch functionality to ensure proper handling of saved conversations.
- Added compatibility tests for CodexLens CLI to verify index initialization despite compatibility conflicts.
- Implemented tests for Smart Search MCP usage to validate default settings and path handling.
- Created tests for UV Manager to ensure Python preference handling works as expected.
- Added a detailed guide for CCW/Codex commands and skills, covering core commands, execution modes, and templates.
2026-03-08 17:30:39 +08:00

52 lines
1.4 KiB
JavaScript

import { afterEach, before, describe, it } from 'node:test';
import assert from 'node:assert/strict';
import { execSync } from 'node:child_process';
const uvManagerPath = new URL('../dist/utils/uv-manager.js', import.meta.url).href;
describe('CodexLens UV python preference', async () => {
let mod;
const originalPython = process.env.CCW_PYTHON;
before(async () => {
mod = await import(uvManagerPath);
});
afterEach(() => {
if (originalPython === undefined) {
delete process.env.CCW_PYTHON;
return;
}
process.env.CCW_PYTHON = originalPython;
});
it('honors CCW_PYTHON override', () => {
process.env.CCW_PYTHON = 'C:/Custom/Python/python.exe';
assert.equal(mod.getPreferredCodexLensPythonSpec(), 'C:/Custom/Python/python.exe');
});
it('prefers Python 3.11 or 3.10 on Windows when available', () => {
if (process.platform !== 'win32') return;
delete process.env.CCW_PYTHON;
let installed = '';
try {
installed = execSync('py -0p', { encoding: 'utf-8' });
} catch {
return;
}
const has311 = installed.includes('-V:3.11');
const has310 = installed.includes('-V:3.10');
if (!has311 && !has310) {
return;
}
const preferred = mod.getPreferredCodexLensPythonSpec();
assert.ok(
preferred === '3.11' || preferred === '3.10',
`expected Windows preference to avoid 3.12 when 3.11/3.10 exists, got ${preferred}`,
);
});
});