mirror of
https://github.com/DeusData/codebase-memory-mcp.git
synced 2026-10-29 07:13:44 +08:00
test(portability): reuse filesystem wrappers in storage tests
Replace direct unlink/rmdir/remove calls in graph buffer, sqlite writer, store node, and token reduction tests with existing cbm filesystem compatibility wrappers. Validation: git diff --check; bash scripts/check-source-safety.sh; make -j8 -f Makefile.cbm build/c/test-runner; CBM_ONLY_SUITE=graph_buffer ./build/c/test-runner; CBM_ONLY_SUITE=sqlite_writer ./build/c/test-runner; CBM_ONLY_SUITE=store_nodes ./build/c/test-runner; CBM_ONLY_SUITE=token_reduction ./build/c/test-runner. Signed-off-by: Andrew Hundt <ATHundt@gmail.com>
This commit is contained in:
@@ -8,6 +8,7 @@
|
||||
#include "graph_buffer/graph_buffer.h"
|
||||
#include "store/store.h"
|
||||
#include "foundation/compat.h" /* cbm_mkstemp */
|
||||
#include "foundation/compat_fs.h"
|
||||
#include "foundation/constants.h"
|
||||
#include "foundation/platform.h"
|
||||
#include "sqlite3.h" /* vendored/sqlite3/ via -Ivendored/sqlite3 */
|
||||
@@ -650,7 +651,7 @@ TEST(gbuf_validate_invariants_valid_graph) {
|
||||
TEST(gbuf_dump_rejects_missing_edge_endpoint) {
|
||||
char path[256];
|
||||
ASSERT_EQ(gbuf_make_temp_db(path, sizeof(path)), 0);
|
||||
unlink(path);
|
||||
cbm_unlink(path);
|
||||
|
||||
cbm_gbuf_t *gb = cbm_gbuf_new("test", "/tmp");
|
||||
ASSERT_NOT_NULL(gb);
|
||||
@@ -1235,7 +1236,7 @@ TEST(gbuf_dump_pipeline_path_integrity) {
|
||||
ASSERT_GT(ecount, 0);
|
||||
|
||||
sqlite3_close(db);
|
||||
unlink(path);
|
||||
cbm_unlink(path);
|
||||
cbm_gbuf_free(gw);
|
||||
cbm_gbuf_free(gb);
|
||||
PASS();
|
||||
@@ -1265,7 +1266,7 @@ TEST(gbuf_dump_relative_root_path_retained) {
|
||||
fclose(f);
|
||||
}
|
||||
|
||||
unlink(path);
|
||||
cbm_unlink(path);
|
||||
cbm_gbuf_free(gb);
|
||||
PASS();
|
||||
}
|
||||
@@ -1305,7 +1306,7 @@ TEST(gbuf_dump_failure_before_replace_keeps_existing_db) {
|
||||
ASSERT(!gbuf_store_has_qn(path, "proj", "proj.new"));
|
||||
|
||||
cbm_gbuf_free(new_gb);
|
||||
unlink(path);
|
||||
cbm_unlink(path);
|
||||
PASS();
|
||||
}
|
||||
|
||||
|
||||
+11
-10
@@ -8,6 +8,7 @@
|
||||
* bypassing the SQL parser entirely. These tests verify integrity.
|
||||
*/
|
||||
#include "../src/foundation/compat.h"
|
||||
#include "../src/foundation/compat_fs.h"
|
||||
#include "../src/foundation/compat_thread.h"
|
||||
#include "../src/foundation/constants.h"
|
||||
#include "test_framework.h"
|
||||
@@ -183,7 +184,7 @@ TEST(sw_minimal_data) {
|
||||
sqlite3_finalize(stmt);
|
||||
|
||||
sqlite3_close(db);
|
||||
unlink(path);
|
||||
cbm_unlink(path);
|
||||
PASS();
|
||||
}
|
||||
|
||||
@@ -220,7 +221,7 @@ TEST(sw_store_open_migrates_exact_delta_metadata) {
|
||||
ASSERT_TRUE(cbm_test_sqlite_object_exists(db, "index", "idx_node_owners_path"));
|
||||
cbm_store_close(store);
|
||||
|
||||
unlink(path);
|
||||
cbm_unlink(path);
|
||||
PASS();
|
||||
}
|
||||
|
||||
@@ -374,7 +375,7 @@ TEST(sw_scale_and_indexes) {
|
||||
sqlite3_finalize(stmt);
|
||||
|
||||
sqlite3_close(db);
|
||||
unlink(path);
|
||||
cbm_unlink(path);
|
||||
PASS();
|
||||
}
|
||||
|
||||
@@ -450,7 +451,7 @@ TEST(sw_long_index_keys_overflow) {
|
||||
|
||||
free(longname);
|
||||
free(longqn);
|
||||
unlink(path);
|
||||
cbm_unlink(path);
|
||||
PASS();
|
||||
}
|
||||
|
||||
@@ -473,7 +474,7 @@ TEST(sw_empty) {
|
||||
sqlite3_finalize(stmt);
|
||||
|
||||
sqlite3_close(db);
|
||||
unlink(path);
|
||||
cbm_unlink(path);
|
||||
PASS();
|
||||
}
|
||||
|
||||
@@ -549,7 +550,7 @@ TEST(sw_vectors_and_token_vectors) {
|
||||
sqlite3_finalize(stmt);
|
||||
|
||||
sqlite3_close(db);
|
||||
unlink(path);
|
||||
cbm_unlink(path);
|
||||
PASS();
|
||||
}
|
||||
|
||||
@@ -626,7 +627,7 @@ TEST(sw_multi_page) {
|
||||
sqlite3_finalize(stmt);
|
||||
|
||||
sqlite3_close(db);
|
||||
unlink(path);
|
||||
cbm_unlink(path);
|
||||
PASS();
|
||||
}
|
||||
|
||||
@@ -690,7 +691,7 @@ TEST(sw_oversized_node) {
|
||||
sqlite3_finalize(stmt);
|
||||
|
||||
sqlite3_close(db);
|
||||
unlink(path);
|
||||
cbm_unlink(path);
|
||||
PASS();
|
||||
}
|
||||
|
||||
@@ -798,7 +799,7 @@ TEST(sw_scale_root_path_integrity) {
|
||||
sqlite3_finalize(stmt);
|
||||
|
||||
sqlite3_close(db);
|
||||
unlink(path);
|
||||
cbm_unlink(path);
|
||||
free(nodes);
|
||||
free(edges);
|
||||
free(namebuf);
|
||||
@@ -900,7 +901,7 @@ TEST(sw_concurrent_writes_are_independent) {
|
||||
ASSERT_EQ(verify_writer_db(jobs[i].path, jobs[i].project, jobs[i].root_path,
|
||||
jobs[i].node_count, jobs[i].edge_count),
|
||||
0);
|
||||
unlink(jobs[i].path);
|
||||
cbm_unlink(jobs[i].path);
|
||||
}
|
||||
PASS();
|
||||
}
|
||||
|
||||
@@ -9,6 +9,7 @@
|
||||
#include "test_helpers.h"
|
||||
#include "test_sqlite_helpers.h"
|
||||
#include <foundation/compat.h>
|
||||
#include <foundation/compat_fs.h>
|
||||
#include <foundation/constants.h>
|
||||
#include <store/store.h>
|
||||
#include <sqlite3.h>
|
||||
@@ -225,7 +226,7 @@ TEST(store_open_path_query_does_not_create_missing_db) {
|
||||
int fd = cbm_mkstemp_s(path, sizeof(path));
|
||||
ASSERT_GT(fd, -1);
|
||||
cbm_close_fd(fd);
|
||||
ASSERT_EQ(remove(path), 0);
|
||||
ASSERT_EQ(cbm_unlink(path), 0);
|
||||
|
||||
cbm_store_t *s = cbm_store_open_path_query(path);
|
||||
ASSERT_NULL(s);
|
||||
|
||||
@@ -8,6 +8,7 @@
|
||||
* until the corresponding feature is implemented (GREEN).
|
||||
*/
|
||||
#include "../src/foundation/compat.h"
|
||||
#include "../src/foundation/compat_fs.h"
|
||||
#include "test_framework.h"
|
||||
#include <mcp/mcp.h>
|
||||
#include <store/store.h>
|
||||
@@ -145,12 +146,12 @@ static cbm_mcp_server_t *setup_limit_test_server(char *tmp_dir, size_t tmp_sz) {
|
||||
static void cleanup_limit_test_dir(const char *tmp_dir) {
|
||||
char path[512];
|
||||
snprintf(path, sizeof(path), "%s/project/many.py", tmp_dir);
|
||||
unlink(path);
|
||||
cbm_unlink(path);
|
||||
snprintf(path, sizeof(path), "%s/project/big.py", tmp_dir);
|
||||
unlink(path);
|
||||
cbm_unlink(path);
|
||||
snprintf(path, sizeof(path), "%s/project", tmp_dir);
|
||||
rmdir(path);
|
||||
rmdir(tmp_dir);
|
||||
cbm_rmdir(path);
|
||||
cbm_rmdir(tmp_dir);
|
||||
}
|
||||
|
||||
/* ══════════════════════════════════════════════════════════════════
|
||||
|
||||
Reference in New Issue
Block a user