Skip to content

Commit 0d7a9a8

Browse files
committed
Fix Windows UI config tests: replace system("mkdir -p") with cbm_mkdir_p()
Two UI config tests (config_corrupt_file, config_missing_fields) used Unix-only system("mkdir -p") to create test directories. On Windows this fails with "The syntax of the command is incorrect." — replaced with the portable cbm_mkdir_p() function already in compat_fs.h.
1 parent 3abc5cd commit 0d7a9a8

1 file changed

Lines changed: 6 additions & 7 deletions

File tree

tests/test_ui.c

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
* Covers: config persistence, embedded asset lookup, layout engine.
55
*/
66
#include "../src/foundation/compat.h"
7+
#include "../src/foundation/compat_fs.h"
78
#include "test_framework.h"
89
#include "ui/config.h"
910
#include "ui/embedded_assets.h"
@@ -13,7 +14,9 @@
1314
#include <stdio.h>
1415
#include <stdlib.h>
1516
#include <string.h>
17+
#ifndef _WIN32
1618
#include <unistd.h>
19+
#endif
1720

1821
/* ── Config tests ─────────────────────────────────────────────── */
1922

@@ -113,12 +116,10 @@ TEST(config_corrupt_file) {
113116
char path[1024];
114117
cbm_ui_config_path(path, (int)sizeof(path));
115118

116-
/* Ensure directory exists */
119+
/* Ensure directory exists (portable — no system("mkdir -p")) */
117120
char dir[1024];
118121
snprintf(dir, sizeof(dir), "%s/.cache/codebase-memory-mcp", td);
119-
char cmd[1200];
120-
snprintf(cmd, sizeof(cmd), "mkdir -p %s", dir);
121-
(void)system(cmd);
122+
cbm_mkdir_p(dir, 0755);
122123

123124
FILE *f = fopen(path, "w");
124125
ASSERT_NOT_NULL(f);
@@ -153,9 +154,7 @@ TEST(config_missing_fields) {
153154

154155
char dir[1024];
155156
snprintf(dir, sizeof(dir), "%s/.cache/codebase-memory-mcp", td);
156-
char cmd[1200];
157-
snprintf(cmd, sizeof(cmd), "mkdir -p %s", dir);
158-
(void)system(cmd);
157+
cbm_mkdir_p(dir, 0755);
159158

160159
FILE *f = fopen(path, "w");
161160
ASSERT_NOT_NULL(f);

0 commit comments

Comments
 (0)