Considering in most cases it just won't work, might as well display
a better error message explaining why.
for pkg in to_builds.iter() {
pkg.manifest().print_teapot(ws.config());
+
+ if build_config.mode.is_any_test()
+ && !ws.is_member(pkg)
+ && pkg.dependencies().iter().any(|dep| !dep.is_transitive())
+ {
+ bail!(
+ "package `{}` cannot be tested because it requires dev-dependencies \
+ and is not a member of the workspace",
+ pkg.name()
+ );
+ }
}
let (extra_args, extra_args_name) = match (target_rustc_args, target_rustdoc_args) {
",
).run();
}
+
+
+#[test]
+fn test_dep_with_dev() {
+ Package::new("devdep", "0.1.0").publish();
+ let p = project()
+ .file(
+ "Cargo.toml",
+ r#"
+ [package]
+ name = "foo"
+ version = "0.0.1"
+
+ [dependencies]
+ bar = { path = "bar" }
+ "#,
+ )
+ .file("src/lib.rs", "")
+ .file(
+ "bar/Cargo.toml",
+ r#"
+ [package]
+ name = "bar"
+ version = "0.0.1"
+
+ [dev-dependencies]
+ devdep = "0.1"
+ "#,
+ )
+ .file("bar/src/lib.rs", "")
+ .build();
+
+ p.cargo("test -p bar")
+ .with_status(101)
+ .with_stderr(
+ "[ERROR] package `bar` cannot be tested because it requires dev-dependencies \
+ and is not a member of the workspace",
+ )
+ .run();
+}