Skip to content

Commit

Permalink
Fixed the bogus dev-dependencies pull in on regular build
Browse files Browse the repository at this point in the history
  • Loading branch information
farcaller committed Jul 10, 2015
1 parent 15b497b commit 54f1d4b
Show file tree
Hide file tree
Showing 2 changed files with 41 additions and 1 deletion.
3 changes: 2 additions & 1 deletion src/cargo/ops/cargo_compile.rs
Original file line number Diff line number Diff line change
Expand Up @@ -149,7 +149,8 @@ pub fn compile_pkg<'a>(package: &Package,
let platform = target.as_ref().map(|e| &e[..]).or(Some(&rustc_host[..]));

let method = Method::Required{
dev_deps: true, // TODO: remove this option?
dev_deps: options.mode == CompileMode::Test ||
options.mode == CompileMode::Bench,
features: &features,
uses_default_features: !no_default_features,
target_platform: platform};
Expand Down
39 changes: 39 additions & 0 deletions tests/test_cargo_features.rs
Original file line number Diff line number Diff line change
Expand Up @@ -741,3 +741,42 @@ test!(unions_work_with_no_default_features {
assert_that(p.cargo("build"), execs().with_status(0).with_stdout(""));
assert_that(p.cargo("build"), execs().with_status(0).with_stdout(""));
});

test!(dev_dependencies_doesnt_leak_features {
let p = project("foo")
.file("Cargo.toml", r#"
[package]
name = "foo"
version = "0.1.0"
authors = []
[dependencies.a]
path = "a"
[dev-dependencies.a]
path = "a"
features = ["badfeature"]
"#)
.file("src/lib.rs", r#"
extern crate a;
pub fn foo() { a::a(); }
"#)
.file("a/Cargo.toml", r#"
[package]
name = "a"
version = "0.1.0"
authors = []
[features]
badfeature = []
"#)
.file("a/src/lib.rs", r#"
#[cfg(feature = "badfeature")]
pub fn a() { panic!(); }
#[cfg(not(feature = "badfeature"))]
pub fn a() { }
"#);

assert_that(p.cargo("run"), execs().with_status(0));
});

0 comments on commit 54f1d4b

Please sign in to comment.