From 89447ed432bfc6a895875c7412bb0da9d93158ac Mon Sep 17 00:00:00 2001 From: Linghong Date: Thu, 10 Sep 2026 09:46:48 +0000 Subject: [PATCH] =?UTF-8?q?=E6=8C=89=E8=AF=84=E5=AE=A1=E6=84=8F=E8=A7=81?= =?UTF-8?q?=E5=BC=BA=E5=8C=96=E5=9B=9E=E9=80=80=E6=A8=A1=E6=9D=BF=E8=AF=BB?= =?UTF-8?q?=E5=8F=96=E9=80=9A=E9=81=93=E5=9B=9E=E5=BD=92=E6=B5=8B=E8=AF=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - tests/configuration.rs 回退模板测试改用与模板无关的 runtime dir,分类断言覆盖按路径归属而非 runtime dir 为 None 的恒真分支,并补充 runtime dir 内路径的 managed 正向断言 - tests/mod.rs 移除不再使用的 clear_test_runtime_config_dir 辅助 --- .../src-tauri/src/tests/configuration.rs | 10 +++++++++- .../src-tauri/src/tests/mod.rs | 14 -------------- 2 files changed, 9 insertions(+), 15 deletions(-) diff --git a/apps/ai-game-creator-shell/src-tauri/src/tests/configuration.rs b/apps/ai-game-creator-shell/src-tauri/src/tests/configuration.rs index 8b517b021..adb540bc2 100644 --- a/apps/ai-game-creator-shell/src-tauri/src/tests/configuration.rs +++ b/apps/ai-game-creator-shell/src-tauri/src/tests/configuration.rs @@ -1195,15 +1195,23 @@ fn fallback_template_read_stays_on_snapshot_channel_outside_runtime_dir() { "{\n \"llm\": { \"model\": \"fallback-template-model\" }\n}\n", ) .expect("write fallback template"); - let _guard = clear_test_runtime_config_dir(); + // 设置一个与模板无关的 runtime dir,让分类断言真正覆盖"按路径归属"而非 + // "runtime dir 为 None 时恒 false"的全局开关。 + let runtime_root = unique_project_path(); + fs::create_dir_all(&runtime_root).expect("unrelated runtime config dir"); + let _guard = use_test_runtime_config_dir(runtime_root.clone()); // 仓库旁边的回退模板是共享输入,读取绝不能走会收紧 owner/DACL 的私有通道。 assert!(!game_creator_config_path_is_runtime_managed(&template)); + assert!(game_creator_config_path_is_runtime_managed( + &runtime_root.join(GAME_CREATOR_CONFIG_FILE_NAME) + )); let content = read_game_creator_config_file(&template).expect("read fallback template"); assert!(content .expect("fallback template content") .contains("fallback-template-model")); fs::remove_dir_all(root).ok(); + fs::remove_dir_all(runtime_root).ok(); } #[test] diff --git a/apps/ai-game-creator-shell/src-tauri/src/tests/mod.rs b/apps/ai-game-creator-shell/src-tauri/src/tests/mod.rs index fc5a2a45b..e2c15a956 100644 --- a/apps/ai-game-creator-shell/src-tauri/src/tests/mod.rs +++ b/apps/ai-game-creator-shell/src-tauri/src/tests/mod.rs @@ -1327,20 +1327,6 @@ fn use_test_runtime_config_dir(path: PathBuf) -> TestRuntimeConfigDirGuard { } } -fn clear_test_runtime_config_dir() -> TestRuntimeConfigDirGuard { - let lock = TEST_CONFIG_LOCK - .lock() - .unwrap_or_else(|poisoned| poisoned.into_inner()); - let previous = game_creator_runtime_config_dir(); - *game_creator_runtime_config_dir_lock() - .lock() - .expect("runtime config dir lock") = None; - TestRuntimeConfigDirGuard { - _lock: lock, - previous, - } -} - fn assert_task_status(manifest: &Value, task_id: &str, status: &str) { let task = manifest["tasks"] .as_array()