Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 13 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -269,10 +269,22 @@ LITHE_TEST_GO_PLUGIN_ARCHIVE="$PWD/dist/go-support-1.3.1-darwin.zip" node script
```

插件包路径要写绝对路径。脚本把固定版本的宿主(只取 `desktop/` 和 `scripts/`)检出到 `.artifacts/lithe-host`,
复制 `e2e/host/desktop/` 下的测试,再在那里运行宿主的 `scripts/desktop/desktop-go.sh test`;第一次运行会克隆并构建
通过 Go overlay 加载 `e2e/host/desktop/` 下的测试,再运行宿主的 `scripts/desktop/desktop-go.sh test`;第一次运行会克隆并构建
Rust Core,`LITHE_CORE_RUST_DIR` 可以指向本地的 Core 检出。`--ref <分支或 commit>` 换一个宿主版本试跑,
`--run <正则>` 只跑部分测试。测试用的是宿主内部的测试工具,升级 `lithe-host.json` 的 `revision` 时可能要同步修改测试。

远程测试需要支持远程插件的宿主版本,以及登录环境里有 `go`、`gopls` 和 `dlv` 的一次性 Linux SSH 目标。使用与客户端平台匹配的插件包和该宿主的 `scripts/desktop/build-remote-server.sh` 生成的服务产物。Windows 上用 Git Bash 启动测试,插件包和路径按 Windows 客户端填写。

```bash
LITHE_TEST_GO_SSH_HOST=my-linux-test-host \
LITHE_REMOTE_SERVER_STAGE=/absolute/path/to/remote-server \
node scripts/e2e-host.mjs --remote --ref "$LITHE_HOST_REF"
```

`LITHE_HOST_REF` 是要验证的宿主分支或提交。也可用 `--worktree /absolute/path/to/Lithe-IDEA` 替换 `--ref "$LITHE_HOST_REF"`,直接测试该检出的当前文件。测试入口在 `.artifacts/` 生成一次性的 Go overlay,结束后移除,不向宿主检出复制测试源码。

用例覆盖远端构建、运行和测试,gopls 诊断与保存,以及 Delve 断点、栈帧跳转和调试资源清理。

## 功能矩阵

插件各项能力在 macOS 和 Windows 上的实现与验收状态见 [docs/feature-matrix.md](docs/feature-matrix.md)。
Expand Down
9 changes: 9 additions & 0 deletions docs/feature-matrix.md
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@
| --- | --- | --- | --- | --- |
| `go-support-plugin` | gopls 代码智能、Go Modules 构建、运行与 `go test` | implemented / pending | implemented / pending | 2026-11-15 macOS 宿主端到端测试通过;Windows ARM64、x64 [原生 CI 通过](https://github.com/Lithe-IDEA/lithe-plugin-go/actions/runs/43728078241) |
| `go-debug-delve` | 用用户的 Delve 调试 Go 包 | implemented / pending | partial / pending | 2026-11-15 macOS 宿主端到端测试通过;Windows x64 [原生 CI 通过](https://github.com/Lithe-IDEA/lithe-plugin-go/actions/runs/43728078241);Windows ARM64 上 Delve 不支持 |
| `go-remote-ssh` | 在 Linux SSH 工作区运行 Go、gopls 和 Delve | implemented / pending | implemented / pending | 2026-11-21,macOS arm64 和 Windows x64 客户端的真实 SSH 端到端测试通过 |
| `go-run-configuration-types` | 「运行/调试配置」里的 Go 构建和 Go 测试 | implemented / pending | implemented / pending | 2026-11-19 macOS 宿主端到端测试通过(桌面端 0.8.8,宿主 d87f114);Windows 只有命令层面的 `scripts/test.mjs` |
| `go-settings-previews` | Go 语言设置页和 Go 构建系统页里插件自己画的预览 | implemented / pending | implemented / pending | 2026-11-19 macOS 宿主端到端测试通过(本地 1.3.1 包,宿主 312a9c63a,即 1lck/Lithe-IDEA#2191 的分支提交);Windows 后端只在 CI 构建,没有在 Windows 版 Lithe 里运行过 |
| `go-project-generator` | 「新建项目」里的 Go 模块,GOROOT 选择和 Go 版本默认值 | implemented / pending | implemented / pending | 2026-11-15 macOS 宿主集成测试通过;Windows ARM64、x64 [原生 CI 通过](https://github.com/Lithe-IDEA/lithe-plugin-go/actions/runs/43728078241)(模板生成的模块能构建和测试) |
Expand Down Expand Up @@ -301,6 +302,14 @@ Core 6477e9a),Homebrew 的 Go 1.27.4。在宿主检出里运行 `internal/pr
拖宽窗口后步骤卡片跟着变宽,较长的 `go` 路径显示得更多。
4. 界面语言换成中文,两个预览都显示中文。

