Open
Description
Given a library crate, I want to have optional features which are available to integration-level tests and examples so that 'cargo test' tests them.
Here's what I have:
[package]
name = "rustls"
version = "0.1.0"
(etc)
[features]
default = []
clientauth = []
[dependencies]
untrusted = "0.2.0"
(etc)
[dev-dependencies]
env_logger = "0.3.3"
(etc)
Here's what I've tried so far. Attempt one: add the crate into dev-dependencies with the feature, ie:
[dev-dependencies.rustls]
path = "."
version = "0.1.0"
features = ["clientauth"]
I kind of expected that to work, but it panics:
jbp@debian:~/rustls$ RUST_BACKTRACE=1 cargo test
thread '<main>' panicked at 'assertion failed: my_dependencies.insert(dep.clone())', src/cargo/util/dependency_queue.rs:86
stack backtrace:
1: 0x558d17c3a2a0 - std::sys::backtrace::tracing::imp::write::h9fb600083204ae7f
2: 0x558d17c4383b - std::panicking::default_hook::_$u7b$$u7b$closure$u7d$$u7d$::hca543c34f11229ac
3: 0x558d17c434c3 - std::panicking::default_hook::hc2c969e7453d080c
4: 0x558d17c28048 - std::panicking::rust_panic_with_hook::hfe203e3083c2b544
5: 0x558d17701fef - std::panicking::begin_panic::h4ebf9fe884b2415f
6: 0x558d17802d27 - cargo::ops::cargo_rustc::job_queue::JobQueue::enqueue::h98b20a33b8744ebe
7: 0x558d177f4faf - cargo::ops::cargo_rustc::compile::h93336dd21aba29d0
8: 0x558d1777a513 - cargo::ops::cargo_rustc::compile_targets::h7223dffae01d6b9d
9: 0x558d1776eec9 - cargo::ops::cargo_compile::compile_pkg::h48656ffa9b1541f3
10: 0x558d1776bd09 - cargo::ops::cargo_compile::compile::h1b43b20047c53d10
11: 0x558d1785fb0d - cargo::ops::cargo_test::compile_tests::h028a22d3131e0d65
12: 0x558d1785f379 - cargo::ops::cargo_test::run_tests::h0ad98c54a6f40c9d
13: 0x558d176de256 - cargo::call_main_without_stdin::hd484f08b17c419d1
14: 0x558d1768afe7 - cargo::execute::hab7accd6bf9b5c64
15: 0x558d17683f8b - cargo::call_main_without_stdin::hf099bd36acb849a3
16: 0x558d17680da1 - cargo::main::h2b219a79f378c1ef
17: 0x558d17c430d8 - std::panicking::try::call::hc5e1f5b484ec7f0e
18: 0x558d17c4e0eb - __rust_try
19: 0x558d17c4e08e - __rust_maybe_catch_panic
20: 0x558d17c42b03 - std::rt::lang_start::h61f4934e780b4dfc
21: 0x7f79ea9bf86f - __libc_start_main
22: 0x558d17680728 - <unknown>
(version: "cargo 0.11.0-nightly (259324c 2016-05-20)")
Attempt two: see if features.*
works like profile.*
:
[features.test]
default = ["clientauth"]
alas
$ cargo test
error: failed to parse manifest at `/home/jbp/rustls/Cargo.toml`
Caused by:
expected a value of type `array`, but found a value of type `table` for the key `features.test`
Is this possible?
See also #4663