tests: keep their sessions out of ~/.splinter
`make check` created a session for every splinter invocation that did not set HOME - the A2A and gateway scripts pass --no-config, which does not change the session directory. The user's ~/.splinter collected hundreds of "hallo", "fehler" and "auth ohne token" sessions; the last three in /sessions were test noise that looked like aborted chats. - SPLINTER_SESSION_DIR overrides the session directory (o->session_dir still wins when a caller names one, so test_engine keeps its temp dir). - make check exports a mktemp session dir and removes it on exit; the scripts that inspect $D/home/.splinter point the variable there. - docs/CONFIG documents the variable. - the existing test sessions were moved to ~/.splinter/test-sessions-2026-11-18 (not deleted) so /sessions shows the real conversations again. make check: all tests passed; ~/.splinter kept 211 sessions before and after.
This commit is contained in:
1 parent
ddf0ec5462
commit
4be6e26f78
10 files changed
+21
-1
No files matched your search
@@ -288,6 +288,9 @@ tests/test_plugin: tests/test_plugin.c $(LIB) $(PLUGIN)
|
||||
check: $(LIB) $(BIN) $(CLIENT) $(PLUGIN) $(TESTS) tests/test_junction
|
||||
@set -e; python3 tools/check_i18n.py; \
|
||||
export LD_LIBRARY_PATH=.; \
|
||||
SPLINTER_SESSION_DIR=$$(mktemp -d "$${TMPDIR:-/tmp}/splinter-check-XXXXXX"); \
|
||||
export SPLINTER_SESSION_DIR; \
|
||||
trap 'rm -rf "$$SPLINTER_SESSION_DIR"' EXIT; \
|
||||
for t in $(TESTS); do echo "== $$t"; ./$$t; done; \
|
||||
echo "== tests/test_delegate_cli.sh"; sh tests/test_delegate_cli.sh; \
|
||||
echo "== tests/test_interview.sh"; sh tests/test_interview.sh; \
|
||||
|
||||
+1
-1
@@ -245,7 +245,7 @@ lies about what it does.
|
||||
| `max_bytes` | conversation budget in bytes, `0` = no limit |
|
||||
| `compact_threshold` | context tokens past which the next request is compacted (`0` = off) |
|
||||
| `compact_target` | the size compaction aims for, in tokens; `/compact [tokens]` forces it now |
|
||||
| `session_dir` | where session logs go (default `~/.splinter`) |
|
||||
| `session_dir` | where session logs go (default `~/.splinter`); `SPLINTER_SESSION_DIR` overrides it, which is how `make check` keeps its test sessions out of yours |
|
||||
| `system_prompt` | sent once at the start of a conversation |
|
||||
| `telegram_allow` | user ids the gateway answers, comma-separated; empty means nobody |
|
||||
| `skills_dir` | a directory of skills, one line each |
|
||||
|
||||
@@ -2521,7 +2521,15 @@ open_session(struct sp_engine *e, const struct sp_engine_opts *o,
|
||||
static char sessbuf[512], idbuf[64];
|
||||
const char *dir = o->session_dir;
|
||||
const char *id = o->session_id;
|
||||
const char *envdir = getenv("SPLINTER_SESSION_DIR");
|
||||
|
||||
/*
|
||||
* Tests and throwaway runs get their own directory without a config:
|
||||
* the suite used to create hundreds of "hallo" sessions in the user's
|
||||
* ~/.splinter because --no-config does not change where sessions go.
|
||||
*/
|
||||
if (dir == NULL && envdir != NULL && *envdir != '\0')
|
||||
dir = envdir;
|
||||
if (dir == NULL) {
|
||||
const char *home = getenv("HOME");
|
||||
|
||||
|
||||
@@ -8,6 +8,7 @@
|
||||
set -u
|
||||
cd "$(dirname "$0")/.." || exit 1
|
||||
D=$(mktemp -d "${TMPDIR:-/var/tmp}/splinter-a2a-XXXXXX") || exit 1
|
||||
SPLINTER_SESSION_DIR="$D/home/.splinter"; export SPLINTER_SESSION_DIR
|
||||
P=$((20000 + ($$ % 20000)))
|
||||
F=
|
||||
cleanup() { [ -n "$F" ] && kill "$F" 2>/dev/null; rm -rf "$D"; }
|
||||
|
||||
@@ -7,6 +7,7 @@
|
||||
set -u
|
||||
cd "$(dirname "$0")/.." || exit 1
|
||||
D=$(mktemp -d "${TMPDIR:-/var/tmp}/splinter-a2a-srv-XXXXXX") || exit 1
|
||||
SPLINTER_SESSION_DIR="$D/home/.splinter"; export SPLINTER_SESSION_DIR
|
||||
P=$((20000 + ($$ % 20000)))
|
||||
P2=$((P + 1))
|
||||
P3=$((P + 2))
|
||||
|
||||
@@ -5,6 +5,7 @@ set -u
|
||||
cd "$(dirname "$0")/.." || exit 1
|
||||
command -v tmux >/dev/null 2>&1 || { echo "test_agents_ui: skipped (no tmux)"; exit 0; }
|
||||
D=$(mktemp -d "${TMPDIR:-/var/tmp}/splinter-ag-XXXXXX") || exit 1
|
||||
SPLINTER_SESSION_DIR="$D/home/.splinter"; export SPLINTER_SESSION_DIR
|
||||
# Our own socket, never the user's. $TMUX (set when this runs inside somebody's
|
||||
# tmux) wins over TMUX_TMPDIR, so drop it and point the server at $D: a key
|
||||
# this test sends can then not land in a real session, and the kill-session
|
||||
|
||||
@@ -9,6 +9,7 @@
|
||||
set -u
|
||||
cd "$(dirname "$0")/.." || exit 1
|
||||
D=$(mktemp -d "${TMPDIR:-/var/tmp}/splinter-gw-XXXXXX") || exit 1
|
||||
SPLINTER_SESSION_DIR="$D/home/.splinter"; export SPLINTER_SESSION_DIR
|
||||
trap 'rm -rf "$D"' EXIT
|
||||
fails=0
|
||||
|
||||
|
||||
@@ -7,6 +7,7 @@
|
||||
set -u
|
||||
cd "$(dirname "$0")/.." || exit 1
|
||||
D=$(mktemp -d "${TMPDIR:-/var/tmp}/splinter-iv-XXXXXX") || exit 1
|
||||
SPLINTER_SESSION_DIR="$D/home/.splinter"; export SPLINTER_SESSION_DIR
|
||||
port=18992
|
||||
srv=
|
||||
cleanup() { [ -n "$srv" ] && kill "$srv" 2>/dev/null; rm -rf "$D"; }
|
||||
|
||||
@@ -12,6 +12,8 @@ if ! command -v tmux >/dev/null 2>&1; then
|
||||
exit 0
|
||||
fi
|
||||
D=$(mktemp -d "${TMPDIR:-/var/tmp}/splinter-reconnect-XXXXXX") || exit 1
|
||||
SPLINTER_SESSION_DIR="$D/server/.splinter"
|
||||
export SPLINTER_SESSION_DIR
|
||||
unset TMUX TMUX_PANE
|
||||
export TMUX_TMPDIR="$D"
|
||||
own_server() {
|
||||
|
||||
@@ -15,6 +15,8 @@ if ! command -v tmux >/dev/null 2>&1; then
|
||||
exit 0
|
||||
fi
|
||||
D=$(mktemp -d "${TMPDIR:-/var/tmp}/splinter-ui-XXXXXX") || exit 1
|
||||
SPLINTER_SESSION_DIR="$D/home/.splinter"
|
||||
export SPLINTER_SESSION_DIR
|
||||
# Our own socket, never the user's. $TMUX wins over both -L and TMUX_TMPDIR
|
||||
# (tmux.c: when $TMUX is set the client takes the socket path out of it), so a
|
||||
# run started from inside the user's tmux would drive the user's server -- and
|
||||
|
||||
Reference in new issue
Block a user