-
Notifications
You must be signed in to change notification settings - Fork 0
feat(ydotool): add comprehensive unit tests for ydotool injector #311
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Conversation
qodo-free-for-open-source-projects
bot
commented
Dec 23, 2025
•
edited by qodo-code-review
bot
Loading
edited by qodo-code-review
bot
PR Compliance Guide 🔍Below is a summary of compliance checks for this PR:
Compliance status legend🟢 - Fully Compliant🟡 - Partial Compliant 🔴 - Not Compliant ⚪ - Requires Further Human Verification 🏷️ - Compliance label |
||||||||||||||||||||||||||
ⓘ Your approaching your monthly quota for Qodo. Upgrade your plan PR Compliance Guide 🔍Below is a summary of compliance checks for this PR:
Compliance status legend🟢 - Fully Compliant🟡 - Partial Compliant 🔴 - Not Compliant ⚪ - Requires Further Human Verification 🏷️ - Compliance label |
|||||||||||||||||||||||
qodo-free-for-open-source-projects
bot
commented
Dec 23, 2025
•
edited by qodo-code-review
bot
Loading
edited by qodo-code-review
bot
PR Code Suggestions ✨Explore these optional code suggestions:
|
|||||||||
ⓘ Your approaching your monthly quota for Qodo. Upgrade your plan PR Code Suggestions ✨Explore these optional code suggestions:
|
||||||||||||||||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull request overview
This PR adds comprehensive unit tests for the ydotool text injection backend, originally drafted in PR #273. The tests validate socket discovery mechanisms, binary permission checks, and text injection behavior with appropriate fallback handling.
Key Changes
- Adds
TestHarnessinfrastructure for isolated test environments with temporary directories - Implements tests covering socket discovery priority order (YDOTOOL_SOCKET → HOME → XDG_RUNTIME_DIR → /run/user/{uid})
- Validates binary permission checks and text injection methods (paste with type fallback)
- Makes internal functions
pub(crate)to enable testing and adds test-specific hooks (e.g., UINPUT_PATH_OVERRIDE)
Reviewed changes
Copilot reviewed 3 out of 3 changed files in this pull request and generated 4 comments.
| File | Description |
|---|---|
crates/coldvox-text-injection/src/ydotool_injector.rs |
Exposes internal functions for testing and adds UINPUT_PATH_OVERRIDE environment variable support for test isolation |
crates/coldvox-text-injection/src/tests/test_ydotool_injector.rs |
Adds comprehensive unit tests with TestHarness for socket discovery, binary permissions, and text injection behavior |
crates/coldvox-text-injection/src/tests/mod.rs |
Gates new test module behind appropriate feature flags (unix + ydotool) |
| #[serial] | ||
| fn test_locate_existing_socket_finds_first_available() { | ||
| let harness = TestHarness::new().unwrap(); | ||
| let _ = harness.runtime_dir.join(".ydotool_socket"); |
Copilot
AI
Dec 23, 2025
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The PathBuf created here is unused. This line appears to be a leftover from development. Either remove it if it's not needed, or create the socket at this path if the intent was to test that the HOME socket takes priority over the runtime directory socket.
| let _ = harness.runtime_dir.join(".ydotool_socket"); | |
| let runtime_socket = harness.runtime_dir.join(".ydotool_socket"); | |
| harness.create_mock_socket(&runtime_socket).unwrap(); |
| #[test] | ||
| #[serial] | ||
| fn test_candidate_socket_paths_priority() { | ||
| let harness = TestHarness::new().unwrap(); |
Copilot
AI
Dec 23, 2025
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The TestHarness is created but only used for its Drop implementation to clean up environment variables. The test itself doesn't use any of the harness's fields or methods. Consider using a simpler cleanup approach with a guard struct that only stores original_path, or rename the variable to _harness to indicate it's intentionally unused except for its Drop implementation.
| let harness = TestHarness::new().unwrap(); | |
| let _harness = TestHarness::new().unwrap(); |
| use crate::ydotool_injector::{ | ||
| candidate_socket_paths, locate_existing_socket, ydotool_daemon_socket, YdotoolInjector, | ||
| }; | ||
| use crate::types::{InjectionConfig, InjectionContext}; |
Copilot
AI
Dec 23, 2025
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The InjectionContext import is unused in this test file. Remove it to clean up the imports.
| use crate::types::{InjectionConfig, InjectionContext}; | |
| use crate::types::InjectionConfig; |
| @@ -0,0 +1,207 @@ | |||
| //! Unit tests for ydotool_injector.rs | |||
| use crate::ydotool_injector::{ | |||
| candidate_socket_paths, locate_existing_socket, ydotool_daemon_socket, YdotoolInjector, | |||
Copilot
AI
Dec 23, 2025
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The ydotool_daemon_socket import is unused in this test file. Remove it to clean up the imports.
| candidate_socket_paths, locate_existing_socket, ydotool_daemon_socket, YdotoolInjector, | |
| candidate_socket_paths, locate_existing_socket, YdotoolInjector, |
qodo-code-review
bot
commented
Dec 23, 2025
•
edited by qodo-free-for-open-source-projects
bot
Loading
edited by qodo-free-for-open-source-projects
bot
CI Feedback 🧐(Feedback updated until commit 46a1988)A test triggered by this PR failed. Here is an AI-generated analysis of the failure:
|
The work to add unit tests for the ydotool injector was completed, but the resulting pull request was superseded by another change (#311). This submission marks the end of the task, as there are no further code changes required.
Head branch was modified
✅ Previous Issues AddressedThe following issues from my previous review have been resolved:
Minor remaining note:
Recommendation: PR is ready to merge - all critical issues resolved Review Details (3 files)Files:
Changes reviewed:
Quality checks:
|
This commit introduces a full suite of unit tests for the `ydotool_injector.rs` module. - A `TestHarness` is implemented to create an isolated test environment, mocking the filesystem, environment variables, and external binaries (`ydotool`, `which`). - The core `ydotool_injector.rs` logic was made testable by introducing a `UINPUT_PATH_OVERRIDE` environment variable under a `cfg(test)` flag to avoid permission issues with `/dev/uinput` during tests. - Tests cover: - Socket path discovery logic. - Binary permission and availability checks. - `inject_text` functionality, including the fallback from 'paste' to 'type' mode. These tests improve the reliability and maintainability of the ydotool injection backend.
Rebased from Jules draft #273. - Add TestHarness for controlled test environment - Add tests for socket discovery, binary permissions, text injection - Gate tests behind ydotool feature flag
- Remove unused imports: ydotool_daemon_socket, InjectionContext - Prefix unused variable with underscore: harness -> _harness - Fixes CI compilation failure due to warnings-as-errors
99c0b5d to
c31b90c
Compare
User description
Summary
Rebased and integrated from Jules draft PR #273.
Changes
TestHarnessstruct for controlled test environment with temp directoriestest_ydotool_injectormodule behind#[cfg(all(unix, feature = "ydotool"))]Testing
cargo test -p coldvox-text-injection --features ydotoolCloses #273
PR Type
Tests, Enhancement
Description
Add comprehensive unit tests for ydotool injector module
Implement TestHarness for isolated test environment with mocks
Test socket discovery priority and binary permission checks
Test text injection with paste/type fallback mechanism
Make ydotool functions testable via UINPUT_PATH_OVERRIDE
Diagram Walkthrough
File Walkthrough
mod.rs
Register ydotool injector test modulecrates/coldvox-text-injection/src/tests/mod.rs
test_ydotool_injectorbehind feature gate#[cfg(all(unix, feature = "ydotool"))]forplatform-specific tests
test_ydotool_injector.rs
Add comprehensive ydotool injector unit testscrates/coldvox-text-injection/src/tests/test_ydotool_injector.rs
TestHarnessstruct for controlled test environment with tempdirectories
systemd → system)
#[serial]attribute to prevent test interferenceydotool_injector.rs
Expose functions and add test-friendly uinput overridecrates/coldvox-text-injection/src/ydotool_injector.rs
candidate_socket_paths()public for testing viapub(crate)locate_existing_socket()public for testing viapub(crate)UINPUT_PATH_OVERRIDEenvironment variable support incheck_uinput_access()/dev/uinputpath without requiring actualdevice permissions