11# Basic Memory - Modern Command Runner
22
3+ TESTMON_FLAGS := env_var_or_default (" BASIC_MEMORY_TESTMON_FLAGS" , " --testmon-noselect" )
4+ TESTMON_SELECT_FLAGS := env_var_or_default (" BASIC_MEMORY_TESTMON_SELECT_FLAGS" , " --testmon --testmon-forceselect" )
5+ TESTMON_REFRESH_FLAGS := env_var_or_default (" BASIC_MEMORY_TESTMON_REFRESH_FLAGS" , " --testmon-noselect" )
6+
37# Install dependencies
48install :
59 uv sync
@@ -35,40 +39,55 @@ test-sqlite: test-unit-sqlite test-int-sqlite
3539test-postgres : test-unit-postgres test-int-postgres
3640
3741# Run unit tests against SQLite
38- test-unit-sqlite :
39- BASIC_MEMORY_ENV=test uv run pytest -p pytest_mock -v --no-cov tests
42+ test-unit-sqlite : testmon-seed
43+ BASIC_MEMORY_ENV=test uv run pytest -p pytest_mock -v --no-cov {{ TESTMON_FLAGS }} --testmon- env =unit-sqlite tests
4044
4145# Run unit tests against Postgres
42- test-unit-postgres :
43- BASIC_MEMORY_ENV=test BASIC_MEMORY_TEST_POSTGRES=1 uv run pytest -p pytest_mock -v --no-cov tests
46+ test-unit-postgres : testmon-seed
47+ BASIC_MEMORY_ENV=test BASIC_MEMORY_TEST_POSTGRES=1 uv run pytest -p pytest_mock -v --no-cov {{ TESTMON_FLAGS }} --testmon- env =unit-postgres tests
4448
4549# Run integration tests against SQLite (excludes semantic benchmarks — use just test-semantic)
46- test-int-sqlite :
47- BASIC_MEMORY_ENV=test uv run pytest -p pytest_mock -v --no-cov -m " not semantic" test-int
50+ test-int-sqlite : testmon-seed
51+ BASIC_MEMORY_ENV=test uv run pytest -p pytest_mock -v --no-cov {{ TESTMON_FLAGS }} --testmon- env =int-sqlite -m " not semantic" test-int
4852
4953# Run integration tests against Postgres
5054# Note: Uses timeout due to FastMCP Client + asyncpg cleanup hang (tests pass, process hangs on exit)
5155# See: https://github.com/jlowin/fastmcp/issues/1311
52- test-int-postgres :
56+ test-int-postgres : testmon-seed
5357 #!/usr/bin/env bash
5458 set -euo pipefail
5559 # Use gtimeout (macOS/Homebrew) or timeout (Linux)
5660 TIMEOUT_CMD=$( command -v gtimeout || command -v timeout || echo " " )
5761 if [[ -n " $TIMEOUT_CMD " ]]; then
58- $TIMEOUT_CMD --signal=KILL 600 bash -c ' BASIC_MEMORY_ENV=test BASIC_MEMORY_TEST_POSTGRES=1 uv run pytest -p pytest_mock -v --no-cov -m "not semantic" test-int' || test $? -eq 137
62+ $TIMEOUT_CMD --signal=KILL 600 bash -c ' BASIC_MEMORY_ENV=test BASIC_MEMORY_TEST_POSTGRES=1 uv run pytest -p pytest_mock -v --no-cov {{TESTMON_FLAGS}} --testmon-env=int-postgres -m "not semantic" test-int' || test $? -eq 137
5963 else
6064 echo " ⚠️ No timeout command found, running without timeout..."
61- BASIC_MEMORY_ENV=test BASIC_MEMORY_TEST_POSTGRES=1 uv run pytest -p pytest_mock -v --no-cov -m " not semantic" test-int
65+ BASIC_MEMORY_ENV=test BASIC_MEMORY_TEST_POSTGRES=1 uv run pytest -p pytest_mock -v --no-cov {{TESTMON_FLAGS}} --testmon-env=int-postgres -m " not semantic" test-int
6266 fi
6367
6468# Run tests impacted by recent changes (requires pytest-testmon)
6569# Pass paths or node ids after `just testmon` to limit the candidate set further.
66- testmon * args :
67- BASIC_MEMORY_ENV=test uv run pytest -p pytest_mock -v --no-cov --testmon {{ args}}
70+ testmon * args : testmon-seed
71+ BASIC_MEMORY_ENV=test uv run pytest -p pytest_mock -v --no-cov {{ TESTMON_SELECT_FLAGS}} --testmon-env =local {{ args}}
72+
73+ # Seed pytest-testmon data into this worktree from the shared Git cache.
74+ testmon-seed :
75+ uv run python scripts/ testmon_cache.py seed
76+
77+ # Refresh the shared pytest-testmon cache from a full backend test run.
78+ testmon-refresh :
79+ #!/usr/bin/env bash
80+ set -euo pipefail
81+ BASIC_MEMORY_TESTMON_FLAGS=" {{TESTMON_REFRESH_FLAGS}}" just test
82+ uv run python scripts/testmon_cache.py refresh
83+
84+ # Show local and shared pytest-testmon cache locations.
85+ testmon-status :
86+ uv run python scripts/ testmon_cache.py status
6887
6988# Run MCP smoke test (fast end-to-end loop)
70- test-smoke :
71- BASIC_MEMORY_ENV=test uv run pytest -p pytest_mock -v --no-cov -m smoke test-int/ mcp/ test_smoke_integration.py
89+ test-smoke : testmon-seed
90+ BASIC_MEMORY_ENV=test uv run pytest -p pytest_mock -v --no-cov {{ TESTMON_FLAGS }} --testmon- env =smoke -m smoke test-int/ mcp/ test_smoke_integration.py
7291
7392# Fast local loop: lint, format, typecheck, impacted tests via pytest-testmon
7493fast-check :
@@ -97,18 +116,18 @@ postgres-migrate:
97116# Run Windows-specific tests only (only works on Windows platform)
98117# These tests verify Windows-specific database optimizations (locking mode, NullPool)
99118# Will be skipped automatically on non-Windows platforms
100- test-windows :
101- BASIC_MEMORY_ENV=test uv run pytest -p pytest_mock -v --no-cov -m windows tests test-int
119+ test-windows : testmon-seed
120+ BASIC_MEMORY_ENV=test uv run pytest -p pytest_mock -v --no-cov {{ TESTMON_FLAGS }} --testmon- env =windows -m windows tests test-int
102121
103122# Run benchmark tests only (performance testing)
104123# These are slow tests that measure sync performance with various file counts
105124# Excluded from default test runs to keep CI fast
106- test-benchmark :
107- BASIC_MEMORY_ENV=test uv run pytest -p pytest_mock -v --no-cov -m benchmark tests test-int
125+ test-benchmark : testmon-seed
126+ BASIC_MEMORY_ENV=test uv run pytest -p pytest_mock -v --no-cov {{ TESTMON_FLAGS }} --testmon- env =benchmark -m benchmark tests test-int
108127
109128# Run semantic search quality benchmarks (all combos)
110- test-semantic :
111- BASIC_MEMORY_ENV=test uv run pytest -p pytest_mock -v --no-cov -m semantic test-int/ semantic/
129+ test-semantic : testmon-seed
130+ BASIC_MEMORY_ENV=test uv run pytest -p pytest_mock -v --no-cov {{ TESTMON_FLAGS }} --testmon- env =semantic -m semantic test-int/ semantic/
112131
113132# Run semantic benchmarks with JSON artifact output, then show report
114133test-semantic-report :
@@ -120,8 +139,8 @@ test-litellm-live *args:
120139 BASIC_MEMORY_ENV=test BASIC_MEMORY_RUN_LITELLM_INTEGRATION=1 PYTHONPATH=test-int:src uv run python -m semantic.litellm_live_harness {{ args}}
121140
122141# Run semantic benchmarks (Postgres combos only)
123- test-semantic-postgres :
124- BASIC_MEMORY_ENV=test uv run pytest -p pytest_mock -v --no-cov -m semantic -k postgres test-int/ semantic/
142+ test-semantic-postgres : testmon-seed
143+ BASIC_MEMORY_ENV=test uv run pytest -p pytest_mock -v --no-cov {{ TESTMON_FLAGS }} --testmon- env =semantic-postgres -m semantic -k postgres test-int/ semantic/
125144
126145# View semantic benchmark results (rich formatted table)
127146# Usage: just semantic-report [--filter-combo sqlite] [--filter-suite paraphrase] [--sort-by avg_latency_ms]
@@ -137,8 +156,8 @@ benchmark-compare baseline candidate *args:
137156
138157# Run all tests including Windows, Postgres, and Benchmarks (for CI/comprehensive testing)
139158# Use this before releasing to ensure everything works across all backends and platforms
140- test-all :
141- BASIC_MEMORY_ENV=test uv run pytest -p pytest_mock -v --no-cov tests test-int
159+ test-all : testmon-seed
160+ BASIC_MEMORY_ENV=test uv run pytest -p pytest_mock -v --no-cov {{ TESTMON_FLAGS }} --testmon- env =all tests test-int
142161
143162# Generate HTML coverage report
144163coverage :
0 commit comments