Skip to content

Commit

Permalink
Use workspaces during cargo install
Browse files Browse the repository at this point in the history
Prevent lock files from oscillating.

Closes #3133
  • Loading branch information
alexcrichton committed Sep 30, 2016
1 parent d8936af commit 7400f24
Show file tree
Hide file tree
Showing 2 changed files with 37 additions and 1 deletion.
5 changes: 4 additions & 1 deletion src/cargo/ops/cargo_install.rs
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,10 @@ pub fn install(root: Option<&str>,
Some(Filesystem::new(config.cwd().join("target-install")))
};

let ws = try!(Workspace::one(pkg, config, overidden_target_dir));
let ws = match overidden_target_dir {
Some(dir) => try!(Workspace::one(pkg, config, Some(dir))),
None => try!(Workspace::new(pkg.manifest_path(), config)),
};
let pkg = try!(ws.current());

// Preflight checks to check up front whether we'll overwrite something.
Expand Down
33 changes: 33 additions & 0 deletions tests/install.rs
Original file line number Diff line number Diff line change
Expand Up @@ -793,3 +793,36 @@ fn readonly_dir() {
execs().with_status(0));
assert_that(cargo_home(), has_installed_exe("foo"));
}

#[test]
fn use_path_workspace() {
Package::new("foo", "1.0.0").publish();
let p = project("foo")
.file("Cargo.toml", r#"
[package]
name = "bar"
version = "0.1.0"
authors = []
[workspace]
members = ["baz"]
"#)
.file("src/main.rs", "fn main() {}")
.file("baz/Cargo.toml", r#"
[package]
name = "baz"
version = "0.1.0"
authors = []
[dependencies]
foo = "1"
"#)
.file("baz/src/lib.rs", "");
p.build();

assert_that(p.cargo("build"), execs().with_status(0));
let lock = p.read_lockfile();
assert_that(p.cargo("install"), execs().with_status(0));
let lock2 = p.read_lockfile();
assert!(lock == lock2, "different lockfiles");
}

0 comments on commit 7400f24

Please sign in to comment.