完成规划 P3 / P4:-race/-bench 开关、自检与 e2e 冒烟
verify / verify (push) Canceled after 0s

P3 测试开关(internal/app/testflags.go)
  测试面板顶部加 -race / -bench 会话级 checkbox(不持久化,-race 会拖慢测试)。
  参数经 withTestFlags 统一注入结果树 / 输出面板 / 覆盖率三个 go test 入口。
  -bench 配 -run=^$,但调用方已有 -run(运行光标处测试)时不覆盖。
  勾 -bench 时「全部测试」改走输出面板,-json 会把 ns/op 埋在 output 行里看不清。
  4 条参数组合单测。

P4 三层守门
  verify.cmd:gofmt / vet / test 一道跑,纯 ASCII(cmd 按 GBK 读 UTF-8 中文
    注释会把中文当命令执行,实测踩过)。用 findstr 判 gofmt 输出非空。
  build.cmd verify:自检通过才构建;build.cmd 不带参数仍直接构建。
  .gitea/workflows/ci.yml:远端是 Gitea 企业版,用 Gitea Actions 兼容语法。
    是否真的运行取决于实例启用 Actions + runner,文档里如实写明这个前提,
    不声称已生效。GOOS=linux CGO_ENABLED=0 交叉编译已验证通过。
  tools/e2e/main.go:自建临时 Go 模块工作区,编译 -tags e2e 二进制,
    以工作区目录作为启动参数(openFromArgs),连 automation 插座跑 4 条场景:
    启动渲染 / 工作区与 gopls / 诊断到达 / 输出面板右键菜单。
    两个坑已处理:全新会话默认底部面板是关的(ensurePanel 先点状态栏「面板」);
    「运行」有页签和右上角真会跑程序的图标两个同名按钮(按 X<700 区分)。
    连跑两次均 4/4,退出码反映结果。

docs/本地自检与CI.md 记录三层守门用法、Gitea Actions 启用前提、e2e 限制
  (原生右键菜单插座测不了,仍靠 ui.Tester 单测)。
待办文档移除 P3/P4,规划只剩 4 项按需。

验证:build.cmd verify 全绿(286 个测试)、go run ./tools/e2e 两次 4/4、
GOOS=linux 交叉编译通过。
This commit is contained in:
zerorigin committed 2026-11-12 16:36:02 +08:00
1 parent e408300324
commit 1c2f5e3be0
12 files changed
+899 -32

No files matched your search

+14 -2
View File
@@ -93,6 +93,7 @@ func (a *App) runOneTest(pkg, name string) {
// startTest 拉起一次 go test 并把结果树清空重填;args 是 go 的完整参数。
func (a *App) startTest(args ...string) {
args = a.withTestFlags(args)
if a.test.running {
a.StopTask()
}
@@ -281,7 +282,12 @@ func (a *App) testView(c *ui.Context) {
ui.Column(c).FillHeight().Children(func() {
ui.Row(c).Padding(3, 10).Gap(8).AlignItems(ui.Center).
BorderWidth(0, 0, 1, 0).BorderColor(t.Border).Children(func() {
ui.Textf(c, "%s", a.test.pattern).FontSize(11).TextColor(t.TextMuted).SingleLine()
ui.Textf(c, "%s", a.testCommandLabel(a.test.pattern)).FontSize(11).
TextColor(t.TextMuted).SingleLine()
// 会话级开关:不写进设置文件,重开 IDE 自动回到关闭状态。
// -race 会明显拖慢测试,不该变成「不知何时被打开」的持久状态。
ui.Checkbox(c, &a.testRace, "-race")
ui.Checkbox(c, &a.testBench, "-bench")
ui.Box(c).Grow(1)
if pass+fail+skip > 0 {
ui.Textf(c, "✓ %d ✗ %d ○ %d", pass, fail, skip).FontSize(11).TextColor(t.TextMuted)
@@ -290,7 +296,13 @@ func (a *App) testView(c *ui.Context) {
ui.Text(c, "运行中…").FontSize(11).TextColor(t.Accent)
}
if ui.Button(c, "全部测试").Clicked() {
a.RunTestTree("")
// -json 会把 benchmark 的 ns/op 埋在 output 行里,结果树看不清;
// 勾了 -bench 就直接走输出面板,数字原样可见。
if a.testBench {
a.RunTests()
} else {
a.RunTestTree("")
}
}
if ui.Button(c, "当前包").Clicked() {
a.runCurrentPackageTests()