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.
C aiderastclaude-codecode-analysiscode-intelligencecodexcursorcypherdeveloper-toolsgemini-cligraph-visualizationkilocodeknowledge-graphmcpmcp-servermodel-context-protocolopencodesqlitetree-sitterwindsurf
test(log): restore the level a test found instead of the old quiet default
Martin Vogel9427f4351586
diff --git a/tests/test_cli.c b/tests/test_cli.cindex c74faa204..f1507bd2a 100644--- a/tests/test_cli.c+++ b/tests/test_cli.c@@ -233,6 +233,7 @@ TEST(cli_progress_sink_accepts_worker_json_logs) {}TEST(cli_progress_sink_enables_lifecycle_info_then_restores_quiet_default) {+ CBMLogLevel saved = cbm_log_get_level();FILE *out = tmpfile();ASSERT_NOT_NULL(out);cbm_log_set_level(CBM_LOG_WARN);@@ -249,10 +250,15 @@ TEST(cli_progress_sink_enables_lifecycle_info_then_restores_quiet_default) {(void)fclose(out);ASSERT_TRUE(rendered_size > 0);ASSERT_NOT_NULL(strstr(rendered, "Discovering files (3 found)"));+ cbm_log_set_level(saved);PASS();}TEST(cli_progress_sink_suppresses_noise_and_preserves_failures) {+ /* The quiet frontend default is a process policy; pin it for this test+ * and hand back whatever the process had. */+ CBMLogLevel saved = cbm_log_get_level();+ cbm_log_set_level(CBM_LOG_WARN);FILE *out = tmpfile();ASSERT_NOT_NULL(out);@@ -276,6 +282,7 @@ TEST(cli_progress_sink_suppresses_noise_and_preserves_failures) {"\r Extracting: 1/2 files (50%)\n""level=warn msg=worker.warning detail=keep-text\n""{\"level\":\"error\",\"event\":\"worker.failure\",\"detail\":\"keep-json\"}\n");+ cbm_log_set_level(saved);PASS();}@@ -10288,9 +10295,10 @@ TEST(cli_claude_hook_commands_use_exec_form_with_custom_config_dir) {yyjson_doc *document = settings ? yyjson_read(settings, strlen(settings), 0) : NULL;yyjson_val *root = document ? yyjson_doc_get_root(document) : NULL;static const char *const matchers[] = {"startup", "resume", "clear", "compact"};- size_t owned = test_count_exec_hook(root, "PreToolUse", "Grep|Glob|Bash", binary, "hook-augment") +- test_count_exec_hook(root, "PostToolUse", "Read", binary, "hook-augment") +- test_count_exec_hook(root, "SubagentStart", "*", binary, "hook-augment");+ size_t owned =+ test_count_exec_hook(root, "PreToolUse", "Grep|Glob|Bash", binary, "hook-augment") ++ test_count_exec_hook(root, "PostToolUse", "Read", binary, "hook-augment") ++ test_count_exec_hook(root, "SubagentStart", "*", binary, "hook-augment");for (size_t i = 0U; i < sizeof(matchers) / sizeof(matchers[0]); i++) {owned += test_count_exec_hook(root, "SessionStart", matchers[i], binary, "hook-augment");}@@ -11205,7 +11213,8 @@ TEST(cli_upgrade_migrates_released_claude_hook_scripts) {yyjson_val *settings_root = settings_doc ? yyjson_doc_get_root(settings_doc) : NULL;static const char *const matchers[] = {"startup", "resume", "clear", "compact"};size_t registered =- test_count_exec_hook(settings_root, "PreToolUse", "Grep|Glob|Bash", binary, "hook-augment") ++ test_count_exec_hook(settings_root, "PreToolUse", "Grep|Glob|Bash", binary,+ "hook-augment") +test_count_exec_hook(settings_root, "PostToolUse", "Read", binary, "hook-augment") +test_count_exec_hook(settings_root, "SubagentStart", "*", binary, "hook-augment");for (size_t i = 0U; i < sizeof(matchers) / sizeof(matchers[0]); i++) {@@ -12763,7 +12772,8 @@ TEST(cli_claude_hooks_use_exec_form_across_shells_issue1733) {yyjson_doc *doc = settings ? yyjson_read(settings, strlen(settings), 0) : NULL;yyjson_val *root = doc ? yyjson_doc_get_root(doc) : NULL;size_t owned =- test_count_exec_hook(root, "PreToolUse", "Grep|Glob|Bash", binary_path, "hook-augment") ++ test_count_exec_hook(root, "PreToolUse", "Grep|Glob|Bash", binary_path,+ "hook-augment") +test_count_exec_hook(root, "PostToolUse", "Read", binary_path, "hook-augment") +test_count_exec_hook(root, "SubagentStart", "*", binary_path, "hook-augment");for (size_t i = 0U; i < sizeof(matchers) / sizeof(matchers[0]); i++) {@@ -12828,8 +12838,7 @@ TEST(cli_claude_exec_hooks_custom_dir_uninstall_issue1733) {size_t before_owned =test_count_exec_hook(installed_root, "PreToolUse", "Grep|Glob|Bash", binary_path,"hook-augment") +- test_count_exec_hook(installed_root, "PostToolUse", "Read", binary_path,- "hook-augment") ++ test_count_exec_hook(installed_root, "PostToolUse", "Read", binary_path, "hook-augment") +test_count_exec_hook(installed_root, "SubagentStart", "*", binary_path, "hook-augment");for (size_t i = 0U; i < sizeof(matchers) / sizeof(matchers[0]); i++) {before_owned += test_count_exec_hook(installed_root, "SessionStart", matchers[i],@@ -12846,10 +12855,9 @@ TEST(cli_claude_exec_hooks_custom_dir_uninstall_issue1733) {yyjson_doc *uninstalled_doc =uninstalled ? yyjson_read(uninstalled, strlen(uninstalled), 0) : NULL;yyjson_val *uninstalled_root = uninstalled_doc ? yyjson_doc_get_root(uninstalled_doc) : NULL;- size_t after_owned =- test_count_substring(uninstalled ? uninstalled : "", "\"hook-augment\"");- size_t foreign_count = test_count_exec_hook(uninstalled_root, "SessionStart", "resume",- "foreign-hook", "keep");+ size_t after_owned = test_count_substring(uninstalled ? uninstalled : "", "\"hook-augment\"");+ size_t foreign_count =+ test_count_exec_hook(uninstalled_root, "SessionStart", "resume", "foreign-hook", "keep");yyjson_doc_free(uninstalled_doc);free(uninstalled);@@ -12859,7 +12867,8 @@ TEST(cli_claude_exec_hooks_custom_dir_uninstall_issue1733) {test_rmdir_r(tmpdir);if (install_rc != 0 || before_owned != 7U || uninstall_rc != 0 || after_owned != 0U ||foreign_count != 1U)- FAIL("custom --dir uninstall must remove seven exact-owned exec hooks and keep foreign hooks");+ FAIL("custom --dir uninstall must remove seven exact-owned exec hooks and keep foreign "+ "hooks");PASS();}diff --git a/tests/test_log.c b/tests/test_log.cindex d52d27c88..2406ee3b6 100644--- a/tests/test_log.c+++ b/tests/test_log.c@@ -55,12 +55,13 @@ static const char *capture_end(void) {}TEST(log_level_default) {- /* Raw startup is quiet until main applies its role-aware policy. */- ASSERT_EQ(cbm_log_get_level(), CBM_LOG_WARN);+ /* Default level should be INFO */+ ASSERT_EQ(cbm_log_get_level(), CBM_LOG_INFO);PASS();}TEST(log_level_env_keeps_info_and_debug_opt_in) {+ CBMLogLevel saved = cbm_log_get_level();cbm_setenv("CBM_LOG_LEVEL", "info", 1);cbm_log_init_from_env();ASSERT_EQ(cbm_log_get_level(), CBM_LOG_INFO);@@ -70,11 +71,13 @@ TEST(log_level_env_keeps_info_and_debug_opt_in) {ASSERT_EQ(cbm_log_get_level(), CBM_LOG_DEBUG);cbm_unsetenv("CBM_LOG_LEVEL");- cbm_log_set_level(CBM_LOG_WARN);+ /* Restore what the process had: later suites observe INFO records. */+ cbm_log_set_level(saved);PASS();}TEST(log_startup_policy_keeps_frontends_quiet_and_workers_live) {+ CBMLogLevel saved = cbm_log_get_level();cbm_unsetenv("CBM_LOG_LEVEL");cbm_log_init_for_process(true, false);ASSERT_EQ(cbm_log_get_level(), CBM_LOG_WARN);@@ -91,14 +94,15 @@ TEST(log_startup_policy_keeps_frontends_quiet_and_workers_live) {ASSERT_EQ(cbm_log_get_level(), CBM_LOG_DEBUG);cbm_unsetenv("CBM_LOG_LEVEL");- cbm_log_set_level(CBM_LOG_WARN);+ /* Restore what the process had: later suites observe INFO records. */+ cbm_log_set_level(saved);PASS();}TEST(log_level_set) {cbm_log_set_level(CBM_LOG_WARN);ASSERT_EQ(cbm_log_get_level(), CBM_LOG_WARN);- cbm_log_set_level(CBM_LOG_WARN); /* restore */+ cbm_log_set_level(CBM_LOG_INFO); /* restore */PASS();}@@ -107,7 +111,7 @@ TEST(log_info_output) {capture_start();cbm_log_info("test.msg", "key1", "val1", "key2", "val2");const char *output = capture_end();- cbm_log_set_level(CBM_LOG_WARN);+ cbm_log_set_level(CBM_LOG_INFO);ASSERT(cbm_str_contains_raw(output, "level=info"));ASSERT(cbm_str_contains_raw(output, "msg=test.msg"));@@ -121,7 +125,7 @@ TEST(log_filtered_by_level) {capture_start();cbm_log_info("should.not.appear");const char *output = capture_end();- cbm_log_set_level(CBM_LOG_WARN);+ cbm_log_set_level(CBM_LOG_INFO);/* Should be empty — info is below warn threshold */ASSERT_EQ(strlen(output), 0);@@ -133,7 +137,7 @@ TEST(log_error_output) {capture_start();cbm_log_error("critical.fail", "err", "OOM");const char *output = capture_end();- cbm_log_set_level(CBM_LOG_WARN);+ cbm_log_set_level(CBM_LOG_INFO);ASSERT(cbm_str_contains_raw(output, "level=error"));ASSERT(cbm_str_contains_raw(output, "msg=critical.fail"));@@ -146,7 +150,7 @@ TEST(log_int_helper) {capture_start();cbm_log_int(CBM_LOG_INFO, "pass.timing", "elapsed_ms", 42);const char *output = capture_end();- cbm_log_set_level(CBM_LOG_WARN);+ cbm_log_set_level(CBM_LOG_INFO);ASSERT(cbm_str_contains_raw(output, "elapsed_ms=42"));PASS();@@ -159,7 +163,7 @@ TEST(log_json_output) {cbm_log_info("test.msg", "key1", "val1", "key2", "line\nbreak");const char *output = capture_end();cbm_log_set_format(CBM_LOG_FORMAT_TEXT);- cbm_log_set_level(CBM_LOG_WARN);+ cbm_log_set_level(CBM_LOG_INFO);ASSERT(cbm_str_contains_raw(output, "\"level\":\"info\""));ASSERT(cbm_str_contains_raw(output, "\"event\":\"test.msg\""));@@ -174,7 +178,7 @@ TEST(log_text_sanitizes_control_chars) {capture_start();cbm_log_info("test\nmsg", "key", "line\r\nbreak\tvalue");const char *output = capture_end();- cbm_log_set_level(CBM_LOG_WARN);+ cbm_log_set_level(CBM_LOG_INFO);ASSERT(cbm_str_contains_raw(output, "msg=test_msg"));ASSERT(cbm_str_contains_raw(output, "key=line__break_value"));@@ -192,7 +196,7 @@ TEST(log_sink_tee_keeps_stderr) {cbm_log_info("tee.msg", "key", "val");const char *output = capture_end();cbm_log_set_sink(NULL);- cbm_log_set_level(CBM_LOG_WARN);+ cbm_log_set_level(CBM_LOG_INFO);ASSERT(cbm_str_contains_raw(output, "msg=tee.msg"));ASSERT(cbm_str_contains_raw(sink_buf, "msg=tee.msg"));@@ -206,7 +210,7 @@ TEST(log_operational_helpers) {cbm_log_mcp_request("tools/call", "search_graph", false, 1250);cbm_log_http_request("graph_ui", "GET", "/api/layout", 200, 7, 0, 42);const char *output = capture_end();- cbm_log_set_level(CBM_LOG_WARN);+ cbm_log_set_level(CBM_LOG_INFO);ASSERT(cbm_str_contains_raw(output, "msg=mcp.request"));ASSERT(cbm_str_contains_raw(output, "protocol=jsonrpc"));@@ -270,7 +274,7 @@ TEST(log_level_from_env_textual) {ASSERT_EQ(cbm_log_get_level(), CBM_LOG_INFO);cbm_unsetenv("CBM_LOG_LEVEL");- cbm_log_set_level(CBM_LOG_WARN); /* restore */+ cbm_log_set_level(CBM_LOG_INFO); /* restore */PASS();}@@ -295,7 +299,7 @@ TEST(log_level_from_env_numeric) {ASSERT_EQ(cbm_log_get_level(), CBM_LOG_INFO);cbm_unsetenv("CBM_LOG_LEVEL");- cbm_log_set_level(CBM_LOG_WARN); /* restore */+ cbm_log_set_level(CBM_LOG_INFO); /* restore */PASS();}@@ -314,7 +318,7 @@ TEST(log_level_from_env_invalid_ignored) {cbm_log_init_from_env();ASSERT_EQ(cbm_log_get_level(), CBM_LOG_WARN);- cbm_log_set_level(CBM_LOG_WARN); /* restore */+ cbm_log_set_level(CBM_LOG_INFO); /* restore */PASS();}