Skip to content

[cargo-wdk] Gate mockall/mockall_double behind cfg(test), move to [dev-dependencies], and clean up the provider/consumer mocking pattern #651

Description

nit/future: mockall and mockall_double are normal deps today, so they ship in non-test builds. This is consistent with every other module in the crate, but we should gate them behind cfg(test) and move them to [dev-dependencies] as a follow-up. The mockall_double README shows the canonical pattern. In short:

Providers (exec.rs, fs.rs, etc.):

#[cfg(test)]
use mockall::automock;

#[cfg_attr(test, automock)]
impl CommandExec { ... }

Consumers (this file, build/mod.rs, cli.rs, etc.):

#[cfg(test)]
use mockall_double::double;

#[cfg_attr(test, double)]
use crate::providers::{exec::CommandExec, fs::Fs};

Scope is cross-cutting (4 provider modules + 6 consumer modules + Cargo.toml), so tracking as a separate issue.

Originally posted by Melvin Wang (@wmmc88) in #638 (comment)


Adjacent work was started in PR #476

Metadata

Metadata

Labels

cleanupminor code cleanup or refactoring

Type

Projects

Status
No status

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions