From: Ralf Jung Date: Mon, 4 Sep 2017 11:33:03 +0000 (+0200) Subject: fix error message when --locked is passed but lockfile is outdated X-Git-Tag: archive/raspbian/0.35.0-2+rpi1~3^2^2^2^2^2^2^2~22^2~6^2~66^2 X-Git-Url: https://dgit.raspbian.org/?a=commitdiff_plain;h=3f4d7e75456d3c92ba41e150fd7e2fb7986262bd;p=cargo.git fix error message when --locked is passed but lockfile is outdated --- diff --git a/src/cargo/ops/lockfile.rs b/src/cargo/ops/lockfile.rs index 53374f851..e4e4463f4 100644 --- a/src/cargo/ops/lockfile.rs +++ b/src/cargo/ops/lockfile.rs @@ -98,7 +98,7 @@ pub fn write_pkg_lockfile(ws: &Workspace, resolve: &Resolve) -> CargoResult<()> } if !ws.config().lock_update_allowed() { - let flag = if ws.config().network_allowed() {"--frozen"} else {"--locked"}; + let flag = if ws.config().network_allowed() {"--locked"} else {"--frozen"}; bail!("the lock file needs to be updated but {} was passed to \ prevent this", flag); } diff --git a/tests/lockfile-compat.rs b/tests/lockfile-compat.rs index 81561e28e..00eacebbf 100644 --- a/tests/lockfile-compat.rs +++ b/tests/lockfile-compat.rs @@ -346,3 +346,27 @@ source = "registry+https://github.com/rust-lang/crates.io-index" let lock = p.read_lockfile(); assert!(lock.starts_with(lockfile.trim())); } + +#[test] +fn locked_correct_error() { + Package::new("foo", "0.1.0").publish(); + + let p = project("bar") + .file("Cargo.toml", r#" + [project] + name = "bar" + version = "0.0.1" + authors = [] + + [dependencies] + foo = "0.1.0" + "#) + .file("src/lib.rs", ""); + p.build(); + + assert_that(p.cargo("build").arg("--locked"), + execs().with_status(101).with_stderr("\ +[UPDATING] registry `[..]` +error: the lock file needs to be updated but --locked was passed to prevent this +")); +}