Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

serde_test should be dev-dependency #99

Closed
Mingun opened this issue May 20, 2023 · 3 comments
Closed

serde_test should be dev-dependency #99

Mingun opened this issue May 20, 2023 · 3 comments

Comments

@Mingun
Copy link

Mingun commented May 20, 2023

If I'm not missing something, it is required only for tests, so it should be in the [dev-dependencies] section

@tormol
Copy link
Collaborator

tormol commented Jun 5, 2023

serde is an optional dependency, so how does one add a feature-specific dev-dependency?

I tried

[target.'cfg(feature="serde")'.dev-dependencies]
serde_test = "1.0"

but cargo warns that it doesn't work as expected, and extern crate serde_test; fails. (With and without resolver = "2").

Is it the norm to require all features to build tests?

(I've also asked about this in an r/rust questions thread, but since this isn't the only project with optional serde support you've opened an issue for, I guess you know.)

@tormol
Copy link
Collaborator

tormol commented Jun 5, 2023

Based on your comment on circular-queue I tried just doing

[dev-dependencies]
serde_test = "1.0"

but when I run cargo build --no-default-features --tests I get

   Compiling serde v1.0.163
   Compiling serde_test v1.0.163
   Compiling ascii v1.1.0 (/home/tbm/p/rust/libs/ascii)
    Finished dev [unoptimized + debuginfo] target(s) in 1.93s

even though serde was not enabled.
so what you said about the serde_test dependency not being compiled appears not to be the case.

@Mingun
Copy link
Author

Mingun commented Jun 6, 2023

Hm, I tried to provide compilation of quick-xml which have only one required dependency, but cargo test --no-default-features builds all libraries listed in [dev-dependencies] section, even unused for the selected test options (for example, tokio-test which needed only when enabling async-tokio feature). So it seems that my assumption is wrong and I observed some other effect that reduced number of used libraries.

@tormol tormol closed this as completed Aug 21, 2023
# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants