Refactor cargo wdk action unit tests#690
Draft
krishnakumar4a4 wants to merge 2 commits into
Draft
Conversation
Contributor
Author
|
@copilot resolve the merge conflicts in this pull request |
Contributor
There was a problem hiding this comment.
Pull request overview
This PR refactors cargo-wdk’s build/package orchestration to improve unit-testability by introducing injectable runner types for the build and package tasks, and rewrites the BuildAction unit tests to use those runners and more targeted expectations.
Changes:
- Add
BuildTaskRunner/BuildTaskRunParamsandPackageTaskRunnerwrappers to enable dependency injection and mocking. - Update
BuildActionto accept runner instances (vianew_with_runners) and route build/package work through the runners. - Replace large, end-to-end style
BuildActiontests with a smaller orchestrator-focused suite + richerPackageTaskunit tests.
Reviewed changes
Copilot reviewed 3 out of 4 changed files in this pull request and generated 3 comments.
| File | Description |
|---|---|
| crates/cargo-wdk/src/actions/build/build_task.rs | Introduces BuildTaskRunner and parameter struct to decouple BuildTask execution for mocking. |
| crates/cargo-wdk/src/actions/build/mod.rs | Refactors BuildAction to use injected runners for build/package phases. |
| crates/cargo-wdk/src/actions/build/package_task.rs | Adds PackageTaskRunner and significantly expands/reshapes PackageTask unit test coverage. |
| crates/cargo-wdk/src/actions/build/tests.rs | Refactors BuildAction tests to validate orchestration via mocked runners and targeted expectations. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Comment on lines
+8
to
+10
| #![allow(dead_code)] | ||
| #![allow(clippy::unused_self)] | ||
|
|
Comment on lines
+52
to
+67
| pub fn run<'a>( | ||
| &self, | ||
| params: &BuildTaskRunParams<'a>, | ||
| command_exec: &CommandExec, | ||
| ) -> Result<Vec<Result<Message, std::io::Error>>, BuildTaskError> { | ||
| BuildTask::new( | ||
| params.package_name, | ||
| params.working_dir, | ||
| params.profile, | ||
| params.target_arch, | ||
| params.verbosity_level, | ||
| command_exec, | ||
| ) | ||
| .run() | ||
| .map(Iterator::collect) | ||
| } |
Comment on lines
+10
to
+12
| #![allow(dead_code)] | ||
| #![allow(clippy::unused_self)] | ||
|
|
This was referenced Jun 25, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
This pull request refactors the build and packaging workflow in the
cargo-wdkcrate to improve testability and modularity. The primary changes introduce runner structs for both build and package tasks, enabling dependency injection and easier mocking during testing. The construction ofBuildActionis also updated to accept these runners, and the internal logic is adjusted to use them.Refactoring for testability and modularity:
BuildTaskRunnerandBuildTaskRunParamsstructs, along with arunmethod and#[automock]attribute to facilitate mocking and dependency injection for build tasks (build_task.rs).PackageTaskRunnerand updated usage to allow for similar dependency injection for package tasks (mod.rs). [1] [2]Changes to
BuildActionconstruction and usage:BuildActionto accept runner instances (BuildTaskRunnerandPackageTaskRunner), added anew_with_runnersconstructor, and refactored the main constructor to use it (mod.rs). [1] [2]mod.rs). [1] [2]General code cleanup:
#![allow(dead_code)]and#![allow(clippy::unused_self)]to suppress related warnings inbuild_task.rs.mod.rs). [1] [2]