Skip to content

Commit da41b4e

Browse files
committed
Add some tests to check that dev-dependencies are not resolved
1 parent df5f7d6 commit da41b4e

File tree

2 files changed

+72
-0
lines changed

2 files changed

+72
-0
lines changed

tests/build.rs

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4188,3 +4188,24 @@ fn no_linkable_target() {
41884188
[WARNING] The package `the_lib` provides no linkable [..] \
41894189
while compiling `foo`. [..] in `the_lib`'s Cargo.toml. [..]"));
41904190
}
4191+
4192+
#[test]
4193+
fn avoid_dev_deps() {
4194+
Package::new("foo", "1.0.0").publish();
4195+
let p = project("foo")
4196+
.file("Cargo.toml", r#"
4197+
[package]
4198+
name = "bar"
4199+
version = "0.1.0"
4200+
authors = []
4201+
4202+
[dev-dependencies]
4203+
baz = "1.0.0"
4204+
"#)
4205+
.file("src/main.rs", "fn main() {}")
4206+
.build();
4207+
4208+
assert_that(p.cargo("build"), execs().with_status(101));
4209+
assert_that(p.cargo("build").masquerade_as_nightly_cargo()
4210+
.arg("-Zavoid-dev-deps"), execs().with_status(0));
4211+
}

tests/install.rs

Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ use std::fs::{self, File, OpenOptions};
66
use std::io::prelude::*;
77

88
use cargo::util::ProcessBuilder;
9+
use cargotest::ChannelChanger;
910
use cargotest::install::{cargo_home, has_installed_exe};
1011
use cargotest::support::git;
1112
use cargotest::support::paths;
@@ -907,6 +908,56 @@ fn use_path_workspace() {
907908
assert!(lock == lock2, "different lockfiles");
908909
}
909910

911+
#[test]
912+
fn dev_dependencies_no_check() {
913+
Package::new("foo", "1.0.0").publish();
914+
let p = project("foo")
915+
.file("Cargo.toml", r#"
916+
[package]
917+
name = "bar"
918+
version = "0.1.0"
919+
authors = []
920+
921+
[dev-dependencies]
922+
baz = "1.0.0"
923+
"#)
924+
.file("src/main.rs", "fn main() {}")
925+
.build();
926+
927+
assert_that(p.cargo("build"), execs().with_status(101));
928+
assert_that(p.cargo("install"), execs().with_status(0));
929+
}
930+
931+
#[test]
932+
fn dev_dependencies_lock_file_untouched() {
933+
Package::new("foo", "1.0.0").publish();
934+
let p = project("foo")
935+
.file("Cargo.toml", r#"
936+
[package]
937+
name = "foo"
938+
version = "0.1.0"
939+
authors = []
940+
941+
[dev-dependencies]
942+
bar = { path = "a" }
943+
"#)
944+
.file("src/main.rs", "fn main() {}")
945+
.file("a/Cargo.toml", r#"
946+
[package]
947+
name = "bar"
948+
version = "0.1.0"
949+
authors = []
950+
"#)
951+
.file("a/src/lib.rs", "")
952+
.build();
953+
954+
assert_that(p.cargo("build"), execs().with_status(0));
955+
let lock = p.read_lockfile();
956+
assert_that(p.cargo("install"), execs().with_status(0));
957+
let lock2 = p.read_lockfile();
958+
assert!(lock == lock2, "different lockfiles");
959+
}
960+
910961
#[test]
911962
fn vers_precise() {
912963
pkg("foo", "0.1.1");

0 commit comments

Comments
 (0)