]> git.proxmox.com Git - cargo.git/commitdiff
fix error message when --locked is passed but lockfile is outdated
authorRalf Jung <post@ralfj.de>
Mon, 4 Sep 2017 11:33:03 +0000 (13:33 +0200)
committerRalf Jung <post@ralfj.de>
Mon, 4 Sep 2017 11:37:06 +0000 (13:37 +0200)
src/cargo/ops/lockfile.rs
tests/lockfile-compat.rs

index 53374f851821ec04411973bfa4194672fb0988cf..e4e4463f4f585506a61af65d98fde893c9baec22 100644 (file)
@@ -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);
     }
index 81561e28eff6745b7cd44344771683b673fb7f13..00eacebbfcbce4c6e585e789d304c02a187c8a58 100644 (file)
@@ -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
+"));
+}