Make --locked required for cargo install --path, too.

This commit is contained in:
Eric Huss 2019-04-13 16:43:53 -07:00
parent c03c85ad49
commit eae89007a6
2 changed files with 11 additions and 10 deletions

View File

@ -215,18 +215,15 @@ fn install_one(
Some(Filesystem::new(config.cwd().join("target-install")))
};
let ws = match overidden_target_dir {
Some(dir) => {
let mut ws = Workspace::ephemeral(pkg, config, Some(dir), false)?;
ws.set_ignore_lock(config.lock_update_allowed());
ws
}
let mut ws = match overidden_target_dir {
Some(dir) => Workspace::ephemeral(pkg, config, Some(dir), false)?,
None => {
let mut ws = Workspace::new(pkg.manifest_path(), config)?;
ws.set_require_optional_deps(false);
ws
}
};
ws.set_ignore_lock(config.lock_update_allowed());
let pkg = ws.current()?;
if from_cwd {

View File

@ -1190,8 +1190,7 @@ fn custom_target_dir_for_git_source() {
#[test]
fn install_respects_lock_file() {
// `cargo install` now requires --locked to use a Cargo.lock for non
// --path installs.
// `cargo install` now requires --locked to use a Cargo.lock.
Package::new("bar", "0.1.0").publish();
Package::new("bar", "0.1.1")
.file("src/lib.rs", "not rust")
@ -1230,7 +1229,8 @@ dependencies = [
#[test]
fn install_path_respects_lock_file() {
// For --path installs, always use local Cargo.lock.
// --path version of install_path_respects_lock_file, --locked is required
// to use Cargo.lock.
Package::new("bar", "0.1.0").publish();
Package::new("bar", "0.1.1")
.file("src/lib.rs", "not rust")
@ -1266,7 +1266,11 @@ dependencies = [
)
.build();
p.cargo("install --path .").run();
p.cargo("install --path .")
.with_stderr_contains("[..]not rust[..]")
.with_status(101)
.run();
p.cargo("install --path . --locked").run();
}
#[test]