fix(test): resolve gbrain detect install paths and session import xargs crash

This commit is contained in:
Mattias Petersson 2026-07-12 16:46:49 +02:00
parent e5d6583e7b
commit 08e1c43e4e
3 changed files with 6 additions and 4 deletions

View File

@ -65,7 +65,7 @@ case "$MODE" in
exit 0
fi
LATEST=$(find "$CODEX_SESSIONS_ROOT" -type f -name "rollout-*.jsonl" -print 2>/dev/null \
| xargs ls -t 2>/dev/null | head -1 || true)
| xargs -r ls -t 2>/dev/null | head -1 || true)
if [ -z "$LATEST" ]; then
echo "NO_SESSIONS: no rollout-*.jsonl files under $CODEX_SESSIONS_ROOT"
exit 0

View File

@ -24,8 +24,10 @@ const INSTALL = path.join(ROOT, 'bin', 'gstack-gbrain-install');
// Minimal PATH with POSIX tools + homebrew (for jq/git/curl) but no user-bin
// dirs — this keeps `gbrain` out of PATH deterministically across dev machines
// while still finding jq, git, curl, sed, cat, etc. Each test can prepend a
// fake-gbrain dir when it wants to simulate presence.
const SAFE_PATH = '/usr/bin:/bin:/usr/sbin:/sbin:/opt/homebrew/bin:/usr/local/bin';
// fake-gbrain dir when it wants to simulate presence. We append the active Bun
// directory so the script shebang can find bun.
const BUN_DIR = path.dirname(process.execPath);
const SAFE_PATH = `/usr/bin:/bin:/usr/sbin:/sbin:/opt/homebrew/bin:/usr/local/bin:${BUN_DIR}`;
let tmpHome: string;
let tmpHomeReal: string;

View File

@ -13,7 +13,7 @@ const SRC = fs.readFileSync(path.join(ROOT, 'bin', 'gstack-config'), 'utf-8');
// satisfied by unrelated text elsewhere in the file.
function okBranch(): string {
const start = SRC.indexOf('gbrain-refresh)');
const ok = SRC.indexOf('ok)', start);
const ok = SRC.indexOf('ok|timeout)', start);
const end = SRC.indexOf(';;', ok);
if (start < 0 || ok < 0 || end < 0) throw new Error('Could not locate gbrain-refresh ok) branch');
return SRC.slice(ok, end);