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: gate LSP benchmarks behind CBM_SKIP_PERF; fix Windows test portability

Martin Vogela805668ef84b
diff --git a/tests/test_cs_lsp_bench.c b/tests/test_cs_lsp_bench.c
index 0c5ce95b9..f9bceb8cc 100644
--- a/tests/test_cs_lsp_bench.c
+++ b/tests/test_cs_lsp_bench.c
@@ -29,6 +29,7 @@
#include "test_framework.h"
#include "cbm.h"
#include "lsp/cs_lsp.h"
+#include <stdlib.h>
#include <time.h>
static const char *bench_source =
@@ -186,6 +187,13 @@ static double elapsed_ms(struct timespec t0, struct timespec t1) {
}
TEST(cslsp_bench_resolution_ratio) {
+ /* Perf benchmark: time-budgeted, so skip under CBM_SKIP_PERF (set by the
+ * CI dry-run). Under ASan+UBSan the budget is unattainable and an early
+ * assert-bail would leak the result; runs normally when perf is enabled. */
+ const char *skip = getenv("CBM_SKIP_PERF");
+ if (skip && skip[0] && skip[0] != '0') {
+ SKIP("CBM_SKIP_PERF=1 (perf benchmark)");
+ }
int slen = (int)strlen(bench_source);
struct timespec t0;
diff --git a/tests/test_path_alias.c b/tests/test_path_alias.c
index 24e6ee842..52ac576a8 100644
--- a/tests/test_path_alias.c
+++ b/tests/test_path_alias.c
@@ -8,6 +8,7 @@
*/
#include "test_framework.h"
#include "../src/pipeline/path_alias.h"
+#include "../src/foundation/compat.h"
#include <stdarg.h>
#include <stdio.h>
@@ -33,7 +34,7 @@ static cbm_path_alias_map_t *make_map(const char *base_url, int count, ...) {
if (star) {
map->entries[i].has_wildcard = true;
map->entries[i].alias_prefix =
- strndup(alias_pattern, (size_t)(star - alias_pattern));
+ cbm_strndup(alias_pattern, (size_t)(star - alias_pattern));
map->entries[i].alias_suffix = strdup(star + 1);
} else {
map->entries[i].has_wildcard = false;
@@ -43,7 +44,7 @@ static cbm_path_alias_map_t *make_map(const char *base_url, int count, ...) {
const char *tstar = strchr(target_pattern, '*');
if (tstar) {
map->entries[i].target_prefix =
- strndup(target_pattern, (size_t)(tstar - target_pattern));
+ cbm_strndup(target_pattern, (size_t)(tstar - target_pattern));
map->entries[i].target_suffix = strdup(tstar + 1);
} else {
map->entries[i].target_prefix = strdup(target_pattern);
@@ -234,9 +235,9 @@ TEST(path_alias_loader_monorepo) {
char sub[512];
snprintf(sub, sizeof(sub), "%s/apps", root);
- mkdir(sub, 0755);
+ cbm_mkdir(sub);
snprintf(sub, sizeof(sub), "%s/apps/manager", root);
- mkdir(sub, 0755);
+ cbm_mkdir(sub);
char path[512];
snprintf(path, sizeof(path), "%s/tsconfig.json", root);
diff --git a/tests/test_pipeline.c b/tests/test_pipeline.c
index 08f5dbafc..0dbe9fb93 100644
--- a/tests/test_pipeline.c
+++ b/tests/test_pipeline.c
@@ -4663,6 +4663,7 @@ TEST(incremental_fast_preserves_mode_skipped_tools_dir) {
fclose(f);
/* Bump mtime explicitly — some filesystems have coarse mtime resolution
* and the rewrite could land in the same tick as the original write. */
+#ifndef _WIN32
struct stat mst;
if (stat(path, &mst) == 0) {
struct timespec times[2];
@@ -4672,6 +4673,7 @@ TEST(incremental_fast_preserves_mode_skipped_tools_dir) {
times[1].tv_nsec = 0;
utimensat(AT_FDCWD, path, times, 0);
}
+#endif /* !_WIN32 */
p = cbm_pipeline_new(tmpdir, dbpath, CBM_MODE_FAST);
ASSERT_NOT_NULL(p);
diff --git a/tests/test_py_lsp_bench.c b/tests/test_py_lsp_bench.c
index 0ada8be80..2e54b6807 100644
--- a/tests/test_py_lsp_bench.c
+++ b/tests/test_py_lsp_bench.c
@@ -28,6 +28,7 @@
#include "test_framework.h"
#include "cbm.h"
#include "lsp/py_lsp.h"
+#include <stdlib.h>
#include <time.h>
static const char *bench_source =
@@ -217,6 +218,13 @@ static double elapsed_ms(struct timespec t0, struct timespec t1) {
}
TEST(pylsp_bench_resolution_ratio) {
+ /* Perf benchmark: time-budgeted, so skip under CBM_SKIP_PERF (set by the
+ * CI dry-run). Under ASan+UBSan the budget is unattainable and an early
+ * assert-bail would leak the result; runs normally when perf is enabled. */
+ const char *skip = getenv("CBM_SKIP_PERF");
+ if (skip && skip[0] && skip[0] != '0') {
+ SKIP("CBM_SKIP_PERF=1 (perf benchmark)");
+ }
int slen = (int)strlen(bench_source);
struct timespec t0;
diff --git a/tests/test_store_pragmas.c b/tests/test_store_pragmas.c
index ee573b743..fdc5377ce 100644
--- a/tests/test_store_pragmas.c
+++ b/tests/test_store_pragmas.c
@@ -17,7 +17,7 @@
#include <unistd.h>
static void clear_mmap_env(void) {
- unsetenv("CBM_SQLITE_MMAP_SIZE");
+ cbm_unsetenv("CBM_SQLITE_MMAP_SIZE");
}
TEST(mmap_size_default_when_unset) {
@@ -27,35 +27,35 @@ TEST(mmap_size_default_when_unset) {
}
TEST(mmap_size_zero_disables_mmap) {
- setenv("CBM_SQLITE_MMAP_SIZE", "0", 1);
+ cbm_setenv("CBM_SQLITE_MMAP_SIZE", "0", 1);
ASSERT_EQ(cbm_store_resolve_mmap_size(), 0LL);
clear_mmap_env();
PASS();
}
TEST(mmap_size_explicit_value) {
- setenv("CBM_SQLITE_MMAP_SIZE", "1048576", 1);
+ cbm_setenv("CBM_SQLITE_MMAP_SIZE", "1048576", 1);
ASSERT_EQ(cbm_store_resolve_mmap_size(), 1048576LL);
clear_mmap_env();
PASS();
}
TEST(mmap_size_negative_clamped_to_zero) {
- setenv("CBM_SQLITE_MMAP_SIZE", "-1", 1);
+ cbm_setenv("CBM_SQLITE_MMAP_SIZE", "-1", 1);
ASSERT_EQ(cbm_store_resolve_mmap_size(), 0LL);
clear_mmap_env();
PASS();
}
TEST(mmap_size_garbage_falls_back_to_default) {
- setenv("CBM_SQLITE_MMAP_SIZE", "not-a-number", 1);
+ cbm_setenv("CBM_SQLITE_MMAP_SIZE", "not-a-number", 1);
ASSERT_EQ(cbm_store_resolve_mmap_size(), 67108864LL);
clear_mmap_env();
PASS();
}
TEST(mmap_size_partial_garbage_falls_back_to_default) {
- setenv("CBM_SQLITE_MMAP_SIZE", "123abc", 1);
+ cbm_setenv("CBM_SQLITE_MMAP_SIZE", "123abc", 1);
ASSERT_EQ(cbm_store_resolve_mmap_size(), 67108864LL);
clear_mmap_env();
PASS();
@@ -64,7 +64,7 @@ TEST(mmap_size_partial_garbage_falls_back_to_default) {
/* Integration smoke: opening a file-backed store with mmap_size=0 must
* succeed. Proves the resolver is wired through configure_pragmas(). */
TEST(store_open_with_mmap_disabled) {
- setenv("CBM_SQLITE_MMAP_SIZE", "0", 1);
+ cbm_setenv("CBM_SQLITE_MMAP_SIZE", "0", 1);
char tmp_path[256];
snprintf(tmp_path, sizeof(tmp_path), "/tmp/cbm_test_pragmas_%d.db", (int)getpid());
unlink(tmp_path);
diff --git a/tests/test_ts_lsp.c b/tests/test_ts_lsp.c
index 06e906b7c..1b91de178 100644
--- a/tests/test_ts_lsp.c
+++ b/tests/test_ts_lsp.c
@@ -23,6 +23,7 @@
*/
#include "test_framework.h"
#include "cbm.h"
+#include "../src/foundation/compat.h"
#include "lsp/ts_lsp.h"
/* ── Helpers ───────────────────────────────────────────────────────────────── */
@@ -2555,13 +2556,13 @@ TEST(tslsp_baseline_vs_lsp_simple) {
"class Conn { ping(): void {} }\n"
"function go(c: Conn) { c.ping(); }\n";
- setenv("CBM_LSP_DISABLED", "1", 1);
+ cbm_setenv("CBM_LSP_DISABLED", "1", 1);
CBMFileResult *base = extract_ts(source);
int br = 0, bu = 0, bt = 0;
count_calls(base, &br, &bu, &bt);
cbm_free_result(base);
- unsetenv("CBM_LSP_DISABLED");
+ cbm_unsetenv("CBM_LSP_DISABLED");
CBMFileResult *lsp = extract_ts(source);
int lr = 0, lu = 0, lt = 0;
count_calls(lsp, &lr, &lu, &lt);
@@ -2579,13 +2580,13 @@ TEST(tslsp_baseline_vs_lsp_chained) {
"function newQ(): Q { return new Q(); }\n"
"function go() { newQ().where('x').limit(5).execute(); }\n";
- setenv("CBM_LSP_DISABLED", "1", 1);
+ cbm_setenv("CBM_LSP_DISABLED", "1", 1);
CBMFileResult *base = extract_ts(source);
int br = 0, bu = 0, bt = 0;
count_calls(base, &br, &bu, &bt);
cbm_free_result(base);
- unsetenv("CBM_LSP_DISABLED");
+ cbm_unsetenv("CBM_LSP_DISABLED");
CBMFileResult *lsp = extract_ts(source);
int lr = 0, lu = 0, lt = 0;
count_calls(lsp, &lr, &lu, &lt);
@@ -2601,13 +2602,13 @@ TEST(tslsp_baseline_vs_lsp_callbacks) {
"class Box { run(): void {} }\n"
"function go(boxes: Box[]) { boxes.map(b => b.run()).forEach(_x => {}); }\n";
- setenv("CBM_LSP_DISABLED", "1", 1);
+ cbm_setenv("CBM_LSP_DISABLED", "1", 1);
CBMFileResult *base = extract_ts(source);
int br = 0, bu = 0, bt = 0;
count_calls(base, &br, &bu, &bt);
cbm_free_result(base);
- unsetenv("CBM_LSP_DISABLED");
+ cbm_unsetenv("CBM_LSP_DISABLED");
CBMFileResult *lsp = extract_ts(source);
int lr = 0, lu = 0, lt = 0;
count_calls(lsp, &lr, &lu, &lt);
@@ -2624,13 +2625,13 @@ TEST(tslsp_baseline_vs_lsp_narrowing) {
"class B { pong(): void {} }\n"
"function go(x: A | B) { if (x instanceof A) x.ping(); else x.pong(); }\n";
- setenv("CBM_LSP_DISABLED", "1", 1);
+ cbm_setenv("CBM_LSP_DISABLED", "1", 1);
CBMFileResult *base = extract_ts(source);
int br = 0, bu = 0, bt = 0;
count_calls(base, &br, &bu, &bt);
cbm_free_result(base);
- unsetenv("CBM_LSP_DISABLED");
+ cbm_unsetenv("CBM_LSP_DISABLED");
CBMFileResult *lsp = extract_ts(source);
int lr = 0, lu = 0, lt = 0;
count_calls(lsp, &lr, &lu, &lt);