Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use workspaces during cargo install #3146

Merged
merged 1 commit into from
Oct 6, 2016
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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");
}