## go-remote-ssh

Go Support 安装在桌面客户端。打开受信任的 Linux SSH 工作区后,构建、运行、测试、gopls 与 Delve 使用远端登录环境的工具,诊断和调试栈帧显示在本机编辑器。

**最近验证**:2026-11-21,Go Support 1.3.1,桌面宿主和 Core 为 [#2231](https://github.com/1lck/Lithe-IDEA/issues/2231) 的开发检出。macOS arm64 客户端连接 Linux arm64,通过仓库的标准入口执行 `TestOfficialGoPluginUsesRemoteWorkspaceOverSSH`。Windows x64 客户端在 ARM64 来宾内仿真执行同一场景。测试覆盖远端模块构建和运行、只在 Linux 上通过的测试、Delve 断点和调用栈导航、调试隧道释放,以及本机编辑触发的 gopls 诊断。手工验收待完成。

**验证方法**:在 macOS 和 Windows 分别安装对应平台的插件包,打开带 Go、gopls 和 dlv 的 Linux SSH 工作区。用构建窗口构建、运行和测试 Go 模块,在编辑器引入可诊断的问题,再设置断点并从调用栈打开源文件。结束调试后检查没有残留转发。自动化入口见 [README 的远程 SSH 验收](../README.md#远程-ssh-验收)。

## Windows 安装包

| 能力 | Windows ARM64 | Windows x64 | 验证入口 |
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,282 @@
//go:build lithe_remote_e2e

package workbench

import (
"context"
"encoding/json"
"os"
"path"
"path/filepath"
"slices"
"strings"
"testing"
"time"

"github.com/1lck/Lithe-IDEA/desktop/internal/core"
"github.com/1lck/Lithe-IDEA/desktop/internal/i18n"
"github.com/1lck/Lithe-IDEA/desktop/internal/remoteplaceholder"
"github.com/1lck/Lithe-IDEA/desktop/internal/remoteserver"
"github.com/vivaui/viva/app"
)

// Use a disposable Linux SSH host with go, gopls and dlv on the remote login PATH. Set
// LITHE_TEST_GO_SSH_HOST to its OpenSSH alias, LITHE_TEST_GO_PLUGIN_ARCHIVE to
// the local plugin ZIP and LITHE_REMOTE_SERVER_STAGE to the staged server builds.
// LITHE_TEST_GO_SSH_PROGRAM optionally names an absolute path to an SSH wrapper.
// LITHE_TEST_GO_SSH_INSTALL_ROOT optionally isolates the installed remote server.
// scripts/e2e-host.mjs --remote enables the build tag on the requested host revision.
func TestOfficialGoPluginUsesRemoteWorkspaceOverSSH(t *testing.T) {
host := os.Getenv("LITHE_TEST_GO_SSH_HOST")
if host == "" {
t.Skip("set LITHE_TEST_GO_SSH_HOST to a disposable Linux OpenSSH target")
}
archive, stage := os.Getenv("LITHE_TEST_GO_PLUGIN_ARCHIVE"), os.Getenv("LITHE_REMOTE_SERVER_STAGE")
if archive == "" || stage == "" {
t.Fatal("set LITHE_TEST_GO_PLUGIN_ARCHIVE and LITHE_REMOTE_SERVER_STAGE")
}
bundle, err := remoteserver.Staged(stage)
if err != nil {
t.Fatal(err)
}
connection := remoteHost{ssh: core.SSHConnection{Host: host}}
builds := make([]core.RemoteServerBuild, 0, len(bundle.Builds))
for _, build := range bundle.Builds {
builds = append(builds, core.RemoteServerBuild{Target: build.Target, Path: build.Path, SHA256: build.SHA256})
}
request := connection.request(builds, bundle.Version)
request.InstallRoot = os.Getenv("LITHE_TEST_GO_SSH_INSTALL_ROOT")
if ssh := os.Getenv("LITHE_TEST_GO_SSH_PROGRAM"); ssh != "" {
data, err := json.Marshal(map[string]any{"version": 1, "sshProgram": ssh})
if err != nil {
t.Fatal(err)
}
preferences := string(data)
request.Preferences = &preferences
}
client := core.NewClient()
connectCtx, cancelConnect := context.WithTimeout(context.Background(), time.Minute)
connected, err := client.RemoteConnect(connectCtx, request)
cancelConnect()
if err != nil || connected.Status != core.RemoteProbeConnected || connected.Session == nil {
t.Fatalf("SSH connection failed: status=%s err=%v diagnostics=%s", connected.Status, err, connected.Diagnostics)
}
session := connected.Session.ID
t.Cleanup(func() {
ctx, cancel := context.WithTimeout(context.Background(), 10*time.Second)
defer cancel()
if _, err := client.RemoteDisconnect(ctx, session, core.RemoteCloseEnd); err != nil {
t.Errorf("disconnect SSH session: %v", err)
}
})
platform := connected.Host.PluginPlatform()
if platform == nil || platform.OS != "linux" {
t.Fatalf("connected target has no Linux plugin platform: %+v", connected.Host)
}
var directory struct {
Path string `json:"path"`
}
setupCtx, cancelSetup := context.WithTimeout(context.Background(), 20*time.Second)
defer cancelSetup()
lease := map[string]string{"directoryId": "go-plugin-ssh-e2e"}
if err := client.RemoteHostRequest(setupCtx, session, "fs.createRunDirectory", lease, &directory); err != nil || !path.IsAbs(directory.Path) {
t.Fatalf("create SSH fixture directory: path=%q err=%v", directory.Path, err)
}
const modulePath = "example.com/lithe-remote-go"
for name, content := range map[string]string{
"go.mod": "module " + modulePath + "\n\ngo 1.21\n",
"main.go": `package main

import "runtime"

func main() {
if runtime.GOOS != "linux" {
panic("expected Linux")
}
println("Lithe Go program on " + runtime.GOOS)
}
`,
"main_test.go": `package main

import (
"runtime"
"testing"
)

func TestRunsOnLinux(t *testing.T) {
if runtime.GOOS != "linux" {
t.Fatalf("expected Linux, got %s", runtime.GOOS)
}
}
`,
} {
if _, saved, err := client.RemoteWriteFile(setupCtx, session, path.Join(directory.Path, name), []byte(content), nil); err != nil || !saved {
t.Fatalf("write remote %s: saved=%v err=%v", name, saved, err)
}
}
cancelSetup()

h := newHarness(t, &testKernel{Client: client})
installed := installOfficialPluginArchive(t, h, archive, officialGoPluginID)
before := packageDigest(t, installed)
h.app.reloadPluginLanguages()
const connectionID = "go-plugin-ssh-e2e"
anchor := filepath.Join(t.TempDir(), remoteplaceholder.AnchorName)
if err := remoteplaceholder.Ensure(anchor); err != nil {
t.Fatal(err)
}
root := remoteplaceholder.Root(anchor, connectionID, directory.Path)
h.app.openRemoteProject(remoteTarget{
connectionID: connectionID, name: "Linux SSH test", host: connection, session: *connected.Session,
platform: platform, remoteRoot: directory.Path, root: root, trusted: true,
})
p := h.app.project
if p == nil || p.remote == nil {
t.Fatal("the SSH project did not open")
}
instance := awaitBuildModel(t, h, p, "go", time.Minute)
module := modelProjectNamed(instance.Model, modulePath)
if module == nil {
t.Fatalf("the remote Go model has no %s module: %+v", modulePath, instance.Model.Projects)
}
runBuildTaskToEnd(t, h, p, module.ID, "build", 2*time.Minute)
var application string
for _, target := range instance.Model.Targets {
if slices.Contains(target.Tags, "application") {
if application != "" {
t.Fatalf("expected a single application target: %+v", instance.Model.Targets)
}
application = target.ID
}
}
if application == "" {
t.Fatalf("the SSH module has no application target: %+v", instance.Model.Targets)
}
if output := runTargetEntryToEnd(t, h, p, instance, application, time.Minute); !strings.Contains(output, "Lithe Go program on linux") {
t.Fatalf("remote Go program did not print its Linux result: %q", output)
}
t.Logf("Built and ran the Go module on Linux %s", platform.Arch)

h.app.post(func(a *App) { a.runBuildProjectTests(p, instance, module.ID) })
awaitStateWithin(t, h, 2*time.Minute, "the Go module test run over SSH", func() bool {
return p.tests.last != nil && !p.tests.running
})
if output := p.tests.output.all(); !p.tests.verdict.Success ||
!strings.Contains(output, "ok") || !strings.Contains(output, modulePath) || strings.Contains(output, "[no test files]") {
t.Fatalf("the Linux-only test did not pass: verdict=%+v failure=%q output=%q", p.tests.verdict, p.tests.failed, output)
}
t.Log("The Build tool window reported the Linux-only test passed")

file := filepath.Join(root, "main.go")
h.app.openFileAt(p, file, 1)
var d *document
awaitStateWithin(t, h, time.Minute, "remote gopls to open main.go", func() bool {
d = p.docs.byPath(file)
return d != nil && d.sync.opened
})
debugOfficialGoProgramOverSSH(t, h, p, file, filepath.Join(root, "go.mod"))
forwardCtx, cancelForward := context.WithTimeout(context.Background(), 10*time.Second)
forwards, err := client.RemoteForwards(forwardCtx, session)
cancelForward()
if err != nil || len(forwards) != 0 {
t.Fatalf("Delve left a port forward after its session ended: forwards=%+v err=%v", forwards, err)
}

if !d.view.GoToNavigation(4, len("func main() {"), false) {
t.Fatal("could not place the caret in remote main.go")
}
input := d.view.TextInput(app.TextInputContext{ID: d.hit})
if _, err := input.OnEvent(app.TextEvent{Kind: app.TextInsert, Text: "\n\tmissingOverSSH()"}); err != nil {
t.Fatal(err)
}
awaitStateWithin(t, h, time.Minute, "a diagnostic from remote gopls", func() bool {
return problemMessagesContain(h.app, "missingOverSSH") && diagnosticsForFile(h.app, file) > 0
})
t.Log("gopls returned a diagnostic for a local edit to the remote file")
h.app.saveDocument(p, d.id)
awaitStateWithin(t, h, 30*time.Second, "remote main.go to save", func() bool { return !d.dirty() })
readCtx, cancelRead := context.WithTimeout(context.Background(), 10*time.Second)
defer cancelRead()
data, _, err := client.RemoteReadFile(readCtx, session, path.Join(directory.Path, "main.go"))
if err != nil || !strings.Contains(string(data), "missingOverSSH()") {
t.Fatalf("the saved source did not reach the remote file: %v", err)
}

h.app.closeProject()
awaitStateWithin(t, h, 20*time.Second, "the SSH project to close or ask about running programs", func() bool {
return h.app.project == nil || len(h.app.prompts.queue) > 0
})
if h.app.project != nil {
prompt := h.app.prompts.queue[0]
language := h.app.language()
end := slices.Index(prompt.actions, i18n.Shared(language, "desktop.remote.close.end"))
if prompt.title != i18n.Shared(language, "desktop.remote.close.title") || end < 0 {
t.Fatalf("unexpected prompt when closing the SSH project: %q", prompt.title)
}
h.app.answerPrompt(&end)
}
awaitStateWithin(t, h, 20*time.Second, "the closed SSH project", func() bool {
return h.app.project == nil && !h.app.closingProject
})
h.settle()
if data, err := os.ReadFile(anchor); err != nil || len(data) != 0 {
t.Fatalf("the remote placeholder changed: size=%d err=%v", len(data), err)
}
assertPackageUnchanged(t, installed, before)
}

func debugOfficialGoProgramOverSSH(t *testing.T, h *harness, p *project, source, moduleFile string) {
t.Helper()
const line = 9
h.app.openToolWindow(itemDebug)
awaitStateWithin(t, h, 30*time.Second, "the Go debug adapter list", func() bool { return p.debug.loaded })
if len(p.debug.adapters) != 1 || p.debug.adapters[0].PluginID != officialGoPluginID {
t.Fatalf("debug adapters = %+v, want the Go adapter; failure: %s", p.debug.adapters, p.debug.failure)
}
h.app.toggleBreakpointAt(p, source, line)
awaitStateWithin(t, h, 10*time.Second, "the remote Go breakpoint", func() bool {
breakpoints := p.debug.breakpoints[source]
return len(breakpoints) == 1 && breakpoints[0].line == line
})
clickNamedWithoutSettling(t, h, h.app.text.Debug.Start)
var session *debugSession
awaitStateWithin(t, h, 2*time.Minute, "Delve to hit the remote Go breakpoint", func() bool {
if p.debug.failure != "" {
t.Fatalf("remote Delve failed: %s\noutput: %q", p.debug.failure, p.debug.output)
}
session = p.debug.activeSession()
return session != nil && p.debug.state == "paused" && len(p.debug.frames) != 0
})
if top := p.debug.frames[0]; top.Name != "main.main" || top.Line != line || top.SourcePath != source {
t.Fatalf("top frame = %+v, want main.main at %s:%d", top, source, line)
}
h.app.openFileAt(p, moduleFile, 1)
// Loading the thread picker shifts the stack rows. Wait for both the editor
// and the picker before locating the row to click.
awaitStateWithin(t, h, 20*time.Second, "go.mod and the debug thread picker to appear", func() bool {
d := p.selectedDocument(p.docs.group)
return d != nil && d.path == moduleFile && len(p.debug.threads) > 0
})
clickNamedWithoutSettling(t, h, "main.main")
awaitStateWithin(t, h, 20*time.Second, "the stack frame to select the remote source line", func() bool {
d := p.selectedDocument(p.docs.group)
if d == nil || d.path != source {
return false
}
caret, _ := d.view.Caret()
return caret == line-1
})
clickNamedWithoutSettling(t, h, h.app.text.Debug.Continue)
awaitStateWithin(t, h, time.Minute, "the remote debug session to terminate and release its resources", func() bool {
select {
case <-session.cleanupDone:
return p.debug.activeSession() == nil && p.debug.state == "terminated"
default:
return false
}
})
if session.cleanupErr != nil {
t.Fatalf("releasing the remote debug session: %v", session.cleanupErr)
}
t.Log("Delve hit a Linux breakpoint, opened the remote source from the call stack and released the session")
}
11 changes: 10 additions & 1 deletion e2e/host/lithe-host.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,16 @@
"./internal/workbench": "^TestOfficialGoPlugin(BuildsAndServesAModule|DebugsEachProjectOfAWorkspaceWithDelve|RunsGoBuildAndGoTestConfigurations|DrawsItsSettingsRegions)$"
},
"requiredEnvironment": {
"LITHE_TEST_GO_PLUGIN_ARCHIVE": "go-support-<version>-darwin.zip to install, for example dist/go-support-1.3.1-darwin.zip"
"LITHE_TEST_GO_PLUGIN_ARCHIVE": "absolute path to the plugin ZIP matching the client platform"
},
"remoteSSH": {
"package": "./internal/workbench",
"test": "TestOfficialGoPluginUsesRemoteWorkspaceOverSSH",
"tag": "lithe_remote_e2e",
"requiredEnvironment": {
"LITHE_TEST_GO_SSH_HOST": "OpenSSH alias of a disposable Linux host with go, gopls and dlv on the login PATH",
"LITHE_REMOTE_SERVER_STAGE": "absolute path to the compatible host's staged lithe-remote-server builds"
}
},
"repositoryEnvironment": {
"LITHE_PLUGIN_GO_DIR": "io.github.lithe-idea.go-support"
Expand Down
Loading
Loading