Skip to content
Merged
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
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,13 @@ Viva 无头驱动的 `Pump()` 只消费已经请求的重绘,不会因测试
那会掩盖生产代码漏通知的问题,也不能用延时等待后台通知替测试完成刷新。
终端菜单用例先消费输出的待绘制帧,再点击终端侧栏按钮;其进程仍由测试清理流程关闭。

### 测试夹具只依赖被测边界

- 默认安装目录发现测试使用已有注册表替身,排除开发机安装;注册表优先级由专门用例验证(#2431)。不得修改开发机注册表来使测试通过。
- 跨 Core 边界的 Windows 可执行路径与运行时目录按 `filepath.Clean` 后的路径比较,命令参数仍严格按顺序比较。失败诊断逐字段输出,不转储含完整环境的启动计划(#2432)。
- 项目树展开上限测试保留 514 个目录与 512 个展开上限;根列表及未知路径由真实 Core 读取,已知子目录由可控夹具返回固定内容。验证全部展开目录已加载、各自文件存在、读取批次不超过 64,未展开目录未被请求。真实小树的展开、折叠和目录读取继续由相邻集成测试覆盖。不要让上限测试依赖 512 次原生 Git/ignore 查询能在通用八秒监听期限内完成,也不通过加长期限掩盖夹具成本(#2433)。
- 同插件运行聚合后,通过执行树里的会话节点切换控制台,并核对实际选中的会话与独立样本;不要沿用聚合前的顶部会话标签名来寻找控件。重新打开后的键盘展开与持久化断言继续保留(#2434)。

## 考虑过的备选方案

- 将整包耗时平均分给测试:不能反映真实慢用例,也无法区分包编译和运行时间。
Expand Down
552 changes: 276 additions & 276 deletions desktop/internal/i18n/shared.generated.go

Large diffs are not rendered by default.

2 changes: 2 additions & 0 deletions desktop/internal/localshell/discovery_windows_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -98,6 +98,8 @@ func TestWindowsDefaultShellPrefersTheStorePowerShell(t *testing.T) {
// TestWindowsShellDiscoveryFindsCygwin covers the setup program's default
// roots beside the system drive, which PATH does not carry (issue #435).
func TestWindowsShellDiscoveryFindsCygwin(t *testing.T) {
// This test covers default roots, independently of the machine's recorded install.
stubCygwinRegistry(t, nil)
root := t.TempDir()
path := filepath.Join(root, "cygwin64", "bin", "bash.exe")
if err := os.MkdirAll(filepath.Dir(path), 0o700); err != nil {
Expand Down
11 changes: 9 additions & 2 deletions desktop/internal/workbench/debug_launch_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -139,8 +139,15 @@ func TestDebugRuntimeArgumentsComeFromTheToolDefinition(t *testing.T) {
t.Fatal(err)
}
expected := []string{"-test.count=1", "-test.run=^TestDebugAdapterRunner$", entry}
if plan.Executable != executable || !reflect.DeepEqual(plan.Arguments, expected) || plan.Environment["FICTIONAL_VM_HOME"] != home {
t.Fatalf("tool definition launch = %+v, arguments want %v", plan, expected)
// Core may return slash-separated paths on Windows as well.
if filepath.Clean(plan.Executable) != filepath.Clean(executable) {
t.Fatalf("executable = %q, want %q", plan.Executable, executable)
}
if !reflect.DeepEqual(plan.Arguments, expected) {
t.Fatalf("arguments = %q, want %q", plan.Arguments, expected)
}
if got := plan.Environment["FICTIONAL_VM_HOME"]; filepath.Clean(got) != filepath.Clean(home) {
t.Fatalf("FICTIONAL_VM_HOME = %q, want %q", got, home)
}
manifests, discoveryErr := h.app.toolchainManifests(ctx)
if len(manifests) == 0 || discoveryErr == nil {
Expand Down
66 changes: 64 additions & 2 deletions desktop/internal/workbench/filetree_actions_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -203,15 +203,58 @@ func TestProjectTreeExpandsAndCollapsesAll(t *testing.T) {
}
}

// expandLimitTreeKernel keeps the limit test independent of 512 native Git/ignore
// queries. The root still comes from Core; each fixture child has its known file.
// Small-tree expansion above covers real directory reads through the same queue.
type expandLimitTreeKernel struct {
*testKernel
mu sync.Mutex
fixtures map[string]core.DirectoryListing
requested map[string]bool
maxBatch int
}

func (k *expandLimitTreeKernel) ListDirectories(ctx context.Context, root string, paths []string) ([]core.DirectoryListing, error) {
if err := ctx.Err(); err != nil {
return nil, err
}
k.mu.Lock()
k.maxBatch = max(k.maxBatch, len(paths))
listings := make([]core.DirectoryListing, 0, len(paths))
var native []string
for _, path := range paths {
listing, ok := k.fixtures[path]
if !ok {
native = append(native, path)
continue
}
k.requested[path] = true
listings = append(listings, listing)
}
k.mu.Unlock()
if len(native) != 0 {
actual, err := k.Client.ListDirectories(ctx, root, native)
if err != nil {
return nil, err
}
listings = append(listings, actual...)
}
return listings, nil
}

func TestProjectTreeExpandAllStopsAtItsLimit(t *testing.T) {
root := t.TempDir()
count := treeExpandAllLimit + 2
paths := make([]string, count)
fixtures := make(map[string]core.DirectoryListing, count)
for i := range paths {
paths[i] = fmt.Sprintf("d%04d/f.txt", i)
folder := fmt.Sprintf("d%04d", i)
paths[i] = folder + "/f.txt"
fixtures[folder] = core.DirectoryListing{Path: folder, Children: []core.WorkspaceNode{{Path: paths[i], Name: "f.txt", Leaf: true}}}
}
writeTreeFiles(t, root, paths...)
h := newHarness(t, &testKernel{Client: core.NewClient()})
kernel := &expandLimitTreeKernel{testKernel: &testKernel{Client: core.NewClient()}, fixtures: fixtures, requested: make(map[string]bool)}
h := newHarness(t, kernel)
p := h.openTree(t, root)
// Observe this action's notice before unrelated native watcher completions
// can replace the single banner (Linux reaches its separate watch cap first).
Expand All @@ -233,6 +276,25 @@ func TestProjectTreeExpandAllStopsAtItsLimit(t *testing.T) {
t.Fatalf("Expand All opened %d folders, want %d", expanded, treeExpandAllLimit)
}
awaitDocumentState(t, h, func() bool { return treeIdle(p) })
kernel.mu.Lock()
defer kernel.mu.Unlock()
if len(kernel.requested) != treeExpandAllLimit || kernel.maxBatch > treeListingBatch {
t.Fatalf("read %d folders, largest batch %d; want %d folders in batches of at most %d", len(kernel.requested), kernel.maxBatch, treeExpandAllLimit, treeListingBatch)
}
loadedExpanded := 0
for _, child := range p.tree.root.children {
if child.expanded {
loadedExpanded++
if !child.listed || child.loading || !kernel.requested[child.path] || p.tree.find(child.path+"/f.txt") == nil {
t.Fatalf("expanded folder %q did not finish loading its file", child.path)
}
} else if child.listed || child.loading || kernel.requested[child.path] {
t.Fatalf("closed folder %q was read past the expansion limit", child.path)
}
}
if len(p.tree.root.children) != count || loadedExpanded != treeExpandAllLimit {
t.Fatalf("final tree has %d folders, %d expanded; want %d folders, %d expanded", len(p.tree.root.children), loadedExpanded, count, treeExpandAllLimit)
}
}

// recordingTreeKernel records the folders each listing asks for.
Expand Down
10 changes: 7 additions & 3 deletions desktop/internal/workbench/run_panels_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -198,7 +198,7 @@ func TestRunPerformanceCollapseKeepsSummaryAndPersistsTheChoice(t *testing.T) {
t.Fatalf("collapse preference was not saved: %+v, err=%v", savedCollapsed, err)
}

// A second run tab shares the collapsed preference while keeping its own samples.
// Grouped executions share the collapsed preference while keeping their own samples.
h.app.applyRunEvent(pluginservice.RunEvent{Type: pluginservice.RunStarted, RunID: "run-second", PluginID: "dev.lithe.test.output-links", Label: "Second run", Workspace: root})
h.settle()
if len(p.build.runs) != 2 {
Expand All @@ -214,8 +214,12 @@ func TestRunPerformanceCollapseKeepsSummaryAndPersistsTheChoice(t *testing.T) {
if !h.shows(h.app.text.Run.Performance.CPU("70")) || !h.shows(h.app.text.Run.Performance.Memory("128")) {
t.Fatal("second run does not show its own resource summary")
}
h.clickNamed("Test run")
firstNode := h.pageHit(run.label + ", " + h.app.runStatusText(run))
h.click(center(firstNode.Bounds))
h.settle()
if p.activeRun() != run {
t.Fatal("the execution tree did not select the first run")
}
if !h.shows(h.app.text.Run.Performance.CPU("25")) || !h.shows(h.app.text.Run.Performance.Memory("96")) {
t.Fatal("switching back did not preserve the first run's samples")
}
Expand Down Expand Up @@ -244,7 +248,7 @@ func TestRunPerformanceCollapseKeepsSummaryAndPersistsTheChoice(t *testing.T) {
if reopenedCollapsedHit.Expanded {
t.Fatalf("reopened run chart started expanded: %+v", reopenedCollapsedHit)
}
reopened.clickNamed("Test run")
reopened.click(center(reopened.pageHit(reopenedRun.label + ", " + reopened.app.runStatusText(reopenedRun)).Bounds))
reopened.settle()
for range 40 {
if reopened.focusedName() == expand {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@
]
},
"owner": "Workspace",
"verification": "项目树磁盘与 Git 目录查询使用独立有界 I/O 限时;运行 TestProjectTreeDirectoryReadsAllowNativeIO 和 TestProjectTreeDirectoryReadCancelsWhenProjectCloses(测试先等待初始根目录 listing 与递归 watch resync 空闲再注入受控阻塞请求,在 macOS `-race -count=50` 下验证关闭项目取消请求且旧结果不恢复项目,原生窗口仍待实机验收),验证超过纯计算限时仍可加载、关闭项目取消请求且旧结果不恢复项目。macOS 和 Windows 无头测试覆盖目录选择、展开、键盘、虚拟绘制、长文件名滚动、外部新增删除、空目录变化、超过 128 个目录、隐藏路径过滤、视口锚定、过期读取以及与搜索共享监听的关闭和重试;真实 Core 测试覆盖共享自然排序样例,以及插件声明的隐藏目录:任意层级、忽略 ASCII 大小写,被拒的清单不生效,清空后重新显示。运行 scripts/desktop/desktop-go.sh test -race ./internal/workbench -run 'TestProjectTree|TestProjectSearch|TestEverywhere' -count=3 和 scripts/desktop/desktop-go.sh test -race ./internal/core -run TestWorkspaceDirectory -count=3。完整文件树和原生窗口行为仍待验收。 标题栏按钮:运行 scripts/desktop/desktop-go.sh test ./internal/workbench -run 'TestProjectTree(Locate|ExpandsAndCollapses|ExpandAll|Refresh)' -count=1 和 scripts/desktop/desktop-go.sh test ./internal/treelist -count=1;实机打开深层文件后折叠祖先,点击定位确认展开、选中并滚动到中间,键盘焦点在该行;在超过 512 个目录的项目中全部展开出现提示;删除并恢复项目根目录后点击刷新恢复树。 Unix 文件名里的反斜杠(2026-11-16,#2009,Lithe-core-rust #62):macOS 和 Linux 上 \\ 与 : 是文件名的一部分。Spring Boot 按 Windows 写法配置 logging.file.path: D:\\logs 后在项目里建出的 D:\\logs 目录,显示为根目录下的一个文件夹,展开后列出其中的文件,不再报 workspace.projectTree.rows 的“A project tree node is not in the folder above it”而让项目树为空;Windows 上 \\ 仍是分隔符,行为不变。运行 scripts/desktop/desktop-go.sh test ./internal/workbench -run TestProjectTreeShowsUnixNamesWithBackslashes -count=1(Windows 上跳过);原生窗口验收待做。 插件声明的隐藏目录(2026-11-16,#1856,Lithe-core-rust #72):运行 scripts/desktop/desktop-go.sh test ./internal/workbench -run 'TestPluginDeclaredFolders|TestHiddenFolders' -count=1 和 scripts/desktop/desktop-go.sh test ./internal/core -run TestWorkspaceVisibility -count=1;实机启用一个在 layout.hiddenDirectoryNames 声明目录的构建插件后,每个打开的项目标签页的项目树都不再显示这些目录、搜索也不再命中其中的文件,禁用或卸载插件后重新显示;原生窗口验收待做。 大同层目录回归:显式设置 LITHE_VISUAL_OUTPUT_DIR,并运行 scripts/desktop/desktop-go.sh test -tags vivahead,lithevisual ./internal/workbench -run '^TestVisualProjectTreeLargeDirectory$' -count=1 -timeout=120s;用真实临时 Git 仓库的 500 个同层忽略目录验证根目录不报不可用、普通源码目录可展开、文件打开后内容正确,并检查浅色中文及深色英文截图。改动前后使用相同场景和生产读取预算,分别链接旧、新 Core。Linux 无头验证不代表 macOS 或 Windows 原生验收,两端 verificationStatus 保持 pending。",
"verification": "项目树磁盘与 Git 目录查询使用独立有界 I/O 限时;运行 TestProjectTreeDirectoryReadsAllowNativeIO 和 TestProjectTreeDirectoryReadCancelsWhenProjectCloses(测试先等待初始根目录 listing 与递归 watch resync 空闲再注入受控阻塞请求,在 macOS `-race -count=50` 下验证关闭项目取消请求且旧结果不恢复项目,原生窗口仍待实机验收),验证超过纯计算限时仍可加载、关闭项目取消请求且旧结果不恢复项目。macOS 和 Windows 无头测试覆盖目录选择、展开、键盘、虚拟绘制、长文件名滚动、外部新增删除、空目录变化、超过 128 个目录、隐藏路径过滤、视口锚定、过期读取以及与搜索共享监听的关闭和重试;真实 Core 测试覆盖共享自然排序样例,以及插件声明的隐藏目录:任意层级、忽略 ASCII 大小写,被拒的清单不生效,清空后重新显示。运行 scripts/desktop/desktop-go.sh test -race ./internal/workbench -run 'TestProjectTree|TestProjectSearch|TestEverywhere' -count=3 和 scripts/desktop/desktop-go.sh test -race ./internal/core -run TestWorkspaceDirectory -count=3。完整文件树和原生窗口行为仍待验收。 标题栏按钮:运行 scripts/desktop/desktop-go.sh test ./internal/workbench -run 'TestProjectTree(Locate|ExpandsAndCollapses|ExpandAll|Refresh)' -count=1 和 scripts/desktop/desktop-go.sh test ./internal/treelist -count=1;实机打开深层文件后折叠祖先,点击定位确认展开、选中并滚动到中间,键盘焦点在该行;在超过 512 个目录的项目中全部展开出现提示;删除并恢复项目根目录后点击刷新恢复树。 Unix 文件名里的反斜杠(2026-11-16,#2009,Lithe-core-rust #62):macOS 和 Linux 上 \\ 与 : 是文件名的一部分。Spring Boot 按 Windows 写法配置 logging.file.path: D:\\logs 后在项目里建出的 D:\\logs 目录,显示为根目录下的一个文件夹,展开后列出其中的文件,不再报 workspace.projectTree.rows 的“A project tree node is not in the folder above it”而让项目树为空;Windows 上 \\ 仍是分隔符,行为不变。运行 scripts/desktop/desktop-go.sh test ./internal/workbench -run TestProjectTreeShowsUnixNamesWithBackslashes -count=1(Windows 上跳过);原生窗口验收待做。 插件声明的隐藏目录(2026-11-16,#1856,Lithe-core-rust #72):运行 scripts/desktop/desktop-go.sh test ./internal/workbench -run 'TestPluginDeclaredFolders|TestHiddenFolders' -count=1 和 scripts/desktop/desktop-go.sh test ./internal/core -run TestWorkspaceVisibility -count=1;实机启用一个在 layout.hiddenDirectoryNames 声明目录的构建插件后,每个打开的项目标签页的项目树都不再显示这些目录、搜索也不再命中其中的文件,禁用或卸载插件后重新显示;原生窗口验收待做。 大同层目录回归:显式设置 LITHE_VISUAL_OUTPUT_DIR,并运行 scripts/desktop/desktop-go.sh test -tags vivahead,lithevisual ./internal/workbench -run '^TestVisualProjectTreeLargeDirectory$' -count=1 -timeout=120s;用真实临时 Git 仓库的 500 个同层忽略目录验证根目录不报不可用、普通源码目录可展开、文件打开后内容正确,并检查浅色中文及深色英文截图。改动前后使用相同场景和生产读取预算,分别链接旧、新 Core。Linux 无头验证不代表 macOS 或 Windows 原生验收,两端 verificationStatus 保持 pending。 #2433:展开上限回归保留 514 个目录和 512 上限,根列表仍走真实 Core,已知子目录用固定读取夹具;核对每个展开目录已完成加载且包含对应文件、批次不超过 64、未展开目录不发子目录请求。相邻小树展开折叠继续覆盖真实 Core 读取;没有延长八秒等待或降低规模。",
"notes": "Viva 接入 Core 按需列目录、单选、方向键及虚拟绘制;项目根节点(包括空项目)可显示和选择,树行尺寸与展开图标参照旧版,批量列目录失败只记录一次宿主错误;新增根节点和失败日志回归仅在 macOS 验证,Windows 待重跑。2026-11-14 起可见行、选择修正、视口顶端行和多选由 Core 计算(workspace.projectTree.rows、workspace.rowSelection.reduce,#1800),树的形状变化时才调用,缩放和重绘不调用;Viva 日志生成与使用门禁跟踪 #1802。macOS 和 Windows 用一个项目级递归监听,供项目树和搜索共用,事件经 Core 过滤,重读保持节点及视口锚点。Linux 暂用最多 128 个按需目录监听,超限提示。多选、批量移动、上下文菜单、完整旧版增量行为与平台差异仍需迁移,macOS 和 Windows 原生窗口、逐像素对照及大项目性能均待验收。 Project 标题栏有定位当前文件、刷新、全部展开、全部折叠四个按钮:定位逐级列出并展开祖先目录后选中、居中并聚焦目标行,路径不可见时放弃并记录 operation_rejected;刷新重读已展开目录,根目录读取失败时重新监听并读取;全部展开按广度优先最多打开 512 个目录,超出时提示;全部折叠保留根目录,被隐藏的选择移到其所在的顶层目录。项目树是 Viva 的 ui.Tree(只声明可见行,RowWidth 使行等宽于最长名称以横向滚动),行尺寸与文字色取自 desktop/internal/treelist,Git Log 改动文件共用。方向键只移动焦点环,选中行跟随点击、Enter 与箭头,待 Viva 提供 TreeState.RowID 后改为跟随焦点。 2026-11-16 起(#1856,Lithe-core-rust #72)Core 自身只隐藏 .git、.worktree、.worktrees、.DS_Store 和 .lithe;构建产物、缓存和 VCS 元数据目录由启用的插件声明(构建系统的 layout.hiddenDirectoryNames、VCS 提供者的目录标记),宿主读取插件语言时一并交给 Core(workspace.configureVisibility),名单变化后每个打开的标签页重读已展开的目录,排除目录图标也只认这份名单。宿主不再内置 target、build、out、node_modules、.idea、.venv、__pycache__ 等名称,没有对应插件的生态不再隐藏这些目录。 大同层忽略目录的按需查询由 Core prepare_parent 复用 tracked_directories 批量检查已跟踪内容,保留嵌套仓库保护、无法可靠批量回答时的逐目录回退和取消语义;不预扫整棵目录树,不改变索引排除与树可见性的区分(#2053,Lithe-core-rust #73)。",
"legacy": {
"revision": "5a54c41aa37a4e6e6b68918a4b05765b9dd07a36",
Expand Down
Loading
Loading