From 02ccac2dd50beb9bbaf1d57bebe68e67bc39654e Mon Sep 17 00:00:00 2001 From: H-Chris233 Date: Sat, 9 May 2026 08:30:23 +0800 Subject: [PATCH] Make Rust-only backend test target explicit The backend-tests crate is intentionally an integration-test harness, but declaring the target explicitly makes Cargo discovery and review intent unambiguous. The harness comment also records that path-included modules run their own cfg(test) unit tests for hotkey, recorder, and insertion without linking the full Tauri library.\n\nConstraint: Stay within Rust-only backend tests; do not add a Tauri lib/runtime target.\nRejected: Add src/lib.rs just to satisfy target discovery | would introduce an unused crate surface instead of the actual test harness.\nConfidence: high\nScope-risk: narrow\nTested: cargo test --manifest-path openless-all/app/src-tauri/backend-tests/Cargo.toml -- --list | grep -E '^(hotkey|recorder|insertion)::'\nTested: cargo test --manifest-path openless-all/app/src-tauri/backend-tests/Cargo.toml\nTested: git diff --check\nNot-tested: GitHub Windows runner rerun result pending after push.\n\nCo-authored-by: OmX --- openless-all/app/src-tauri/backend-tests/Cargo.toml | 4 ++++ .../app/src-tauri/backend-tests/tests/backend_rust.rs | 2 ++ 2 files changed, 6 insertions(+) diff --git a/openless-all/app/src-tauri/backend-tests/Cargo.toml b/openless-all/app/src-tauri/backend-tests/Cargo.toml index 8b8b5e47..d3dc05c1 100644 --- a/openless-all/app/src-tauri/backend-tests/Cargo.toml +++ b/openless-all/app/src-tauri/backend-tests/Cargo.toml @@ -5,6 +5,10 @@ edition = "2021" rust-version = "1.77" publish = false +[[test]] +name = "backend_rust" +path = "tests/backend_rust.rs" + [dependencies] arboard = "3" cpal = "0.15" diff --git a/openless-all/app/src-tauri/backend-tests/tests/backend_rust.rs b/openless-all/app/src-tauri/backend-tests/tests/backend_rust.rs index 23e75a81..08ef2f2a 100644 --- a/openless-all/app/src-tauri/backend-tests/tests/backend_rust.rs +++ b/openless-all/app/src-tauri/backend-tests/tests/backend_rust.rs @@ -2,6 +2,8 @@ //! //! 这个测试 crate 只把纯 Rust 后端模块按源码路径编进来,不链接完整 Tauri //! `openless_lib`,避免 Windows CI 在 test harness 启动前被桌面运行时 DLL 拦截。 +//! Cargo 以 `cfg(test)` 编译这些 path-included 模块,所以各模块自己的 +//! `#[cfg(test)]` 单测会在这里实际执行(见 hotkey / recorder / insertion)。 #![allow(dead_code, unused_variables)]