How to Run Tests for a Specific OpenLogi Crate: A Complete Guide
To run tests for a specific OpenLogi crate, use the cargo test -p <crate-name> command from the workspace root, which limits execution to the selected package while leaving other crates untouched.
OpenLogi is organized as a Cargo workspace containing multiple crates such as openlogi-core, openlogi-agent, and openlogi-hid. When contributing to this repository, you often need to verify changes in isolation without waiting for the entire workspace test suite to complete. The workspace configuration in Cargo.toml defines these member crates, allowing you to target specific packages using Cargo's built-in flags.
Understanding the OpenLogi Workspace Structure
OpenLogi follows a monorepo architecture where individual components live as separate crates under the crates/ directory. Each directory name corresponds to the package name used in Cargo commands. According to the repository's guidance in AGENTS.md (line 77), this structure enables targeted testing through the -p (package) flag, ensuring fast feedback loops during development.
Running Tests for a Single Crate
Basic Syntax
The fundamental command pattern follows Cargo's standard package selection syntax:
cargo test -p <crate-name>
This instructs Cargo to build and test only the specified package and its dependencies, ignoring other workspace members. For example, to test the core agent functionality, you would execute:
cargo test -p openlogi-agent-core
Step-by-Step Instructions
-
Open a terminal at the repository root – All Cargo commands must be executed from the workspace root where the top-level
Cargo.tomlresides. -
Identify the crate name – Verify the exact package name by checking the
crates/directory or theCargo.tomlworkspace member list. -
Run the tests – Execute
cargo test -p <crate>to launch all unit and integration tests within that crate. -
Optional filtering – Append a test name pattern after the crate specification to run only matching tests (e.g.,
cargo test -p openlogi-agent-core dpi). -
Verify the result – Cargo outputs a test summary specific to the selected crate, confirming that other crates remain untouched.
Filtering Tests Within a Specific Crate
Beyond running all tests in a crate, you can target specific test functions or modules by adding a filter argument after the package name. As documented in the CI rules at .claude/rules/ci.md (lines 93‑94), this pattern supports granular validation workflows.
Run tests matching a specific pattern:
# Run only tests containing "dpi" in the openlogi-agent-core crate
cargo test -p openlogi-agent-core dpi
Execute a specific test function using its full path:
# Run a single test function in openlogi-hid
cargo test -p openlogi-hid test_write_dpi
Run only integration tests for a specific crate:
# Verify wire-format tests for the IPC crate exclusively
cargo test -p openlogi-ipc --test wire_format
CI and Automation Patterns
The repository's continuous integration configuration leverages these commands for efficient pipeline execution. The CI rules reference concrete examples such as:
# i18n end-to-end tests for the desktop UI
cargo test -p openlogi-desktop i18n
These patterns ensure that pull requests trigger only relevant test suites, reducing CI latency while maintaining coverage standards.
Key Configuration Files
Several files define the testing workflow and crate organization:
AGENTS.md(line 77) – Outlines the genericcargo test -p <crate>pattern for agent development workflows..claude/rules/ci.md(lines 93‑94) – Contains concrete CI examples including integration test targeting with--testflags.Cargo.toml– Defines the workspace members and dependencies, serving as the source of truth for available crate names.docs/DEVELOPMENT.md(lines 197‑199) – Explains the overall testing workflow includingcargo test --workspacefor full-suite validation when needed.
Summary
- OpenLogi uses Cargo workspaces with crates located in the
crates/directory. - Use
cargo test -p <crate-name>to execute tests for a single crate only. - Append test name patterns after the crate specification to filter specific tests.
- Reference
AGENTS.mdand.claude/rules/ci.mdfor authoritative testing patterns. - All commands must run from the repository root where the workspace
Cargo.tomlresides.
Frequently Asked Questions
What is the difference between cargo test and cargo test -p?
Running cargo test without flags executes tests for the entire workspace, which can be time-consuming in large repositories like OpenLogi. The -p flag restricts the test run to a specific package, drastically reducing compilation and execution time when you are working on isolated changes.
How do I find the exact crate name to use with the -p flag?
The crate name matches the directory name under crates/ (e.g., openlogi-agent-core). You can also verify the exact package name by inspecting the [workspace.members] section in the root Cargo.toml, which lists all available crates in the repository.
Can I run tests for multiple specific crates at once?
Yes, you can specify multiple -p flags in a single command: cargo test -p openlogi-core -p openlogi-hid. This approach tests only the listed crates while skipping other workspace members, providing a middle ground between single-crate and full-workspace testing.
How do I run only integration tests for a specific crate?
Use the --test flag followed by the integration test name: cargo test -p openlogi-ipc --test wire_format. This command exclusively builds and runs the specified integration test file within the target crate, bypassing unit tests and other integration suites.
Have a question about this repo?
These articles cover the highlights, but your codebase questions are specific. Give your agent direct access to the source. Share this with your agent to get started:
curl -s "https://instagit.com/install.md" Maintain an open-source project? Get it listed too →