From 153ef75bdc50771cc9ff23fcf8debcc8bcd4edd1 Mon Sep 17 00:00:00 2001 From: Yao Jingxi <23722032@bjtu.edu.cn> Date: Sat, 21 Nov 2026 12:31:47 +0800 Subject: [PATCH] =?UTF-8?q?fix(desktop):=20=E5=9B=BA=E5=AE=9A=20Core=20mai?= =?UTF-8?q?n=2066a1476=20(#2231)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - #2256 把 Core 固定在 d1a5b82。它是 #145 分支上的提交,不在 Core main 上。 这次换成 main 66a1476,带上已合入的五个 PR: #145 已保存的连接, #146 上传前核对清单哈希(S17), #148 ssh 子进程只保留白名单环境变量(S26), #149 server.state 补关闭确认所需字段, #147 端口转发的开始、停止和列出,以及监听端口所属进程(S28/S29)。 - 测试修复:core 和 workbench 的测试二进制同时充当 AskPass 助手。#148 之后,Core 只把 ssh 需要的环境变量交给助手。包级变量在初始化时读取 LITHE_PLUGIN_CONTRACT_DIR,这发生在 TestMain 判断助手模式之前,所以会崩溃。两处 fixture 路径改为函数,只在测试用到时读取。 --- .../internal/core/project_generators_test.go | 11 ++++++++--- desktop/internal/workbench/new_project_test.go | 15 ++++++++++----- scripts/desktop/build-desktop-core.sh | 17 ++++++++++++----- 3 files changed, 30 insertions(+), 13 deletions(-) diff --git a/desktop/internal/core/project_generators_test.go b/desktop/internal/core/project_generators_test.go index 679c289e0c..25f26ed6fb 100644 --- a/desktop/internal/core/project_generators_test.go +++ b/desktop/internal/core/project_generators_test.go @@ -13,11 +13,16 @@ import ( "github.com/1lck/Lithe-IDEA/desktop/internal/contractfixture" ) -var projectGeneratorFixtures = contractfixture.Path("fixtures/project-generators") +// projectGeneratorFixtures is a function, not a package variable: this test binary also runs as +// the AskPass helper, whose environment Core cuts to what ssh needs, and package initialisation +// runs before TestMain can see that mode. +func projectGeneratorFixtures() string { + return contractfixture.Path("fixtures/project-generators") +} func projectFixture(t *testing.T, name string) json.RawMessage { t.Helper() - data, err := os.ReadFile(filepath.Join(projectGeneratorFixtures, name)) + data, err := os.ReadFile(filepath.Join(projectGeneratorFixtures(), name)) if err != nil { t.Fatal(err) } @@ -99,7 +104,7 @@ func TestProjectGeneratorWrappersMatchTheSharedGoldenCases(t *testing.T) { t.Fatalf("form = %+v\nwant %+v", form, *expected.Form) } case "generationPlan": - plan, err := client.ProjectGenerationPlanOf(projectContext(t), manifest, test.GeneratorID, projectGeneratorFixtures, input) + plan, err := client.ProjectGenerationPlanOf(projectContext(t), manifest, test.GeneratorID, projectGeneratorFixtures(), input) if expected.Status == "rejected" { var rejection *ProjectRejection if !errors.As(err, &rejection) || rejection.Code != expected.Error.Code { diff --git a/desktop/internal/workbench/new_project_test.go b/desktop/internal/workbench/new_project_test.go index 8e3f96884b..1d1e8d5e94 100644 --- a/desktop/internal/workbench/new_project_test.go +++ b/desktop/internal/workbench/new_project_test.go @@ -72,7 +72,12 @@ func (h *harness) openNewProjectSheet() { h.await("the generator catalog", func() bool { return h.app.newProject.catalogLoaded }) } -var generatorFixtures = contractfixture.Path("fixtures/project-generators") +// generatorFixtures is a function, not a package variable: this test binary also runs as the +// AskPass helper, whose environment Core cuts to what ssh needs, and package initialisation runs +// before TestMain can see that mode. +func generatorFixtures() string { + return contractfixture.Path("fixtures/project-generators") +} const ( generatorToolPlugin = "dev.lithe.test.generator-tools" @@ -165,11 +170,11 @@ func TestNewProjectOnlyDiscoversToolsRequestedByTheForm(t *testing.T) { func fixtureGeneratorPlugin(t *testing.T) pluginservice.GeneratorPlugin { t.Helper() - data, err := os.ReadFile(filepath.Join(generatorFixtures, "project-generator.plugin.json")) + data, err := os.ReadFile(filepath.Join(generatorFixtures(), "project-generator.plugin.json")) if err != nil { t.Fatal(err) } - path, err := filepath.Abs(generatorFixtures) + path, err := filepath.Abs(generatorFixtures()) if err != nil { t.Fatal(err) } @@ -1024,11 +1029,11 @@ func TestNewProjectGeneratorKeepsTheCreatedDirectoryWhenGitFails(t *testing.T) { } func TestNewProjectToolFieldListsInstallationsAndPinsTheChoice(t *testing.T) { - data, err := os.ReadFile(filepath.Join(generatorFixtures, "project-generator-tool-field.plugin.json")) + data, err := os.ReadFile(filepath.Join(generatorFixtures(), "project-generator-tool-field.plugin.json")) if err != nil { t.Fatal(err) } - path, _ := filepath.Abs(generatorFixtures) + path, _ := filepath.Abs(generatorFixtures()) plugin := pluginservice.GeneratorPlugin{PluginID: "dev.lithe.fixture.project-generator-tool-field", Version: "1.0.0", Path: path, Enabled: true, Manifest: data} parent := t.TempDir() h := newGeneratorHarness(t, &testKernel{Client: core.NewClient()}, plugin) diff --git a/scripts/desktop/build-desktop-core.sh b/scripts/desktop/build-desktop-core.sh index 735e09a729..d97a4bc442 100755 --- a/scripts/desktop/build-desktop-core.sh +++ b/scripts/desktop/build-desktop-core.sh @@ -306,11 +306,18 @@ PINNED_CORE_REPOSITORY="https://github.com/Lithe-IDEA/Lithe-core-rust.git" # code for a workspace the user has not trusted (#2208). # Lithe-core-rust main at 94408ca: #142 returns Git's authentication failure without asking to # retry once a credential question was cancelled or expired unanswered (#2231). -# Lithe-core-rust feat/2231-saved-connections at d1a5b82 (#145, on main 7c1cd55): #143 shares the -# Unix socket peer check, #144 adds and removes single trusted locations (#2207), #145 keeps the -# saved SSH connections (remote.connections, remote.editConnections) and refuses a field of a -# connection by name. Replace with the main commit once #145 is merged. -PINNED_CORE_REVISION="d1a5b829ef508f3b1a692a7d05df66004fe87b08" +# Lithe-core-rust main at 7c1cd55: #143 shares one peer_uid implementation across the remote +# crate; #144 lets toolchains.editCatalog add and remove trustedLocations, refusing filesystem +# roots and lists over 256 entries (#2207). +# Lithe-core-rust main at 7901a86: #145 keeps the saved SSH connections (remote.connections, +# remote.editConnections) and refuses a field of a connection by name; #146 checks the server +# build against the SHA-256 the client names before uploading it (S17); #148 gives OpenSSH only +# allow-listed environment variables (S26); #149 reports resource labels, running time and the +# terminal command in server.state (#2231). +# Lithe-core-rust main at 66a1476: #147 starts, stops and lists port forwards +# (remote.startForward, remote.stopForward, remote.forwards) and names the process of each +# listening port (S28/S29, #2231). +PINNED_CORE_REVISION="66a147629cc9f82fc551a52682b522230e6a8340" PROFILE="debug" CHECKOUT_ONLY="no" while [[ $# -gt 0 ]]; do