Skip to content

Support for features #59

New issue

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

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

Already on GitHub? Sign in to your account

Closed
dbrgn opened this issue Nov 20, 2018 · 4 comments
Closed

Support for features #59

dbrgn opened this issue Nov 20, 2018 · 4 comments

Comments

@dbrgn
Copy link

dbrgn commented Nov 20, 2018

Hi. I'm currently a user of assert_cli in tealdeer and am thinking about moving to assert_cmd. The main issue I'm facing there is that the binary (when calling Assert::main_binary()) is always compiled with default features, even if I compile the tests with --no-default-features.

Does assert_cmd have a solution for this? Ideally I'd either be able to pass the features to the main_binary or cargo_bin methods, or would have a way to specify the features per-invocation by other means (e.g. set_features(&["networking"]) or set_features(&[])). This way, I could test different feature flags from a single test binary.

Alternatively compiling the main binary with the same flags as the test binary would be fine too.

@epage
Copy link
Contributor

epage commented Nov 20, 2018

Unfortunately, there is not a good way to auto-detect features and I'm wanting to be cautious about effectively embedding a cargo API into assert_cmd.

The good news is you can instead call into the API that assert_cmd is built on top of. We even include an example in the docs

We need to expand the docs to list caveats of the simple API. We should be sure to list features in that.

@epage
Copy link
Contributor

epage commented Nov 21, 2018

Now documented as of #62

@epage epage closed this as completed Nov 21, 2018
@dbrgn
Copy link
Author

dbrgn commented Dec 21, 2018

Thanks!

@epage
Copy link
Contributor

epage commented Mar 14, 2019

So it looks like we can programmatically get featutes

The downsides

  • Only works from build.rs. We'd have to write a code-generator, have clients call the code-generator, and then include the generated code. Not very ergonomic
  • It changes the name in an irreversible way.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants