Compare commits

...
2 Commits
Author SHA1 Message Date
wangdefa 74e815bedf ci: 移除已过时的 TempDir 重试兜底,测试改为单跑
ci / frontend (push) Successful in 53s
ci / backend (push) Successful in 2m11s
release / release (push) Successful in 8m30s
db 跨轮污染(f8454d3)与 server TempDir 竞态(98515a3)均已根治,
重试兜底的前提不复存在:恢复为 go test 单跑,红了即真红。
2026-10-20 23:20:17 -07:00
wangdefa 1e3536f571 test: 对齐 coverage.scope 移除、测试改名,删掉 CI -skip
06a43f3 已有意删除 coverage.scope(范围根资产+company 富化)以精简规划上
下文,但该测试仍断言此字段。去掉相关断言、改名为 TestAssociatedCompany
AssetsEnterTaskContext(仍校验公司资产进入任务上下文),并移除 CI 里的 -skip。
2026-10-20 23:16:31 -07:00
2 changed files with 11 additions and 38 deletions

No files matched your search

+2 -16
View File
@@ -114,22 +114,8 @@ jobs:
run: go vet ./... run: go vet ./...
- name: 测试 - name: 测试
run: | # -p 1:各包共用一个库,串行执行避免跨包数据竞争。
# -p 1:各包共用一个库,串行执行避免跨包数据竞争。 run: go test -p 1 ./... -count=1
# -skip:TestGraphOverviewExpandsAssociatedCompanyScope 在当前代码上
# 已失败(coverage["scope"] 为 nil),与本流程无关,修好后请删掉。
run_tests() {
go test -p 1 ./... -count=1 -skip 'TestGraphOverviewExpandsAssociatedCompanyScope'
}
# 已知偶发:server 包的后台 worker 会在测试结束后继续写 t.TempDir(),
# 触发 "TempDir RemoveAll cleanup: directory not empty"。根因是
# Manager.Close() 只关库、不等 task goroutine 退出,属于既有问题。
# 先重试一次兜住;真实失败会在两次里都失败,不会被掩盖。
if run_tests; then
exit 0
fi
echo "::: 第一次失败,重试一次(可能是已知的 TempDir 清理竞态)" >&2
run_tests
frontend: frontend:
runs-on: ubuntu-latest-amd64 runs-on: ubuntu-latest-amd64
+9 -22
View File
@@ -25,7 +25,15 @@ func callReadJSON(t *testing.T, tool actool.CoreTool, input string) any {
return out return out
} }
func TestGraphOverviewExpandsAssociatedCompanyScope(t *testing.T) { // TestAssociatedCompanyAssetsEnterTaskContext verifies that an asset attributed
// to a task's company surfaces in the agent's task context: it is linked to the
// task with company provenance, counted in coverage.host_count, and reachable via
// list_untested_assets / list_assets and as an intent target — with or without the
// coverage feature. It no longer asserts coverage.scope: that overview field (scope
// root assets + company enrichment) was intentionally dropped in 06a43f3 to slim the
// per-round planner context; the association itself still holds through the checks
// below.
func TestAssociatedCompanyAssetsEnterTaskContext(t *testing.T) {
d := testDB(t) d := testDB(t)
defer d.Close() defer d.Close()
@@ -82,27 +90,6 @@ func TestGraphOverviewExpandsAssociatedCompanyScope(t *testing.T) {
if !ok { if !ok {
t.Fatalf("coverage missing: %#v", overview["coverage"]) t.Fatalf("coverage missing: %#v", overview["coverage"])
} }
scopeRows, ok := coverage["scope"].([]map[string]any)
if !ok || len(scopeRows) != 1 {
t.Fatalf("task scope missing: %#v", coverage["scope"])
}
companyScope, ok := scopeRows[0]["company_scope"].([]map[string]any)
if !ok || len(companyScope) != len(inputs) {
t.Fatalf("company scope not expanded: %#v", scopeRows[0])
}
kinds := make(map[string]string, len(companyScope))
for _, rule := range companyScope {
kinds[fmt.Sprint(rule["kind"])] = fmt.Sprint(rule["value"])
}
for _, input := range inputs {
if kinds[input.Kind] != input.Value {
t.Errorf("scope %s=%q want %q", input.Kind, kinds[input.Kind], input.Value)
}
}
keywords, ok := scopeRows[0]["company_keywords"].([]string)
if !ok || len(keywords) != 1 || keywords[0] != keyword {
t.Fatalf("company keywords missing: %#v", scopeRows[0]["company_keywords"])
}
if hc, _ := coverage["host_count"].(int); hc < 1 { if hc, _ := coverage["host_count"].(int); hc < 1 {
t.Fatalf("company asset host not counted in agent context: %#v", coverage["host_count"]) t.Fatalf("company asset host not counted in agent context: %#v", coverage["host_count"])
} }