# Shared parallelism default for the test gates (sourced by tools/test.sh and client/e2e/run.sh). # # FFF_TEST_JOBS overrides it (FFF_TEST_JOBS=1 serialises). The default is half the cores, capped at # 8: the host froze under an uncapped, memory-heavy load before, so the gate never saturates it. # The client e2e runs whole browsers (SwiftShader is CPU-hungry per worker), so it caps its workers # lower unless FFF_E2E_JOBS names one explicitly. fff_half_cores() { local n=$(( $(nproc) / 2 )) [ "$n" -ge 1 ] || n=1 echo "$n" } fff_test_jobs() { local n=${FFF_TEST_JOBS:-} if [ -z "$n" ]; then n=$(fff_half_cores) [ "$n" -le 8 ] || n=8 fi echo "$n" } fff_e2e_jobs() { local n=${FFF_E2E_JOBS:-} if [ -z "$n" ]; then n=$(fff_test_jobs) [ "$n" -le 4 ] || n=4 fi echo "$n" } # Test state dirs live on tmpfs when the host has it. Every harness state dir carries a SQLite WAL # with synchronous=FULL commits (authoring) plus transcripts and tile fixtures; on a disk-backed # /tmp, eight suites fanning out at once can stall a first commit long enough for a harness ack to # look lost. /dev/shm keeps the same SQLite/restart semantics (a SIGKILL restart still reads the # same files) without the fsync storm. An explicit TMPDIR is respected; the directory is removed # on exit. FFF_TEST_TMPDIR=dir picks another base. fff_setup_tmpdir() { if [ -n "${FFF_TEST_NO_TMPFS:-}" ] || { [ -n "${TMPDIR:-}" ] && [ "${TMPDIR}" != "/tmp" ]; }; then return 0 fi local base=${FFF_TEST_TMPDIR:-/dev/shm} [ -d "$base" ] && [ -w "$base" ] || return 0 TMPDIR=$(mktemp -d "$base/fffvtt-run.XXXXXX") || return 0 export TMPDIR trap 'rm -rf "$TMPDIR"' EXIT }