feat(xce-harness-component): relocate xce_test into standalone harness component
Move xce_test's 15 production sources + headers from src/controller/testsuite/ into a new src/harness/ component with its own meson.build, and strip every now-dangling controller-side reference (11 controller_unit_test_src entries, 4 standalone test-binary blocks, 11 controller_test.c extern/RUN_TEST lines) so the controller build is never left broken. Fixes a broken relative-symlink bridge (xce_test_controller_link) added to keep two controller-embedded tests (test_test_cli.c, test_xcetest_process_entry.c) finding the relocated xce_test binary until task 2.1 moves them too. Discovered and documented in design.md: four controller-domain regression tests call functions directly from four of xce_test's own files, requiring controller_unit_test to permanently recompile them from src/harness/ — a real dependency neither the original discovery nor design audit caught. controller_unit_test: 1228 Tests 0 Failures 0 Ignored (verified via the Unity binary's own printed summary line, not just meson's aggregate count). Task 1.1 of xce-harness-component. Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01RLSNJhNoULvVcUhXEFafQC
This commit is contained in:
parent
b8ef82c1b2
commit
cf55d691de
36 changed files with 550 additions and 180 deletions
80
src/harness/rcfile.c
Normal file
80
src/harness/rcfile.c
Normal file
|
|
@ -0,0 +1,80 @@
|
|||
#define _GNU_SOURCE
|
||||
#include "rcfile.h"
|
||||
|
||||
#include <errno.h>
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
|
||||
/* Suffixes appended to the resolved base directory to form the rc-file
|
||||
* path -- kept as two separate constants (rather than one shared tail)
|
||||
* since the XDG_CONFIG_HOME branch is already rooted at a "config home"
|
||||
* directory while the HOME fallback still needs the "/.config" segment. */
|
||||
#define RCFILE_XDG_SUFFIX "/xce_test/rc"
|
||||
#define RCFILE_HOME_SUFFIX "/.config/xce_test/rc"
|
||||
|
||||
char* rcfile_resolve_path(void)
|
||||
{
|
||||
const char* xdg_config_home = getenv("XDG_CONFIG_HOME");
|
||||
if (xdg_config_home && *xdg_config_home) {
|
||||
size_t len = strlen(xdg_config_home) + strlen(RCFILE_XDG_SUFFIX) + 1;
|
||||
char* path = (char*)malloc(len);
|
||||
if (!path)
|
||||
return NULL;
|
||||
snprintf(path, len, "%s%s", xdg_config_home, RCFILE_XDG_SUFFIX);
|
||||
return path;
|
||||
}
|
||||
|
||||
const char* home = getenv("HOME");
|
||||
if (home && *home) {
|
||||
size_t len = strlen(home) + strlen(RCFILE_HOME_SUFFIX) + 1;
|
||||
char* path = (char*)malloc(len);
|
||||
if (!path)
|
||||
return NULL;
|
||||
snprintf(path, len, "%s%s", home, RCFILE_HOME_SUFFIX);
|
||||
return path;
|
||||
}
|
||||
|
||||
return NULL;
|
||||
}
|
||||
|
||||
int rcfile_load(const char* path, int (*runner)(char* line))
|
||||
{
|
||||
if (!path)
|
||||
return 0;
|
||||
|
||||
FILE* f = fopen(path, "r");
|
||||
if (!f) {
|
||||
if (errno == ENOENT)
|
||||
return 0; /* missing rc file: silent no-op success */
|
||||
fprintf(stderr, "xce_test: warning: could not open rc file %s: %s\n",
|
||||
path, strerror(errno));
|
||||
return 0; /* present but unreadable: non-fatal warning */
|
||||
}
|
||||
|
||||
int rc = 0;
|
||||
char* line = NULL;
|
||||
size_t cap = 0;
|
||||
ssize_t n;
|
||||
while ((n = getline(&line, &cap, f)) != -1) {
|
||||
if (n > 0 && line[n - 1] == '\n')
|
||||
line[n - 1] = '\0';
|
||||
rc = runner(line);
|
||||
if (rc != 0)
|
||||
break;
|
||||
}
|
||||
|
||||
/* fopen() succeeds on a directory on this platform -- the failure only
|
||||
* surfaces on the first read (getline() returns -1 with errno==EISDIR
|
||||
* and ferror(f) set, feof(f) NOT set). Treat that the same as an open
|
||||
* failure: one non-fatal stderr warning, no runner calls attributed to
|
||||
* it (rc is still 0 here since no line was ever successfully read). */
|
||||
if (rc == 0 && ferror(f)) {
|
||||
fprintf(stderr, "xce_test: warning: could not read rc file %s: %s\n",
|
||||
path, strerror(errno));
|
||||
}
|
||||
|
||||
free(line);
|
||||
fclose(f);
|
||||
return rc;
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue