Skip to content

Local code intelligence for developers and AI agents. Connect code, docs and infrastructure in a persistent graph, with CBM Lens, MCP tools, agent integrations and change-aware test selection.

test(config): a v0.10.2 Codex block now upgrades in place to the PreToolUse block

Martin Vogel18d7273b745f
diff --git a/tests/test_config_toml_edit.c b/tests/test_config_toml_edit.c
index 68930617c..43c390a8b 100644
--- a/tests/test_config_toml_edit.c
+++ b/tests/test_config_toml_edit.c
@@ -1457,14 +1457,18 @@ TEST(config_toml_codex_accepts_v0102_managed_windows_crlf) {
ASSERT_EQ(cte_read(path, actual, sizeof(actual)), 0);
ASSERT_STR_EQ(actual, before);
+ /* The v0.10.2 lifecycle-only block is ours: the upsert upgrades it in place to
+ * the current block (which adds PreToolUse Bash) and keeps the BOM, CRLF and
+ * the surrounding tables; a second upsert is then byte-identical. */
ASSERT_EQ(cte_codex_edit_commands_detailed(path, command, command_windows,
CBM_TOML_CODEX_HOOK_UPSERT, 0, &failure),
0);
ASSERT_EQ(cte_read(path, actual, sizeof(actual)), 0);
- ASSERT_STR_EQ(actual, before);
+ ASSERT_EQ(strncmp(actual, "\xEF\xBB\xBF", 3U), 0);
ASSERT_EQ(cte_occurrences(actual, CTE_CODEX_BEGIN), 1);
ASSERT_EQ(cte_occurrences(actual, "[[hooks.SessionStart]]"), 1);
ASSERT_EQ(cte_occurrences(actual, "[[hooks.SubagentStart]]"), 1);
+ ASSERT_EQ(cte_occurrences(actual, "[[hooks.PreToolUse]]"), 1);
ASSERT_NOT_NULL(strstr(actual, "[mcp_servers.other]"));
ASSERT_NOT_NULL(strstr(actual, "keep = true"));
for (const char *cursor = actual; *cursor; ++cursor) {
@@ -1472,12 +1476,14 @@ TEST(config_toml_codex_accepts_v0102_managed_windows_crlf) {
ASSERT(cursor > actual && cursor[-1] == '\r');
}
}
+ char upgraded[CTE_FILE_CAP];
+ ASSERT_GT(snprintf(upgraded, sizeof(upgraded), "%s", actual), 0);
ASSERT_EQ(cte_codex_edit_commands_detailed(path, command, command_windows,
CBM_TOML_CODEX_HOOK_UPSERT, 0, &failure),
0);
ASSERT_EQ(cte_read(path, actual, sizeof(actual)), 0);
- ASSERT_STR_EQ(actual, before);
+ ASSERT_STR_EQ(actual, upgraded);
ASSERT_EQ(cte_codex_edit_commands_detailed(path, command, command_windows,
CBM_TOML_CODEX_HOOK_REMOVE, 0, &failure),