Skip to content

Commit e6d3026

Browse files
committed
fix(e2e): 在桌面主线运行完整 Python 宿主回归
1 parent 50b554a commit e6d3026

7 files changed

Lines changed: 32 additions & 11 deletions

File tree

‎.github/workflows/ci.yml‎

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -111,7 +111,9 @@ jobs:
111111
with:
112112
name: python-support-archive-darwin-arm64
113113
path: dist
114+
- name: Install pytest for the host suite
115+
run: python -m pip install --disable-pip-version-check pytest
114116
- name: Verify Python highlighting on Lithe 0.8.9
115117
run: node scripts/e2e-host.mjs --ref 4d1b88f03f243356c855299464baa2647cc57226 --run '^TestPythonSupportPluginGrammarHighlighting$'
116-
- name: Verify highlighting and shebang diagnostics on the pinned desktop
117-
run: node scripts/e2e-host.mjs --run '^TestPythonSupportPlugin(GrammarHighlighting|Shebang)$'
118+
- name: Run the full Python host suite on the pinned desktop
119+
run: PYTEST_PYTHON="$(command -v python)" node scripts/e2e-host.mjs

‎README.md‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -114,7 +114,7 @@ node --test --test-timeout=60000 scripts/package/*.test.mjs
114114
cargo test --locked --manifest-path backend/Cargo.toml
115115
node scripts/test.mjs
116116

117-
# 使用 e2e/host/lithe-host.json 固定的兼容桌面提交
117+
# 使用 e2e/host/lithe-host.json 固定的桌面主线提交运行完整宿主套件
118118
node scripts/e2e-host.mjs
119119

120120
# 用同一个 ZIP 检查 0.8.9 能安装插件并正常高亮 .py

‎docs/feature-matrix.md‎

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313
| 能力域 | 功能项 | `darwin-arm64` | `darwin-x64` | `windows-x64` / `windows-arm64` | `linux-x64` / `linux-arm64` | 最近实机验证 | 实现与测试证据路径(本仓库) |
1414
| --- | --- | --- | --- | --- | --- | --- | --- |
1515
| 语言基础 (`languages`) | `.py` / `.pyi` / `.pyw` 识别、`#` 行注释、括号/引号配对、项目标记与 `.venv` / `venv` / `.conda` 依赖目录 | ✅ 已验证 | ⏳ pending(归档与清单已校验) | ⏳ pending(归档与 Windows 清单已校验) | ⏳ pending(归档与清单已校验) | `2026-11-20`(`darwin-arm64`,0.8.9 复验 `.py` 高亮) | `io.github.lithe-idea.python-support/plugin.json`<br>`scripts/test.mjs`<br>`e2e/host/desktop/internal/workbench/python_support_plugin_e2e_test.go`<br>`e2e/host/desktop/internal/workbench/python_shebang_e2e_test.go` |
16-
| 无后缀 Python 脚本 | 支持 TextMate 首行匹配的桌面按解释器路径或 `env` shebang 打开,提供 Python 高亮、注释与 Pyrefly 诊断 | ✅ 已验证 | ⏳ 待实机验证 | ⏳ 待实机验证 | ⏳ 待实机验证 | `2026-11-20`(`darwin-arm64`,桌面 `3dd5a79e9`) | `io.github.lithe-idea.python-support/grammars/python.first-line.json`<br>`scripts/test.mjs`<br>`e2e/host/desktop/internal/workbench/python_shebang_e2e_test.go` |
16+
| 无后缀 Python 脚本 | 支持 TextMate 首行匹配的桌面按解释器路径或 `env` shebang 打开,提供 Python 高亮、注释与 Pyrefly 诊断 | ✅ 已验证 | ⏳ 待实机验证 | ⏳ 待实机验证 | ⏳ 待实机验证 | `2026-11-20`(`darwin-arm64`,桌面 `645a3aee8`) | `io.github.lithe-idea.python-support/grammars/python.first-line.json`<br>`scripts/test.mjs`<br>`e2e/host/desktop/internal/workbench/python_shebang_e2e_test.go` |
1717
| 插件后端与语言服务器启动解析 (`backend` + `languageServers`) | 包内 Rust SDK 后端协商 `litheLogging` 0 与 `litheFunctions` 0。解析 `pyrefly lsp` 启动,传入宿主提供的解释器,缺失时使用 Pyrefly 原生检测。 | ✅ 已验证(桌面主线) | ⏳ 归档已校验 | ⏳ 待 CI 与宿主验收 | ⏳ 待 CI 与宿主验收 | 2026-11-20(macOS ARM64,桌面主线) | `backend/src/pyrefly.rs`<br>`scripts/test.mjs`<br>`e2e/host/desktop/internal/workbench/python_support_plugin_e2e_test.go`<br>`e2e/host/desktop/internal/workbench/python_editor_debug_e2e_test.go` |
1818
| 工具链与环境自动发现 (`toolDefinitions`) | `python` 4 层解析:项目绑定 → `.venv` / `venv` / `.conda`(受工作区信任门控,保留字面软链路径)→ 全局设置 → `VIRTUAL_ENV` + `PATH` → 16 条跨平台自动发现规则(覆盖 `UV_PYTHON_INSTALL_DIR`、`XDG_DATA_HOME`、`PYENV_ROOT`、`CONDA_ENVS_PATH`、`CONDA_PREFIX`、`WORKON_HOME`、`LOCALAPPDATA`、`APPDATA`、Homebrew、Framework、`~/.pyenv`、`~/.local/share/uv`、`*conda*/envs/*`、`miniforge*/envs/*`) | ✅ 已验证 | ⏳ pending(清单与 Core 规则已校验) | ⏳ pending(`Scripts/python.exe` / `python.exe` 布局与环境变量发现规则已通过 Core 校验) | ⏳ pending(清单与 Core 规则已校验) | `2026-11-18`(`darwin-arm64`) | `io.github.lithe-idea.python-support/plugin.json`<br>`scripts/test.mjs`<br>`e2e/host/desktop/internal/workbench/python_support_plugin_e2e_test.go` |
1919
| 构建模型与运行 (`buildSystems: python` + `provider`) | `scripts/build_provider.py`(`python -I -B`,`lithe/build/model`)复用 `scripts/build_model.py` 纯 AST + `tomllib` / `vendor/tomli` 静态提取 `[project.scripts]`、包 `__main__.py`、顶层 `__main__` 脚本、Django `manage.py`、FastAPI ASGI、Flask WSGI 并派生 7 类声明式 `run` 配置;支持损坏 `pyproject.toml` 降级与修复后恢复诊断,并在协商 `litheBuild` 1 时支持 `lithe/build/runEntrypoints` | ✅ 已验证 | ⏳ pending(归档已校验) | ⏳ pending(归档已校验) | ⏳ pending(归档已校验) | `2026-11-18`(`darwin-arm64`) | `io.github.lithe-idea.python-support/scripts/build_model.py`<br>`io.github.lithe-idea.python-support/scripts/build_provider.py`<br>`io.github.lithe-idea.python-support/plugin.json`<br>`scripts/test.mjs`<br>`e2e/host/desktop/internal/workbench/python_support_plugin_e2e_test.go` |
@@ -28,8 +28,8 @@
2828
## 宿主版本与验证
2929

3030
- 插件要求宿主声明 `toolchainProviders: 0`、`buildSystems: 1` 和 `languages: 0`。桌面 0.8.9 支持安装与原有 Python 功能。支持 TextMate 首行匹配的桌面会额外识别无后缀脚本。
31-
- 现有 M3 在兼容桌面主线 `761e6f882`(#2192、#2193)独立验过。`e2e/host/lithe-host.json` 固定支持 TextMate 首行匹配的桌面候选版本。
32-
- 插件 CI 用同一个 macOS ARM64 ZIP 验证 0.8.9 与候选桌面的普通 Python 高亮,并在候选版验证无后缀脚本编辑后收到 Pyrefly 诊断。
31+
- `e2e/host/lithe-host.json` 固定支持 TextMate 首行匹配的桌面主线提交 `645a3aee8`。
32+
- 插件 CI 用同一个 macOS ARM64 ZIP 在 0.8.9 验证普通 Python 高亮,并在固定的桌面主线上运行完整宿主套件,覆盖项目生成、解释器切换、pytest、debugpy、普通文件高亮和无后缀脚本的编辑诊断。
3333
- macOS ARM64 的工作台测试从 ZIP 安装插件,改变项目版本要求以切换外部解释器,检查全局候选和项目 `.venv` 信任,精确重跑一个参数化 pytest 用例并核对 JUnit。
3434
- 无头工作台打开 `.py` 后,Pyrefly 返回所选环境独有模块的类型诊断。debugpy 使用同一环境执行当前文件,并将日志写入宿主分配目录。关闭后,已安装插件的文件清单和 SHA-256 与启动前一致。
3535
- 宿主按 Core 的文件事实校验安装。外部虚拟环境里指向环境外的 Python 链接不可作为提供者候选,项目内环境由宿主信任流程单独处理。

‎e2e/host/desktop/internal/workbench/python_editor_debug_e2e_test.go‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -76,7 +76,7 @@ Path('interpreter.txt').write_text(sys.prefix, encoding='utf-8')
7676
if failure := h.app.pluginServerFailed["python"]; failure != nil {
7777
t.Fatalf("Pyrefly start: %s", failure.message)
7878
}
79-
return problemMessagesContain(h.app, "`ProjectInterpreterType` is not assignable to `int`")
79+
return pythonDiagnosticMessage(h.app, source, "`ProjectInterpreterType` is not assignable to `int`") != ""
8080
})
8181
t.Logf("Pyrefly reported %q for the open editor document", problemMessages(h.app))
8282
h.app.startDebug(p)

‎e2e/host/desktop/internal/workbench/python_shebang_e2e_test.go‎

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -31,13 +31,17 @@ func openPythonGrammarWorkbench(t *testing.T) *harness {
3131
if err := os.WriteFile(filepath.Join(preferences.Dir(), settingsFile), []byte(`{"theme":"dark"}`), 0o600); err != nil {
3232
t.Fatal(err)
3333
}
34+
workspace, err := filepath.EvalSymlinks(t.TempDir())
35+
if err != nil {
36+
t.Fatal(err)
37+
}
3438
h := newHarnessWithOptions(t, Options{
3539
Kernel: kernel, PluginKernel: kernel, PluginRoot: service.Root, Store: preferences, Languages: []string{"en"},
3640
Logs: &pluginFilesLog{directory: t.TempDir()}, LogKernel: kernel,
3741
})
3842
h.app.reloadPluginLanguages()
3943
h.settle()
40-
h.open(t.TempDir())
44+
h.open(workspace)
4145
return h
4246
}
4347

@@ -117,7 +121,6 @@ func TestPythonSupportPluginShebang(t *testing.T) {
117121
t.Fatal("extensionless script edit was not applied")
118122
}
119123
awaitStateWithin(t, h, 15*time.Second, "Pyrefly to diagnose the edited extensionless script", func() bool {
120-
return diagnosticsForFile(h.app, path) > 0 &&
121-
problemMessagesContain(h.app, "int") && problemMessagesContain(h.app, "bad")
124+
return pythonDiagnosticMessage(h.app, path, "bad", "`int`") != ""
122125
})
123126
}

‎e2e/host/desktop/internal/workbench/python_support_plugin_e2e_test.go‎

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,22 @@ import (
3535

3636
const pythonSupportPluginID = "io.github.lithe-idea.python-support"
3737

38+
// Require all parts of the message on one diagnostic from this plugin and file.
39+
func pythonDiagnosticMessage(a *App, path string, parts ...string) string {
40+
set := a.pluginDiagnostics[pythonSupportPluginID]
41+
if set == nil {
42+
return ""
43+
}
44+
for _, record := range set.All() {
45+
if record.FileKey == path && !slices.ContainsFunc(parts, func(part string) bool {
46+
return !strings.Contains(record.Message, part)
47+
}) {
48+
return record.Message
49+
}
50+
}
51+
return ""
52+
}
53+
3854
func pythonPackageDigest(t *testing.T, root string) map[string]string {
3955
t.Helper()
4056
digest := map[string]string{}

‎e2e/host/lithe-host.json‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"repository": "https://github.com/1lck/Lithe-IDEA.git",
3-
"revision": "3dd5a79e97d0c4ac2eedddd06baaf327a20487d0",
3+
"revision": "645a3aee86e3ee5d6a308defa350678f8048baa8",
44
"packages": {
55
"./internal/projectgen": "^TestPythonPlugin",
66
"./internal/workbench": "^TestPythonSupportPlugin"

0 commit comments

Comments
 (0)