Sprinter: добавить отладку C-исходников и интеграцию VS Code
This commit is contained in:
@@ -0,0 +1,67 @@
|
||||
const assert = require('node:assert/strict');
|
||||
const path = require('node:path');
|
||||
const test = require('node:test');
|
||||
const {resolvePython, localPythonVersion, pyenvEnvironment} = require('./runtime');
|
||||
|
||||
test('auto использует pyenv shim без PATH GUI', () => {
|
||||
const home = path.join(path.sep, 'Users', 'tester');
|
||||
const shim = path.join(home, '.pyenv', 'shims', 'python');
|
||||
const result = resolvePython({
|
||||
command: 'auto',
|
||||
workspace: path.join(home, 'project'),
|
||||
home,
|
||||
isExecutable: filename => filename === shim,
|
||||
});
|
||||
assert.deepEqual(result, {command: shim, args: []});
|
||||
});
|
||||
|
||||
test('local pyenv имеет приоритет над случайным .venv', () => {
|
||||
const home = path.join(path.sep, 'Users', 'tester');
|
||||
const workspace = path.join(home, 'project');
|
||||
const shim = path.join(home, '.pyenv', 'shims', 'python');
|
||||
const venv = path.join(workspace, '.venv', 'bin', 'python');
|
||||
const result = resolvePython({
|
||||
command: 'auto', workspace, home,
|
||||
isExecutable: filename => filename === shim || filename === venv,
|
||||
});
|
||||
assert.equal(result.command, shim);
|
||||
});
|
||||
|
||||
test('явная команда и аргументы сохраняются', () => {
|
||||
const result = resolvePython({
|
||||
command: '/python/custom',
|
||||
args: ['-I'],
|
||||
isExecutable: () => false,
|
||||
});
|
||||
assert.deepEqual(result, {command: '/python/custom', args: ['-I']});
|
||||
});
|
||||
|
||||
test('auto сообщает понятную ошибку без Python 3.12', () => {
|
||||
assert.throws(
|
||||
() => resolvePython({command: 'auto', isExecutable: () => false}),
|
||||
/Задайте абсолютный путь/,
|
||||
);
|
||||
});
|
||||
|
||||
test('внешний workspace без .python-version выбирает установленный pyenv 3.12', () => {
|
||||
const home = path.join(path.sep, 'Users', 'tester');
|
||||
const installed = path.join(home, '.pyenv', 'versions', '3.12.14',
|
||||
'bin', 'python');
|
||||
const result = resolvePython({
|
||||
command: 'auto', workspace: '/tmp/external-project', home,
|
||||
localVersion: null, installedPyenv: [installed],
|
||||
isExecutable: filename => filename === installed ||
|
||||
filename === path.join(home, '.pyenv', 'shims', 'python'),
|
||||
});
|
||||
assert.equal(result.command, installed);
|
||||
});
|
||||
|
||||
test('shim получает версию workspace при сборке за пределами его дерева', () => {
|
||||
const workspace = path.resolve(__dirname, '..', '..');
|
||||
const version = localPythonVersion(workspace);
|
||||
assert.match(version, /^3\.12/);
|
||||
const shim = path.join(require('node:os').homedir(), '.pyenv',
|
||||
'shims', 'python');
|
||||
assert.deepEqual(pyenvEnvironment(shim, workspace),
|
||||
{PYENV_VERSION: version});
|
||||
});
|
||||
Reference in New Issue
Block a user