mirror of
https://github.com/rust-lang/cargo
synced 2024-10-06 15:59:39 +00:00
Always generate a lockfile with dev-dependencies
Previously an invocation of `cargo build` would generate a lockfile *without* dev dependencies, but an invocation of `cargo test` would generate a lockfile *with* dependencies. This causes odd problems and diffs with the lockfile. This commit switches the resolve-to-be-a-lockfile to using all dependencies of a package, while the resolve-to-be-compiled continues to use just the dependencies needed for the current build.
This commit is contained in:
parent
51de050e6c
commit
8626fa725d
|
@ -91,7 +91,7 @@ pub fn compile(manifest_path: &Path,
|
|||
}
|
||||
|
||||
let resolved = try!(resolver::resolve(package.get_package_id(),
|
||||
dependencies.as_slice(),
|
||||
package.get_dependencies(),
|
||||
&mut registry));
|
||||
|
||||
try!(registry.add_overrides(override_ids));
|
||||
|
|
|
@ -952,3 +952,62 @@ test!(dep_with_changed_submodule {
|
|||
.with_stderr("")
|
||||
.with_status(0));
|
||||
})
|
||||
|
||||
test!(dev_deps_with_testing {
|
||||
let p2 = git_repo("bar", |project| {
|
||||
project.file("Cargo.toml", r#"
|
||||
[package]
|
||||
name = "bar"
|
||||
version = "0.5.0"
|
||||
authors = ["wycats@example.com"]
|
||||
"#)
|
||||
.file("src/lib.rs", r#"
|
||||
pub fn gimme() -> &'static str { "zoidberg" }
|
||||
"#)
|
||||
}).assert();
|
||||
|
||||
let p = project("foo")
|
||||
.file("Cargo.toml", format!(r#"
|
||||
[project]
|
||||
|
||||
name = "foo"
|
||||
version = "0.5.0"
|
||||
authors = ["wycats@example.com"]
|
||||
|
||||
[dev-dependencies.bar]
|
||||
version = "0.5.0"
|
||||
git = '{}'
|
||||
"#, p2.url()).as_slice())
|
||||
.file("src/main.rs", r#"
|
||||
fn main() {}
|
||||
|
||||
#[cfg(test)]
|
||||
mod tests {
|
||||
extern crate bar;
|
||||
#[test] fn foo() { bar::gimme(); }
|
||||
}
|
||||
"#);
|
||||
|
||||
// Generate a lockfile which did not use `bar` to compile, but had to update
|
||||
// `bar` to generate the lockfile
|
||||
assert_that(p.cargo_process("cargo-build"),
|
||||
execs().with_stdout(format!("\
|
||||
{updating} git repository `{bar}`
|
||||
{compiling} foo v0.5.0 ({url})
|
||||
", updating = UPDATING, compiling = COMPILING, url = p.url(), bar = p2.url())));
|
||||
|
||||
// Make sure we use the previous resolution of `bar` instead of updating it
|
||||
// a second time.
|
||||
assert_that(p.process(cargo_dir().join("cargo-test")),
|
||||
execs().with_stdout(format!("\
|
||||
{compiling} bar v0.5.0 ({bar}#[..])
|
||||
{compiling} foo v0.5.0 ({url})
|
||||
{running} target[..]test[..]foo-[..]
|
||||
|
||||
running 1 test
|
||||
test tests::foo ... ok
|
||||
|
||||
test result: ok. 1 passed; 0 failed; 0 ignored; 0 measured
|
||||
|
||||
", compiling = COMPILING, url = p.url(), running = RUNNING, bar = p2.url())));
|
||||
})
|
||||
|
|
Loading…
Reference in a new issue