temporalio / sdk-core

Core Temporal SDK that can be used as a base for language specific Temporal SDKs
MIT License
266 stars 70 forks source link

[Feature Request] Can I rewrite `#[cfg_attr(test, mockall::automock)]` to `#[cfg_attr(feature = "test-utils", mockall::automock)]` #798

Closed bxb100 closed 3 weeks ago

bxb100 commented 3 weeks ago

Is your feature request related to a problem? Please describe.

using Rustrover, and it seems to exist a bug to treat #[cfg_attr(test, mockall::automock)] like #[cfg(test)], so I can't import to use this trait. I know it's not the wrong usage, but it's so boring.

Describe the solution you'd like

like https://stackoverflow.com/questions/76831451/automock-added-only-in-test-config-but-mock-structure-not-recognized-in-integ

it seems there only the test-utils crate uses this, so can I rewrite this like the title mentioned?

Additional context

image image
Sushisource commented 3 weeks ago

It sounds like you're saying you want the mock of this trait to be publicly exposed. What do you need to use it for? It's a fairly high level client, and the only reason I have a mock for it at all is to test the RetryClient wrapper. Other than that, it's not really used by much of anything except an end-user directly, so mocking it doesn't really provide much value.

bxb100 commented 3 weeks ago

@Sushisource I want to use this trait, not mock, but Jetbrains' IDE RustRover seems not to ignore cfg_attr(test, it's behavior like cfg(test), so I can't import this trait, and use the impl.

so basically I want to use another form cfg_attr(feature that IDE behavior can normal

Sushisource commented 3 weeks ago

What RustRover says has no bearing on what the compiler is willing to do. You can absolutely use this trait and import it wherever you like. That said, I also use RustRover, and it has no problem picking up this trait and automatically importing it in places I try to use it, if that's what you're referring to. Seems like this might just be something specific to your setup.

I'm going to close this since it's really a RustRover problem, not a Core issue, and I don't want to change the code to work around a particular IDE.