Restricting tests/examples to unix

I have those in my Cargo.toml:

[[example]]
name = "quitting_gio"
required-features = ["use_gio", "unix"]
target = "unix"


[[test]]
name = "nested_requests_gio"
target = "unix"
required-features = ["use_gio", "localspawn"]

Trouble is, cargo ignores the target keys, and tries to run those on windows as well (e.g. when trying cargo check --examples). I've read the documenation I could find and asked google for hints, but somehow this is eluding me. Is what I want achieveable somehow? Thanks for any pointers :slight_smile:

Maybe something like [target.'cfg(target_env = "unix")'.example]

You can also add #![cfg(unix)] at the top of the file to simply compile an empty example on windows.

1 Like

Alas, that did not work out, cargo simply complains about this as an "unused key".

Huh, better than nothing. Thanks!

This topic was automatically closed 90 days after the last reply. New replies are no longer allowed.