Code
Hub
Workspaces
Following
Trending
Connect
MCP
copy
Create free account
hub
/
github.com/ZhangShenao/harness9
/ functions
Functions
1,385 in github.com/ZhangShenao/harness9
⨍
Functions
1,385
◇
Types & classes
252
Function
TestFuzzyReplace_L4_LineByLineIndentDifference
L4: 真正测试逐行去缩进 — 每行缩进级别不同,L1/L2/L3 均无法匹配
internal/tools/edit_file_test.go:454
Function
TestFuzzyReplace_L4_LineByLineMatch
L4: 逐行去缩进匹配
internal/tools/edit_file_test.go:181
Function
TestFuzzyReplace_L4_MultipleMatch_Error
L4: 逐行去缩进多处匹配 → 返回错误
internal/tools/edit_file_test.go:231
Function
TestFuzzyReplace_L4_PreservesBlockIndentation
TestFuzzyReplace_L4_PreservesBlockIndentation 验证 L4 缩进无关匹配命中后, 模型提供的 target 会被重新缩进到被替换块的缩进层级(防止 Python IndentationError)。
internal/tools/edit_file_test.go:553
Function
TestFuzzyReplace_L4_SingleLine
L4: 单行匹配
internal/tools/edit_file_test.go:344
Function
TestFuzzyReplace_L4_WithBlankLines
L4: 包含空行的代码块匹配
internal/tools/edit_file_test.go:316
Function
TestFuzzyReplace_NoMatch
L4: 无匹配 → 返回错误
internal/tools/edit_file_test.go:247
Function
TestGenerateRetry_DoesNotRetryOnContextCancel
TestGenerateRetry_DoesNotRetryOnContextCancel 验证:context 取消不触发重试。
internal/engine/agent_loop_test.go:159
Function
TestGenerateRetry_ExhaustsThenFails
TestGenerateRetry_ExhaustsThenFails 验证:持续失败时耗尽重试后返回错误(有界)。
internal/engine/agent_loop_test.go:144
Function
TestGenerateRetry_RecoversFromTransientError
TestGenerateRetry_RecoversFromTransientError 验证:瞬时 LLM 错误经有界重试后恢复, 整条轨迹不被一次抖动杀死。
internal/engine/agent_loop_test.go:129
Function
TestGetModelLimits_Anthropic
(t *testing.T)
internal/provider/model_limits_test.go:33
Function
TestGetModelLimits_AnthropicWithPrefix
(t *testing.T)
internal/provider/model_limits_test.go:40
Function
TestGetModelLimits_EmptyString
(t *testing.T)
internal/provider/model_limits_test.go:47
Function
TestGetModelLimits_GeminiLargeContext
(t *testing.T)
internal/provider/model_limits_test.go:54
Function
TestGetModelLimits_KnownModel
(t *testing.T)
internal/provider/model_limits_test.go:9
Function
TestGetModelLimits_UnknownModel
(t *testing.T)
internal/provider/model_limits_test.go:26
Function
TestGetModelLimits_WithProviderPrefix
(t *testing.T)
internal/provider/model_limits_test.go:19
Function
TestGlobContains_Patterns
TestGlobContains_Patterns 覆盖 matchPattern / globContains 的各类匹配路径: 尾部星号快捷路径、精确工具名、大小写不敏感、空括号。
internal/permission/rules_test.go:133
Function
TestHTTPTransport_CloseIsNoop
TestHTTPTransport_CloseIsNoop 验证 HTTPTransport.Close 始终返回 nil。
internal/mcp/transport_test.go:35
Function
TestHTTPTransport_Send_NetworkError
TestHTTPTransport_Send_NetworkError 验证向不可达地址发送请求时 Send 返回 HTTP 错误。 使用本地不存在的端口(9998),确保立即返回连接错误而不超时。
internal/mcp/transport_test.go:44
Function
TestHTTPTransport_StartIsNoop
---- HTTPTransport 单元测试 ---- TestHTTPTransport_StartIsNoop 验证 HTTPTransport.Start 始终返回 nil(HTTP 是无状态的)。
internal/mcp/transport_test.go:27
Function
TestHandleTaskPanelKeyNavigation
TestHandleTaskPanelKeyNavigation 验证任务面板的列表/详情导航: ↑↓ 光标夹紧、Enter 进详情、Esc 列表态关闭/详情态返回。
cmd/harness9/tui_test.go:1091
Function
TestHardAssertions_IsSoftFalse
(t *testing.T)
internal/evals/assertions_test.go:155
Function
TestHookRegistry_AllowThenAsk
TestHookRegistry_AllowThenAsk 验证白名单修复:前置 hook 显式 Allow 后,后续 hook 的 Ask 不再弹出审批。 复现场景:permHook 返回 Allow(命中白名单),dangerHook 返回 Ask(命中危险模式), 用户不应被再次要求审批。 注
internal/hooks/hook_test.go:260
Function
TestHookRegistry_AllowWithModifiedArgs
TestHookRegistry_AllowWithModifiedArgs 验证 HookActionAllow 携带 ModifiedArgs 时参数被正确应用。 场景:路径沙箱 hook 显式放行并重写参数,内层工具应收到重写后的参数。
internal/hooks/hook_test.go:204
Function
TestHookRegistry_AskApprovedOnce
TestHookRegistry_AskApprovedOnce 验证:同一工具调用已由人类审批后,后续相同的 Ask hook 不再弹框。 场景:两个 Ask hook 串联,第一个触发审批(通过),第二个应检测到 withApproved 标记而跳过。
internal/hooks/hook_test.go:234
Function
TestHookRegistry_BeforeAsk_NoApprovalFn_Allows
(t *testing.T)
internal/hooks/hook_test.go:160
Function
TestHookRegistry_BeforeAsk_WithApprovalFn_Allow
(t *testing.T)
internal/hooks/hook_test.go:187
Function
TestHookRegistry_BeforeAsk_WithApprovalFn_Deny
(t *testing.T)
internal/hooks/hook_test.go:172
Function
TestHookRegistry_BeforeDeny
(t *testing.T)
internal/hooks/hook_test.go:140
Function
TestHookRegistry_BeforeShortCircuit
(t *testing.T)
internal/hooks/hook_test.go:87
Function
TestHookRegistry_NoHooks_PassThrough
(t *testing.T)
internal/hooks/hook_test.go:74
Function
TestHookRegistry_OnionOrder
(t *testing.T)
internal/hooks/hook_test.go:108
Function
TestHookRegistry_Register_Delegates
(t *testing.T)
internal/hooks/hook_test.go:128
Function
TestIndex_GetFullContent_FileMissing
(t *testing.T)
internal/skills/skills_test.go:135
Function
TestIndex_GetFullContent_Found
(t *testing.T)
internal/skills/skills_test.go:158
Function
TestIndex_GetFullContent_NotFound
(t *testing.T)
internal/skills/skills_test.go:147
Function
TestIndex_IsEmpty
--- Index tests ---
internal/skills/skills_test.go:81
Function
TestIndex_Names
(t *testing.T)
internal/skills/skills_test.go:113
Function
TestIndex_Summary_Empty
(t *testing.T)
internal/skills/skills_test.go:92
Function
TestIndex_Summary_WithSkills
(t *testing.T)
internal/skills/skills_test.go:99
Function
TestIsInteractiveCmd
(t *testing.T)
cmd/harness9/tui_test.go:915
Function
TestIsSafeURL
(t *testing.T)
internal/tools/web_safety_test.go:8
Function
TestKeyCtrlC_WhenIdle_ReturnsQuitCmd
(t *testing.T)
cmd/harness9/tui_test.go:173
Function
TestKeyCtrlC_WhenRunning_CallsCancelFn
(t *testing.T)
cmd/harness9/tui_test.go:187
Function
TestKeyEnd_ReturnsToAutoScroll
(t *testing.T)
cmd/harness9/tui_test.go:272
Function
TestKeyEnter_EmptyInput_Ignored
(t *testing.T)
cmd/harness9/tui_test.go:204
Function
TestKeyEnter_WhenRunning_Ignored
(t *testing.T)
cmd/harness9/tui_test.go:216
Function
TestKeyPgDown_AtBottom_StaysAutoScroll
(t *testing.T)
cmd/harness9/tui_test.go:283
Function
TestKeyPgUp_EntersManualScroll
(t *testing.T)
cmd/harness9/tui_test.go:229
Function
TestLoadConfig_EmptyServersField
TestLoadConfig_EmptyServersField 验证 mcpServers 为 null/缺省时 Servers 被初始化为空 map。
internal/mcp/config_test.go:85
Function
TestLoadConfig_FileNotFound
TestLoadConfig_FileNotFound 验证文件不存在时返回空 Config(不报错)。
internal/mcp/config_test.go:10
Function
TestLoadConfig_InvalidJSON
TestLoadConfig_InvalidJSON 验证非法 JSON 文件时返回解析错误。
internal/mcp/config_test.go:71
Function
TestLoadConfig_ValidFile
TestLoadConfig_ValidFile 验证合法 .mcp.json 被正确解析。
internal/mcp/config_test.go:24
Function
TestLoadDataset
(t *testing.T)
cmd/swebench/dataset_test.go:9
Function
TestLoadDatasetFileNotFound
(t *testing.T)
cmd/swebench/dataset_test.go:32
Function
TestLoadDataset_ParsesEnvironmentFields
TestLoadDataset_ParsesEnvironmentFields 验证新增的环境/评测字段被正确解析: version / environment_setup_commit / FAIL_TO_PASS / test_patch。 这些字段是为每实例 provision 依赖、选对 P
cmd/swebench/dataset_test.go:68
Function
TestLoadExistingIDs
TestLoadExistingIDs 验证 --resume 跳过逻辑:仅"已产出非空 patch"的实例算完成并被跳过; 空 patch(无改动 / 瞬时失败被记空)不计入,从而在续跑时获得重试机会。
cmd/swebench/report_test.go:25
Function
TestLoadExistingIDsEmpty
(t *testing.T)
cmd/swebench/report_test.go:13
Function
TestLoadFromDirLoadsAgents
(t *testing.T)
internal/subagent/loader_test.go:26
Function
TestLoadFromDirMissingIsSilent
(t *testing.T)
internal/subagent/loader_test.go:16
Function
TestLoadFromDirNameFallbackToFilename
(t *testing.T)
internal/subagent/loader_test.go:49
Function
TestLoadFromDirOverridesProgrammatic
(t *testing.T)
internal/subagent/loader_test.go:81
Function
TestLoadFromDirSkipsInvalid
(t *testing.T)
internal/subagent/loader_test.go:64
Function
TestLoadRules_InvalidJSON_ReturnsError
(t *testing.T)
internal/permission/rules_test.go:94
Function
TestLoadRules_MissingFile_ReturnsEmpty
(t *testing.T)
internal/permission/rules_test.go:84
Function
TestLoadRules_ValidJSON
(t *testing.T)
internal/permission/rules_test.go:58
Function
TestLoadSkills_EmptyDir
(t *testing.T)
internal/skills/skills_test.go:203
Function
TestLoadSkills_NonExistentDir
(t *testing.T)
internal/skills/skills_test.go:193
Function
TestLoadSkills_SkipsInvalidFrontmatter
(t *testing.T)
internal/skills/skills_test.go:237
Function
TestLoadSkills_SkipsSubdirWithoutSkillMd
(t *testing.T)
internal/skills/skills_test.go:257
Function
TestLoadSkills_ValidSkills
(t *testing.T)
internal/skills/skills_test.go:214
Function
TestLoad_DoesNotOverride
TestLoad_DoesNotOverride 验证已存在的系统环境变量不会被 .env 文件覆盖。 这确保了"系统环境变量 > .env 文件"的优先级策略。
internal/env/env_test.go:62
Function
TestLoad_DoesNotOverrideEmptyString
TestLoad_DoesNotOverrideEmptyString 验证手动设置为空字符串的环境变量不会被 .env 文件覆盖。 这区分了"变量未定义"与"变量被显式设置为空字符串"两种情况。
internal/env/env_test.go:123
Function
TestLoad_ExistingFile
TestLoad_ExistingFile 验证 Load 正确解析包含各种格式的 .env 文件: 普通值、双引号值、单引号值、空值
internal/env/env_test.go:15
Function
TestLoad_FileNotFound
TestLoad_FileNotFound 验证 .env 文件不存在时的优雅降级: Load 应返回 nil(而非错误),使程序可以在没有 .env 文件时仍正常运行。
internal/env/env_test.go:53
Function
TestLocalEnvironment_Close
(t *testing.T)
internal/sandbox/local_environment_test.go:68
Function
TestLocalEnvironment_ID
(t *testing.T)
internal/sandbox/local_environment_test.go:10
Function
TestLocalEnvironment_ReadWriteFile
(t *testing.T)
internal/sandbox/local_environment_test.go:39
Function
TestLocalEnvironment_RunBash_Failure
(t *testing.T)
internal/sandbox/local_environment_test.go:28
Function
TestLocalEnvironment_RunBash_Success
(t *testing.T)
internal/sandbox/local_environment_test.go:17
Function
TestLocalEnvironment_WriteFile_AutoMkdir
(t *testing.T)
internal/sandbox/local_environment_test.go:56
Function
TestLockPath_ExclusiveWriter
TestLockPath_ExclusiveWriter 验证写锁的排他性:写锁持有期间,其他写锁无法获取。 通过两个 goroutine 协同操作,验证锁的正确排他行为。
internal/tools/path_locker_test.go:34
Function
TestLooksLikeTestRun
TestLooksLikeTestRun 验证测试运行识别启发式:真实测试调用判 true,只读/安装命令判 false。
cmd/swebench/runner_test.go:20
Function
TestMCPPanelOverhead_LayoutConsistency
TestMCPPanelOverhead_LayoutConsistency 验证 mcpPanelOverhead 常量与实际布局吻合。 模拟 View() 拼接:panel + "\n" + statusBar,总行数应等于 contentH + mcpPanelOverhead。
cmd/harness9/tui_test.go:1290
Function
TestMCPToolAdapter_Definition
(t *testing.T)
internal/tools/mcp_adapter_test.go:27
Function
TestMCPToolAdapter_Execute
(t *testing.T)
internal/tools/mcp_adapter_test.go:42
Function
TestMCPToolAdapter_Name
(t *testing.T)
internal/tools/mcp_adapter_test.go:9
Function
TestManagerDBAccessor
(t *testing.T)
internal/memory/manager_test.go:187
Function
TestManager_BootstrapCmd_Runs
TestManager_BootstrapCmd_Runs 验证:配置 BootstrapCmd 时,容器就绪后通过 docker exec 执行一次该命令(接入官方预装镜像 / 依赖安装的关键接缝)。
internal/sandbox/manager_test.go:14
Function
TestManager_ConcurrentCreate
(t *testing.T)
internal/sandbox/manager_test.go:131
Function
TestManager_CreateAndListAll
(t *testing.T)
internal/sandbox/manager_test.go:78
Function
TestManager_CreatesDirectory
(t *testing.T)
internal/memory/manager_test.go:109
Function
TestManager_DeleteSession
(t *testing.T)
internal/memory/manager_test.go:82
Function
TestManager_DeleteSession_CleansOffloadDir
(t *testing.T)
internal/memory/manager_test.go:130
Function
TestManager_DeleteSession_NoToolResultsDir_NoError
(t *testing.T)
internal/memory/manager_test.go:170
Function
TestManager_Destroy
(t *testing.T)
internal/sandbox/manager_test.go:102
Function
TestManager_DestroyAll
(t *testing.T)
internal/sandbox/manager_test.go:114
Function
TestManager_InjectTools
TestManager_InjectTools 验证 InjectTools 将已连接 server 的工具注入 Registry, 返回值等于注入工具数量,且 Registry 中工具数量正确。
internal/mcp/manager_test.go:87
Function
TestManager_InjectTools_DuplicateSkipped
TestManager_InjectTools_DuplicateSkipped 验证对同一个 Registry 二次调用 InjectTools 时,已存在的工具被跳过,第二次调用返回 0。
internal/mcp/manager_test.go:116
← previous
next →
901–1,000 of 1,385, ranked by callers