@debugmcp/mcp-debugger
Version:
Run-time step-through debugging for LLM agents.
133 lines (110 loc) • 4.61 kB
text/typescript
/**
* Unit tests for session migration from pythonPath to executablePath
*/
import { describe, it, expect } from 'vitest';
import { SessionStore, CreateSessionParams } from '../../../../src/session/session-store.js';
import { DebugLanguage } from '../../../../src/session/models.js';
describe('Session Migration Verification', () => {
it('should not accept pythonPath parameter', () => {
const store = new SessionStore();
// TypeScript should prevent this at compile time
const params = {
language: DebugLanguage.PYTHON,
// pythonPath: '/usr/bin/python3' // This should not be allowed
executablePath: '/usr/bin/python3'
} as CreateSessionParams;
const session = store.createSession(params);
const managedSession = store.get(session.id);
// Verify only executablePath exists
expect(managedSession?.executablePath).toBe('/usr/bin/python3');
expect(managedSession).not.toHaveProperty('pythonPath');
});
it('should work with all supported languages using executablePath', () => {
const store = new SessionStore();
// Test Python
const pythonSession = store.createSession({
language: DebugLanguage.PYTHON,
executablePath: '/usr/bin/python3'
});
const pythonManaged = store.get(pythonSession.id);
expect(pythonManaged?.executablePath).toBe('/usr/bin/python3');
expect(pythonManaged?.language).toBe(DebugLanguage.PYTHON);
// Test Mock (doesn't require executablePath)
const mockSession = store.createSession({
language: DebugLanguage.MOCK
});
const mockManaged = store.get(mockSession.id);
expect(mockManaged?.language).toBe(DebugLanguage.MOCK);
});
it('should use language-appropriate defaults when executablePath not provided', () => {
const store = new SessionStore();
// Clear environment variable to test defaults
const originalPythonPath = process.env.PYTHON_PATH;
delete process.env.PYTHON_PATH;
try {
const pythonSession = store.createSession({
language: DebugLanguage.PYTHON
});
const managedSession = store.get(pythonSession.id);
const expectedDefault = process.platform === 'win32' ? 'python' : 'python3';
expect(managedSession?.executablePath).toBe(expectedDefault);
} finally {
// Restore environment
if (originalPythonPath) {
process.env.PYTHON_PATH = originalPythonPath;
}
}
});
it('should validate that all API endpoints use executablePath', () => {
// This test documents the migration is complete
// All the following interfaces should use executablePath:
// 1. CreateSessionParams
const createParams: CreateSessionParams = {
language: DebugLanguage.PYTHON,
executablePath: '/usr/bin/python3' // ✓ Uses executablePath
};
// 2. ProxyConfig
const proxyConfig = {
sessionId: 'test',
language: DebugLanguage.PYTHON,
executablePath: '/usr/bin/python3', // ✓ Uses executablePath
adapterHost: 'localhost',
adapterPort: 5678,
logDir: '/tmp',
scriptPath: 'test.py'
};
// 3. ProxyInitPayload
const proxyPayload = {
cmd: 'init' as const,
sessionId: 'test',
executablePath: '/usr/bin/python3', // ✓ Uses executablePath
adapterHost: 'localhost',
adapterPort: 5678,
logDir: '/tmp',
scriptPath: 'test.py'
};
// All interfaces have been migrated successfully
expect(createParams.executablePath).toBeDefined();
expect(proxyConfig.executablePath).toBeDefined();
expect(proxyPayload.executablePath).toBeDefined();
});
it('should demonstrate multi-language support with executablePath', () => {
const store = new SessionStore();
// Different languages can use different executables
const testCases = [
{ language: DebugLanguage.PYTHON, executablePath: '/usr/bin/python3' },
{ language: DebugLanguage.PYTHON, executablePath: 'C:\\Python310\\python.exe' },
{ language: DebugLanguage.PYTHON, executablePath: '/opt/anaconda3/bin/python' },
// Mock doesn't need executable but can accept it
{ language: DebugLanguage.MOCK, executablePath: 'node' }
];
testCases.forEach(testCase => {
const session = store.createSession(testCase);
const managed = store.get(session.id);
expect(managed?.language).toBe(testCase.language);
if (testCase.executablePath) {
expect(managed?.executablePath).toBe(testCase.executablePath);
}
});
});
});