From 7ec641bdfd86337344e9ba111867e8c9add986a4 Mon Sep 17 00:00:00 2001 From: "peng.li24" <734991033@qq.com> Date: Tue, 8 Sep 2026 08:45:58 +0800 Subject: [PATCH] =?UTF-8?q?test:=20=5Fflush=5Fredis=20=E2=86=92=20=5Fflush?= =?UTF-8?q?=5Fbackend=EF=BC=88kvspace=20clear=20=E5=8F=96=E4=BB=A3=20redis?= =?UTF-8?q?-cli=20FLUSHALL=EF=BC=89?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 后端无关的清理:经 kvspace CLI clear(KVSPACE env),适配 shm/fs/redis 全后端; kvtut*(402MB shm 产物)gitignore。 --- .gitignore | 3 +++ tutorial/test.py | 15 ++++++++------- 2 files changed, 11 insertions(+), 7 deletions(-) diff --git a/.gitignore b/.gitignore index 9fddc79c..b3abe0cb 100644 --- a/.gitignore +++ b/.gitignore @@ -75,3 +75,6 @@ d[0-9][0-9][0-9][0-9][0-9][0-9][0-9] # 五语言对齐 reference 材料(本地查阅用,不入库) stdlib/kvlang/reference/ + +# tutorial shm 测试产物(相对路径 DSN) +kvtut* diff --git a/tutorial/test.py b/tutorial/test.py index a3464a78..53477016 100755 --- a/tutorial/test.py +++ b/tutorial/test.py @@ -65,11 +65,12 @@ def _needs_skip(f: Path) -> bool: return False -def _flush_redis() -> None: +def _flush_backend() -> None: try: subprocess.run( - ["redis-cli", "-p", "6379", "FLUSHALL"], - capture_output=True, timeout=5, + ["kvspace", "clear"], + capture_output=True, timeout=10, + env={**os.environ, "KVSPACE": _C_DSN}, ) except FileNotFoundError: pass @@ -141,7 +142,7 @@ def _benchmark_file(f: Path, expects: list[str]) -> tuple[dict[str, str], str]: return invalid, "C compilation failed" try: - _flush_redis() + _flush_backend() kv_result, kv_ms = _timed_run([KV, rel], env=_KV_ENV) py_result, py_ms = _timed_run([sys.executable, str(f.with_suffix(".py"))]) c_result, c_ms = _timed_run([str(executable)]) @@ -202,7 +203,7 @@ def _run_test_file(f: Path, expects: list[str], env: dict) -> tuple[bool, str]: elif _C_DSN.startswith("fs://"): shutil.rmtree(_C_DSN[len("fs://"):], ignore_errors=True) else: - _flush_redis() + _flush_backend() layout = subprocess.run([LAYOUT_BIN, rel, _C_DSN], capture_output=True, text=True, timeout=60, cwd=str(ROOT), env=env) if layout.returncode != 0: @@ -210,7 +211,7 @@ def _run_test_file(f: Path, expects: list[str], env: dict) -> tuple[bool, str]: entry = "test" # 约定入口:每个 tutorial 顶层 rwfunc test()(pkg 空、裸名) try: crun = subprocess.run([TERM_BIN, entry], capture_output=True, text=True, - timeout=120, cwd=str(ROOT), env={**env, "KVSPACE": _C_DSN}) + timeout=int(os.environ.get("KV_CASE_TIMEOUT", "120")), cwd=str(ROOT), env={**env, "KVSPACE": _C_DSN}) except subprocess.TimeoutExpired: return False, "timeout" if crun.returncode != 0: @@ -322,7 +323,7 @@ def setUp(self): mock.patch.object(MODULE, "KV", str(self.kvlang)), mock.patch.object(MODULE, "FAIL_CSV", self.tutorial / "test_failures.csv"), mock.patch.object(MODULE, "BENCH_CSV", self.tutorial / "benchmark.csv"), - mock.patch.object(MODULE, "_flush_redis"), + mock.patch.object(MODULE, "_flush_backend"), mock.patch("builtins.print"), ] for patcher in self.patchers: