- 编辑器:多标签、语法高亮、gopls 全套(补全/诊断/跳转/重命名/代码动作/内联提示/签名大纲) - 调试:Delve DAP(断点/条件断点/变量树/表达式求值/goroutine 列表) - 测试:结果树、覆盖率行着色、失败跳源码、-run 精确运行、行号可跑标记 - Git:状态着色、选择性暂存提交、pull/push、历史并排对比 - 本地历史 + 自动快照 + 崩溃恢复、会话/光标恢复 - 全局搜索替换(预览+确认,GBK 安全)、多终端、gopls 崩溃自愈 - 设计文档与验证记录见 docs/plans/
59 lines
1.6 KiB
Go
59 lines
1.6 KiB
Go
package app
|
|
|
|
import "testing"
|
|
|
|
func TestSplitLoc(t *testing.T) {
|
|
tests := []struct {
|
|
in string
|
|
ok bool
|
|
path string
|
|
line int
|
|
col int
|
|
}{
|
|
{"internal/app/app.go:42:7: undefined: x", true, "internal/app/app.go", 42, 7},
|
|
{`D:\work\demo\main.go:10: cannot use n`, true, `D:\work\demo\main.go`, 10, 0},
|
|
{"./main.go:3:1: syntax error", true, "./main.go", 3, 1},
|
|
{"2026/10/29 10:23:45 something", false, "", 0, 0},
|
|
{"go: downloading example.com/x v1.0.0", false, "", 0, 0},
|
|
{"plain output", false, "", 0, 0},
|
|
{"main.go:0:1: bad line", false, "", 0, 0},
|
|
}
|
|
for _, tt := range tests {
|
|
loc, ok := splitLoc(tt.in)
|
|
if ok != tt.ok {
|
|
t.Fatalf("%q: ok got %v want %v", tt.in, ok, tt.ok)
|
|
}
|
|
if !ok {
|
|
continue
|
|
}
|
|
if loc.Path != tt.path || loc.Line != tt.line || loc.Col != tt.col {
|
|
t.Fatalf("%q: got %+v want %s:%d:%d", tt.in, loc, tt.path, tt.line, tt.col)
|
|
}
|
|
}
|
|
}
|
|
|
|
func TestParseOutLine(t *testing.T) {
|
|
tests := []struct {
|
|
in string
|
|
kind OutKind
|
|
loc bool
|
|
}{
|
|
{"# demo/pkg", OutHeader, false},
|
|
{"ok \tdemo/pkg\t0.012s", OutSuccess, false},
|
|
{"FAIL\tdemo/pkg [build failed]", OutError, false},
|
|
{"--- FAIL: TestX (0.00s)", OutWarn, false},
|
|
{"panic: runtime error: index out of range", OutError, false},
|
|
{"main.go:5:2: undefined: foo", OutError, true},
|
|
{"just some text", OutPlain, false},
|
|
}
|
|
for _, tt := range tests {
|
|
got := parseOutLine(tt.in)
|
|
if got.Kind != tt.kind {
|
|
t.Fatalf("%q: kind got %v want %v", tt.in, got.Kind, tt.kind)
|
|
}
|
|
if (got.Loc != nil) != tt.loc {
|
|
t.Fatalf("%q: loc got %v want %v", tt.in, got.Loc, tt.loc)
|
|
}
|
|
}
|
|
}
|