Skip to content

Commit

Permalink
Auto merge of #3146 - alexcrichton:install-same-workspace, r=brson
Browse files Browse the repository at this point in the history
Use workspaces during `cargo install`

Prevent lock files from oscillating.

Closes #3133
  • Loading branch information
bors authored Oct 6, 2016
2 parents 803eb8d + 7400f24 commit d132a62
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 d132a62

Please sign in to comment.